From 2bf4925cb3fa8fa782b78de164e3a841bf5fdf4f Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 15 Jan 2016 17:54:12 -0800 Subject: [PATCH 001/203] Initial project for Google Cloud DNS in gcloud-java --- gcloud-java-dns/pom.xml | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 gcloud-java-dns/pom.xml diff --git a/gcloud-java-dns/pom.xml b/gcloud-java-dns/pom.xml new file mode 100644 index 000000000000..55d720bc0a36 --- /dev/null +++ b/gcloud-java-dns/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + com.google.gcloud + gcloud-java-dns + jar + GCloud Java DNS + + Java idiomatic client for Google Cloud DNS. + + + com.google.gcloud + gcloud-java-pom + 0.1.3-SNAPSHOT + + + gcloud-java-dns + + + + ${project.groupId} + gcloud-java-core + ${project.version} + + + com.google.apis + google-api-services-dns + v1-rev7-1.21.0 + compile + + + com.google.guava + guava-jdk5 + + + com.google.api-client + google-api-client + + + + + junit + junit + 4.12 + test + + + org.easymock + easymock + 3.3 + test + + + From fe4e137fce65882465ca0e092761e080f366fece Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 15 Jan 2016 17:56:24 -0800 Subject: [PATCH 002/203] Added DnsRecord as a part of the basic data model. ManagedZoneInfo is to be completed and it is included only as it is required as a builder parameter. This class will change in the near future. --- .../java/com/google/gcloud/dns/DnsRecord.java | 254 ++++++++++++++++++ .../google/gcloud/dns/ManagedZoneInfo.java | 44 +++ .../com/google/gcloud/dns/DnsRecordTest.java | 94 +++++++ 3 files changed, 392 insertions(+) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java new file mode 100644 index 000000000000..8abf335969f8 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -0,0 +1,254 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.collect.ImmutableList; + +import java.util.LinkedList; +import java.util.List; + +/** + * A class that represents Google Cloud DNS record set. + * + *

+ * A unit of data that will be returned by the DNS servers. + * + * @see Google + * Cloud DNS documentation + */ +public class DnsRecord { + + private String name; + private List rrdatas = new LinkedList<>(); + private Integer ttl = 86400; // the default ttl of 24 hours + private DnsRecordType type; + private String parentName; + private Long parentId; + + /** + * A private constructor. Obtain an instance using {@link DnsRecord#Builder}. + */ + private DnsRecord() { + } + + DnsRecord(Builder builder) { + this.name = builder.name; + this.rrdatas = ImmutableList.copyOf(builder.rrdatas); + this.ttl = builder.ttl; + this.type = builder.type; + this.parentName = builder.parentName; + this.parentId = builder.parentId; + } + + /** + * Enum for the DNS record types supported by Cloud DNS. + * + *

+ * Google Cloud DNS currently supports records of type A, AAAA, CNAME, MX + * NAPTR, NS, PTR, SOA, SPF, SRV, TXT. + * + * @see + * Cloud + * DNS supported record types + */ + public enum DnsRecordType { + A("A"), + AAAA("AAAA"), + CNAME("CNAME"), + MX("MX"), + NAPTR("NAPTR"), + NS("NS"), + PTR("PTR"), + SOA("SOA"), + SPF("SPF"), + SRV("SRV"), + TXT("TXT"); + + private final String type; + + private DnsRecordType(String type) { + this.type = type; + } + } + + public static class Builder { + + private List rrdatas = new LinkedList<>(); + private String name; + private Integer ttl = 86400; // default ttl of 24 hours + private DnsRecordType type; + private String parentName; + private Long parentId; + + private Builder() { + } + + /** + * Creates a builder and pre-populates attributes with the values from the + * provided DnsRecord instance. + */ + public Builder(DnsRecord record) { + this.name = record.name; + this.ttl = record.ttl; + this.type = record.type; + this.parentId = record.parentId; + this.parentName = record.parentName; + this.rrdatas.addAll(record.rrdatas); + } + + /** + * Adds a record to the record set. + * + *

+ * The records should be as defined in RFC 1035 (section 5) and RFC 1034 + * (section 3.6.1). Examples of records are available in + * Cloud + * DNS documentation. + */ + public Builder add(String record) { + this.rrdatas.add(checkNotNull(record)); + return this; + } + + /** + * Sets name for this DNS record set. For example, www.example.com. + */ + public Builder name(String name) { + this.name = checkNotNull(name); + return this; + } + + /** + * Sets the number of seconds that this record can be cached by resolvers. + * This number must be non-negative. + * + * @param ttl A non-negative number of seconds + */ + public Builder ttl(int ttl) { + // change only if + if (ttl < 0) { + throw new IllegalArgumentException( + "TTL cannot be negative. The supplied value was " + ttl + "." + ); + } + this.ttl = ttl; + return this; + } + + /** + * The identifier of a supported record type, for example, A, AAAA, MX, TXT, + * and so on. + */ + public Builder type(DnsRecordType type) { + this.type = checkNotNull(type); + return this; + } + + /** + * Builds the DNS record. + */ + public DnsRecord build() { + return new DnsRecord(this); + } + + /** + * Sets references to the managed zone that this DNS record belongs to. + */ + public Builder managedZone(ManagedZoneInfo parent) { + checkNotNull(parent); + this.parentId = parent.id(); + this.parentName = parent.name(); + return this; + } + } + + /** + * Creates a builder pre-populated with the attribute values of this instance. + */ + public Builder toBuilder() { + return new Builder(this); + } + + /** + * Creates an empty builder + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Get user assigned name of this DNS record. + * + * TODO: is this field mandatory? + */ + public String name() { + return name; + } + + /** + * Returns a list of DNS record stored in this record set. + */ + public List rrdatas() { + return rrdatas; + } + + /** + * Returns the number of seconds that this ResourceRecordSet can be cached by + * resolvers. + * + *

+ * This number is provided by the user. If this values is not set, we use + * default of 86400. + */ + public Integer ttl() { + return ttl; + } + + /** + * Returns the type of this DNS record. + */ + public DnsRecordType type() { + return type; + } + + /** + * Returns name of the managed zone that this record belongs to. + * + *

+ * The name of the managed zone is provided by the user when the managed zone + * is created. It is unique within a project. If this DNS record is not + * associated with a managed zone, this returns null. + */ + public String parentName() { + return parentName; + } + + /** + * Returns name of the managed zone that this record belongs to. + * + *

+ * The id of the managed zone is determined by the server when the managed + * zone is created. It is a read only value. If this DNS record is not + * associated with a managed zone, or if the id of the managed zone was not + * loaded from the cloud service, this returns null. + */ + public Long parentId() { + return parentId; + } + +} diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java new file mode 100644 index 000000000000..003854a91918 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +/** + * TODO: Implement. + * TODO: Add documentation. + */ +public class ManagedZoneInfo { + + private final String name; + private final Long id; + + public String name() { + throw new UnsupportedOperationException("Not implemented yet."); + // TODO: Implement + } + + public Long id() { + return id; + // TODO: Implement + } + + private ManagedZoneInfo() { + name = null; + id = null; + throw new UnsupportedOperationException("Not implemented yet"); + // TODO: Implement + } + +} diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java new file mode 100644 index 000000000000..0709ca3bf0e4 --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java @@ -0,0 +1,94 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import org.easymock.EasyMock; + +import org.junit.Test; +import org.junit.Before; + +import static org.junit.Assert.*; + +public class DnsRecordTest { + + private static final String NAME = "example.com."; + private static final Integer TTL = 3600; + private static final DnsRecord.DnsRecordType TYPE = DnsRecord.DnsRecordType.AAAA; + private static final ManagedZoneInfo MANAGED_ZONE_INFO_MOCK + = EasyMock.createMock(ManagedZoneInfo.class); + private static final Long PARENT_ID = 12L; + private static final String PARENT_NAME = "name"; + static { + EasyMock.expect(MANAGED_ZONE_INFO_MOCK.id()).andReturn(PARENT_ID); + EasyMock.expect(MANAGED_ZONE_INFO_MOCK.name()).andReturn(PARENT_NAME); + EasyMock.replay(MANAGED_ZONE_INFO_MOCK); + } + private static final DnsRecord RECORD = DnsRecord.builder() + .name(NAME) + .ttl(TTL) + .managedZone(MANAGED_ZONE_INFO_MOCK) + .build(); + private static final Integer DEFAULT_TTL = 86400; + + @Test + public void testDefaultDnsRecord() { + DnsRecord record = DnsRecord.builder().build(); + assertEquals(DEFAULT_TTL, record.ttl()); + assertEquals(0, record.rrdatas().size()); + } + + @Test + public void testBuilder() { + + assertEquals(NAME, RECORD.name()); + assertEquals(TTL, RECORD.ttl()); + + assertEquals(PARENT_ID, RECORD.parentId()); // this was never assigned + assertEquals(PARENT_NAME, RECORD.parentName()); + assertEquals(0, RECORD.rrdatas().size()); + // verify that one can add records to the record set + String testingRecord = "Testing record"; + String anotherTestingRecord = "Another record 123"; + DnsRecord anotherRecord = RECORD.toBuilder() + .add(testingRecord) + .add(anotherTestingRecord) + .build(); + assertEquals(2, anotherRecord.rrdatas().size()); + assertTrue(anotherRecord.rrdatas().contains(testingRecord)); + assertTrue(anotherRecord.rrdatas().contains(anotherTestingRecord)); + } + + @Test + public void testValidTtl() { + try { + DnsRecord.builder().ttl(-1); + fail("A negative value is not acceptable for ttl."); + } catch (IllegalArgumentException e) { + // ok + } + try { + DnsRecord.builder().ttl(0); + } catch (IllegalArgumentException e) { + fail("0 is a valid value."); + } + try { + DnsRecord.builder().ttl(Integer.MAX_VALUE); + } catch (Exception e) { + fail("Large numbers should be ok too."); + } + } + +} From f652277e166b7d3cb3f248e0dafd92ea063c0caf Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 19 Jan 2016 15:37:51 -0800 Subject: [PATCH 003/203] Implemented comments by @mziccard --- .../java/com/google/gcloud/dns/DnsRecord.java | 188 ++++++++++-------- .../google/gcloud/dns/ManagedZoneInfo.java | 10 +- .../com/google/gcloud/dns/DnsRecordTest.java | 82 +++++--- 3 files changed, 165 insertions(+), 115 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index 8abf335969f8..56da63dc5fe3 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -15,35 +15,45 @@ */ package com.google.gcloud.dns; +import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableList; +import java.io.Serializable; + import java.util.LinkedList; import java.util.List; +import java.util.Objects; /** * A class that represents Google Cloud DNS record set. * - *

- * A unit of data that will be returned by the DNS servers. + *

A unit of data that will be returned by the DNS servers. * - * @see Google - * Cloud DNS documentation + * @see Google Cloud DNS + * documentation */ -public class DnsRecord { +public class DnsRecord implements Serializable { - private String name; - private List rrdatas = new LinkedList<>(); - private Integer ttl = 86400; // the default ttl of 24 hours - private DnsRecordType type; - private String parentName; - private Long parentId; + private static final long serialVersionUID = 2016011914302204L; + private final String name; + private final List rrdatas; + private final Integer ttl; + private final DnsRecordType type; + private final String zoneName; + private final Long zoneId; /** * A private constructor. Obtain an instance using {@link DnsRecord#Builder}. */ private DnsRecord() { + this.name = null; + this.rrdatas = null; + this.ttl = null; + this.type = null; + this.zoneName = null; + this.zoneId = null; } DnsRecord(Builder builder) { @@ -51,74 +61,64 @@ private DnsRecord() { this.rrdatas = ImmutableList.copyOf(builder.rrdatas); this.ttl = builder.ttl; this.type = builder.type; - this.parentName = builder.parentName; - this.parentId = builder.parentId; + this.zoneName = builder.zoneName; + this.zoneId = builder.zoneId; } /** * Enum for the DNS record types supported by Cloud DNS. * - *

- * Google Cloud DNS currently supports records of type A, AAAA, CNAME, MX - * NAPTR, NS, PTR, SOA, SPF, SRV, TXT. + *

Google Cloud DNS currently supports records of type A, AAAA, CNAME, MX NAPTR, NS, PTR, SOA, + * SPF, SRV, TXT. * - * @see - * Cloud - * DNS supported record types + * @see Cloud DNS + * supported record types */ public enum DnsRecordType { - A("A"), - AAAA("AAAA"), - CNAME("CNAME"), - MX("MX"), - NAPTR("NAPTR"), - NS("NS"), - PTR("PTR"), - SOA("SOA"), - SPF("SPF"), - SRV("SRV"), - TXT("TXT"); - - private final String type; - - private DnsRecordType(String type) { - this.type = type; - } + A, + AAAA, + CNAME, + MX, + NAPTR, + NS, + PTR, + SOA, + SPF, + SRV, + TXT; } public static class Builder { private List rrdatas = new LinkedList<>(); private String name; - private Integer ttl = 86400; // default ttl of 24 hours + private Integer ttl; private DnsRecordType type; - private String parentName; - private Long parentId; + private String zoneName; + private Long zoneId; private Builder() { } /** - * Creates a builder and pre-populates attributes with the values from the - * provided DnsRecord instance. + * Creates a builder and pre-populates attributes with the values from the provided DnsRecord + * instance. */ public Builder(DnsRecord record) { this.name = record.name; this.ttl = record.ttl; this.type = record.type; - this.parentId = record.parentId; - this.parentName = record.parentName; + this.zoneId = record.zoneId; + this.zoneName = record.zoneName; this.rrdatas.addAll(record.rrdatas); } /** - * Adds a record to the record set. + * Adds a record to the record set. The records should be as defined in RFC 1035 (section 5) and + * RFC 1034 (section 3.6.1). Examples of records are available in Google DNS documentation. * - *

- * The records should be as defined in RFC 1035 (section 5) and RFC 1034 - * (section 3.6.1). Examples of records are available in - * Cloud - * DNS documentation. + * @see Google + * DNS documentation . */ public Builder add(String record) { this.rrdatas.add(checkNotNull(record)); @@ -134,25 +134,19 @@ public Builder name(String name) { } /** - * Sets the number of seconds that this record can be cached by resolvers. - * This number must be non-negative. + * Sets the number of seconds that this record can be cached by resolvers. This number must be + * non-negative. * * @param ttl A non-negative number of seconds */ public Builder ttl(int ttl) { - // change only if - if (ttl < 0) { - throw new IllegalArgumentException( - "TTL cannot be negative. The supplied value was " + ttl + "." - ); - } + checkArgument(ttl >= 0, "TTL cannot be negative. The supplied value was " + ttl + "."); this.ttl = ttl; return this; } /** - * The identifier of a supported record type, for example, A, AAAA, MX, TXT, - * and so on. + * The identifier of a supported record type, for example, A, AAAA, MX, TXT, and so on. */ public Builder type(DnsRecordType type) { this.type = checkNotNull(type); @@ -171,8 +165,8 @@ public DnsRecord build() { */ public Builder managedZone(ManagedZoneInfo parent) { checkNotNull(parent); - this.parentId = parent.id(); - this.parentName = parent.name(); + this.zoneId = parent.id(); + this.zoneName = parent.name(); return this; } } @@ -192,9 +186,7 @@ public static Builder builder() { } /** - * Get user assigned name of this DNS record. - * - * TODO: is this field mandatory? + * Get the mandatory user assigned name of this DNS record. */ public String name() { return name; @@ -204,16 +196,12 @@ public String name() { * Returns a list of DNS record stored in this record set. */ public List rrdatas() { - return rrdatas; + return ImmutableList.copyOf(rrdatas); } /** - * Returns the number of seconds that this ResourceRecordSet can be cached by - * resolvers. - * - *

- * This number is provided by the user. If this values is not set, we use - * default of 86400. + * Returns the number of seconds that this ResourceRecordSet can be cached by resolvers. This + * number is provided by the user. */ public Integer ttl() { return ttl; @@ -227,28 +215,56 @@ public DnsRecordType type() { } /** - * Returns name of the managed zone that this record belongs to. - * - *

- * The name of the managed zone is provided by the user when the managed zone - * is created. It is unique within a project. If this DNS record is not - * associated with a managed zone, this returns null. + * Returns name of the managed zone that this record belongs to. The name of the managed zone is + * provided by the user when the managed zone is created. It is unique within a project. If this + * DNS record is not associated with a managed zone, this returns null. */ - public String parentName() { - return parentName; + public String zoneName() { + return zoneName; } /** * Returns name of the managed zone that this record belongs to. * - *

- * The id of the managed zone is determined by the server when the managed - * zone is created. It is a read only value. If this DNS record is not - * associated with a managed zone, or if the id of the managed zone was not - * loaded from the cloud service, this returns null. + *

The id of the managed zone is determined by the server when the managed zone is created. It + * is a read only value. If this DNS record is not associated with a managed zone, or if the id of + * the managed zone was not loaded from the cloud service, this returns null. */ - public Long parentId() { - return parentId; + public Long zoneId() { + return zoneId; + } + + @Override + public int hashCode() { + return Objects.hash(name, rrdatas, ttl, type, zoneName, zoneId); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof DnsRecord) { + DnsRecord other = (DnsRecord) obj; + return zoneId == other.zoneId() + && zoneName == other.zoneName + && this.toRRSet().equals(other.toRRSet()); + } + return false; + } + + com.google.api.services.dns.model.ResourceRecordSet toRRSet() { + com.google.api.services.dns.model.ResourceRecordSet rrset = + new com.google.api.services.dns.model.ResourceRecordSet(); + rrset.setName(name); + rrset.setRrdatas(this.rrdatas()); + rrset.setTtl(ttl); + rrset.setType(type == null ? null : type.name()); + return rrset; + } + + @Override + public String toString() { + return "DnsRecord{" + "name=" + name + ", rrdatas=" + rrdatas + + ", ttl=" + ttl + ", type=" + type + ", zoneName=" + + zoneName + ", zoneId=" + zoneId + '}'; } } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java index 003854a91918..d5ed8351dc34 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java @@ -16,8 +16,8 @@ package com.google.gcloud.dns; /** - * TODO: Implement. - * TODO: Add documentation. + * todo(mderka): Implement. + * todo(mderka): Add documentation. */ public class ManagedZoneInfo { @@ -26,19 +26,19 @@ public class ManagedZoneInfo { public String name() { throw new UnsupportedOperationException("Not implemented yet."); - // TODO: Implement + // todo(mderka): Implement } public Long id() { return id; - // TODO: Implement + // todo(mderka): Implement } private ManagedZoneInfo() { name = null; id = null; throw new UnsupportedOperationException("Not implemented yet"); - // TODO: Implement + // todo(mderka): Implement } } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java index 0709ca3bf0e4..55c72d794e87 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java @@ -15,38 +15,42 @@ */ package com.google.gcloud.dns; -import org.easymock.EasyMock; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotEquals; +import org.junit.BeforeClass; import org.junit.Test; -import org.junit.Before; -import static org.junit.Assert.*; +import org.easymock.EasyMock; + public class DnsRecordTest { private static final String NAME = "example.com."; private static final Integer TTL = 3600; private static final DnsRecord.DnsRecordType TYPE = DnsRecord.DnsRecordType.AAAA; - private static final ManagedZoneInfo MANAGED_ZONE_INFO_MOCK - = EasyMock.createMock(ManagedZoneInfo.class); - private static final Long PARENT_ID = 12L; - private static final String PARENT_NAME = "name"; + private static final ManagedZoneInfo MANAGED_ZONE_INFO_MOCK = + EasyMock.createMock(ManagedZoneInfo.class); + private static final Long ZONE_ID = 12L; + private static final String ZONE_NAME = "name"; + static { - EasyMock.expect(MANAGED_ZONE_INFO_MOCK.id()).andReturn(PARENT_ID); - EasyMock.expect(MANAGED_ZONE_INFO_MOCK.name()).andReturn(PARENT_NAME); + EasyMock.expect(MANAGED_ZONE_INFO_MOCK.id()).andReturn(ZONE_ID); + EasyMock.expect(MANAGED_ZONE_INFO_MOCK.name()).andReturn(ZONE_NAME); EasyMock.replay(MANAGED_ZONE_INFO_MOCK); } + private static final DnsRecord RECORD = DnsRecord.builder() .name(NAME) .ttl(TTL) .managedZone(MANAGED_ZONE_INFO_MOCK) .build(); - private static final Integer DEFAULT_TTL = 86400; @Test public void testDefaultDnsRecord() { DnsRecord record = DnsRecord.builder().build(); - assertEquals(DEFAULT_TTL, record.ttl()); assertEquals(0, record.rrdatas().size()); } @@ -56,8 +60,8 @@ public void testBuilder() { assertEquals(NAME, RECORD.name()); assertEquals(TTL, RECORD.ttl()); - assertEquals(PARENT_ID, RECORD.parentId()); // this was never assigned - assertEquals(PARENT_NAME, RECORD.parentName()); + assertEquals(ZONE_ID, RECORD.zoneId()); // this was never assigned + assertEquals(ZONE_NAME, RECORD.zoneName()); assertEquals(0, RECORD.rrdatas().size()); // verify that one can add records to the record set String testingRecord = "Testing record"; @@ -77,18 +81,48 @@ public void testValidTtl() { DnsRecord.builder().ttl(-1); fail("A negative value is not acceptable for ttl."); } catch (IllegalArgumentException e) { - // ok - } - try { - DnsRecord.builder().ttl(0); - } catch (IllegalArgumentException e) { - fail("0 is a valid value."); - } - try { - DnsRecord.builder().ttl(Integer.MAX_VALUE); - } catch (Exception e) { - fail("Large numbers should be ok too."); + // expected } + DnsRecord.builder().ttl(0); + DnsRecord.builder().ttl(Integer.MAX_VALUE); + } + + @Test + public void testEqualsAndNotEquals() { + DnsRecord clone = RECORD.toBuilder().build(); + assertEquals(clone, RECORD); + clone = RECORD.toBuilder().add("another record").build(); + final String differentName = "totally different name"; + clone = RECORD.toBuilder().name(differentName).build(); + assertNotEquals(clone, RECORD); + clone = RECORD.toBuilder().ttl(RECORD.ttl() + 1).build(); + assertNotEquals(clone, RECORD); + clone = RECORD.toBuilder().type(DnsRecord.DnsRecordType.TXT).build(); + assertNotEquals(clone, RECORD); + ManagedZoneInfo anotherMock = EasyMock.createMock(ManagedZoneInfo.class); + EasyMock.expect(anotherMock.id()).andReturn(ZONE_ID + 1); + EasyMock.expect(anotherMock.name()).andReturn(ZONE_NAME + "more text"); + EasyMock.replay(anotherMock); + clone = RECORD.toBuilder().managedZone(anotherMock).build(); + assertNotEquals(clone, RECORD); + } + + @Test + public void testSameHashCodeOnEquals() { + int hash = RECORD.hashCode(); + DnsRecord clone = RECORD.toBuilder().build(); + assertEquals(clone.hashCode(), hash); + } + + @Test + public void testDifferentHashCodeOnDifferent() { + int hash = RECORD.hashCode(); + final String differentName = "totally different name"; + DnsRecord clone = RECORD.toBuilder().name(differentName).build(); + assertNotEquals(differentName, RECORD.name()); + assertNotEquals(clone.hashCode(), hash); + DnsRecord anotherClone = RECORD.toBuilder().add("another record").build(); + assertNotEquals(anotherClone.hashCode(), hash); } } From b29945fd1fd920571d115b746185dfef36d2a0ab Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 20 Jan 2016 11:14:09 -0800 Subject: [PATCH 004/203] Second round of comments from @mziccard --- .../java/com/google/gcloud/dns/DnsRecord.java | 68 +++++++++------- .../com/google/gcloud/dns/DnsRecordTest.java | 78 ++++++++++--------- 2 files changed, 80 insertions(+), 66 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index 56da63dc5fe3..91278fa2a1e7 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; import java.io.Serializable; @@ -29,7 +30,7 @@ /** * A class that represents Google Cloud DNS record set. * - *

A unit of data that will be returned by the DNS servers. + *

A unit of data that will be returned by the DNS servers. * * @see Google Cloud DNS * documentation @@ -44,9 +45,6 @@ public class DnsRecord implements Serializable { private final String zoneName; private final Long zoneId; - /** - * A private constructor. Obtain an instance using {@link DnsRecord#Builder}. - */ private DnsRecord() { this.name = null; this.rrdatas = null; @@ -68,7 +66,7 @@ private DnsRecord() { /** * Enum for the DNS record types supported by Cloud DNS. * - *

Google Cloud DNS currently supports records of type A, AAAA, CNAME, MX NAPTR, NS, PTR, SOA, + *

Google Cloud DNS currently supports records of type A, AAAA, CNAME, MX NAPTR, NS, PTR, SOA, * SPF, SRV, TXT. * * @see Cloud DNS @@ -85,7 +83,7 @@ public enum DnsRecordType { SOA, SPF, SRV, - TXT; + TXT } public static class Builder { @@ -162,13 +160,23 @@ public DnsRecord build() { /** * Sets references to the managed zone that this DNS record belongs to. + * + * todo(mderka): consider if this method is needed; may not be possible when listing records */ - public Builder managedZone(ManagedZoneInfo parent) { + Builder managedZone(ManagedZoneInfo parent) { checkNotNull(parent); this.zoneId = parent.id(); this.zoneName = parent.name(); return this; } + + /** + * Sets name reference to the managed zone that this DNS record belongs to. + */ + Builder managedZone(String managedZoneName) { + this.zoneName = checkNotNull(managedZoneName); + return this; + } } /** @@ -196,12 +204,12 @@ public String name() { * Returns a list of DNS record stored in this record set. */ public List rrdatas() { - return ImmutableList.copyOf(rrdatas); + return rrdatas; } /** - * Returns the number of seconds that this ResourceRecordSet can be cached by resolvers. This - * number is provided by the user. + * Returns the number of seconds that this DnsResource can be cached by resolvers. This number is + * provided by the user. */ public Integer ttl() { return ttl; @@ -224,9 +232,9 @@ public String zoneName() { } /** - * Returns name of the managed zone that this record belongs to. + * Returns id of the managed zone that this record belongs to. * - *

The id of the managed zone is determined by the server when the managed zone is created. It + *

The id of the managed zone is determined by the server when the managed zone is created. It * is a read only value. If this DNS record is not associated with a managed zone, or if the id of * the managed zone was not loaded from the cloud service, this returns null. */ @@ -241,30 +249,32 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (obj instanceof DnsRecord) { - DnsRecord other = (DnsRecord) obj; - return zoneId == other.zoneId() - && zoneName == other.zoneName - && this.toRRSet().equals(other.toRRSet()); - } - return false; + return (obj instanceof DnsRecord) && Objects.equals(this.toPb(), ((DnsRecord) obj).toPb()) + && this.zoneId().equals(((DnsRecord) obj).zoneId()) + && this.zoneName().equals(((DnsRecord) obj).zoneName()); + } - com.google.api.services.dns.model.ResourceRecordSet toRRSet() { - com.google.api.services.dns.model.ResourceRecordSet rrset = + com.google.api.services.dns.model.ResourceRecordSet toPb() { + com.google.api.services.dns.model.ResourceRecordSet pb = new com.google.api.services.dns.model.ResourceRecordSet(); - rrset.setName(name); - rrset.setRrdatas(this.rrdatas()); - rrset.setTtl(ttl); - rrset.setType(type == null ? null : type.name()); - return rrset; + pb.setName(this.name()); + pb.setRrdatas(this.rrdatas()); + pb.setTtl(this.ttl()); + pb.setType(this.type() == null ? null : this.type().name()); + return pb; } @Override public String toString() { - return "DnsRecord{" + "name=" + name + ", rrdatas=" + rrdatas - + ", ttl=" + ttl + ", type=" + type + ", zoneName=" - + zoneName + ", zoneId=" + zoneId + '}'; + return MoreObjects.toStringHelper(this) + .add("name", name()) + .add("rrdatas", rrdatas()) + .add("ttl", ttl()) + .add("type", type()) + .add("zoneName", zoneName()) + .add("zoneId", zoneId()) + .toString(); } } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java index 55c72d794e87..ee9e6e58d61d 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java @@ -25,29 +25,30 @@ import org.easymock.EasyMock; - public class DnsRecordTest { private static final String NAME = "example.com."; private static final Integer TTL = 3600; private static final DnsRecord.DnsRecordType TYPE = DnsRecord.DnsRecordType.AAAA; - private static final ManagedZoneInfo MANAGED_ZONE_INFO_MOCK = - EasyMock.createMock(ManagedZoneInfo.class); private static final Long ZONE_ID = 12L; private static final String ZONE_NAME = "name"; - - static { - EasyMock.expect(MANAGED_ZONE_INFO_MOCK.id()).andReturn(ZONE_ID); - EasyMock.expect(MANAGED_ZONE_INFO_MOCK.name()).andReturn(ZONE_NAME); - EasyMock.replay(MANAGED_ZONE_INFO_MOCK); + // the following is initialized in @BeforeClass setUp() + private static DnsRecord record; + private static ManagedZoneInfo managedZoneInfoMock; + + @BeforeClass + public static void setUp() { + managedZoneInfoMock = EasyMock.createMock(ManagedZoneInfo.class); + EasyMock.expect(managedZoneInfoMock.id()).andReturn(ZONE_ID); + EasyMock.expect(managedZoneInfoMock.name()).andReturn(ZONE_NAME); + EasyMock.replay(managedZoneInfoMock); + record = DnsRecord.builder() + .name(NAME) + .ttl(TTL) + .managedZone(managedZoneInfoMock) + .build(); } - private static final DnsRecord RECORD = DnsRecord.builder() - .name(NAME) - .ttl(TTL) - .managedZone(MANAGED_ZONE_INFO_MOCK) - .build(); - @Test public void testDefaultDnsRecord() { DnsRecord record = DnsRecord.builder().build(); @@ -57,20 +58,23 @@ public void testDefaultDnsRecord() { @Test public void testBuilder() { - assertEquals(NAME, RECORD.name()); - assertEquals(TTL, RECORD.ttl()); + assertEquals(NAME, record.name()); + assertEquals(TTL, record.ttl()); - assertEquals(ZONE_ID, RECORD.zoneId()); // this was never assigned - assertEquals(ZONE_NAME, RECORD.zoneName()); - assertEquals(0, RECORD.rrdatas().size()); + assertEquals(ZONE_ID, record.zoneId()); // this was never assigned + assertEquals(ZONE_NAME, record.zoneName()); + assertEquals(0, record.rrdatas().size()); // verify that one can add records to the record set String testingRecord = "Testing record"; String anotherTestingRecord = "Another record 123"; - DnsRecord anotherRecord = RECORD.toBuilder() + String differentName = ZONE_NAME + "something"; + DnsRecord anotherRecord = record.toBuilder() .add(testingRecord) .add(anotherTestingRecord) + .managedZone(differentName) .build(); assertEquals(2, anotherRecord.rrdatas().size()); + assertEquals(differentName, anotherRecord.zoneName()); assertTrue(anotherRecord.rrdatas().contains(testingRecord)); assertTrue(anotherRecord.rrdatas().contains(anotherTestingRecord)); } @@ -89,39 +93,39 @@ public void testValidTtl() { @Test public void testEqualsAndNotEquals() { - DnsRecord clone = RECORD.toBuilder().build(); - assertEquals(clone, RECORD); - clone = RECORD.toBuilder().add("another record").build(); + DnsRecord clone = record.toBuilder().build(); + assertEquals(clone, record); + clone = record.toBuilder().add("another record").build(); final String differentName = "totally different name"; - clone = RECORD.toBuilder().name(differentName).build(); - assertNotEquals(clone, RECORD); - clone = RECORD.toBuilder().ttl(RECORD.ttl() + 1).build(); - assertNotEquals(clone, RECORD); - clone = RECORD.toBuilder().type(DnsRecord.DnsRecordType.TXT).build(); - assertNotEquals(clone, RECORD); + clone = record.toBuilder().name(differentName).build(); + assertNotEquals(clone, record); + clone = record.toBuilder().ttl(record.ttl() + 1).build(); + assertNotEquals(clone, record); + clone = record.toBuilder().type(DnsRecord.DnsRecordType.TXT).build(); + assertNotEquals(clone, record); ManagedZoneInfo anotherMock = EasyMock.createMock(ManagedZoneInfo.class); EasyMock.expect(anotherMock.id()).andReturn(ZONE_ID + 1); EasyMock.expect(anotherMock.name()).andReturn(ZONE_NAME + "more text"); EasyMock.replay(anotherMock); - clone = RECORD.toBuilder().managedZone(anotherMock).build(); - assertNotEquals(clone, RECORD); + clone = record.toBuilder().managedZone(anotherMock).build(); + assertNotEquals(clone, record); } @Test public void testSameHashCodeOnEquals() { - int hash = RECORD.hashCode(); - DnsRecord clone = RECORD.toBuilder().build(); + int hash = record.hashCode(); + DnsRecord clone = record.toBuilder().build(); assertEquals(clone.hashCode(), hash); } @Test public void testDifferentHashCodeOnDifferent() { - int hash = RECORD.hashCode(); + int hash = record.hashCode(); final String differentName = "totally different name"; - DnsRecord clone = RECORD.toBuilder().name(differentName).build(); - assertNotEquals(differentName, RECORD.name()); + DnsRecord clone = record.toBuilder().name(differentName).build(); + assertNotEquals(differentName, record.name()); assertNotEquals(clone.hashCode(), hash); - DnsRecord anotherClone = RECORD.toBuilder().add("another record").build(); + DnsRecord anotherClone = record.toBuilder().add("another record").build(); assertNotEquals(anotherClone.hashCode(), hash); } From 1fc0e3275e352706734dc935c6d4bab77976fb1c Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 20 Jan 2016 17:55:43 -0800 Subject: [PATCH 005/203] Implemented comments by @aozarov. Also removed incomplete ManagedZoneInfo.java. --- .../java/com/google/gcloud/dns/DnsRecord.java | 170 ++++++++++-------- .../google/gcloud/dns/ManagedZoneInfo.java | 44 ----- .../com/google/gcloud/dns/DnsRecordTest.java | 68 ++----- 3 files changed, 105 insertions(+), 177 deletions(-) delete mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index 91278fa2a1e7..9cc21acfa0a5 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.gcloud.dns; import static com.google.common.base.Preconditions.checkArgument; @@ -20,6 +21,7 @@ import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import java.io.Serializable; @@ -30,7 +32,10 @@ /** * A class that represents Google Cloud DNS record set. * - *

A unit of data that will be returned by the DNS servers. + *

A DnsRecord is the unit of data that will be returned by the DNS servers upon a DNS request + * for a specific domain. The DnsRecord holds the current state of the DNS records that make up a + * managed zone. You can read the records but you do not modify them directly. Rather, you edit + * the records in a managed zone by creating a {@link ChangeRequest}. * * @see Google Cloud DNS * documentation @@ -42,26 +47,6 @@ public class DnsRecord implements Serializable { private final List rrdatas; private final Integer ttl; private final DnsRecordType type; - private final String zoneName; - private final Long zoneId; - - private DnsRecord() { - this.name = null; - this.rrdatas = null; - this.ttl = null; - this.type = null; - this.zoneName = null; - this.zoneId = null; - } - - DnsRecord(Builder builder) { - this.name = builder.name; - this.rrdatas = ImmutableList.copyOf(builder.rrdatas); - this.ttl = builder.ttl; - this.type = builder.type; - this.zoneName = builder.zoneName; - this.zoneId = builder.zoneId; - } /** * Enum for the DNS record types supported by Cloud DNS. @@ -73,16 +58,51 @@ private DnsRecord() { * supported record types */ public enum DnsRecordType { + /** + * Address record, which is used to map host names to their IPv4 address. + */ A, + /** + * IPv6 Address record, which is used to map host names to their IPv6 address. + */ AAAA, + /** + * Canonical name record, which is used to alias names. + */ CNAME, + /** + * Mail exchange record, which is used in routing requests to mail servers. + */ MX, + /** + * Naming authority pointer record, defined by RFC3403. + */ NAPTR, + /** + * Name server record, which delegates a DNS zone to an authoritative server. + */ NS, + /** + * Pointer record, which is often used for reverse DNS lookups. + */ PTR, + /** + * Start of authority record, which specifies authoritative information about a DNS zone. + */ SOA, + /** + * Sender policy framework record, which is used in email validation systems. + */ SPF, + /** + * Service locator record, which is used by some voice over IP, instant messaging protocols and + * other applications. + */ SRV, + /** + * Text record, which can contain arbitrary text and can also be used to define machine readable + * data such as security or abuse prevention information. + */ TXT } @@ -92,8 +112,6 @@ public static class Builder { private String name; private Integer ttl; private DnsRecordType type; - private String zoneName; - private Long zoneId; private Builder() { } @@ -102,12 +120,10 @@ private Builder() { * Creates a builder and pre-populates attributes with the values from the provided DnsRecord * instance. */ - public Builder(DnsRecord record) { + private Builder(DnsRecord record) { this.name = record.name; this.ttl = record.ttl; this.type = record.type; - this.zoneId = record.zoneId; - this.zoneName = record.zoneName; this.rrdatas.addAll(record.rrdatas); } @@ -118,11 +134,46 @@ public Builder(DnsRecord record) { * @see Google * DNS documentation . */ - public Builder add(String record) { + public Builder addRecord(String record) { this.rrdatas.add(checkNotNull(record)); return this; } + /** + * Removes a record from the set. An exact match is required. + */ + public Builder removerRecord(String record) { + this.rrdatas.remove(checkNotNull(record)); + return this; + } + + /** + * Removes a record on the given index from the set. + */ + public Builder removerRecord(int index) { + checkArgument(index >= 0 && index < this.rrdatas.size(), "The index is out of bounds. An " + + "integer between 0 and " + (this.rrdatas.size() - 1) + " is required. The provided " + + "value was " + index + "."); + this.rrdatas.remove(index); + return this; + } + + /** + * Removes all the records. + */ + public Builder clearRecords() { + this.rrdatas.clear(); + return this; + } + + /** + * Replaces the current records with the provided list of records. + */ + public Builder records(List records) { + this.rrdatas = Lists.newLinkedList(checkNotNull(records)); + return this; + } + /** * Sets name for this DNS record set. For example, www.example.com. */ @@ -157,26 +208,13 @@ public Builder type(DnsRecordType type) { public DnsRecord build() { return new DnsRecord(this); } + } - /** - * Sets references to the managed zone that this DNS record belongs to. - * - * todo(mderka): consider if this method is needed; may not be possible when listing records - */ - Builder managedZone(ManagedZoneInfo parent) { - checkNotNull(parent); - this.zoneId = parent.id(); - this.zoneName = parent.name(); - return this; - } - - /** - * Sets name reference to the managed zone that this DNS record belongs to. - */ - Builder managedZone(String managedZoneName) { - this.zoneName = checkNotNull(managedZoneName); - return this; - } + DnsRecord(Builder builder) { + this.name = builder.name; + this.rrdatas = ImmutableList.copyOf(builder.rrdatas); + this.ttl = builder.ttl; + this.type = builder.type; } /** @@ -187,7 +225,7 @@ public Builder toBuilder() { } /** - * Creates an empty builder + * Creates an empty builder. */ public static Builder builder() { return new Builder(); @@ -203,13 +241,12 @@ public String name() { /** * Returns a list of DNS record stored in this record set. */ - public List rrdatas() { + public List records() { return rrdatas; } /** - * Returns the number of seconds that this DnsResource can be cached by resolvers. This number is - * provided by the user. + * Returns the number of seconds that this DnsResource can be cached by resolvers. */ public Integer ttl() { return ttl; @@ -222,44 +259,21 @@ public DnsRecordType type() { return type; } - /** - * Returns name of the managed zone that this record belongs to. The name of the managed zone is - * provided by the user when the managed zone is created. It is unique within a project. If this - * DNS record is not associated with a managed zone, this returns null. - */ - public String zoneName() { - return zoneName; - } - - /** - * Returns id of the managed zone that this record belongs to. - * - *

The id of the managed zone is determined by the server when the managed zone is created. It - * is a read only value. If this DNS record is not associated with a managed zone, or if the id of - * the managed zone was not loaded from the cloud service, this returns null. - */ - public Long zoneId() { - return zoneId; - } - @Override public int hashCode() { - return Objects.hash(name, rrdatas, ttl, type, zoneName, zoneId); + return Objects.hash(name, rrdatas, ttl, type); } @Override public boolean equals(Object obj) { - return (obj instanceof DnsRecord) && Objects.equals(this.toPb(), ((DnsRecord) obj).toPb()) - && this.zoneId().equals(((DnsRecord) obj).zoneId()) - && this.zoneName().equals(((DnsRecord) obj).zoneName()); - + return (obj instanceof DnsRecord) && Objects.equals(this.toPb(), ((DnsRecord) obj).toPb()); } com.google.api.services.dns.model.ResourceRecordSet toPb() { com.google.api.services.dns.model.ResourceRecordSet pb = new com.google.api.services.dns.model.ResourceRecordSet(); pb.setName(this.name()); - pb.setRrdatas(this.rrdatas()); + pb.setRrdatas(this.records()); pb.setTtl(this.ttl()); pb.setType(this.type() == null ? null : this.type().name()); return pb; @@ -269,11 +283,9 @@ com.google.api.services.dns.model.ResourceRecordSet toPb() { public String toString() { return MoreObjects.toStringHelper(this) .add("name", name()) - .add("rrdatas", rrdatas()) + .add("rrdatas", records()) .add("ttl", ttl()) .add("type", type()) - .add("zoneName", zoneName()) - .add("zoneId", zoneId()) .toString(); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java deleted file mode 100644 index d5ed8351dc34..000000000000 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * 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.gcloud.dns; - -/** - * todo(mderka): Implement. - * todo(mderka): Add documentation. - */ -public class ManagedZoneInfo { - - private final String name; - private final Long id; - - public String name() { - throw new UnsupportedOperationException("Not implemented yet."); - // todo(mderka): Implement - } - - public Long id() { - return id; - // todo(mderka): Implement - } - - private ManagedZoneInfo() { - name = null; - id = null; - throw new UnsupportedOperationException("Not implemented yet"); - // todo(mderka): Implement - } - -} diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java index ee9e6e58d61d..4c03306ffb02 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java @@ -20,63 +20,40 @@ import static org.junit.Assert.fail; import static org.junit.Assert.assertNotEquals; -import org.junit.BeforeClass; import org.junit.Test; -import org.easymock.EasyMock; - public class DnsRecordTest { private static final String NAME = "example.com."; private static final Integer TTL = 3600; private static final DnsRecord.DnsRecordType TYPE = DnsRecord.DnsRecordType.AAAA; - private static final Long ZONE_ID = 12L; - private static final String ZONE_NAME = "name"; - // the following is initialized in @BeforeClass setUp() - private static DnsRecord record; - private static ManagedZoneInfo managedZoneInfoMock; - - @BeforeClass - public static void setUp() { - managedZoneInfoMock = EasyMock.createMock(ManagedZoneInfo.class); - EasyMock.expect(managedZoneInfoMock.id()).andReturn(ZONE_ID); - EasyMock.expect(managedZoneInfoMock.name()).andReturn(ZONE_NAME); - EasyMock.replay(managedZoneInfoMock); - record = DnsRecord.builder() - .name(NAME) - .ttl(TTL) - .managedZone(managedZoneInfoMock) - .build(); - } + private static final DnsRecord record = DnsRecord.builder() + .name(NAME) + .ttl(TTL) + .type(TYPE) + .build(); @Test public void testDefaultDnsRecord() { DnsRecord record = DnsRecord.builder().build(); - assertEquals(0, record.rrdatas().size()); + assertEquals(0, record.records().size()); } @Test public void testBuilder() { - assertEquals(NAME, record.name()); assertEquals(TTL, record.ttl()); - - assertEquals(ZONE_ID, record.zoneId()); // this was never assigned - assertEquals(ZONE_NAME, record.zoneName()); - assertEquals(0, record.rrdatas().size()); + assertEquals(0, record.records().size()); // verify that one can add records to the record set String testingRecord = "Testing record"; String anotherTestingRecord = "Another record 123"; - String differentName = ZONE_NAME + "something"; DnsRecord anotherRecord = record.toBuilder() - .add(testingRecord) - .add(anotherTestingRecord) - .managedZone(differentName) + .addRecord(testingRecord) + .addRecord(anotherTestingRecord) .build(); - assertEquals(2, anotherRecord.rrdatas().size()); - assertEquals(differentName, anotherRecord.zoneName()); - assertTrue(anotherRecord.rrdatas().contains(testingRecord)); - assertTrue(anotherRecord.rrdatas().contains(anotherTestingRecord)); + assertEquals(2, anotherRecord.records().size()); + assertTrue(anotherRecord.records().contains(testingRecord)); + assertTrue(anotherRecord.records().contains(anotherTestingRecord)); } @Test @@ -95,7 +72,8 @@ public void testValidTtl() { public void testEqualsAndNotEquals() { DnsRecord clone = record.toBuilder().build(); assertEquals(clone, record); - clone = record.toBuilder().add("another record").build(); + clone = record.toBuilder().addRecord("another record").build(); + assertNotEquals(clone, record); final String differentName = "totally different name"; clone = record.toBuilder().name(differentName).build(); assertNotEquals(clone, record); @@ -103,12 +81,6 @@ public void testEqualsAndNotEquals() { assertNotEquals(clone, record); clone = record.toBuilder().type(DnsRecord.DnsRecordType.TXT).build(); assertNotEquals(clone, record); - ManagedZoneInfo anotherMock = EasyMock.createMock(ManagedZoneInfo.class); - EasyMock.expect(anotherMock.id()).andReturn(ZONE_ID + 1); - EasyMock.expect(anotherMock.name()).andReturn(ZONE_NAME + "more text"); - EasyMock.replay(anotherMock); - clone = record.toBuilder().managedZone(anotherMock).build(); - assertNotEquals(clone, record); } @Test @@ -117,16 +89,4 @@ public void testSameHashCodeOnEquals() { DnsRecord clone = record.toBuilder().build(); assertEquals(clone.hashCode(), hash); } - - @Test - public void testDifferentHashCodeOnDifferent() { - int hash = record.hashCode(); - final String differentName = "totally different name"; - DnsRecord clone = record.toBuilder().name(differentName).build(); - assertNotEquals(differentName, record.name()); - assertNotEquals(clone.hashCode(), hash); - DnsRecord anotherClone = record.toBuilder().add("another record").build(); - assertNotEquals(anotherClone.hashCode(), hash); - } - } From 01662be5e9f6bf11496d84b909676f97ca0401b9 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 21 Jan 2016 10:00:41 -0800 Subject: [PATCH 006/203] Implements comments by @ajkannan --- gcloud-java-dns/pom.xml | 12 +++--- .../java/com/google/gcloud/dns/DnsRecord.java | 37 ++++++++++++------- .../com/google/gcloud/dns/DnsRecordTest.java | 36 ++++++++++++++---- pom.xml | 1 + 4 files changed, 59 insertions(+), 27 deletions(-) diff --git a/gcloud-java-dns/pom.xml b/gcloud-java-dns/pom.xml index 55d720bc0a36..5f04f261d500 100644 --- a/gcloud-java-dns/pom.xml +++ b/gcloud-java-dns/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 com.google.gcloud gcloud-java-dns @@ -28,10 +30,10 @@ v1-rev7-1.21.0 compile - - com.google.guava - guava-jdk5 - + + com.google.guava + guava-jdk5 + com.google.api-client google-api-client diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index 9cc21acfa0a5..f73c880f22f3 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -24,18 +24,17 @@ import com.google.common.collect.Lists; import java.io.Serializable; - import java.util.LinkedList; import java.util.List; import java.util.Objects; /** - * A class that represents Google Cloud DNS record set. + * A class that represents a Google Cloud DNS record set. * - *

A DnsRecord is the unit of data that will be returned by the DNS servers upon a DNS request - * for a specific domain. The DnsRecord holds the current state of the DNS records that make up a - * managed zone. You can read the records but you do not modify them directly. Rather, you edit - * the records in a managed zone by creating a {@link ChangeRequest}. + *

A {@code DnsRecord} is the unit of data that will be returned by the DNS servers upon a DNS + * request for a specific domain. The {@code DnsRecord} holds the current state of the DNS records + * that make up a managed zone. You can read the records but you do not modify them directly. + * Rather, you edit the records in a managed zone by creating a ChangeRequest. * * @see Google Cloud DNS * documentation @@ -117,8 +116,8 @@ private Builder() { } /** - * Creates a builder and pre-populates attributes with the values from the provided DnsRecord - * instance. + * Creates a builder and pre-populates attributes with the values from the provided {@code + * DnsRecord} instance. */ private Builder(DnsRecord record) { this.name = record.name; @@ -142,7 +141,7 @@ public Builder addRecord(String record) { /** * Removes a record from the set. An exact match is required. */ - public Builder removerRecord(String record) { + public Builder removeRecord(String record) { this.rrdatas.remove(checkNotNull(record)); return this; } @@ -150,7 +149,7 @@ public Builder removerRecord(String record) { /** * Removes a record on the given index from the set. */ - public Builder removerRecord(int index) { + public Builder removeRecord(int index) { checkArgument(index >= 0 && index < this.rrdatas.size(), "The index is out of bounds. An " + "integer between 0 and " + (this.rrdatas.size() - 1) + " is required. The provided " + "value was " + index + "."); @@ -225,10 +224,10 @@ public Builder toBuilder() { } /** - * Creates an empty builder. + * Creates a builder for {@code DnsRecord} with mandatorily set name and type of the record. */ - public static Builder builder() { - return new Builder(); + public static Builder builder(String name, DnsRecordType type) { + return new Builder().name(name).type(type); } /** @@ -279,6 +278,17 @@ com.google.api.services.dns.model.ResourceRecordSet toPb() { return pb; } + static DnsRecord fromPb(com.google.api.services.dns.model.ResourceRecordSet pb) { + Builder b = builder(pb.getName(), DnsRecordType.valueOf(pb.getType())); + if (pb.getRrdatas() != null) { + b.records(pb.getRrdatas()); + } + if (pb.getTtl() != null) { + b.ttl(pb.getTtl()); + } + return b.build(); + } + @Override public String toString() { return MoreObjects.toStringHelper(this) @@ -288,5 +298,4 @@ public String toString() { .add("type", type()) .toString(); } - } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java index 4c03306ffb02..e5b283a20acc 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java @@ -27,15 +27,13 @@ public class DnsRecordTest { private static final String NAME = "example.com."; private static final Integer TTL = 3600; private static final DnsRecord.DnsRecordType TYPE = DnsRecord.DnsRecordType.AAAA; - private static final DnsRecord record = DnsRecord.builder() - .name(NAME) + private static final DnsRecord record = DnsRecord.builder(NAME, TYPE) .ttl(TTL) - .type(TYPE) .build(); @Test public void testDefaultDnsRecord() { - DnsRecord record = DnsRecord.builder().build(); + DnsRecord record = DnsRecord.builder(NAME, TYPE).build(); assertEquals(0, record.records().size()); } @@ -59,13 +57,13 @@ public void testBuilder() { @Test public void testValidTtl() { try { - DnsRecord.builder().ttl(-1); + DnsRecord.builder(NAME, TYPE).ttl(-1); fail("A negative value is not acceptable for ttl."); } catch (IllegalArgumentException e) { // expected } - DnsRecord.builder().ttl(0); - DnsRecord.builder().ttl(Integer.MAX_VALUE); + DnsRecord.builder(NAME, TYPE).ttl(0); + DnsRecord.builder(NAME, TYPE).ttl(Integer.MAX_VALUE); } @Test @@ -89,4 +87,26 @@ public void testSameHashCodeOnEquals() { DnsRecord clone = record.toBuilder().build(); assertEquals(clone.hashCode(), hash); } -} + + @Test + public void testToAndFromPb() { + assertEquals(record, DnsRecord.fromPb(record.toPb())); + DnsRecord partial = DnsRecord.builder(NAME, TYPE).build(); + assertEquals(partial, DnsRecord.fromPb(partial.toPb())); + partial = DnsRecord.builder(NAME, TYPE).addRecord("test").build(); + assertEquals(partial, DnsRecord.fromPb(partial.toPb())); + partial = DnsRecord.builder(NAME, TYPE).ttl(15).build(); + assertEquals(partial, DnsRecord.fromPb(partial.toPb())); + } + + @Test + public void testToBuilder() { + assertEquals(record, record.toBuilder().build()); + DnsRecord partial = DnsRecord.builder(NAME, TYPE).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = DnsRecord.builder(NAME, TYPE).addRecord("test").build(); + assertEquals(partial, partial.toBuilder().build()); + partial = DnsRecord.builder(NAME, TYPE).ttl(15).build(); + assertEquals(partial, partial.toBuilder().build()); + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index cd5c19720cd8..7a435cc1dbae 100644 --- a/pom.xml +++ b/pom.xml @@ -70,6 +70,7 @@ gcloud-java-bigquery gcloud-java-core gcloud-java-datastore + gcloud-java-dns gcloud-java-examples gcloud-java-resourcemanager gcloud-java-storage From 1c657158857a343c2ad4c761cb287d535f396704 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 21 Jan 2016 13:44:40 -0800 Subject: [PATCH 007/203] Removed the method for removing a record by index. --- .../main/java/com/google/gcloud/dns/DnsRecord.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index f73c880f22f3..41a8569d3937 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -146,17 +146,6 @@ public Builder removeRecord(String record) { return this; } - /** - * Removes a record on the given index from the set. - */ - public Builder removeRecord(int index) { - checkArgument(index >= 0 && index < this.rrdatas.size(), "The index is out of bounds. An " + - "integer between 0 and " + (this.rrdatas.size() - 1) + " is required. The provided " + - "value was " + index + "."); - this.rrdatas.remove(index); - return this; - } - /** * Removes all the records. */ From f994057f1d2e8bf4f6b1196d4ae578ba3321951b Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 22 Jan 2016 10:17:34 -0800 Subject: [PATCH 008/203] Another round of comments from @aozarov. --- .../java/com/google/gcloud/dns/DnsRecord.java | 47 ++++++++++--------- .../com/google/gcloud/dns/DnsRecordTest.java | 41 ++++++++++++---- 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index 41a8569d3937..c41e72a77400 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -33,7 +33,7 @@ * *

A {@code DnsRecord} is the unit of data that will be returned by the DNS servers upon a DNS * request for a specific domain. The {@code DnsRecord} holds the current state of the DNS records - * that make up a managed zone. You can read the records but you do not modify them directly. + * that make up a managed zone. You can read the records but you cannot modify them directly. * Rather, you edit the records in a managed zone by creating a ChangeRequest. * * @see Google Cloud DNS @@ -45,7 +45,7 @@ public class DnsRecord implements Serializable { private final String name; private final List rrdatas; private final Integer ttl; - private final DnsRecordType type; + private final Type type; /** * Enum for the DNS record types supported by Cloud DNS. @@ -56,7 +56,7 @@ public class DnsRecord implements Serializable { * @see Cloud DNS * supported record types */ - public enum DnsRecordType { + public enum Type { /** * Address record, which is used to map host names to their IPv4 address. */ @@ -105,14 +105,19 @@ public enum DnsRecordType { TXT } + /** + * A builder of {@link DnsRecord}. + */ public static class Builder { private List rrdatas = new LinkedList<>(); private String name; private Integer ttl; - private DnsRecordType type; + private Type type; - private Builder() { + private Builder(String name, Type type) { + this.name = checkNotNull(name); + this.type = checkNotNull(type); } /** @@ -177,7 +182,7 @@ public Builder name(String name) { * @param ttl A non-negative number of seconds */ public Builder ttl(int ttl) { - checkArgument(ttl >= 0, "TTL cannot be negative. The supplied value was " + ttl + "."); + checkArgument(ttl >= 0, "TTL cannot be negative. The supplied value was %s.", ttl); this.ttl = ttl; return this; } @@ -185,7 +190,7 @@ public Builder ttl(int ttl) { /** * The identifier of a supported record type, for example, A, AAAA, MX, TXT, and so on. */ - public Builder type(DnsRecordType type) { + public Builder type(Type type) { this.type = checkNotNull(type); return this; } @@ -198,7 +203,7 @@ public DnsRecord build() { } } - DnsRecord(Builder builder) { + private DnsRecord(Builder builder) { this.name = builder.name; this.rrdatas = ImmutableList.copyOf(builder.rrdatas); this.ttl = builder.ttl; @@ -213,14 +218,14 @@ public Builder toBuilder() { } /** - * Creates a builder for {@code DnsRecord} with mandatorily set name and type of the record. + * Creates a {@code DnsRecord} builder for the given {@code name} and {@code type}. */ - public static Builder builder(String name, DnsRecordType type) { - return new Builder().name(name).type(type); + public static Builder builder(String name, Type type) { + return new Builder(name, type); } /** - * Get the mandatory user assigned name of this DNS record. + * Returns the user-assigned name of this DNS record. */ public String name() { return name; @@ -243,7 +248,7 @@ public Integer ttl() { /** * Returns the type of this DNS record. */ - public DnsRecordType type() { + public Type type() { return type; } @@ -259,16 +264,16 @@ public boolean equals(Object obj) { com.google.api.services.dns.model.ResourceRecordSet toPb() { com.google.api.services.dns.model.ResourceRecordSet pb = - new com.google.api.services.dns.model.ResourceRecordSet(); + new com.google.api.services.dns.model.ResourceRecordSet(); pb.setName(this.name()); pb.setRrdatas(this.records()); pb.setTtl(this.ttl()); - pb.setType(this.type() == null ? null : this.type().name()); + pb.setType(this.type().name()); return pb; } static DnsRecord fromPb(com.google.api.services.dns.model.ResourceRecordSet pb) { - Builder b = builder(pb.getName(), DnsRecordType.valueOf(pb.getType())); + Builder b = builder(pb.getName(), Type.valueOf(pb.getType())); if (pb.getRrdatas() != null) { b.records(pb.getRrdatas()); } @@ -281,10 +286,10 @@ static DnsRecord fromPb(com.google.api.services.dns.model.ResourceRecordSet pb) @Override public String toString() { return MoreObjects.toStringHelper(this) - .add("name", name()) - .add("rrdatas", records()) - .add("ttl", ttl()) - .add("type", type()) - .toString(); + .add("name", name()) + .add("rrdatas", records()) + .add("ttl", ttl()) + .add("type", type()) + .toString(); } } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java index e5b283a20acc..43ced20cf207 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java @@ -26,29 +26,32 @@ public class DnsRecordTest { private static final String NAME = "example.com."; private static final Integer TTL = 3600; - private static final DnsRecord.DnsRecordType TYPE = DnsRecord.DnsRecordType.AAAA; + private static final DnsRecord.Type TYPE = DnsRecord.Type.AAAA; private static final DnsRecord record = DnsRecord.builder(NAME, TYPE) - .ttl(TTL) - .build(); + .ttl(TTL) + .build(); @Test public void testDefaultDnsRecord() { DnsRecord record = DnsRecord.builder(NAME, TYPE).build(); assertEquals(0, record.records().size()); + assertEquals(TYPE, record.type()); + assertEquals(NAME, record.name()); } @Test public void testBuilder() { assertEquals(NAME, record.name()); assertEquals(TTL, record.ttl()); + assertEquals(TYPE, record.type()); assertEquals(0, record.records().size()); // verify that one can add records to the record set String testingRecord = "Testing record"; String anotherTestingRecord = "Another record 123"; DnsRecord anotherRecord = record.toBuilder() - .addRecord(testingRecord) - .addRecord(anotherTestingRecord) - .build(); + .addRecord(testingRecord) + .addRecord(anotherTestingRecord) + .build(); assertEquals(2, anotherRecord.records().size()); assertTrue(anotherRecord.records().contains(testingRecord)); assertTrue(anotherRecord.records().contains(anotherTestingRecord)); @@ -72,12 +75,12 @@ public void testEqualsAndNotEquals() { assertEquals(clone, record); clone = record.toBuilder().addRecord("another record").build(); assertNotEquals(clone, record); - final String differentName = "totally different name"; + String differentName = "totally different name"; clone = record.toBuilder().name(differentName).build(); assertNotEquals(clone, record); clone = record.toBuilder().ttl(record.ttl() + 1).build(); assertNotEquals(clone, record); - clone = record.toBuilder().type(DnsRecord.DnsRecordType.TXT).build(); + clone = record.toBuilder().type(DnsRecord.Type.TXT).build(); assertNotEquals(clone, record); } @@ -109,4 +112,24 @@ public void testToBuilder() { partial = DnsRecord.builder(NAME, TYPE).ttl(15).build(); assertEquals(partial, partial.toBuilder().build()); } -} \ No newline at end of file + + @Test + public void clearRecordSet() { + // make sure that we are starting not empty + DnsRecord clone = record.toBuilder().addRecord("record").addRecord("another").build(); + assertNotEquals(0, clone.records().size()); + clone = clone.toBuilder().clearRecords().build(); + assertEquals(0, clone.records().size()); + clone.toPb(); // verify that pb allows it + } + + @Test + public void removeFromRecordSet() { + String recordString = "record"; + // make sure that we are starting not empty + DnsRecord clone = record.toBuilder().addRecord(recordString).build(); + assertNotEquals(0, clone.records().size()); + clone = clone.toBuilder().removeRecord(recordString).build(); + assertEquals(0, clone.records().size()); + } +} From e8dd142fb0a6db4322fb83b79e999d97bd88e94e Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 19 Jan 2016 16:34:50 -0800 Subject: [PATCH 009/203] Created a ManagedZoneInfo class as part of the model. --- .../google/gcloud/dns/ManagedZoneInfo.java | 334 ++++++++++++++++++ .../gcloud/dns/ManagedZoneInfoTest.java | 198 +++++++++++ 2 files changed, 532 insertions(+) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java new file mode 100644 index 000000000000..e5b50b3e6669 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java @@ -0,0 +1,334 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; + +import org.joda.time.DateTime; +import org.joda.time.format.ISODateTimeFormat; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; + +/** + * This class is a container for the managed zone metainformation. Managed zone is a resource that + * represents a DNS zone hosted by the Cloud DNS service. See Google + * Cloud DNS documentation for more information. + */ +public class ManagedZoneInfo implements Serializable { + + private static final long serialVersionUID = 201601191647L; + private final String name; + private final Long id; + private final Long creationTimeMillis; + private final String dnsName; + private final String description; + private final String nameServerSet; + private final List nameServers; + + /** + * A builder for {@code ManagedZoneInfo}. + */ + public static class Builder { + private String name; + private Long id; + private Long creationTimeMillis; + private String dnsName; + private String description; + private String nameServerSet; + private List nameServers = new LinkedList<>(); + + private Builder() { + } + + private Builder(Long id) { + this.id = checkNotNull(id); + } + + private Builder(String name) { + this.name = checkNotNull(name); + } + + private Builder(String name, Long id) { + this.name = checkNotNull(name); + this.id = checkNotNull(id); + } + + /** + * Creates a builder from an existing ManagedZoneInfo object. + */ + Builder(ManagedZoneInfo info) { + this.name = info.name; + this.id = info.id; + this.creationTimeMillis = info.creationTimeMillis; + this.dnsName = info.dnsName; + this.description = info.description; + this.nameServerSet = info.nameServerSet; + this.nameServers.addAll(info.nameServers); + } + + /** + * Sets a mandatory user-provided name for the zone. It must be unique within the project. + */ + public Builder name(String name) { + this.name = checkNotNull(name); + return this; + } + + /** + * Sets an id for the managed zone which is assigned to the managed zone by the server. + */ + public Builder id(long id) { + this.id = id; + return this; + } + + /** + * Sets the time when this managed zone was created. + */ + Builder creationTimeMillis(long creationTimeMillis) { + checkArgument(creationTimeMillis >= 0, "The timestamp cannot be negative."); + this.creationTimeMillis = creationTimeMillis; + return this; + } + + /** + * Sets a mandatory DNS name of this managed zone, for instance "example.com.". + */ + public Builder dnsName(String dnsName) { + this.dnsName = checkNotNull(dnsName); + return this; + } + + /** + * Sets a mandatory description for this managed zone. The value is a string of at most 1024 + * characters (this limit is posed by Google Cloud DNS; gcloud-java does not enforce the limit) + * which has no effect on the managed zone's function. + */ + public Builder description(String description) { + this.description = checkNotNull(description); + return this; + } + + /** + * Optionally specifies the NameServerSet for this managed zone. A NameServerSet is a set of DNS + * name servers that all host the same ManagedZones. + */ + public Builder nameServerSet(String nameServerSet) { + // todo(mderka) add more to the doc when questions are answered by the service owner + this.nameServerSet = checkNotNull(nameServerSet); + return this; + } + + /** + * Sets a list of servers that hold the information about the managed zone. This information is + * provided by Google Cloud DNS and is read only. + */ + Builder nameServers(List nameServers) { + this.nameServers.addAll(checkNotNull(nameServers)); + return this; + } + + /** + * Removes all the nameservers from the list. + */ + Builder clearNameServers() { + this.nameServers.clear(); + return this; + } + + /** + * Builds the instance of ManagedZoneInfo based on the information set here. + */ + public ManagedZoneInfo build() { + return new ManagedZoneInfo(this); + } + } + + private ManagedZoneInfo(Builder builder) { + this.name = builder.name; + this.id = builder.id; + this.creationTimeMillis = builder.creationTimeMillis; + this.dnsName = builder.dnsName; + this.description = builder.description; + this.nameServerSet = builder.nameServerSet; + this.nameServers = ImmutableList.copyOf(builder.nameServers); + } + + /** + * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code name}. + */ + public static Builder builder(String name) { + return new Builder(name); + } + + /** + * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code id}. + */ + public static Builder builder(Long id) { + return new Builder(id); + } + + /** + * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code name} and {@code id}. + */ + public static Builder builder(String name, Long id) { + return new Builder(name, id); + } + + /** + * Returns an empty builder for {@code ManagedZoneInfo}. We use it internally in {@code toPb()}. + */ + private static Builder builder() { + return new Builder(); + } + + /** + * Returns the user-defined name of the managed zone. + */ + public String name() { + return name; + } + + /** + * Returns the read-only managed zone id assigned by the server. + */ + public Long id() { + return id; + } + + /** + * Returns the time when this time that this managed zone was created on the server. + */ + public Long creationTimeMillis() { + return creationTimeMillis; + } + + /** + * Returns the DNS name of this managed zone, for instance "example.com.". + */ + public String dnsName() { + return dnsName; + } + + /** + * Returns the description of this managed zone. This is at most 1024 long mandatory string + * provided by the user. + */ + public String description() { + return description; + } + + /** + * Returns the optionally specified set of DNS name servers that all host this managed zone. + */ + public String nameServerSet() { + // todo(mderka) update this doc after finding out more about this from the service owners + return nameServerSet; + } + + /** + * The nameservers that the managed zone should be delegated to. This is defined by the Google DNS + * cloud. + */ + public List nameServers() { + return nameServers; + } + + /** + * Returns a builder for {@code ManagedZoneInfo} prepopulated with the metadata of this managed + * zone. + */ + public Builder toBuilder() { + return new Builder(this); + } + + com.google.api.services.dns.model.ManagedZone toPb() { + com.google.api.services.dns.model.ManagedZone pb = + new com.google.api.services.dns.model.ManagedZone(); + pb.setDescription(this.description()); + pb.setDnsName(this.dnsName()); + if (this.id() != null) { + pb.setId(BigInteger.valueOf(this.id())); + } + pb.setName(this.name()); + pb.setNameServers(this.nameServers()); + pb.setNameServerSet(this.nameServerSet()); + if (this.creationTimeMillis() != null) { + pb.setCreationTime(ISODateTimeFormat.dateTime() + .withZoneUTC() + .print(this.creationTimeMillis())); + } + return pb; + } + + static ManagedZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) { + Builder b = builder(); + if (pb.getDescription() != null) { + b.description(pb.getDescription()); + } + if (pb.getDnsName() != null) { + b.dnsName(pb.getDnsName()); + } + if (pb.getId() != null) { + b.id(pb.getId().longValue()); + } + if (pb.getName() != null) { + b.name(pb.getName()); + } + if (pb.getNameServers() != null) { + b.nameServers(pb.getNameServers()); + } + if (pb.getNameServerSet() != null) { + b.nameServerSet(pb.getNameServerSet()); + } + if (pb.getCreationTime() != null) { + b.creationTimeMillis(DateTime.parse(pb.getCreationTime()).getMillis()); + } + return b.build(); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof ManagedZoneInfo && Objects.equals(toPb(), ((ManagedZoneInfo) obj).toPb()); + } + + @Override + public int hashCode() { + return Objects.hash(name, id, creationTimeMillis, dnsName, + description, nameServerSet, nameServers); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("name", name()) + .add("id", id()) + .add("description", description()) + .add("dnsName", dnsName()) + .add("nameServerSet", nameServerSet()) + .add("nameServers", nameServers()) + .toString(); + } +} diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java new file mode 100644 index 000000000000..6516c7577d2f --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java @@ -0,0 +1,198 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.common.collect.Lists; + +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.LinkedList; +import java.util.List; + +public class ManagedZoneInfoTest { + + private static final String NAME = "mz-example.com"; + private static final Long ID = 123L; + private static final Long CREATION_TIME_MILLIS = 1123468321321L; + private static final String DNS_NAME = "example.com."; + private static final String DESCRIPTION = "description for the zone"; + private static final String NAME_SERVER_SET = "some set"; + private static final String NS1 = "name server 1"; + private static final String NS2 = "name server 2"; + private static final String NS3 = "name server 3"; + private static List nameServers = new LinkedList<>(); + private static ManagedZoneInfo info; + + @BeforeClass + public static void setUp() { + nameServers.add(NS1); + nameServers.add(NS2); + nameServers.add(NS3); + assertEquals(3, nameServers.size()); + info = ManagedZoneInfo.builder(NAME, ID) + .creationTimeMillis(CREATION_TIME_MILLIS) + .dnsName(DNS_NAME) + .description(DESCRIPTION) + .nameServerSet(NAME_SERVER_SET) + .nameServers(nameServers) + .build(); + System.out.println(info); + } + + @Test + public void testDefaultBuilders() { + ManagedZoneInfo withName = ManagedZoneInfo.builder(NAME).build(); + assertTrue(withName.nameServers().isEmpty()); + assertEquals(NAME, withName.name()); + assertNull(withName.id()); + assertNull(withName.creationTimeMillis()); + assertNull(withName.nameServerSet()); + assertNull(withName.description()); + assertNull(withName.dnsName()); + ManagedZoneInfo withId = ManagedZoneInfo.builder(ID).build(); + assertTrue(withId.nameServers().isEmpty()); + assertEquals(ID, withId.id()); + assertNull(withId.name()); + assertNull(withId.creationTimeMillis()); + assertNull(withId.nameServerSet()); + assertNull(withId.description()); + assertNull(withId.dnsName()); + ManagedZoneInfo withBoth = ManagedZoneInfo.builder(NAME, ID).build(); + assertTrue(withBoth.nameServers().isEmpty()); + assertEquals(ID, withBoth.id()); + assertEquals(NAME, withBoth.name()); + assertNull(withBoth.creationTimeMillis()); + assertNull(withBoth.nameServerSet()); + assertNull(withBoth.description()); + assertNull(withBoth.dnsName()); + } + + @Test + public void testBuilder() { + assertEquals(3, info.nameServers().size()); + assertEquals(NS1, info.nameServers().get(0)); + assertEquals(NS2, info.nameServers().get(1)); + assertEquals(NS3, info.nameServers().get(2)); + assertEquals(NAME, info.name()); + assertEquals(ID, info.id()); + assertEquals(CREATION_TIME_MILLIS, info.creationTimeMillis()); + assertEquals(NAME_SERVER_SET, info.nameServerSet()); + assertEquals(DESCRIPTION, info.description()); + assertEquals(DNS_NAME, info.dnsName()); + } + + @Test + public void testValidCreationTime() { + try { + ManagedZoneInfo.builder(NAME).creationTimeMillis(-1); + fail("A negative value is not acceptable for creation time."); + } catch (IllegalArgumentException e) { + // expected + } + ManagedZoneInfo.builder(NAME).creationTimeMillis(0); + ManagedZoneInfo.builder(NAME).creationTimeMillis(Long.MAX_VALUE); + } + + @Test + public void testEqualsAndNotEquals() { + ManagedZoneInfo clone = info.toBuilder().build(); + assertEquals(clone, info); + List moreServers = Lists.newLinkedList(nameServers); + moreServers.add(NS1); + clone = info.toBuilder().nameServers(moreServers).build(); + assertNotEquals(clone, info); + String differentName = "totally different name"; + clone = info.toBuilder().name(differentName).build(); + assertNotEquals(clone, info); + clone = info.toBuilder().creationTimeMillis(info.creationTimeMillis() + 1).build(); + assertNotEquals(clone, info); + clone = info.toBuilder().description(info.description() + "aaaa").build(); + assertNotEquals(clone, info); + clone = info.toBuilder().dnsName(differentName).build(); + assertNotEquals(clone, info); + clone = info.toBuilder().id(info.id() + 1).build(); + assertNotEquals(clone, info); + clone = info.toBuilder().nameServerSet(info.nameServerSet() + "salt").build(); + assertNotEquals(clone, info); + } + + @Test + public void testSameHashCodeOnEquals() { + int hash = info.hashCode(); + ManagedZoneInfo clone = info.toBuilder().build(); + assertEquals(clone.hashCode(), hash); + } + + @Test + public void testToBuilder() { + assertEquals(info, info.toBuilder().build()); + ManagedZoneInfo partial = ManagedZoneInfo.builder(NAME).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ManagedZoneInfo.builder(ID).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ManagedZoneInfo.builder(NAME).description(DESCRIPTION).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ManagedZoneInfo.builder(NAME).dnsName(DNS_NAME).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ManagedZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build(); + assertEquals(partial, partial.toBuilder().build()); + List nameServers = new LinkedList<>(); + nameServers.add(NS1); + partial = ManagedZoneInfo.builder(NAME).nameServers(nameServers).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ManagedZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build(); + assertEquals(partial, partial.toBuilder().build()); + } + + @Test + public void testToAndFromPb() { + assertEquals(info, ManagedZoneInfo.fromPb(info.toPb())); + ManagedZoneInfo partial = ManagedZoneInfo.builder(NAME).build(); + assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); + partial = ManagedZoneInfo.builder(ID).build(); + assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); + partial = ManagedZoneInfo.builder(NAME).description(DESCRIPTION).build(); + assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); + partial = ManagedZoneInfo.builder(NAME).dnsName(DNS_NAME).build(); + assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); + partial = ManagedZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build(); + assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); + List nameServers = new LinkedList<>(); + nameServers.add(NS1); + partial = ManagedZoneInfo.builder(NAME).nameServers(nameServers).build(); + assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); + partial = ManagedZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build(); + assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); + } + + @Test + public void testClearNameServers() { + ManagedZoneInfo clone = info.toBuilder().build(); + assertFalse(clone.nameServers().isEmpty()); + clone = clone.toBuilder().clearNameServers().build(); + assertTrue(clone.nameServers().isEmpty()); + clone.toPb(); // test that this is allowed + } +} From c95c3aaa0c514ba573f29ee8d19a7619a0bf0e1c Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 22 Jan 2016 18:38:10 -0800 Subject: [PATCH 010/203] Implemented comments by @aozarov. --- .../google/gcloud/dns/ManagedZoneInfo.java | 65 ++++++++----------- .../gcloud/dns/ManagedZoneInfoTest.java | 43 ++++++------ 2 files changed, 49 insertions(+), 59 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java index e5b50b3e6669..191d41967124 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java @@ -16,11 +16,11 @@ package com.google.gcloud.dns; -import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import org.joda.time.DateTime; import org.joda.time.format.ISODateTimeFormat; @@ -32,15 +32,16 @@ import java.util.Objects; /** - * This class is a container for the managed zone metainformation. Managed zone is a resource that - * represents a DNS zone hosted by the Cloud DNS service. See Google - * Cloud DNS documentation for more information. + * A {@code ManagedZone} represents a DNS zone hosted by the Google Cloud DNS service. A zone is a + * subtree of the DNS namespace under one administrative responsibility. See Google Cloud DNS documentation for + * more information. */ public class ManagedZoneInfo implements Serializable { private static final long serialVersionUID = 201601191647L; private final String name; - private final Long id; + private final BigInteger id; private final Long creationTimeMillis; private final String dnsName; private final String description; @@ -52,17 +53,21 @@ public class ManagedZoneInfo implements Serializable { */ public static class Builder { private String name; - private Long id; + private BigInteger id; private Long creationTimeMillis; private String dnsName; private String description; private String nameServerSet; private List nameServers = new LinkedList<>(); + /** + * Returns an empty builder for {@code ManagedZoneInfo}. We use it internally in {@code + * toPb()}. + */ private Builder() { } - private Builder(Long id) { + private Builder(BigInteger id) { this.id = checkNotNull(id); } @@ -70,7 +75,7 @@ private Builder(String name) { this.name = checkNotNull(name); } - private Builder(String name, Long id) { + private Builder(String name, BigInteger id) { this.name = checkNotNull(name); this.id = checkNotNull(id); } @@ -99,7 +104,7 @@ public Builder name(String name) { /** * Sets an id for the managed zone which is assigned to the managed zone by the server. */ - public Builder id(long id) { + Builder id(BigInteger id) { this.id = id; return this; } @@ -108,7 +113,6 @@ public Builder id(long id) { * Sets the time when this managed zone was created. */ Builder creationTimeMillis(long creationTimeMillis) { - checkArgument(creationTimeMillis >= 0, "The timestamp cannot be negative."); this.creationTimeMillis = creationTimeMillis; return this; } @@ -123,8 +127,7 @@ public Builder dnsName(String dnsName) { /** * Sets a mandatory description for this managed zone. The value is a string of at most 1024 - * characters (this limit is posed by Google Cloud DNS; gcloud-java does not enforce the limit) - * which has no effect on the managed zone's function. + * characters which has no effect on the managed zone's function. */ public Builder description(String description) { this.description = checkNotNull(description); @@ -133,7 +136,8 @@ public Builder description(String description) { /** * Optionally specifies the NameServerSet for this managed zone. A NameServerSet is a set of DNS - * name servers that all host the same ManagedZones. + * name servers that all host the same ManagedZones. Most users will not need to specify this + * value. */ public Builder nameServerSet(String nameServerSet) { // todo(mderka) add more to the doc when questions are answered by the service owner @@ -146,20 +150,13 @@ public Builder nameServerSet(String nameServerSet) { * provided by Google Cloud DNS and is read only. */ Builder nameServers(List nameServers) { - this.nameServers.addAll(checkNotNull(nameServers)); + checkNotNull(nameServers); + this.nameServers = Lists.newLinkedList(nameServers); return this; } /** - * Removes all the nameservers from the list. - */ - Builder clearNameServers() { - this.nameServers.clear(); - return this; - } - - /** - * Builds the instance of ManagedZoneInfo based on the information set here. + * Builds the instance of {@code ManagedZoneInfo} based on the information set by this builder. */ public ManagedZoneInfo build() { return new ManagedZoneInfo(this); @@ -186,24 +183,17 @@ public static Builder builder(String name) { /** * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code id}. */ - public static Builder builder(Long id) { + public static Builder builder(BigInteger id) { return new Builder(id); } /** * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code name} and {@code id}. */ - public static Builder builder(String name, Long id) { + public static Builder builder(String name, BigInteger id) { return new Builder(name, id); } - /** - * Returns an empty builder for {@code ManagedZoneInfo}. We use it internally in {@code toPb()}. - */ - private static Builder builder() { - return new Builder(); - } - /** * Returns the user-defined name of the managed zone. */ @@ -214,7 +204,7 @@ public String name() { /** * Returns the read-only managed zone id assigned by the server. */ - public Long id() { + public BigInteger id() { return id; } @@ -233,8 +223,7 @@ public String dnsName() { } /** - * Returns the description of this managed zone. This is at most 1024 long mandatory string - * provided by the user. + * Returns the description of this managed zone. */ public String description() { return description; @@ -270,7 +259,7 @@ com.google.api.services.dns.model.ManagedZone toPb() { pb.setDescription(this.description()); pb.setDnsName(this.dnsName()); if (this.id() != null) { - pb.setId(BigInteger.valueOf(this.id())); + pb.setId(this.id()); } pb.setName(this.name()); pb.setNameServers(this.nameServers()); @@ -284,7 +273,7 @@ com.google.api.services.dns.model.ManagedZone toPb() { } static ManagedZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) { - Builder b = builder(); + Builder b = new Builder(); if (pb.getDescription() != null) { b.description(pb.getDescription()); } @@ -292,7 +281,7 @@ static ManagedZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) b.dnsName(pb.getDnsName()); } if (pb.getId() != null) { - b.id(pb.getId().longValue()); + b.id(pb.getId()); } if (pb.getName() != null) { b.name(pb.getName()); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java index 6516c7577d2f..89c9426f5b81 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java @@ -17,24 +17,23 @@ package com.google.gcloud.dns; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import com.google.common.collect.Lists; -import org.junit.BeforeClass; +import org.junit.Before; import org.junit.Test; +import java.math.BigInteger; import java.util.LinkedList; import java.util.List; public class ManagedZoneInfoTest { private static final String NAME = "mz-example.com"; - private static final Long ID = 123L; + private static final BigInteger ID = BigInteger.valueOf(123L); private static final Long CREATION_TIME_MILLIS = 1123468321321L; private static final String DNS_NAME = "example.com."; private static final String DESCRIPTION = "description for the zone"; @@ -42,15 +41,14 @@ public class ManagedZoneInfoTest { private static final String NS1 = "name server 1"; private static final String NS2 = "name server 2"; private static final String NS3 = "name server 3"; - private static List nameServers = new LinkedList<>(); - private static ManagedZoneInfo info; + private List nameServers = new LinkedList<>(); + private ManagedZoneInfo info; - @BeforeClass - public static void setUp() { + @Before + public void setUp() { nameServers.add(NS1); nameServers.add(NS2); nameServers.add(NS3); - assertEquals(3, nameServers.size()); info = ManagedZoneInfo.builder(NAME, ID) .creationTimeMillis(CREATION_TIME_MILLIS) .dnsName(DNS_NAME) @@ -58,7 +56,6 @@ public static void setUp() { .nameServerSet(NAME_SERVER_SET) .nameServers(nameServers) .build(); - System.out.println(info); } @Test @@ -105,12 +102,7 @@ public void testBuilder() { @Test public void testValidCreationTime() { - try { - ManagedZoneInfo.builder(NAME).creationTimeMillis(-1); - fail("A negative value is not acceptable for creation time."); - } catch (IllegalArgumentException e) { - // expected - } + ManagedZoneInfo.builder(NAME).creationTimeMillis(-1); ManagedZoneInfo.builder(NAME).creationTimeMillis(0); ManagedZoneInfo.builder(NAME).creationTimeMillis(Long.MAX_VALUE); } @@ -132,7 +124,7 @@ public void testEqualsAndNotEquals() { assertNotEquals(clone, info); clone = info.toBuilder().dnsName(differentName).build(); assertNotEquals(clone, info); - clone = info.toBuilder().id(info.id() + 1).build(); + clone = info.toBuilder().id(info.id().add(BigInteger.ONE)).build(); assertNotEquals(clone, info); clone = info.toBuilder().nameServerSet(info.nameServerSet() + "salt").build(); assertNotEquals(clone, info); @@ -188,11 +180,20 @@ public void testToAndFromPb() { } @Test - public void testClearNameServers() { - ManagedZoneInfo clone = info.toBuilder().build(); - assertFalse(clone.nameServers().isEmpty()); - clone = clone.toBuilder().clearNameServers().build(); + public void testEmptyNameServers() { + ManagedZoneInfo clone = info.toBuilder().nameServers(new LinkedList()).build(); assertTrue(clone.nameServers().isEmpty()); clone.toPb(); // test that this is allowed } + + @Test + public void testDateParsing() { + com.google.api.services.dns.model.ManagedZone pb = + info.toPb(); + pb.setCreationTime("2016-01-19T18:00:12.854Z"); // a real value obtained from Google Cloud DNS + ManagedZoneInfo mz = ManagedZoneInfo.fromPb(pb); // parses the string timestamp to millis + com.google.api.services.dns.model.ManagedZone pbClone = mz.toPb(); // converts it back to string + assertEquals(pb, pbClone); + assertEquals(pb.getCreationTime(), pbClone.getCreationTime()); + } } From dacea19f586e0ae5f344da65f4ebc5c248818288 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 25 Jan 2016 09:06:33 -0800 Subject: [PATCH 011/203] Another round of comments from @aozarov. --- .../google/gcloud/dns/ManagedZoneInfo.java | 1 + .../com/google/gcloud/dns/DnsRecordTest.java | 10 +- .../gcloud/dns/ManagedZoneInfoTest.java | 100 ++++++++---------- 3 files changed, 48 insertions(+), 63 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java index 191d41967124..d27e134ad908 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java @@ -318,6 +318,7 @@ public String toString() { .add("dnsName", dnsName()) .add("nameServerSet", nameServerSet()) .add("nameServers", nameServers()) + .add("creationTimeMillis", creationTimeMillis()) .toString(); } } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java index 43ced20cf207..412aa2ce08ad 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java @@ -72,16 +72,16 @@ public void testValidTtl() { @Test public void testEqualsAndNotEquals() { DnsRecord clone = record.toBuilder().build(); - assertEquals(clone, record); + assertEquals(record, clone); clone = record.toBuilder().addRecord("another record").build(); - assertNotEquals(clone, record); + assertNotEquals(record, clone); String differentName = "totally different name"; clone = record.toBuilder().name(differentName).build(); - assertNotEquals(clone, record); + assertNotEquals(record, clone); clone = record.toBuilder().ttl(record.ttl() + 1).build(); - assertNotEquals(clone, record); + assertNotEquals(record, clone); clone = record.toBuilder().type(DnsRecord.Type.TXT).build(); - assertNotEquals(clone, record); + assertNotEquals(record, clone); } @Test diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java index 89c9426f5b81..936164c81723 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java @@ -21,9 +21,9 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import org.junit.Before; import org.junit.Test; import java.math.BigInteger; @@ -41,22 +41,14 @@ public class ManagedZoneInfoTest { private static final String NS1 = "name server 1"; private static final String NS2 = "name server 2"; private static final String NS3 = "name server 3"; - private List nameServers = new LinkedList<>(); - private ManagedZoneInfo info; - - @Before - public void setUp() { - nameServers.add(NS1); - nameServers.add(NS2); - nameServers.add(NS3); - info = ManagedZoneInfo.builder(NAME, ID) - .creationTimeMillis(CREATION_TIME_MILLIS) - .dnsName(DNS_NAME) - .description(DESCRIPTION) - .nameServerSet(NAME_SERVER_SET) - .nameServers(nameServers) - .build(); - } + private static final List NAME_SERVERS = ImmutableList.of(NS1, NS2, NS3); + private static final ManagedZoneInfo INFO = ManagedZoneInfo.builder(NAME, ID) + .creationTimeMillis(CREATION_TIME_MILLIS) + .dnsName(DNS_NAME) + .description(DESCRIPTION) + .nameServerSet(NAME_SERVER_SET) + .nameServers(NAME_SERVERS) + .build(); @Test public void testDefaultBuilders() { @@ -88,58 +80,51 @@ public void testDefaultBuilders() { @Test public void testBuilder() { - assertEquals(3, info.nameServers().size()); - assertEquals(NS1, info.nameServers().get(0)); - assertEquals(NS2, info.nameServers().get(1)); - assertEquals(NS3, info.nameServers().get(2)); - assertEquals(NAME, info.name()); - assertEquals(ID, info.id()); - assertEquals(CREATION_TIME_MILLIS, info.creationTimeMillis()); - assertEquals(NAME_SERVER_SET, info.nameServerSet()); - assertEquals(DESCRIPTION, info.description()); - assertEquals(DNS_NAME, info.dnsName()); - } - - @Test - public void testValidCreationTime() { - ManagedZoneInfo.builder(NAME).creationTimeMillis(-1); - ManagedZoneInfo.builder(NAME).creationTimeMillis(0); - ManagedZoneInfo.builder(NAME).creationTimeMillis(Long.MAX_VALUE); + assertEquals(3, INFO.nameServers().size()); + assertEquals(NS1, INFO.nameServers().get(0)); + assertEquals(NS2, INFO.nameServers().get(1)); + assertEquals(NS3, INFO.nameServers().get(2)); + assertEquals(NAME, INFO.name()); + assertEquals(ID, INFO.id()); + assertEquals(CREATION_TIME_MILLIS, INFO.creationTimeMillis()); + assertEquals(NAME_SERVER_SET, INFO.nameServerSet()); + assertEquals(DESCRIPTION, INFO.description()); + assertEquals(DNS_NAME, INFO.dnsName()); } @Test public void testEqualsAndNotEquals() { - ManagedZoneInfo clone = info.toBuilder().build(); - assertEquals(clone, info); - List moreServers = Lists.newLinkedList(nameServers); + ManagedZoneInfo clone = INFO.toBuilder().build(); + assertEquals(INFO, clone); + List moreServers = Lists.newLinkedList(NAME_SERVERS); moreServers.add(NS1); - clone = info.toBuilder().nameServers(moreServers).build(); - assertNotEquals(clone, info); + clone = INFO.toBuilder().nameServers(moreServers).build(); + assertNotEquals(INFO, clone); String differentName = "totally different name"; - clone = info.toBuilder().name(differentName).build(); - assertNotEquals(clone, info); - clone = info.toBuilder().creationTimeMillis(info.creationTimeMillis() + 1).build(); - assertNotEquals(clone, info); - clone = info.toBuilder().description(info.description() + "aaaa").build(); - assertNotEquals(clone, info); - clone = info.toBuilder().dnsName(differentName).build(); - assertNotEquals(clone, info); - clone = info.toBuilder().id(info.id().add(BigInteger.ONE)).build(); - assertNotEquals(clone, info); - clone = info.toBuilder().nameServerSet(info.nameServerSet() + "salt").build(); - assertNotEquals(clone, info); + clone = INFO.toBuilder().name(differentName).build(); + assertNotEquals(INFO, clone); + clone = INFO.toBuilder().creationTimeMillis(INFO.creationTimeMillis() + 1).build(); + assertNotEquals(INFO, clone); + clone = INFO.toBuilder().description(INFO.description() + "aaaa").build(); + assertNotEquals(INFO, clone); + clone = INFO.toBuilder().dnsName(differentName).build(); + assertNotEquals(INFO, clone); + clone = INFO.toBuilder().id(INFO.id().add(BigInteger.ONE)).build(); + assertNotEquals(INFO, clone); + clone = INFO.toBuilder().nameServerSet(INFO.nameServerSet() + "salt").build(); + assertNotEquals(INFO, clone); } @Test public void testSameHashCodeOnEquals() { - int hash = info.hashCode(); - ManagedZoneInfo clone = info.toBuilder().build(); + int hash = INFO.hashCode(); + ManagedZoneInfo clone = INFO.toBuilder().build(); assertEquals(clone.hashCode(), hash); } @Test public void testToBuilder() { - assertEquals(info, info.toBuilder().build()); + assertEquals(INFO, INFO.toBuilder().build()); ManagedZoneInfo partial = ManagedZoneInfo.builder(NAME).build(); assertEquals(partial, partial.toBuilder().build()); partial = ManagedZoneInfo.builder(ID).build(); @@ -160,7 +145,7 @@ public void testToBuilder() { @Test public void testToAndFromPb() { - assertEquals(info, ManagedZoneInfo.fromPb(info.toPb())); + assertEquals(INFO, ManagedZoneInfo.fromPb(INFO.toPb())); ManagedZoneInfo partial = ManagedZoneInfo.builder(NAME).build(); assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); partial = ManagedZoneInfo.builder(ID).build(); @@ -181,15 +166,14 @@ public void testToAndFromPb() { @Test public void testEmptyNameServers() { - ManagedZoneInfo clone = info.toBuilder().nameServers(new LinkedList()).build(); + ManagedZoneInfo clone = INFO.toBuilder().nameServers(new LinkedList()).build(); assertTrue(clone.nameServers().isEmpty()); clone.toPb(); // test that this is allowed } @Test public void testDateParsing() { - com.google.api.services.dns.model.ManagedZone pb = - info.toPb(); + com.google.api.services.dns.model.ManagedZone pb = INFO.toPb(); pb.setCreationTime("2016-01-19T18:00:12.854Z"); // a real value obtained from Google Cloud DNS ManagedZoneInfo mz = ManagedZoneInfo.fromPb(pb); // parses the string timestamp to millis com.google.api.services.dns.model.ManagedZone pbClone = mz.toPb(); // converts it back to string From 273b4418df7ed3d1dae00f6f66228c1dcee3b1ac Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 25 Jan 2016 17:11:34 -0800 Subject: [PATCH 012/203] Implemented ChangeRequest. --- .../com/google/gcloud/dns/ChangeRequest.java | 340 ++++++++++++++++++ .../com/google/gcloud/dns/DnsRecordTest.java | 1 + 2 files changed, 341 insertions(+) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java new file mode 100644 index 000000000000..40c6ff0ad151 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java @@ -0,0 +1,340 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import com.google.common.base.MoreObjects; +import com.google.common.collect.Lists; + +import org.joda.time.DateTime; +import org.joda.time.format.ISODateTimeFormat; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * A class representing a change. A change is an atomic update to a collection of {@link DnsRecord}s + * within a {@code ManagedZone}. + * + * @see Google Cloud DNS documentation + */ +public class ChangeRequest implements Serializable { + + private static final long serialVersionUID = 201601251649L; + private final List additions; + private final List deletions; + private final String id; + private final Long startTimeMillis; + private final Status status; + + /** + * This enumerates the possible states of a {@code ChangeRequest}. + * + * @see Google Cloud DNS + * documentation + */ + public enum Status { + PENDING("pending"), + DONE("done"); + + private final String status; + + Status(String status) { + this.status = status; + } + + static Status translate(String status) { + if ("pending".equals(status)) { + return PENDING; + } else if ("done".equals(status)) { + return DONE; + } else { + throw new IllegalArgumentException("Such a status is unknown."); + } + } + } + + /** + * A builder for {@code ChangeRequest}s. + */ + public static class Builder { + + private List additions = new LinkedList<>(); + private List deletions = new LinkedList<>(); + private String id; + private Long startTimeMillis; + private Status status; + + private Builder(ChangeRequest cr) { + this.additions = Lists.newLinkedList(cr.additions()); + this.deletions = Lists.newLinkedList(cr.deletions()); + this.id = cr.id(); + this.startTimeMillis = cr.startTimeMillis(); + this.status = cr.status(); + } + + private Builder() { + } + + /** + * Sets a collection of {@link DnsRecord}s which are to be added to the zone upon executing this + * {@code ChangeRequest}. + */ + public Builder additions(List additions) { + this.additions = Lists.newLinkedList(checkNotNull(additions)); + return this; + } + + /** + * Adds a {@link DnsRecord} which to be added to the zone upon executing this + * {@code ChangeRequest}. + */ + public Builder add(DnsRecord record) { + this.additions.add(checkNotNull(record)); + return this; + } + + /** + * Adds a {@link DnsRecord} which to be deleted to the zone upon executing this + * {@code ChangeRequest}. + */ + public Builder delete(DnsRecord record) { + this.deletions.add(checkNotNull(record)); + return this; + } + + /** + * Clears the collection of {@link DnsRecord}s which are to be added to the zone upon executing + * this {@code ChangeRequest}. + */ + public Builder clearAdditions() { + this.additions.clear(); + return this; + } + + /** + * Clears the collection of {@link DnsRecord}s which are to be deleted from the zone upon + * executing this {@code ChangeRequest}. + */ + public Builder clearDeletions() { + this.deletions.clear(); + return this; + } + + /** + * Removes a single {@link DnsRecord} from the collection of of records to be + * added to the zone upon executing this {@code ChangeRequest}. + */ + public Builder removeAddition(DnsRecord record) { + this.additions.remove(record); + return this; + } + + /** + * Removes a single {@link DnsRecord} from the collection of of records to be + * deleted from the zone upon executing this {@code ChangeRequest}. + */ + public Builder removeDeletion(DnsRecord record) { + this.deletions.remove(record); + return this; + } + + /** + * Sets a collection of {@link DnsRecord}s which are to be deleted from the zone upon executing + * this {@code ChangeRequest}. + */ + public Builder deletions(List deletions) { + this.deletions = Lists.newLinkedList(checkNotNull(deletions)); + return this; + } + + /** + * Associates a server-assigned id to this {@code ChangeRequest}. + */ + Builder id(String id) { + this.id = checkNotNull(id); + return this; + } + + /** + * Sets the time when this {@code ChangeRequest} was started by a server. + */ + Builder startTimeMillis(long startTimeMillis) { + this.startTimeMillis = startTimeMillis; + return this; + } + + /** + * Sets the current status of this {@code ChangeRequest}. + */ + Builder status(Status status) { + this.status = checkNotNull(status); + return this; + } + + /** + * Creates a {@code ChangeRequest} instance populated by the values associated with this + * builder. + */ + public ChangeRequest build() { + return new ChangeRequest(this); + } + } + + private ChangeRequest(Builder builder) { + this.additions = builder.additions; + this.deletions = builder.deletions; + this.id = builder.id; + this.startTimeMillis = builder.startTimeMillis; + this.status = builder.status; + } + + /** + * Returns an empty builder for the {@code ChangeRequest} class. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Creates a builder populated with values of this {@code ChangeRequest}. + */ + public Builder toBuilder() { + return new Builder(this); + } + + /** + * Returns the list of {@link DnsRecord}s to be added to the zone upon executing this {@code + * ChangeRequest}. + */ + public List additions() { + return additions; + } + + /** + * Returns the list of {@link DnsRecord}s to be deleted from the zone upon executing this {@code + * ChangeRequest}. + */ + public List deletions() { + return deletions; + } + + /** + * Returns the id assigned to this {@code ChangeRequest} by the server. + */ + public String id() { + return id; + } + + /** + * Returns the time when this {@code ChangeRequest} was started by the server. + */ + public Long startTimeMillis() { + return startTimeMillis; + } + + /** + * Returns the status of this {@code ChangeRequest}. + */ + public Status status() { + return status; + } + + com.google.api.services.dns.model.Change toPb() { + com.google.api.services.dns.model.Change pb = + new com.google.api.services.dns.model.Change(); + // set id + if (id() != null) { + pb.setId(id()); + } + // set timestamp + if (startTimeMillis() != null) { + pb.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC().print(startTimeMillis())); + } + // set status + if (status() != null) { + pb.setStatus(status().status); + } + // set a list of additions + if (additions() != null) { + LinkedList additionsPb = + new LinkedList<>(); + for (DnsRecord addition : additions()) { + additionsPb.add(addition.toPb()); + } + pb.setAdditions(additionsPb); + } + // set a list of deletions + if (deletions() != null) { + LinkedList deletionsPb = + new LinkedList<>(); + for (DnsRecord deletion : deletions()) { + deletionsPb.add(deletion.toPb()); + } + pb.setDeletions(deletionsPb); + } + return pb; + } + + static ChangeRequest fromPb(com.google.api.services.dns.model.Change pb) { + Builder b = builder(); + if (pb.getId() != null) { + b.id(pb.getId()); + } + if (pb.getStartTime() != null) { + b.startTimeMillis(DateTime.parse(pb.getStartTime()).getMillis()); + } + if (pb.getStatus() != null) { + b.status(ChangeRequest.Status.translate(pb.getStatus())); + } + if (pb.getDeletions() != null) { + for (com.google.api.services.dns.model.ResourceRecordSet deletion : pb.getDeletions()) { + b.delete(DnsRecord.fromPb(deletion)); + } + } + if (pb.getAdditions() != null) { + for (com.google.api.services.dns.model.ResourceRecordSet addition : pb.getAdditions()) { + b.add(DnsRecord.fromPb(addition)); + } + } + return b.build(); + } + + @Override + public boolean equals(Object o) { + return (o instanceof ChangeRequest) && this.toPb().equals(((ChangeRequest) o).toPb()); + } + + @Override + public int hashCode() { + return Objects.hash(additions, deletions, id, startTimeMillis, status); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("additions", additions) + .add("deletions", deletions) + .add("id", id) + .add("startTimeMillis", startTimeMillis) + .add("status", status) + .toString(); + } +} diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java index 43ced20cf207..312cf564cbf2 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.gcloud.dns; import static org.junit.Assert.assertEquals; From 35cfd616b7294419d16aed9232fe40bb94321884 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 26 Jan 2016 14:31:39 -0800 Subject: [PATCH 013/203] Added test for ChangeRequest. --- .../google/gcloud/dns/ChangeRequestTest.java | 231 ++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java new file mode 100644 index 000000000000..da8006da8b51 --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java @@ -0,0 +1,231 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.common.collect.ImmutableList; + +import org.junit.Test; + +import java.util.List; + +public class ChangeRequestTest { + + private static final String ID = "cr-id-1"; + private static final Long START_TIME_MILLIS = 12334567890L; + private static final ChangeRequest.Status STATUS = ChangeRequest.Status.PENDING; + private static final String NAME1 = "dns1"; + private static final DnsRecord.Type TYPE1 = DnsRecord.Type.A; + private static final String NAME2 = "dns2"; + private static final DnsRecord.Type TYPE2 = DnsRecord.Type.AAAA; + private static final String NAME3 = "dns3"; + private static final DnsRecord.Type TYPE3 = DnsRecord.Type.MX; + private static final DnsRecord RECORD1 = DnsRecord.builder(NAME1, TYPE1).build(); + private static final DnsRecord RECORD2 = DnsRecord.builder(NAME2, TYPE2).build(); + private static final DnsRecord RECORD3 = DnsRecord.builder(NAME3, TYPE3).build(); + private static final List ADDITIONS = ImmutableList.of(RECORD1, RECORD2); + private static final List DELETIONS = ImmutableList.of(RECORD3); + private static final ChangeRequest CHANGE = ChangeRequest.builder() + .add(RECORD1) + .add(RECORD2) + .delete(RECORD3) + .startTimeMillis(START_TIME_MILLIS) + .status(STATUS) + .id(ID) + .build(); + + @Test + public void testEmptyBuilder() { + ChangeRequest cr = ChangeRequest.builder().build(); + assertNotNull(cr.deletions()); + assertTrue(cr.deletions().isEmpty()); + assertNotNull(cr.additions()); + assertTrue(cr.additions().isEmpty()); + } + + @Test + public void testBuilder() { + assertEquals(ID, CHANGE.id()); + assertEquals(STATUS, CHANGE.status()); + assertEquals(START_TIME_MILLIS, CHANGE.startTimeMillis()); + assertEquals(ADDITIONS, CHANGE.additions()); + assertEquals(DELETIONS, CHANGE.deletions()); + List recordList = ImmutableList.of(RECORD1); + ChangeRequest another = CHANGE.toBuilder().additions(recordList).build(); + assertEquals(recordList, another.additions()); + assertEquals(CHANGE.deletions(), another.deletions()); + another = CHANGE.toBuilder().deletions(recordList).build(); + assertEquals(recordList, another.deletions()); + assertEquals(CHANGE.additions(), another.additions()); + } + + @Test + public void testEqualsAndNotEquals() { + ChangeRequest clone = CHANGE.toBuilder().build(); + assertEquals(CHANGE, clone); + clone = ChangeRequest.fromPb(CHANGE.toPb()); + assertEquals(CHANGE, clone); + clone = CHANGE.toBuilder().id("some-other-id").build(); + assertNotEquals(CHANGE, clone); + clone = CHANGE.toBuilder().startTimeMillis(CHANGE.startTimeMillis() + 1).build(); + assertNotEquals(CHANGE, clone); + clone = CHANGE.toBuilder().add(RECORD3).build(); + assertNotEquals(CHANGE, clone); + clone = CHANGE.toBuilder().delete(RECORD1).build(); + assertNotEquals(CHANGE, clone); + ChangeRequest empty = ChangeRequest.builder().build(); + assertNotEquals(CHANGE, empty); + assertEquals(empty, ChangeRequest.builder().build()); + } + + @Test + public void testSameHashCodeOnEquals() { + ChangeRequest clone = CHANGE.toBuilder().build(); + assertEquals(CHANGE, clone); + assertEquals(CHANGE.hashCode(), clone.hashCode()); + ChangeRequest empty = ChangeRequest.builder().build(); + assertEquals(empty.hashCode(), ChangeRequest.builder().build().hashCode()); + } + + @Test + public void testToAndFromPb() { + assertEquals(CHANGE, ChangeRequest.fromPb(CHANGE.toPb())); + ChangeRequest partial = ChangeRequest.builder().build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().id(ID).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().add(RECORD1).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().delete(RECORD1).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().additions(ADDITIONS).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().deletions(DELETIONS).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().startTimeMillis(START_TIME_MILLIS).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().status(STATUS).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + } + + @Test + public void testToBuilder() { + assertEquals(CHANGE, CHANGE.toBuilder().build()); + ChangeRequest partial = ChangeRequest.builder().build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().id(ID).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().add(RECORD1).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().delete(RECORD1).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().additions(ADDITIONS).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().deletions(DELETIONS).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().startTimeMillis(START_TIME_MILLIS).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().status(STATUS).build(); + assertEquals(partial, partial.toBuilder().build()); + } + + @Test + public void testClearAdditions() { + ChangeRequest clone = CHANGE.toBuilder().clearAdditions().build(); + assertTrue(clone.additions().isEmpty()); + assertFalse(clone.deletions().isEmpty()); + } + + @Test + public void testAddAddition() { + try { + CHANGE.toBuilder().add(null).build(); + fail("Should not be able to add null DnsRecord."); + } catch (NullPointerException e) { + // expected + } + ChangeRequest clone = CHANGE.toBuilder().add(RECORD1).build(); + assertEquals(CHANGE.additions().size() + 1, clone.additions().size()); + } + + @Test + public void testAddDeletion() { + try { + ChangeRequest clone = CHANGE.toBuilder().delete(null).build(); + fail("Should not be able to delete null DnsRecord."); + } catch (NullPointerException e) { + // expected + } + ChangeRequest clone = CHANGE.toBuilder().delete(RECORD1).build(); + assertEquals(CHANGE.deletions().size() + 1, clone.deletions().size()); + } + + @Test + public void testClearDeletions() { + ChangeRequest clone = CHANGE.toBuilder().clearDeletions().build(); + assertTrue(clone.deletions().isEmpty()); + assertFalse(clone.additions().isEmpty()); + } + + @Test + public void testRemoveAddition() { + ChangeRequest clone = CHANGE.toBuilder().removeAddition(RECORD1).build(); + assertTrue(clone.additions().contains(RECORD2)); + assertFalse(clone.additions().contains(RECORD1)); + assertTrue(clone.deletions().contains(RECORD3)); + clone = CHANGE.toBuilder().removeAddition(RECORD2).removeAddition(RECORD1).build(); + assertFalse(clone.additions().contains(RECORD2)); + assertFalse(clone.additions().contains(RECORD1)); + assertTrue(clone.additions().isEmpty()); + assertTrue(clone.deletions().contains(RECORD3)); + } + + @Test + public void testRemoveDeletion() { + ChangeRequest clone = CHANGE.toBuilder().removeDeletion(RECORD3).build(); + assertFalse(clone.deletions().contains(RECORD3)); + assertTrue(clone.deletions().isEmpty()); + } + + @Test + public void testDateParsing() { + String startTime = "2016-01-26T18:33:43.512Z"; // obtained from service + com.google.api.services.dns.model.Change change = CHANGE.toPb().setStartTime(startTime); + ChangeRequest converted = ChangeRequest.fromPb(change); + assertNotNull(converted.startTimeMillis()); + assertEquals(change, converted.toPb()); + assertEquals(change.getStartTime(), converted.toPb().getStartTime()); + } + + @Test + public void testStatusTranslation() { + assertEquals(ChangeRequest.Status.DONE, ChangeRequest.Status.translate("done")); + assertEquals(ChangeRequest.Status.PENDING, ChangeRequest.Status.translate("pending")); + try { + ChangeRequest.Status.translate("another"); + fail("Such a status does not exist."); + } catch (IllegalArgumentException e) { + // expected + } + } +} From 6f9e1c09b831b39def386076826eecf20daa1bc2 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 26 Jan 2016 17:15:14 -0800 Subject: [PATCH 014/203] Implements comments from @ajkannan and @aozarov. --- .../com/google/gcloud/dns/ChangeRequest.java | 126 ++++++++---------- .../java/com/google/gcloud/dns/DnsRecord.java | 8 +- .../google/gcloud/dns/ChangeRequestTest.java | 17 +-- .../com/google/gcloud/dns/DnsRecordTest.java | 2 +- 4 files changed, 62 insertions(+), 91 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java index 40c6ff0ad151..5ed03b1ea071 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java @@ -16,7 +16,12 @@ package com.google.gcloud.dns; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.services.dns.model.ResourceRecordSet; +import com.google.common.base.Function; import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import org.joda.time.DateTime; @@ -27,17 +32,29 @@ import java.util.List; import java.util.Objects; -import static com.google.common.base.Preconditions.checkNotNull; - /** - * A class representing a change. A change is an atomic update to a collection of {@link DnsRecord}s - * within a {@code ManagedZone}. + * A class representing an atomic update to a collection of {@link DnsRecord}s within a {@code + * ManagedZone}. * * @see Google Cloud DNS documentation */ public class ChangeRequest implements Serializable { - private static final long serialVersionUID = 201601251649L; + private static final Function FROM_PB_FUNCTION = + new Function() { + @Override + public DnsRecord apply(com.google.api.services.dns.model.ResourceRecordSet pb) { + return DnsRecord.fromPb(pb); + } + }; + private static final Function TO_PB_FUNCTION = + new Function() { + @Override + public com.google.api.services.dns.model.ResourceRecordSet apply(DnsRecord error) { + return error.toPb(); + } + }; + private static final long serialVersionUID = -8703939628990291682L; private final List additions; private final List deletions; private final String id; @@ -51,24 +68,8 @@ public class ChangeRequest implements Serializable { * documentation */ public enum Status { - PENDING("pending"), - DONE("done"); - - private final String status; - - Status(String status) { - this.status = status; - } - - static Status translate(String status) { - if ("pending".equals(status)) { - return PENDING; - } else if ("done".equals(status)) { - return DONE; - } else { - throw new IllegalArgumentException("Such a status is unknown."); - } - } + PENDING, + DONE } /** @@ -101,10 +102,19 @@ public Builder additions(List additions) { this.additions = Lists.newLinkedList(checkNotNull(additions)); return this; } + + /** + * Sets a collection of {@link DnsRecord}s which are to be deleted from the zone upon executing + * this {@code ChangeRequest}. + */ + public Builder deletions(List deletions) { + this.deletions = Lists.newLinkedList(checkNotNull(deletions)); + return this; + } /** - * Adds a {@link DnsRecord} which to be added to the zone upon executing this - * {@code ChangeRequest}. + * Adds a {@link DnsRecord} to be added to the zone upon executing this {@code + * ChangeRequest}. */ public Builder add(DnsRecord record) { this.additions.add(checkNotNull(record)); @@ -112,7 +122,7 @@ public Builder add(DnsRecord record) { } /** - * Adds a {@link DnsRecord} which to be deleted to the zone upon executing this + * Adds a {@link DnsRecord} to be deleted to the zone upon executing this * {@code ChangeRequest}. */ public Builder delete(DnsRecord record) { @@ -139,7 +149,7 @@ public Builder clearDeletions() { } /** - * Removes a single {@link DnsRecord} from the collection of of records to be + * Removes a single {@link DnsRecord} from the collection of records to be * added to the zone upon executing this {@code ChangeRequest}. */ public Builder removeAddition(DnsRecord record) { @@ -148,7 +158,7 @@ public Builder removeAddition(DnsRecord record) { } /** - * Removes a single {@link DnsRecord} from the collection of of records to be + * Removes a single {@link DnsRecord} from the collection of records to be * deleted from the zone upon executing this {@code ChangeRequest}. */ public Builder removeDeletion(DnsRecord record) { @@ -156,15 +166,6 @@ public Builder removeDeletion(DnsRecord record) { return this; } - /** - * Sets a collection of {@link DnsRecord}s which are to be deleted from the zone upon executing - * this {@code ChangeRequest}. - */ - public Builder deletions(List deletions) { - this.deletions = Lists.newLinkedList(checkNotNull(deletions)); - return this; - } - /** * Associates a server-assigned id to this {@code ChangeRequest}. */ @@ -199,8 +200,8 @@ public ChangeRequest build() { } private ChangeRequest(Builder builder) { - this.additions = builder.additions; - this.deletions = builder.deletions; + this.additions = ImmutableList.copyOf(builder.additions); + this.deletions = ImmutableList.copyOf(builder.deletions); this.id = builder.id; this.startTimeMillis = builder.startTimeMillis; this.status = builder.status; @@ -221,7 +222,7 @@ public Builder toBuilder() { } /** - * Returns the list of {@link DnsRecord}s to be added to the zone upon executing this {@code + * Returns the list of {@link DnsRecord}s to be added to the zone upon submitting this {@code * ChangeRequest}. */ public List additions() { @@ -229,7 +230,7 @@ public List additions() { } /** - * Returns the list of {@link DnsRecord}s to be deleted from the zone upon executing this {@code + * Returns the list of {@link DnsRecord}s to be deleted from the zone upon submitting this {@code * ChangeRequest}. */ public List deletions() { @@ -270,56 +271,39 @@ com.google.api.services.dns.model.Change toPb() { } // set status if (status() != null) { - pb.setStatus(status().status); + pb.setStatus(status().name().toLowerCase()); } // set a list of additions - if (additions() != null) { - LinkedList additionsPb = - new LinkedList<>(); - for (DnsRecord addition : additions()) { - additionsPb.add(addition.toPb()); - } - pb.setAdditions(additionsPb); - } + pb.setAdditions(Lists.transform(additions(), TO_PB_FUNCTION)); // set a list of deletions - if (deletions() != null) { - LinkedList deletionsPb = - new LinkedList<>(); - for (DnsRecord deletion : deletions()) { - deletionsPb.add(deletion.toPb()); - } - pb.setDeletions(deletionsPb); - } + pb.setDeletions(Lists.transform(deletions(), TO_PB_FUNCTION)); return pb; } static ChangeRequest fromPb(com.google.api.services.dns.model.Change pb) { - Builder b = builder(); + Builder builder = builder(); if (pb.getId() != null) { - b.id(pb.getId()); + builder.id(pb.getId()); } if (pb.getStartTime() != null) { - b.startTimeMillis(DateTime.parse(pb.getStartTime()).getMillis()); + builder.startTimeMillis(DateTime.parse(pb.getStartTime()).getMillis()); } if (pb.getStatus() != null) { - b.status(ChangeRequest.Status.translate(pb.getStatus())); + // we are assuming that status indicated in pb is a lower case version of the enum name + builder.status(ChangeRequest.Status.valueOf(pb.getStatus().toUpperCase())); } if (pb.getDeletions() != null) { - for (com.google.api.services.dns.model.ResourceRecordSet deletion : pb.getDeletions()) { - b.delete(DnsRecord.fromPb(deletion)); - } + builder.deletions(Lists.transform(pb.getDeletions(), FROM_PB_FUNCTION)); } if (pb.getAdditions() != null) { - for (com.google.api.services.dns.model.ResourceRecordSet addition : pb.getAdditions()) { - b.add(DnsRecord.fromPb(addition)); - } + builder.additions(Lists.transform(pb.getAdditions(), FROM_PB_FUNCTION)); } - return b.build(); + return builder.build(); } @Override - public boolean equals(Object o) { - return (o instanceof ChangeRequest) && this.toPb().equals(((ChangeRequest) o).toPb()); + public boolean equals(Object other) { + return (other instanceof ChangeRequest) && toPb().equals(((ChangeRequest) other).toPb()); } @Override diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index c41e72a77400..4236d9c1c561 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -273,14 +273,14 @@ com.google.api.services.dns.model.ResourceRecordSet toPb() { } static DnsRecord fromPb(com.google.api.services.dns.model.ResourceRecordSet pb) { - Builder b = builder(pb.getName(), Type.valueOf(pb.getType())); + Builder builder = builder(pb.getName(), Type.valueOf(pb.getType())); if (pb.getRrdatas() != null) { - b.records(pb.getRrdatas()); + builder.records(pb.getRrdatas()); } if (pb.getTtl() != null) { - b.ttl(pb.getTtl()); + builder.ttl(pb.getTtl()); } - return b.build(); + return builder.build(); } @Override diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java index da8006da8b51..8b40a4dcff34 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java @@ -159,7 +159,7 @@ public void testClearAdditions() { @Test public void testAddAddition() { try { - CHANGE.toBuilder().add(null).build(); + CHANGE.toBuilder().add(null); fail("Should not be able to add null DnsRecord."); } catch (NullPointerException e) { // expected @@ -171,7 +171,7 @@ public void testAddAddition() { @Test public void testAddDeletion() { try { - ChangeRequest clone = CHANGE.toBuilder().delete(null).build(); + CHANGE.toBuilder().delete(null); fail("Should not be able to delete null DnsRecord."); } catch (NullPointerException e) { // expected @@ -203,7 +203,6 @@ public void testRemoveAddition() { @Test public void testRemoveDeletion() { ChangeRequest clone = CHANGE.toBuilder().removeDeletion(RECORD3).build(); - assertFalse(clone.deletions().contains(RECORD3)); assertTrue(clone.deletions().isEmpty()); } @@ -216,16 +215,4 @@ public void testDateParsing() { assertEquals(change, converted.toPb()); assertEquals(change.getStartTime(), converted.toPb().getStartTime()); } - - @Test - public void testStatusTranslation() { - assertEquals(ChangeRequest.Status.DONE, ChangeRequest.Status.translate("done")); - assertEquals(ChangeRequest.Status.PENDING, ChangeRequest.Status.translate("pending")); - try { - ChangeRequest.Status.translate("another"); - fail("Such a status does not exist."); - } catch (IllegalArgumentException e) { - // expected - } - } } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java index 312cf564cbf2..60eb6f033ce0 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java @@ -17,9 +17,9 @@ package com.google.gcloud.dns; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.junit.Assert.assertNotEquals; import org.junit.Test; From 9b4ff48b64c2192a42d914a672d9004e59a4b822 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 25 Jan 2016 16:23:48 -0800 Subject: [PATCH 015/203] Added ProjectInfo. --- .../com/google/gcloud/dns/ProjectInfo.java | 284 ++++++++++++++++++ .../google/gcloud/dns/ProjectInfoTest.java | 118 ++++++++ 2 files changed, 402 insertions(+) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java new file mode 100644 index 000000000000..614b9033a18e --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java @@ -0,0 +1,284 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.MoreObjects; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.Objects; + +/** + * The class that encapsulates information about a project in Google Cloud DNS. A project is a top + * level container for resources including {@link ManagedZone}s. Projects can be created only in the + * APIs console. + * + * @see Google Cloud DNS documentation + */ +public class ProjectInfo implements Serializable { + + private static final long serialVersionUID = 201601251420L; + private final String id; + private final BigInteger number; + private final Quota quota; + + /** + * This class represents quotas assigned to the {@code ProjectInfo}. + * + * @see Google Cloud DNS documentation + */ + public static class Quota { + + private Integer zones; + private Integer resourceRecordsPerRrset; + private Integer rrsetAdditionsPerChange; + private Integer rrsetDeletionsPerChange; + private Integer rrsetsPerManagedZone; + private Integer totalRrdataSizePerChange; + + /** + * Creates an instance of {@code Quota}. + * + * This is the only way of creating an instance of {@code Quota}. As the service does not allow + * for specifying options, quota is an "all-or-nothing object" and we do not need a builder. + */ + Quota(Integer zones, + Integer resourceRecordsPerRrset, + Integer rrsetAdditionsPerChange, + Integer rrsetDeletionsPerChange, + Integer rrsetsPerManagedZone, + Integer totalRrdataSizePerChange) { + this.zones = checkNotNull(zones); + this.resourceRecordsPerRrset = checkNotNull(resourceRecordsPerRrset); + this.rrsetAdditionsPerChange = checkNotNull(rrsetAdditionsPerChange); + this.rrsetDeletionsPerChange = checkNotNull(rrsetDeletionsPerChange); + this.rrsetsPerManagedZone = checkNotNull(rrsetsPerManagedZone); + this.totalRrdataSizePerChange = checkNotNull(totalRrdataSizePerChange); + } + + /** + * Returns the maximum allowed number of managed zones in the project. + */ + public Integer zones() { + return zones; + } + + /** + * Returns the maximum allowed number of records per {@link DnsRecord}. + */ + public Integer resourceRecordsPerRrset() { + return resourceRecordsPerRrset; + } + + /** + * Returns the maximum allowed number of {@link DnsRecord}s to add per {@code ChangesRequest}. + */ + public Integer rrsetAdditionsPerChange() { + return rrsetAdditionsPerChange; + } + + /** + * Returns the maximum allowed number of {@link DnsRecord}s to delete per {@code + * ChangesRequest}. + */ + public Integer rrsetDeletionsPerChange() { + return rrsetDeletionsPerChange; + } + + /** + * Returns the maximum allowed number of {@link DnsRecord}s per {@link ManagedZone} in the + * project. + */ + public Integer rrsetsPerManagedZone() { + return rrsetsPerManagedZone; + } + + /** + * Returns the maximum allowed size for total records in one ChangesRequest in bytes. + */ + public Integer totalRrdataSizePerChange() { + return totalRrdataSizePerChange; + } + + @Override + public boolean equals(Object o) { + return (o instanceof Quota) && this.toPb().equals(((Quota) o).toPb()); + } + + @Override + public int hashCode() { + return Objects.hash(zones, resourceRecordsPerRrset, rrsetAdditionsPerChange, + rrsetDeletionsPerChange, rrsetsPerManagedZone, totalRrdataSizePerChange); + } + + com.google.api.services.dns.model.Quota toPb() { + com.google.api.services.dns.model.Quota pb = new com.google.api.services.dns.model.Quota(); + pb.setManagedZones(zones); + pb.setResourceRecordsPerRrset(resourceRecordsPerRrset); + pb.setRrsetAdditionsPerChange(rrsetAdditionsPerChange); + pb.setRrsetDeletionsPerChange(rrsetDeletionsPerChange); + pb.setRrsetsPerManagedZone(rrsetsPerManagedZone); + pb.setTotalRrdataSizePerChange(totalRrdataSizePerChange); + return pb; + } + + static Quota fromPb(com.google.api.services.dns.model.Quota pb) { + Quota q = new Quota(pb.getManagedZones(), + pb.getResourceRecordsPerRrset(), + pb.getRrsetAdditionsPerChange(), + pb.getRrsetDeletionsPerChange(), + pb.getRrsetsPerManagedZone(), + pb.getTotalRrdataSizePerChange() + ); + return q; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("zones", zones) + .add("resourceRecordsPerRrset", resourceRecordsPerRrset) + .add("rrsetAdditionsPerChange", rrsetAdditionsPerChange) + .add("rrsetDeletionsPerChange", rrsetDeletionsPerChange) + .add("rrsetsPerManagedZone", rrsetsPerManagedZone) + .add("totalRrdataSizePerChange", totalRrdataSizePerChange) + .toString(); + } + } + + /** + * A builder for {@code ProjectInfo}. + */ + static class Builder { + private String id; + private BigInteger number; + private Quota quota; + + private Builder() { + } + + /** + * Sets an id of the project. + */ + Builder id(String id) { + this.id = checkNotNull(id); + return this; + } + + /** + * Sets a number of the project. + */ + Builder number(BigInteger number) { + this.number = checkNotNull(number); + return this; + } + + /** + * Sets quotas assigned to the project. + */ + Builder quota(Quota quota) { + this.quota = checkNotNull(quota); + return this; + } + + /** + * Builds an instance of the {@code ProjectInfo}. + */ + ProjectInfo build() { + return new ProjectInfo(this); + } + } + + private ProjectInfo(Builder b) { + this.id = b.id; + this.number = b.number; + this.quota = b.quota; + } + + /** + * Returns a builder for {@code ProjectInfo}. + */ + static Builder builder() { + return new Builder(); + } + + /** + * Returns the user-assigned unique identifier for the project. + */ + public String id() { + return id; + } + + /** + * Returns the unique numeric identifier for the project. + */ + public BigInteger number() { + return number; + } + + /** + * Returns the {@code Quota} object which contains quotas assigned to this project. + */ + public Quota quota() { + return quota; + } + + com.google.api.services.dns.model.Project toPb() { + com.google.api.services.dns.model.Project pb = new com.google.api.services.dns.model.Project(); + pb.setId(id()); + pb.setNumber(number()); + if (this.quota() != null) { + pb.setQuota(quota().toPb()); + } + return pb; + } + + static ProjectInfo fromPb(com.google.api.services.dns.model.Project pb) { + Builder b = builder(); + if (pb.getId() != null) { + b.id(pb.getId()); + } + if (pb.getNumber() != null) { + b.number(pb.getNumber()); + } + if (pb.getQuota() != null) { + b.quota(Quota.fromPb(pb.getQuota())); + } + return b.build(); + } + + @Override + public boolean equals(Object o) { + return (o instanceof ProjectInfo) && this.toPb().equals(((ProjectInfo) o).toPb()); + } + + @Override + public int hashCode() { + return Objects.hash(id, number, quota); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .add("number", number) + .add("quota", quota) + .toString(); + } +} diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java new file mode 100644 index 000000000000..2c5e1ffa7100 --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java @@ -0,0 +1,118 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +import java.math.BigInteger; + +public class ProjectInfoTest { + + private static final String ID = "project-id-123"; + private static final BigInteger NUMBER = new BigInteger("123"); + private static final ProjectInfo.Quota QUOTA = new ProjectInfo.Quota(1, 2, 3, 4, 5, 6); + private static final ProjectInfo PROJECT_INFO = ProjectInfo.builder() + .id(ID).number(NUMBER).quota(QUOTA).build(); + + @Test + public void testBuilder() { + ProjectInfo withId = ProjectInfo.builder().id(ID).build(); + assertEquals(ID, withId.id()); + assertNull(withId.number()); + assertNull(withId.quota()); + ProjectInfo withNumber = ProjectInfo.builder().number(NUMBER).build(); + assertEquals(NUMBER, withNumber.number()); + assertNull(withNumber.quota()); + assertNull(withNumber.id()); + ProjectInfo withQuota = ProjectInfo.builder().quota(QUOTA).build(); + assertEquals(QUOTA, withQuota.quota()); + assertNull(withQuota.id()); + assertNull(withQuota.number()); + assertEquals(QUOTA, PROJECT_INFO.quota()); + assertEquals(NUMBER, PROJECT_INFO.number()); + assertEquals(ID, PROJECT_INFO.id()); + } + + @Test + public void testQuotaConstructor() { + assertEquals(Integer.valueOf(1), QUOTA.zones()); + assertEquals(Integer.valueOf(2), QUOTA.resourceRecordsPerRrset()); + assertEquals(Integer.valueOf(3), QUOTA.rrsetAdditionsPerChange()); + assertEquals(Integer.valueOf(4), QUOTA.rrsetDeletionsPerChange()); + assertEquals(Integer.valueOf(5), QUOTA.rrsetsPerManagedZone()); + assertEquals(Integer.valueOf(6), QUOTA.totalRrdataSizePerChange()); + } + + @Test + public void testEqualsAndNotEqualsQuota() { + ProjectInfo.Quota clone = new ProjectInfo.Quota(6, 5, 4, 3, 2, 1); + assertNotEquals(QUOTA, clone); + clone = ProjectInfo.Quota.fromPb(QUOTA.toPb()); + assertEquals(QUOTA, clone); + } + + @Test + public void testSameHashCodeOnEqualsQuota() { + ProjectInfo.Quota clone = ProjectInfo.Quota.fromPb(QUOTA.toPb()); + assertEquals(QUOTA, clone); + assertEquals(QUOTA.hashCode(), clone.hashCode()); + } + + @Test + public void testEqualsAndNotEquals() { + ProjectInfo clone = ProjectInfo.builder().build(); + assertNotEquals(PROJECT_INFO, clone); + clone = ProjectInfo.builder().id(PROJECT_INFO.id()).number(PROJECT_INFO.number()).build(); + assertNotEquals(PROJECT_INFO, clone); + clone = ProjectInfo.builder().id(PROJECT_INFO.id()).quota(PROJECT_INFO.quota()).build(); + assertNotEquals(PROJECT_INFO, clone); + clone = ProjectInfo.builder().number(PROJECT_INFO.number()).quota(PROJECT_INFO.quota()).build(); + assertNotEquals(PROJECT_INFO, clone); + clone = ProjectInfo.fromPb(PROJECT_INFO.toPb()); + assertEquals(PROJECT_INFO, clone); + } + + @Test + public void testSameHashCodeOnEquals() { + ProjectInfo clone = ProjectInfo.fromPb(PROJECT_INFO.toPb()); + assertEquals(PROJECT_INFO, clone); + assertEquals(PROJECT_INFO.hashCode(), clone.hashCode()); + } + + @Test + public void testToAndFromPb() { + assertEquals(PROJECT_INFO, ProjectInfo.fromPb(PROJECT_INFO.toPb())); + ProjectInfo partial = ProjectInfo.builder().id(ID).build(); + assertEquals(partial, PROJECT_INFO.fromPb(partial.toPb())); + partial = ProjectInfo.builder().number(NUMBER).build(); + assertEquals(partial, PROJECT_INFO.fromPb(partial.toPb())); + partial = ProjectInfo.builder().quota(QUOTA).build(); + assertEquals(partial, PROJECT_INFO.fromPb(partial.toPb())); + assertNotEquals(PROJECT_INFO, partial); + } + + @Test + public void testToAndFromPbQuota() { + assertEquals(QUOTA, ProjectInfo.Quota.fromPb(QUOTA.toPb())); + ProjectInfo.Quota wrong = new ProjectInfo.Quota(5, 6, 3, 6, 2, 1); + assertNotEquals(QUOTA, ProjectInfo.Quota.fromPb(wrong.toPb())); + } +} From a47158db527eeb220534189ee24c7837f75bddda Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 27 Jan 2016 12:35:32 -0800 Subject: [PATCH 016/203] Fixed serialization, javadoc and checkstyle. --- .../com/google/gcloud/dns/ProjectInfo.java | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java index 614b9033a18e..dc9c2e6ef55e 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java @@ -26,14 +26,14 @@ /** * The class that encapsulates information about a project in Google Cloud DNS. A project is a top - * level container for resources including {@link ManagedZone}s. Projects can be created only in the + * level container for resources including {@code ManagedZone}s. Projects can be created only in the * APIs console. * * @see Google Cloud DNS documentation */ public class ProjectInfo implements Serializable { - private static final long serialVersionUID = 201601251420L; + private static final long serialVersionUID = 8696578863323485036L; private final String id; private final BigInteger number; private final Quota quota; @@ -55,8 +55,9 @@ public static class Quota { /** * Creates an instance of {@code Quota}. * - * This is the only way of creating an instance of {@code Quota}. As the service does not allow - * for specifying options, quota is an "all-or-nothing object" and we do not need a builder. + *

This is the only way of creating an instance of {@code Quota}. As the service does not + * allow for specifying options, quota is an "all-or-nothing object" and we do not need a + * builder. */ Quota(Integer zones, Integer resourceRecordsPerRrset, @@ -102,7 +103,7 @@ public Integer rrsetDeletionsPerChange() { } /** - * Returns the maximum allowed number of {@link DnsRecord}s per {@link ManagedZone} in the + * Returns the maximum allowed number of {@link DnsRecord}s per {@code ManagedZone} in the * project. */ public Integer rrsetsPerManagedZone() { @@ -117,8 +118,8 @@ public Integer totalRrdataSizePerChange() { } @Override - public boolean equals(Object o) { - return (o instanceof Quota) && this.toPb().equals(((Quota) o).toPb()); + public boolean equals(Object other) { + return (other instanceof Quota) && this.toPb().equals(((Quota) other).toPb()); } @Override @@ -139,14 +140,14 @@ com.google.api.services.dns.model.Quota toPb() { } static Quota fromPb(com.google.api.services.dns.model.Quota pb) { - Quota q = new Quota(pb.getManagedZones(), + Quota quota = new Quota(pb.getManagedZones(), pb.getResourceRecordsPerRrset(), pb.getRrsetAdditionsPerChange(), pb.getRrsetDeletionsPerChange(), pb.getRrsetsPerManagedZone(), pb.getTotalRrdataSizePerChange() ); - return q; + return quota; } @Override @@ -205,10 +206,10 @@ ProjectInfo build() { } } - private ProjectInfo(Builder b) { - this.id = b.id; - this.number = b.number; - this.quota = b.quota; + private ProjectInfo(Builder builder) { + this.id = builder.id; + this.number = builder.number; + this.quota = builder.quota; } /** @@ -250,22 +251,22 @@ com.google.api.services.dns.model.Project toPb() { } static ProjectInfo fromPb(com.google.api.services.dns.model.Project pb) { - Builder b = builder(); + Builder builder = builder(); if (pb.getId() != null) { - b.id(pb.getId()); + builder.id(pb.getId()); } if (pb.getNumber() != null) { - b.number(pb.getNumber()); + builder.number(pb.getNumber()); } if (pb.getQuota() != null) { - b.quota(Quota.fromPb(pb.getQuota())); + builder.quota(Quota.fromPb(pb.getQuota())); } - return b.build(); + return builder.build(); } @Override - public boolean equals(Object o) { - return (o instanceof ProjectInfo) && this.toPb().equals(((ProjectInfo) o).toPb()); + public boolean equals(Object other) { + return (other instanceof ProjectInfo) && this.toPb().equals(((ProjectInfo) other).toPb()); } @Override From 9db27d44a072233955a57670c4c77a8a1f72afca Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 27 Jan 2016 16:00:44 -0800 Subject: [PATCH 017/203] Implements comment from @aozarov and @ajkannan into ProjectInfo. --- .../com/google/gcloud/dns/ProjectInfo.java | 83 ++++++++++--------- .../google/gcloud/dns/ProjectInfoTest.java | 12 +-- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java index dc9c2e6ef55e..f8b2e33a1e9f 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java @@ -25,9 +25,9 @@ import java.util.Objects; /** - * The class that encapsulates information about a project in Google Cloud DNS. A project is a top - * level container for resources including {@code ManagedZone}s. Projects can be created only in the - * APIs console. + * The class provides the Google Cloud DNS information associated with this project. A project is a + * top level container for resources including {@code ManagedZone}s. Projects can be created only in + * the APIs console. * * @see Google Cloud DNS documentation */ @@ -41,16 +41,17 @@ public class ProjectInfo implements Serializable { /** * This class represents quotas assigned to the {@code ProjectInfo}. * - * @see Google Cloud DNS documentation + * @see Google Cloud DNS + * documentation */ public static class Quota { - private Integer zones; - private Integer resourceRecordsPerRrset; - private Integer rrsetAdditionsPerChange; - private Integer rrsetDeletionsPerChange; - private Integer rrsetsPerManagedZone; - private Integer totalRrdataSizePerChange; + private final int zones; + private final int resourceRecordsPerRrset; + private final int rrsetAdditionsPerChange; + private final int rrsetDeletionsPerChange; + private final int rrsetsPerManagedZone; + private final int totalRrdataSizePerChange; /** * Creates an instance of {@code Quota}. @@ -59,38 +60,38 @@ public static class Quota { * allow for specifying options, quota is an "all-or-nothing object" and we do not need a * builder. */ - Quota(Integer zones, - Integer resourceRecordsPerRrset, - Integer rrsetAdditionsPerChange, - Integer rrsetDeletionsPerChange, - Integer rrsetsPerManagedZone, - Integer totalRrdataSizePerChange) { - this.zones = checkNotNull(zones); - this.resourceRecordsPerRrset = checkNotNull(resourceRecordsPerRrset); - this.rrsetAdditionsPerChange = checkNotNull(rrsetAdditionsPerChange); - this.rrsetDeletionsPerChange = checkNotNull(rrsetDeletionsPerChange); - this.rrsetsPerManagedZone = checkNotNull(rrsetsPerManagedZone); - this.totalRrdataSizePerChange = checkNotNull(totalRrdataSizePerChange); + Quota(int zones, + int resourceRecordsPerRrset, + int rrsetAdditionsPerChange, + int rrsetDeletionsPerChange, + int rrsetsPerManagedZone, + int totalRrdataSizePerChange) { + this.zones = zones; + this.resourceRecordsPerRrset = resourceRecordsPerRrset; + this.rrsetAdditionsPerChange = rrsetAdditionsPerChange; + this.rrsetDeletionsPerChange = rrsetDeletionsPerChange; + this.rrsetsPerManagedZone = rrsetsPerManagedZone; + this.totalRrdataSizePerChange = totalRrdataSizePerChange; } /** * Returns the maximum allowed number of managed zones in the project. */ - public Integer zones() { + public int zones() { return zones; } /** * Returns the maximum allowed number of records per {@link DnsRecord}. */ - public Integer resourceRecordsPerRrset() { + public int resourceRecordsPerRrset() { return resourceRecordsPerRrset; } /** * Returns the maximum allowed number of {@link DnsRecord}s to add per {@code ChangesRequest}. */ - public Integer rrsetAdditionsPerChange() { + public int rrsetAdditionsPerChange() { return rrsetAdditionsPerChange; } @@ -98,7 +99,7 @@ public Integer rrsetAdditionsPerChange() { * Returns the maximum allowed number of {@link DnsRecord}s to delete per {@code * ChangesRequest}. */ - public Integer rrsetDeletionsPerChange() { + public int rrsetDeletionsPerChange() { return rrsetDeletionsPerChange; } @@ -106,14 +107,14 @@ public Integer rrsetDeletionsPerChange() { * Returns the maximum allowed number of {@link DnsRecord}s per {@code ManagedZone} in the * project. */ - public Integer rrsetsPerManagedZone() { + public int rrsetsPerManagedZone() { return rrsetsPerManagedZone; } /** * Returns the maximum allowed size for total records in one ChangesRequest in bytes. */ - public Integer totalRrdataSizePerChange() { + public int totalRrdataSizePerChange() { return totalRrdataSizePerChange; } @@ -220,32 +221,32 @@ static Builder builder() { } /** - * Returns the user-assigned unique identifier for the project. + * Returns the {@code Quota} object which contains quotas assigned to this project. */ - public String id() { - return id; + public Quota quota() { + return quota; } /** - * Returns the unique numeric identifier for the project. + * Returns project number. For internal use only. */ - public BigInteger number() { + BigInteger number() { return number; } /** - * Returns the {@code Quota} object which contains quotas assigned to this project. + * Returns project id. For internal use only. */ - public Quota quota() { - return quota; + String id() { + return id; } com.google.api.services.dns.model.Project toPb() { com.google.api.services.dns.model.Project pb = new com.google.api.services.dns.model.Project(); - pb.setId(id()); - pb.setNumber(number()); - if (this.quota() != null) { - pb.setQuota(quota().toPb()); + pb.setId(id); + pb.setNumber(number); + if (this.quota != null) { + pb.setQuota(quota.toPb()); } return pb; } @@ -266,7 +267,7 @@ static ProjectInfo fromPb(com.google.api.services.dns.model.Project pb) { @Override public boolean equals(Object other) { - return (other instanceof ProjectInfo) && this.toPb().equals(((ProjectInfo) other).toPb()); + return (other instanceof ProjectInfo) && toPb().equals(((ProjectInfo) other).toPb()); } @Override diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java index 2c5e1ffa7100..2af8b5ad3995 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java @@ -53,12 +53,12 @@ public void testBuilder() { @Test public void testQuotaConstructor() { - assertEquals(Integer.valueOf(1), QUOTA.zones()); - assertEquals(Integer.valueOf(2), QUOTA.resourceRecordsPerRrset()); - assertEquals(Integer.valueOf(3), QUOTA.rrsetAdditionsPerChange()); - assertEquals(Integer.valueOf(4), QUOTA.rrsetDeletionsPerChange()); - assertEquals(Integer.valueOf(5), QUOTA.rrsetsPerManagedZone()); - assertEquals(Integer.valueOf(6), QUOTA.totalRrdataSizePerChange()); + assertEquals(1, QUOTA.zones()); + assertEquals(2, QUOTA.resourceRecordsPerRrset()); + assertEquals(3, QUOTA.rrsetAdditionsPerChange()); + assertEquals(4, QUOTA.rrsetDeletionsPerChange()); + assertEquals(5, QUOTA.rrsetsPerManagedZone()); + assertEquals(6, QUOTA.totalRrdataSizePerChange()); } @Test From 4412c7304cda6bd5d3846161b6451740972bc929 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 27 Jan 2016 16:13:37 -0800 Subject: [PATCH 018/203] Changed documentation @code to @link where applicable. --- .../src/main/java/com/google/gcloud/dns/ProjectInfo.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java index f8b2e33a1e9f..e65524913920 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java @@ -89,22 +89,22 @@ public int resourceRecordsPerRrset() { } /** - * Returns the maximum allowed number of {@link DnsRecord}s to add per {@code ChangesRequest}. + * Returns the maximum allowed number of {@link DnsRecord}s to add per {@link ChangeRequest}. */ public int rrsetAdditionsPerChange() { return rrsetAdditionsPerChange; } /** - * Returns the maximum allowed number of {@link DnsRecord}s to delete per {@code - * ChangesRequest}. + * Returns the maximum allowed number of {@link DnsRecord}s to delete per {@link + * ChangeRequest}. */ public int rrsetDeletionsPerChange() { return rrsetDeletionsPerChange; } /** - * Returns the maximum allowed number of {@link DnsRecord}s per {@code ManagedZone} in the + * Returns the maximum allowed number of {@link DnsRecord}s per {@link ManagedZoneInfo} in the * project. */ public int rrsetsPerManagedZone() { From 81a46d8429909998bdbf65cdc0726e9a404d62b1 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 27 Jan 2016 18:01:27 -0800 Subject: [PATCH 019/203] Renames ManagedZone to Zone. Acommodates codecheck. Fixes #579. --- .../com/google/gcloud/dns/ChangeRequest.java | 4 +- .../java/com/google/gcloud/dns/DnsRecord.java | 4 +- .../com/google/gcloud/dns/ProjectInfo.java | 6 +- .../{ManagedZoneInfo.java => ZoneInfo.java} | 88 +++++++++---------- ...gedZoneInfoTest.java => ZoneInfoTest.java} | 62 ++++++------- 5 files changed, 80 insertions(+), 84 deletions(-) rename gcloud-java-dns/src/main/java/com/google/gcloud/dns/{ManagedZoneInfo.java => ZoneInfo.java} (70%) rename gcloud-java-dns/src/test/java/com/google/gcloud/dns/{ManagedZoneInfoTest.java => ZoneInfoTest.java} (72%) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java index 5ed03b1ea071..582dd2b2e05b 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java @@ -34,7 +34,7 @@ /** * A class representing an atomic update to a collection of {@link DnsRecord}s within a {@code - * ManagedZone}. + * Zone}. * * @see Google Cloud DNS documentation */ @@ -102,7 +102,7 @@ public Builder additions(List additions) { this.additions = Lists.newLinkedList(checkNotNull(additions)); return this; } - + /** * Sets a collection of {@link DnsRecord}s which are to be deleted from the zone upon executing * this {@code ChangeRequest}. diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index 4236d9c1c561..b9e8134d9921 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -33,8 +33,8 @@ * *

A {@code DnsRecord} is the unit of data that will be returned by the DNS servers upon a DNS * request for a specific domain. The {@code DnsRecord} holds the current state of the DNS records - * that make up a managed zone. You can read the records but you cannot modify them directly. - * Rather, you edit the records in a managed zone by creating a ChangeRequest. + * that make up a zone. You can read the records but you cannot modify them directly. + * Rather, you edit the records in a zone by creating a ChangeRequest. * * @see Google Cloud DNS * documentation diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java index e65524913920..b7933956ed88 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java @@ -26,7 +26,7 @@ /** * The class provides the Google Cloud DNS information associated with this project. A project is a - * top level container for resources including {@code ManagedZone}s. Projects can be created only in + * top level container for resources including {@code Zone}s. Projects can be created only in * the APIs console. * * @see Google Cloud DNS documentation @@ -75,7 +75,7 @@ public static class Quota { } /** - * Returns the maximum allowed number of managed zones in the project. + * Returns the maximum allowed number of zones in the project. */ public int zones() { return zones; @@ -104,7 +104,7 @@ public int rrsetDeletionsPerChange() { } /** - * Returns the maximum allowed number of {@link DnsRecord}s per {@link ManagedZoneInfo} in the + * Returns the maximum allowed number of {@link DnsRecord}s per {@link ZoneInfo} in the * project. */ public int rrsetsPerManagedZone() { diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java similarity index 70% rename from gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java index d27e134ad908..3e8afd9a30f9 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ManagedZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java @@ -32,12 +32,12 @@ import java.util.Objects; /** - * A {@code ManagedZone} represents a DNS zone hosted by the Google Cloud DNS service. A zone is a - * subtree of the DNS namespace under one administrative responsibility. See Google Cloud DNS documentation for * more information. */ -public class ManagedZoneInfo implements Serializable { +public class ZoneInfo implements Serializable { private static final long serialVersionUID = 201601191647L; private final String name; @@ -49,7 +49,7 @@ public class ManagedZoneInfo implements Serializable { private final List nameServers; /** - * A builder for {@code ManagedZoneInfo}. + * A builder for {@code ZoneInfo}. */ public static class Builder { private String name; @@ -61,8 +61,7 @@ public static class Builder { private List nameServers = new LinkedList<>(); /** - * Returns an empty builder for {@code ManagedZoneInfo}. We use it internally in {@code - * toPb()}. + * Returns an empty builder for {@code ZoneInfo}. We use it internally in {@code toPb()}. */ private Builder() { } @@ -81,9 +80,9 @@ private Builder(String name, BigInteger id) { } /** - * Creates a builder from an existing ManagedZoneInfo object. + * Creates a builder from an existing ZoneInfo object. */ - Builder(ManagedZoneInfo info) { + Builder(ZoneInfo info) { this.name = info.name; this.id = info.id; this.creationTimeMillis = info.creationTimeMillis; @@ -102,7 +101,7 @@ public Builder name(String name) { } /** - * Sets an id for the managed zone which is assigned to the managed zone by the server. + * Sets an id for the zone which is assigned to the zone by the server. */ Builder id(BigInteger id) { this.id = id; @@ -110,7 +109,7 @@ Builder id(BigInteger id) { } /** - * Sets the time when this managed zone was created. + * Sets the time when this zone was created. */ Builder creationTimeMillis(long creationTimeMillis) { this.creationTimeMillis = creationTimeMillis; @@ -118,7 +117,7 @@ Builder creationTimeMillis(long creationTimeMillis) { } /** - * Sets a mandatory DNS name of this managed zone, for instance "example.com.". + * Sets a mandatory DNS name of this zone, for instance "example.com.". */ public Builder dnsName(String dnsName) { this.dnsName = checkNotNull(dnsName); @@ -126,8 +125,8 @@ public Builder dnsName(String dnsName) { } /** - * Sets a mandatory description for this managed zone. The value is a string of at most 1024 - * characters which has no effect on the managed zone's function. + * Sets a mandatory description for this zone. The value is a string of at most 1024 characters + * which has no effect on the zone's function. */ public Builder description(String description) { this.description = checkNotNull(description); @@ -135,9 +134,8 @@ public Builder description(String description) { } /** - * Optionally specifies the NameServerSet for this managed zone. A NameServerSet is a set of DNS - * name servers that all host the same ManagedZones. Most users will not need to specify this - * value. + * Optionally specifies the NameServerSet for this zone. A NameServerSet is a set of DNS name + * servers that all host the same zones. Most users will not need to specify this value. */ public Builder nameServerSet(String nameServerSet) { // todo(mderka) add more to the doc when questions are answered by the service owner @@ -146,8 +144,8 @@ public Builder nameServerSet(String nameServerSet) { } /** - * Sets a list of servers that hold the information about the managed zone. This information is - * provided by Google Cloud DNS and is read only. + * Sets a list of servers that hold the information about the zone. This information is provided + * by Google Cloud DNS and is read only. */ Builder nameServers(List nameServers) { checkNotNull(nameServers); @@ -156,14 +154,14 @@ Builder nameServers(List nameServers) { } /** - * Builds the instance of {@code ManagedZoneInfo} based on the information set by this builder. + * Builds the instance of {@code ZoneInfo} based on the information set by this builder. */ - public ManagedZoneInfo build() { - return new ManagedZoneInfo(this); + public ZoneInfo build() { + return new ZoneInfo(this); } } - private ManagedZoneInfo(Builder builder) { + private ZoneInfo(Builder builder) { this.name = builder.name; this.id = builder.id; this.creationTimeMillis = builder.creationTimeMillis; @@ -174,63 +172,63 @@ private ManagedZoneInfo(Builder builder) { } /** - * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code name}. + * Returns a builder for {@code ZoneInfo} with an assigned {@code name}. */ public static Builder builder(String name) { return new Builder(name); } /** - * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code id}. + * Returns a builder for {@code ZoneInfo} with an assigned {@code id}. */ public static Builder builder(BigInteger id) { return new Builder(id); } /** - * Returns a builder for {@code ManagedZoneInfo} with an assigned {@code name} and {@code id}. + * Returns a builder for {@code ZoneInfo} with an assigned {@code name} and {@code id}. */ public static Builder builder(String name, BigInteger id) { return new Builder(name, id); } /** - * Returns the user-defined name of the managed zone. + * Returns the user-defined name of the zone. */ public String name() { return name; } /** - * Returns the read-only managed zone id assigned by the server. + * Returns the read-only zone id assigned by the server. */ public BigInteger id() { return id; } /** - * Returns the time when this time that this managed zone was created on the server. + * Returns the time when this time that this zone was created on the server. */ public Long creationTimeMillis() { return creationTimeMillis; } /** - * Returns the DNS name of this managed zone, for instance "example.com.". + * Returns the DNS name of this zone, for instance "example.com.". */ public String dnsName() { return dnsName; } /** - * Returns the description of this managed zone. + * Returns the description of this zone. */ public String description() { return description; } /** - * Returns the optionally specified set of DNS name servers that all host this managed zone. + * Returns the optionally specified set of DNS name servers that all host this zone. */ public String nameServerSet() { // todo(mderka) update this doc after finding out more about this from the service owners @@ -238,16 +236,14 @@ public String nameServerSet() { } /** - * The nameservers that the managed zone should be delegated to. This is defined by the Google DNS - * cloud. + * The nameservers that the zone should be delegated to. This is defined by the Google DNS cloud. */ public List nameServers() { return nameServers; } /** - * Returns a builder for {@code ManagedZoneInfo} prepopulated with the metadata of this managed - * zone. + * Returns a builder for {@code ZoneInfo} prepopulated with the metadata of this zone. */ public Builder toBuilder() { return new Builder(this); @@ -272,35 +268,35 @@ com.google.api.services.dns.model.ManagedZone toPb() { return pb; } - static ManagedZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) { - Builder b = new Builder(); + static ZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) { + Builder builder = new Builder(); if (pb.getDescription() != null) { - b.description(pb.getDescription()); + builder.description(pb.getDescription()); } if (pb.getDnsName() != null) { - b.dnsName(pb.getDnsName()); + builder.dnsName(pb.getDnsName()); } if (pb.getId() != null) { - b.id(pb.getId()); + builder.id(pb.getId()); } if (pb.getName() != null) { - b.name(pb.getName()); + builder.name(pb.getName()); } if (pb.getNameServers() != null) { - b.nameServers(pb.getNameServers()); + builder.nameServers(pb.getNameServers()); } if (pb.getNameServerSet() != null) { - b.nameServerSet(pb.getNameServerSet()); + builder.nameServerSet(pb.getNameServerSet()); } if (pb.getCreationTime() != null) { - b.creationTimeMillis(DateTime.parse(pb.getCreationTime()).getMillis()); + builder.creationTimeMillis(DateTime.parse(pb.getCreationTime()).getMillis()); } - return b.build(); + return builder.build(); } @Override public boolean equals(Object obj) { - return obj instanceof ManagedZoneInfo && Objects.equals(toPb(), ((ManagedZoneInfo) obj).toPb()); + return obj instanceof ZoneInfo && Objects.equals(toPb(), ((ZoneInfo) obj).toPb()); } @Override diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java similarity index 72% rename from gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java rename to gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java index 936164c81723..2c9fea8f7bde 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ManagedZoneInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java @@ -30,7 +30,7 @@ import java.util.LinkedList; import java.util.List; -public class ManagedZoneInfoTest { +public class ZoneInfoTest { private static final String NAME = "mz-example.com"; private static final BigInteger ID = BigInteger.valueOf(123L); @@ -42,7 +42,7 @@ public class ManagedZoneInfoTest { private static final String NS2 = "name server 2"; private static final String NS3 = "name server 3"; private static final List NAME_SERVERS = ImmutableList.of(NS1, NS2, NS3); - private static final ManagedZoneInfo INFO = ManagedZoneInfo.builder(NAME, ID) + private static final ZoneInfo INFO = ZoneInfo.builder(NAME, ID) .creationTimeMillis(CREATION_TIME_MILLIS) .dnsName(DNS_NAME) .description(DESCRIPTION) @@ -52,7 +52,7 @@ public class ManagedZoneInfoTest { @Test public void testDefaultBuilders() { - ManagedZoneInfo withName = ManagedZoneInfo.builder(NAME).build(); + ZoneInfo withName = ZoneInfo.builder(NAME).build(); assertTrue(withName.nameServers().isEmpty()); assertEquals(NAME, withName.name()); assertNull(withName.id()); @@ -60,7 +60,7 @@ public void testDefaultBuilders() { assertNull(withName.nameServerSet()); assertNull(withName.description()); assertNull(withName.dnsName()); - ManagedZoneInfo withId = ManagedZoneInfo.builder(ID).build(); + ZoneInfo withId = ZoneInfo.builder(ID).build(); assertTrue(withId.nameServers().isEmpty()); assertEquals(ID, withId.id()); assertNull(withId.name()); @@ -68,7 +68,7 @@ public void testDefaultBuilders() { assertNull(withId.nameServerSet()); assertNull(withId.description()); assertNull(withId.dnsName()); - ManagedZoneInfo withBoth = ManagedZoneInfo.builder(NAME, ID).build(); + ZoneInfo withBoth = ZoneInfo.builder(NAME, ID).build(); assertTrue(withBoth.nameServers().isEmpty()); assertEquals(ID, withBoth.id()); assertEquals(NAME, withBoth.name()); @@ -94,7 +94,7 @@ public void testBuilder() { @Test public void testEqualsAndNotEquals() { - ManagedZoneInfo clone = INFO.toBuilder().build(); + ZoneInfo clone = INFO.toBuilder().build(); assertEquals(INFO, clone); List moreServers = Lists.newLinkedList(NAME_SERVERS); moreServers.add(NS1); @@ -118,55 +118,55 @@ public void testEqualsAndNotEquals() { @Test public void testSameHashCodeOnEquals() { int hash = INFO.hashCode(); - ManagedZoneInfo clone = INFO.toBuilder().build(); + ZoneInfo clone = INFO.toBuilder().build(); assertEquals(clone.hashCode(), hash); } @Test public void testToBuilder() { assertEquals(INFO, INFO.toBuilder().build()); - ManagedZoneInfo partial = ManagedZoneInfo.builder(NAME).build(); + ZoneInfo partial = ZoneInfo.builder(NAME).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ManagedZoneInfo.builder(ID).build(); + partial = ZoneInfo.builder(ID).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ManagedZoneInfo.builder(NAME).description(DESCRIPTION).build(); + partial = ZoneInfo.builder(NAME).description(DESCRIPTION).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ManagedZoneInfo.builder(NAME).dnsName(DNS_NAME).build(); + partial = ZoneInfo.builder(NAME).dnsName(DNS_NAME).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ManagedZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build(); + partial = ZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build(); assertEquals(partial, partial.toBuilder().build()); List nameServers = new LinkedList<>(); nameServers.add(NS1); - partial = ManagedZoneInfo.builder(NAME).nameServers(nameServers).build(); + partial = ZoneInfo.builder(NAME).nameServers(nameServers).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ManagedZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build(); + partial = ZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build(); assertEquals(partial, partial.toBuilder().build()); } @Test public void testToAndFromPb() { - assertEquals(INFO, ManagedZoneInfo.fromPb(INFO.toPb())); - ManagedZoneInfo partial = ManagedZoneInfo.builder(NAME).build(); - assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); - partial = ManagedZoneInfo.builder(ID).build(); - assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); - partial = ManagedZoneInfo.builder(NAME).description(DESCRIPTION).build(); - assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); - partial = ManagedZoneInfo.builder(NAME).dnsName(DNS_NAME).build(); - assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); - partial = ManagedZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build(); - assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); + assertEquals(INFO, ZoneInfo.fromPb(INFO.toPb())); + ZoneInfo partial = ZoneInfo.builder(NAME).build(); + assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); + partial = ZoneInfo.builder(ID).build(); + assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); + partial = ZoneInfo.builder(NAME).description(DESCRIPTION).build(); + assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); + partial = ZoneInfo.builder(NAME).dnsName(DNS_NAME).build(); + assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); + partial = ZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build(); + assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); List nameServers = new LinkedList<>(); nameServers.add(NS1); - partial = ManagedZoneInfo.builder(NAME).nameServers(nameServers).build(); - assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); - partial = ManagedZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build(); - assertEquals(partial, ManagedZoneInfo.fromPb(partial.toPb())); + partial = ZoneInfo.builder(NAME).nameServers(nameServers).build(); + assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); + partial = ZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build(); + assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); } @Test public void testEmptyNameServers() { - ManagedZoneInfo clone = INFO.toBuilder().nameServers(new LinkedList()).build(); + ZoneInfo clone = INFO.toBuilder().nameServers(new LinkedList()).build(); assertTrue(clone.nameServers().isEmpty()); clone.toPb(); // test that this is allowed } @@ -175,7 +175,7 @@ public void testEmptyNameServers() { public void testDateParsing() { com.google.api.services.dns.model.ManagedZone pb = INFO.toPb(); pb.setCreationTime("2016-01-19T18:00:12.854Z"); // a real value obtained from Google Cloud DNS - ManagedZoneInfo mz = ManagedZoneInfo.fromPb(pb); // parses the string timestamp to millis + ZoneInfo mz = ZoneInfo.fromPb(pb); // parses the string timestamp to millis com.google.api.services.dns.model.ManagedZone pbClone = mz.toPb(); // converts it back to string assertEquals(pb, pbClone); assertEquals(pb.getCreationTime(), pbClone.getCreationTime()); From c364ff322187be6404c1a9cd0e1673b8f64a7c35 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 28 Jan 2016 09:30:55 -0800 Subject: [PATCH 020/203] Modified ttl to accept time unit. Fixed #581. --- .../java/com/google/gcloud/dns/DnsRecord.java | 30 +++++++++----- .../com/google/gcloud/dns/DnsRecordTest.java | 39 ++++++++++++------- 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index b9e8134d9921..a3a673b99cc6 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -27,14 +27,15 @@ import java.util.LinkedList; import java.util.List; import java.util.Objects; +import java.util.concurrent.TimeUnit; /** * A class that represents a Google Cloud DNS record set. * *

A {@code DnsRecord} is the unit of data that will be returned by the DNS servers upon a DNS * request for a specific domain. The {@code DnsRecord} holds the current state of the DNS records - * that make up a zone. You can read the records but you cannot modify them directly. - * Rather, you edit the records in a zone by creating a ChangeRequest. + * that make up a zone. You can read the records but you cannot modify them directly. Rather, you + * edit the records in a zone by creating a ChangeRequest. * * @see Google Cloud DNS * documentation @@ -44,7 +45,7 @@ public class DnsRecord implements Serializable { private static final long serialVersionUID = 2016011914302204L; private final String name; private final List rrdatas; - private final Integer ttl; + private final Integer ttl; // this is in seconds private final Type type; /** @@ -176,14 +177,23 @@ public Builder name(String name) { } /** - * Sets the number of seconds that this record can be cached by resolvers. This number must be - * non-negative. + * Sets the time that this record can be cached by resolvers. This number must be non-negative. + * The maximum duration must be equivalent to at most {@link Integer#MAX_VALUE} seconds. * - * @param ttl A non-negative number of seconds + * @param duration A non-negative number of time units + * @param unit The unit of the ttl parameter */ - public Builder ttl(int ttl) { - checkArgument(ttl >= 0, "TTL cannot be negative. The supplied value was %s.", ttl); - this.ttl = ttl; + public Builder ttl(int duration, TimeUnit unit) { + checkArgument(duration >= 0, + "Duration cannot be negative. The supplied value was %s.", duration); + checkNotNull(unit); + // convert to seconds and check that we are not overflowing int + // we cannot do that because pb does not support it + long converted = unit.toSeconds(duration); + checkArgument(converted <= Integer.MAX_VALUE, + "The duration converted to seconds is out of range of int. The value converts to %s sec.", + converted); + ttl = (int) converted; return this; } @@ -278,7 +288,7 @@ static DnsRecord fromPb(com.google.api.services.dns.model.ResourceRecordSet pb) builder.records(pb.getRrdatas()); } if (pb.getTtl() != null) { - builder.ttl(pb.getTtl()); + builder.ttl(pb.getTtl(), TimeUnit.SECONDS); } return builder.build(); } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java index 7a7daf8aac3c..5fc972cede78 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java @@ -16,6 +16,7 @@ package com.google.gcloud.dns; +import static com.google.gcloud.dns.DnsRecord.builder; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; @@ -23,18 +24,22 @@ import org.junit.Test; +import java.util.concurrent.TimeUnit; + public class DnsRecordTest { private static final String NAME = "example.com."; private static final Integer TTL = 3600; + private static final TimeUnit UNIT = TimeUnit.HOURS; + private static final Integer UNIT_TTL = 1; private static final DnsRecord.Type TYPE = DnsRecord.Type.AAAA; - private static final DnsRecord record = DnsRecord.builder(NAME, TYPE) - .ttl(TTL) + private static final DnsRecord record = builder(NAME, TYPE) + .ttl(UNIT_TTL, UNIT) .build(); @Test public void testDefaultDnsRecord() { - DnsRecord record = DnsRecord.builder(NAME, TYPE).build(); + DnsRecord record = builder(NAME, TYPE).build(); assertEquals(0, record.records().size()); assertEquals(TYPE, record.type()); assertEquals(NAME, record.name()); @@ -61,13 +66,21 @@ public void testBuilder() { @Test public void testValidTtl() { try { - DnsRecord.builder(NAME, TYPE).ttl(-1); + builder(NAME, TYPE).ttl(-1, TimeUnit.SECONDS); fail("A negative value is not acceptable for ttl."); } catch (IllegalArgumentException e) { // expected } - DnsRecord.builder(NAME, TYPE).ttl(0); - DnsRecord.builder(NAME, TYPE).ttl(Integer.MAX_VALUE); + builder(NAME, TYPE).ttl(0, TimeUnit.SECONDS); + builder(NAME, TYPE).ttl(Integer.MAX_VALUE, TimeUnit.SECONDS); + try { + builder(NAME, TYPE).ttl(Integer.MAX_VALUE, TimeUnit.HOURS); + fail("This value is too large for int."); + } catch (IllegalArgumentException e) { + // expected + } + DnsRecord record = DnsRecord.builder(NAME, TYPE).ttl(UNIT_TTL, UNIT).build(); + assertEquals(TTL, record.ttl()); } @Test @@ -79,7 +92,7 @@ public void testEqualsAndNotEquals() { String differentName = "totally different name"; clone = record.toBuilder().name(differentName).build(); assertNotEquals(record, clone); - clone = record.toBuilder().ttl(record.ttl() + 1).build(); + clone = record.toBuilder().ttl(record.ttl() + 1, TimeUnit.SECONDS).build(); assertNotEquals(record, clone); clone = record.toBuilder().type(DnsRecord.Type.TXT).build(); assertNotEquals(record, clone); @@ -95,22 +108,22 @@ public void testSameHashCodeOnEquals() { @Test public void testToAndFromPb() { assertEquals(record, DnsRecord.fromPb(record.toPb())); - DnsRecord partial = DnsRecord.builder(NAME, TYPE).build(); + DnsRecord partial = builder(NAME, TYPE).build(); assertEquals(partial, DnsRecord.fromPb(partial.toPb())); - partial = DnsRecord.builder(NAME, TYPE).addRecord("test").build(); + partial = builder(NAME, TYPE).addRecord("test").build(); assertEquals(partial, DnsRecord.fromPb(partial.toPb())); - partial = DnsRecord.builder(NAME, TYPE).ttl(15).build(); + partial = builder(NAME, TYPE).ttl(15, TimeUnit.SECONDS).build(); assertEquals(partial, DnsRecord.fromPb(partial.toPb())); } @Test public void testToBuilder() { assertEquals(record, record.toBuilder().build()); - DnsRecord partial = DnsRecord.builder(NAME, TYPE).build(); + DnsRecord partial = builder(NAME, TYPE).build(); assertEquals(partial, partial.toBuilder().build()); - partial = DnsRecord.builder(NAME, TYPE).addRecord("test").build(); + partial = builder(NAME, TYPE).addRecord("test").build(); assertEquals(partial, partial.toBuilder().build()); - partial = DnsRecord.builder(NAME, TYPE).ttl(15).build(); + partial = builder(NAME, TYPE).ttl(15, TimeUnit.SECONDS).build(); assertEquals(partial, partial.toBuilder().build()); } From 7bcff48454c09e73ab94b1b995563e390200d081 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 28 Jan 2016 10:27:21 -0800 Subject: [PATCH 021/203] Implemented comments by @aozarov. --- .../java/com/google/gcloud/dns/DnsRecord.java | 9 +++------ .../java/com/google/gcloud/dns/ProjectInfo.java | 16 ++++++++-------- .../java/com/google/gcloud/dns/ZoneInfo.java | 2 +- .../com/google/gcloud/dns/ProjectInfoTest.java | 8 ++++---- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index a3a673b99cc6..99ca20386419 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -22,6 +22,7 @@ import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import com.google.common.primitives.Ints; import java.io.Serializable; import java.util.LinkedList; @@ -187,13 +188,9 @@ public Builder ttl(int duration, TimeUnit unit) { checkArgument(duration >= 0, "Duration cannot be negative. The supplied value was %s.", duration); checkNotNull(unit); - // convert to seconds and check that we are not overflowing int - // we cannot do that because pb does not support it + // we cannot have long because pb does not support it long converted = unit.toSeconds(duration); - checkArgument(converted <= Integer.MAX_VALUE, - "The duration converted to seconds is out of range of int. The value converts to %s sec.", - converted); - ttl = (int) converted; + ttl = Ints.checkedCast(converted); return this; } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java index b7933956ed88..4db0497946b1 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java @@ -50,7 +50,7 @@ public static class Quota { private final int resourceRecordsPerRrset; private final int rrsetAdditionsPerChange; private final int rrsetDeletionsPerChange; - private final int rrsetsPerManagedZone; + private final int rrsetsPerZone; private final int totalRrdataSizePerChange; /** @@ -64,13 +64,13 @@ public static class Quota { int resourceRecordsPerRrset, int rrsetAdditionsPerChange, int rrsetDeletionsPerChange, - int rrsetsPerManagedZone, + int rrsetsPerZone, int totalRrdataSizePerChange) { this.zones = zones; this.resourceRecordsPerRrset = resourceRecordsPerRrset; this.rrsetAdditionsPerChange = rrsetAdditionsPerChange; this.rrsetDeletionsPerChange = rrsetDeletionsPerChange; - this.rrsetsPerManagedZone = rrsetsPerManagedZone; + this.rrsetsPerZone = rrsetsPerZone; this.totalRrdataSizePerChange = totalRrdataSizePerChange; } @@ -107,8 +107,8 @@ public int rrsetDeletionsPerChange() { * Returns the maximum allowed number of {@link DnsRecord}s per {@link ZoneInfo} in the * project. */ - public int rrsetsPerManagedZone() { - return rrsetsPerManagedZone; + public int rrsetsPerZone() { + return rrsetsPerZone; } /** @@ -126,7 +126,7 @@ public boolean equals(Object other) { @Override public int hashCode() { return Objects.hash(zones, resourceRecordsPerRrset, rrsetAdditionsPerChange, - rrsetDeletionsPerChange, rrsetsPerManagedZone, totalRrdataSizePerChange); + rrsetDeletionsPerChange, rrsetsPerZone, totalRrdataSizePerChange); } com.google.api.services.dns.model.Quota toPb() { @@ -135,7 +135,7 @@ com.google.api.services.dns.model.Quota toPb() { pb.setResourceRecordsPerRrset(resourceRecordsPerRrset); pb.setRrsetAdditionsPerChange(rrsetAdditionsPerChange); pb.setRrsetDeletionsPerChange(rrsetDeletionsPerChange); - pb.setRrsetsPerManagedZone(rrsetsPerManagedZone); + pb.setRrsetsPerManagedZone(rrsetsPerZone); pb.setTotalRrdataSizePerChange(totalRrdataSizePerChange); return pb; } @@ -158,7 +158,7 @@ public String toString() { .add("resourceRecordsPerRrset", resourceRecordsPerRrset) .add("rrsetAdditionsPerChange", rrsetAdditionsPerChange) .add("rrsetDeletionsPerChange", rrsetDeletionsPerChange) - .add("rrsetsPerManagedZone", rrsetsPerManagedZone) + .add("rrsetsPerZone", rrsetsPerZone) .add("totalRrdataSizePerChange", totalRrdataSizePerChange) .toString(); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java index 3e8afd9a30f9..524309eaa8e9 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java @@ -207,7 +207,7 @@ public BigInteger id() { } /** - * Returns the time when this time that this zone was created on the server. + * Returns the time when this zone was created on the server. */ public Long creationTimeMillis() { return creationTimeMillis; diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java index 2af8b5ad3995..d959d44d4351 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ProjectInfoTest.java @@ -57,7 +57,7 @@ public void testQuotaConstructor() { assertEquals(2, QUOTA.resourceRecordsPerRrset()); assertEquals(3, QUOTA.rrsetAdditionsPerChange()); assertEquals(4, QUOTA.rrsetDeletionsPerChange()); - assertEquals(5, QUOTA.rrsetsPerManagedZone()); + assertEquals(5, QUOTA.rrsetsPerZone()); assertEquals(6, QUOTA.totalRrdataSizePerChange()); } @@ -101,11 +101,11 @@ public void testSameHashCodeOnEquals() { public void testToAndFromPb() { assertEquals(PROJECT_INFO, ProjectInfo.fromPb(PROJECT_INFO.toPb())); ProjectInfo partial = ProjectInfo.builder().id(ID).build(); - assertEquals(partial, PROJECT_INFO.fromPb(partial.toPb())); + assertEquals(partial, ProjectInfo.fromPb(partial.toPb())); partial = ProjectInfo.builder().number(NUMBER).build(); - assertEquals(partial, PROJECT_INFO.fromPb(partial.toPb())); + assertEquals(partial, ProjectInfo.fromPb(partial.toPb())); partial = ProjectInfo.builder().quota(QUOTA).build(); - assertEquals(partial, PROJECT_INFO.fromPb(partial.toPb())); + assertEquals(partial, ProjectInfo.fromPb(partial.toPb())); assertNotEquals(PROJECT_INFO, partial); } From f9b6f6a4762484da32ceee58e5281f1d615a1a12 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 28 Jan 2016 15:55:06 -0800 Subject: [PATCH 022/203] Added DnsService interface. --- .../com/google/gcloud/dns/DnsService.java | 507 ++++++++++++++++++ 1 file changed, 507 insertions(+) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java new file mode 100644 index 000000000000..694b0b288154 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java @@ -0,0 +1,507 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import com.google.common.base.Joiner; +import com.google.common.collect.Sets; +import com.google.gcloud.spi.DnsServiceRpc; + +import java.io.Serializable; +import java.util.Set; + +/** + * An interface for the Google Cloud DNS service. + * + * @see Google Cloud DNS + */ +public interface DnsService extends Service { + + /** + * The fields of a project. + * + *

These values can be used to specify the fields to include in a partial response when calling + * {@code DnsService#getProjectInfo(ProjectOptions...)}. Project ID is always returned, even if + * not specified. + */ + enum ProjectField { + PROJECT_ID("id"), + PROJECT_NUMBER("number"), + QUOTA("quota"); + + private final String selector; + + ProjectField(String selector) { + this.selector = selector; + } + + public String selector() { + return selector; + } + + static String selector(ProjectField... fields) { + Set fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1); + fieldStrings.add(PROJECT_ID.selector()); + for (ProjectField field : fields) { + fieldStrings.add(field.selector()); + } + return Joiner.on(',').join(fieldStrings); + } + } + + /** + * The fields of a zone. + * + *

These values can be used to specify the fields to include in a partial response when calling + * {@code DnsService#getZone(BigInteger, ZoneFieldOptions...)} or {@code + * DnsService#getZone(String, ZoneFieldOptions...)}. The ID is always returned, even if not + * specified. + */ + enum ZoneField { + CREATION_TIME("creationTime"), + DESCRIPTION("description"), + DNS_NAME("dnsName"), + ZONE_ID("id"), + NAME("name"), + NAME_SERVER_SET("nameServerSet"), + NAME_SERVERS("nameServers"); + + private final String selector; + + ZoneField(String selector) { + this.selector = selector; + } + + public String selector() { + return selector; + } + + static String selector(ZoneField... fields) { + Set fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1); + fieldStrings.add(ZONE_ID.selector()); + for (ZoneField field : fields) { + fieldStrings.add(field.selector()); + } + return Joiner.on(',').join(fieldStrings); + } + } + + /** + * The fields of a DNS record. + * + *

These values can be used to specify the fields to include in a partial response when calling + * {@code DnsService#listDnsRecords(BigInteger, DnsRecordOptions...)} or {@code + * DnsService#listDnsRecords(String, DnsRecordOptions...)}. The name is always returned even if + * not selected. + */ + enum DnsRecordField { + DNS_RECORDS("rrdatas"), + NAME("name"), + TTL("ttl"), + TYPE("type"); + + private final String selector; + + DnsRecordField(String selector) { + this.selector = selector; + } + + public String selector() { + return selector; + } + + static String selector(DnsRecordField... fields) { + Set fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1); + fieldStrings.add(NAME.selector()); + for (DnsRecordField field : fields) { + fieldStrings.add(field.selector()); + } + return Joiner.on(',').join(fieldStrings); + } + } + + /** + * The fields of a change request. + * + *

These values can be used to specify the fields to include in a partial response when calling + * {@code DnsService#applyChangeRequest(ChangeRequest, BigInteger, ChangeRequestFieldOptions...)} + * or {@code DnsService#applyChangeRequest(ChangeRequest, String, ChangeRequestFieldOptions...)} + * The ID is always returned even if not selected. + */ + enum ChangeRequestField { + ID("id"), + START_TIME("startTime"), + STATUS("status"), + ADDITIONS("additions"), + DELETIONS("deletions"); + + private final String selector; + + ChangeRequestField(String selector) { + this.selector = selector; + } + + public String selector() { + return selector; + } + + static String selector(ChangeRequestField... fields) { + Set fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1); + fieldStrings.add(ID.selector()); + for (ChangeRequestField field : fields) { + fieldStrings.add(field.selector()); + } + return Joiner.on(',').join(fieldStrings); + } + } + + /** + * The sorting keys for listing change requests. The only currently supported sorting key is the + * change sequence. + */ + enum ChangeRequestSortingKey { + CHANGE_SEQUENCE("changeSequence"); + + private final String selector; + + ChangeRequestSortingKey(String selector) { + this.selector = selector; + } + + public String selector() { + return selector; + } + } + + /** + * The sorting order for listing change requests. + */ + enum ChangeRequestSortingOrder { + DESCENDING, ASCENDING; + + public String selector() { + return this.name().toLowerCase(); + } + } + + /** + * Class that for specifying DNS record options. + */ + class DnsRecordOptions extends AbstractOption implements Serializable { + + private static final long serialVersionUID = 201601261646L; + + DnsRecordOptions(DnsServiceRpc.Option option, Object value) { + super(option, value); + } + + /** + * Returns an option to specify the DNS record's fields to be returned by the RPC call. + * + *

If this option is not provided all record fields are returned. {@code + * DnsRecordField.fields} can be used to specify only the fields of interest. The name of the + * DNS record always returned, even if not specified. {@link DnsRecordField} provides a list of + * fields that can be used. + */ + public static DnsRecordOptions fields(DnsRecordField... fields) { + StringBuilder builder = new StringBuilder(); + builder.append("rrsets(").append(DnsRecordField.selector(fields)).append(")"); + return new DnsRecordOptions(DnsServiceRpc.Option.FIELDS, builder.toString()); + } + + /** + * Returns an option to specify a page token. + * + *

The page token (returned from a previous call to list) indicates from where listing should + * continue. + */ + public static DnsRecordOptions pageToken(String pageToken) { + return new DnsRecordOptions(DnsServiceRpc.Option.PAGE_TOKEN, pageToken); + } + + /** + * The maximum number of DNS records to return per RPC. + * + *

The server can return fewer records than requested. When there are more results than the + * page size, the server will return a page token that can be used to fetch other results. + */ + public static DnsRecordOptions pageSize(int pageSize) { + return new DnsRecordOptions(DnsServiceRpc.Option.PAGE_SIZE, pageSize); + } + + /** + * Restricts the list to return only zones with this fully qualified domain name. + */ + public static DnsRecordOptions dnsName(String dnsName) { + return new DnsRecordOptions(DnsServiceRpc.Option.DNS_NAME, dnsName); + } + } + + /** + * Class for specifying zone field options. + */ + class ZoneFieldOptions extends AbstractOption implements Serializable { + + private static final long serialVersionUID = -7294186261285469986L; + + ZoneFieldOptions(DnsServiceRpc.Option option, Object value) { + super(option, value); + } + + /** + * Returns an option to specify the zones's fields to be returned by the RPC call. + * + *

If this option is not provided all zone fields are returned. {@code + * ZoneFieldOptions.fields} can be used to specify only the fields of interest. Zone ID is + * always returned, even if not specified. {@link ZoneField} provides a list of fields that can + * be used. + */ + public static ZoneFieldOptions fields(ZoneField... fields) { + return new ZoneFieldOptions(DnsServiceRpc.Option.FIELDS, ZoneField.selector(fields)); + } + } + + /** + * Class for specifying zone listing options. + */ + class ZoneListOptions extends AbstractOption implements Serializable { + + private static final long serialVersionUID = -7922038132321229290L; + + ZoneListOptions(DnsServiceRpc.Option option, Object value) { + super(option, value); + } + + /** + * Returns an option to specify the zones's fields to be returned by the RPC call. + * + *

If this option is not provided all zone fields are returned. {@code + * ZoneFieldOptions.fields} can be used to specify only the fields of interest. Zone ID is + * always returned, even if not specified. {@link ZoneField} provides a list of fields that can + * be used. + */ + public static ZoneListOptions fields(ZoneField... fields) { + return new ZoneListOptions(DnsServiceRpc.Option.FIELDS, ZoneField.selector(fields)); + } + + /** + * Returns an option to specify a page token. + * + *

The page token (returned from a previous call to list) indicates from where listing should + * continue. + */ + public static ZoneListOptions pageToken(String pageToken) { + return new ZoneListOptions(DnsServiceRpc.Option.PAGE_TOKEN, pageToken); + } + + /** + * The maximum number of zones to return per RPC. + * + *

The server can return fewer zones than requested. When there are more results than the + * page size, the server will return a page token that can be used to fetch other results. + */ + public static ZoneListOptions pageSize(int pageSize) { + return new ZoneListOptions(DnsServiceRpc.Option.PAGE_SIZE, pageSize); + } + + /** + * Restricts the list to return only zones with this fully qualified domain name. + */ + public static ZoneListOptions dnsName(String dnsName) { + return new ZoneListOptions(DnsServiceRpc.Option.DNS_NAME, dnsName); + } + } + + /** + * Class for specifying project options. + */ + class ProjectOptions extends AbstractOption implements Serializable { + + private static final long serialVersionUID = 6817937338218847748L; + + ProjectOptions(DnsServiceRpc.Option option, Object value) { + super(option, value); + } + + /** + * Returns an option to specify the project's fields to be returned by the RPC call. + * + *

If this option is not provided all project fields are returned. {@code + * ProjectOptions.fields} can be used to specify only the fields of interest. Project ID is + * always returned, even if not specified. {@link ProjectField} provides a list of fields that + * can be used. + */ + public static ProjectOptions fields(ProjectField... fields) { + return new ProjectOptions(DnsServiceRpc.Option.FIELDS, ProjectField.selector(fields)); + } + } + + /** + * Class for specifying change request field options. + */ + class ChangeRequestFieldOptions extends AbstractOption implements Serializable { + + private static final long serialVersionUID = 1067273695061077782L; + + ChangeRequestFieldOptions(DnsServiceRpc.Option option, Object value) { + super(option, value); + } + + /** + * Returns an option to specify which fields of DNS records to be added by the {@link + * ChangeRequest} should be returned by the service. + * + *

If this option is not provided, all record fields are returned. {@code + * ChangeRequestFieldOptions.additionsFields} can be used to specify only the fields of + * interest. The name of the DNS record always returned, even if not specified. {@link + * DnsRecordField} provides a list of fields that can be used. + */ + public static ChangeRequestFieldOptions additionsFields(DnsRecordField... fields) { + StringBuilder builder = new StringBuilder(); + builder.append("additions(").append(DnsRecordField.selector(fields)).append(")"); + return new ChangeRequestFieldOptions(DnsServiceRpc.Option.FIELDS, builder.toString()); + } + + /** + * Returns an option to specify which fields of DNS records to be deleted by the {@link + * ChangeRequest} should be returned by the service. + * + *

If this option is not provided, all record fields are returned. {@code + * ChangeRequestFieldOptions.deletionsFields} can be used to specify only the fields of + * interest. The name of the DNS record always returned, even if not specified. {@link + * DnsRecordField} provides a list of fields that can be used. + */ + public static ChangeRequestFieldOptions deletionsFields(DnsRecordField... fields) { + StringBuilder builder = new StringBuilder(); + builder.append("deletions(").append(DnsRecordField.selector(fields)).append(")"); + return new ChangeRequestFieldOptions(DnsServiceRpc.Option.FIELDS, builder.toString()); + + } + + /** + * Returns an option to specify which fields of {@link ChangeRequest} should be returned by the + * service. + * + *

If this option is not provided all change request fields are returned. {@code + * ChangeRequestFieldOptions.fields} can be used to specify only the fields of interest. The ID + * of the change request is always returned, even if not specified. {@link ChangeRequestField} + * provides a list of fields that can be used. + */ + public static ChangeRequestFieldOptions fields(ChangeRequestField... fields) { + return new ChangeRequestFieldOptions( + DnsServiceRpc.Option.FIELDS, + ChangeRequestField.selector(fields) + ); + } + } + + /** + * Class for specifying change request listing options. + */ + class ChangeRequestListOptions extends AbstractOption implements Serializable { + + private static final long serialVersionUID = -900209143895376089L; + + ChangeRequestListOptions(DnsServiceRpc.Option option, Object value) { + super(option, value); + } + + /** + * Returns an option to specify which fields of DNS records to be added by the {@link + * ChangeRequest} should be returned by the service. + * + *

If this option is not provided, all record fields are returned. {@code + * ChangeRequestFieldOptions.additionsFields} can be used to specify only the fields of + * interest. The name of the DNS record always returned, even if not specified. {@link + * DnsRecordField} provides a list of fields that can be used. + */ + public static ChangeRequestListOptions additionsFields(DnsRecordField... fields) { + StringBuilder builder = new StringBuilder(); + builder.append("changes(additions(").append(DnsRecordField.selector(fields)).append("))"); + return new ChangeRequestListOptions(DnsServiceRpc.Option.FIELDS, builder.toString()); + } + + /** + * Returns an option to specify which fields of DNS records to be deleted by the {@link + * ChangeRequest} should be returned by the service. + * + *

If this option is not provided, all record fields are returned. {@code + * ChangeRequestFieldOptions.deletionsFields} can be used to specify only the fields of + * interest. The name of the DNS record always returned, even if not specified. {@link + * DnsRecordField} provides a list of fields that can be used. + */ + public static ChangeRequestListOptions deletionsFields(DnsRecordField... fields) { + StringBuilder builder = new StringBuilder(); + builder.append("changes(deletions(").append(DnsRecordField.selector(fields)).append("))"); + return new ChangeRequestListOptions(DnsServiceRpc.Option.FIELDS, builder.toString()); + } + + /** + * Returns an option to specify which fields of{@link ChangeRequest} should be returned by the + * service. + * + *

If this option is not provided all change request fields are returned. {@code + * ChangeRequestFieldOptions.fields} can be used to specify only the fields of interest. The ID + * of the change request is always returned, even if not specified. {@link ChangeRequestField} + * provides a list of fields that can be used. + */ + public static ChangeRequestListOptions fields(ChangeRequestField... fields) { + return new ChangeRequestListOptions( + DnsServiceRpc.Option.FIELDS, + ChangeRequestField.selector(fields) + ); + } + + /** + * Returns an option to specify a page token. + * + *

The page token (returned from a previous call to list) indicates from where listing should + * continue. + */ + public static ChangeRequestListOptions pageToken(String pageToken) { + return new ChangeRequestListOptions(DnsServiceRpc.Option.PAGE_TOKEN, pageToken); + } + + /** + * The maximum number of change requests to return per RPC. + * + *

The server can return fewer change requests than requested. When there are more results + * than the page size, the server will return a page token that can be used to fetch other + * results. + */ + public static ChangeRequestListOptions pageSize(int pageSize) { + return new ChangeRequestListOptions(DnsServiceRpc.Option.PAGE_SIZE, pageSize); + } + + /** + * Returns an option for specifying the sorting criterion of change requests. Note the the only + * currently supported criterion is the change sequence. + */ + public static ChangeRequestListOptions sortBy(ChangeRequestSortingKey key) { + return new ChangeRequestListOptions(DnsServiceRpc.Option.SORTING_KEY, key.selector()); + } + + /** + * Returns an option to specify whether the the change requests should be listed in ascending or + * descending order. + */ + public static ChangeRequestListOptions sortOrder(ChangeRequestSortingOrder order) { + return new ChangeRequestListOptions(DnsServiceRpc.Option.SORTING_ORDER, order.selector()); + } + } + + // TODO(mderka) Add methods. Created issue #596. +} From 4fdc8ee53b189a137aa990dca366db369e47cf9c Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 28 Jan 2016 15:57:12 -0800 Subject: [PATCH 023/203] Added AbstractOption. --- .../com/google/gcloud/dns/AbstractOption.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java new file mode 100644 index 000000000000..6b6fbbf0606e --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java @@ -0,0 +1,69 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.MoreObjects; +import com.google.gcloud.spi.DnsServiceRpc; + +import java.io.Serializable; +import java.util.Objects; + +/** + * A base class for options. + */ +public abstract class AbstractOption implements Serializable { + + private static final long serialVersionUID = 201601261704L; + private final Object value; + private final DnsServiceRpc.Option rpcOption; + + AbstractOption(DnsServiceRpc.Option rpcOption, Object value) { + this.rpcOption = checkNotNull(rpcOption); + this.value = value; + } + + Object value() { + return value; + } + + DnsServiceRpc.Option rpcOption() { + return rpcOption; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof AbstractOption)) { + return false; + } + AbstractOption other = (AbstractOption) obj; + return Objects.equals(value, other.value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("value", value) + .toString(); + } +} From 06becd885dc0d4c45cd779a06be448b5179e77d1 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 28 Jan 2016 15:58:13 -0800 Subject: [PATCH 024/203] Added DnsException. --- .../com/google/gcloud/dns/DnsException.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java new file mode 100644 index 000000000000..ab4a3df0f457 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java @@ -0,0 +1,37 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import com.google.gcloud.BaseServiceException; + +/** + * DNS service exception. + */ +public class DnsException extends BaseServiceException { + + private static final long serialVersionUID = 490302380416260252L; + + public DnsException(int code, String message, boolean retryable) { + super(code, message, retryable); + } + + public DnsException(int code, String message, boolean retryable, Exception cause) { + super(code, message, retryable, cause); + } + + //TODO(mderka) Add translation and retry functionality. Created issue #593. +} From 81cedc4edf78e745817c831c1d7cde7653dfc4f8 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 28 Jan 2016 16:00:19 -0800 Subject: [PATCH 025/203] Added DnsServiceRpc. --- .../com/google/gcloud/spi/DnsServiceRpc.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpc.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpc.java new file mode 100644 index 000000000000..e97ee9a1b001 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpc.java @@ -0,0 +1,56 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.spi; + +import java.util.Map; + +public interface DnsServiceRpc { + + enum Option { + FIELDS("fields"), + PAGE_SIZE("maxSize"), + PAGE_TOKEN("pageToken"), + DNS_NAME("dnsName"), + SORTING_KEY("sortBy"), + SORTING_ORDER("sortOrder"); + + private final String value; + + Option(String value) { + this.value = value; + } + + public String value() { + return value; + } + + @SuppressWarnings("unchecked") + T get(Map options) { + return (T) options.get(this); + } + + String getString(Map options) { + return get(options); + } + + Integer getInt(Map options) { + return get(options); + } + } + + //TODO(mderka) add supported operations. Created issue #594. +} From bf1361c034633137ba395f6e565a1579fb4797fb Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 28 Jan 2016 16:38:21 -0800 Subject: [PATCH 026/203] Added DnsServiceOptions and necessary dependencies. --- .../com/google/gcloud/dns/DnsService.java | 1 + .../google/gcloud/dns/DnsServiceFactory.java | 25 ++++++ .../google/gcloud/dns/DnsServiceOptions.java | 85 +++++++++++++++++++ .../gcloud/spi/DnsServiceRpcFactory.java | 26 ++++++ 4 files changed, 137 insertions(+) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceFactory.java create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceOptions.java create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpcFactory.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java index 694b0b288154..9cbd60eccf5a 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java @@ -18,6 +18,7 @@ import com.google.common.base.Joiner; import com.google.common.collect.Sets; +import com.google.gcloud.Service; import com.google.gcloud.spi.DnsServiceRpc; import java.io.Serializable; diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceFactory.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceFactory.java new file mode 100644 index 000000000000..aaa0dfb68e1b --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceFactory.java @@ -0,0 +1,25 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import com.google.gcloud.ServiceFactory; + +/** + * An interface for DnsService factories. + */ +public interface DnsServiceFactory extends ServiceFactory { +} diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceOptions.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceOptions.java new file mode 100644 index 000000000000..84eb9c33dcaa --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceOptions.java @@ -0,0 +1,85 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import com.google.gcloud.ServiceOptions; +import com.google.gcloud.spi.DnsServiceRpc; +import com.google.gcloud.spi.DnsServiceRpcFactory; + +import java.util.Set; + +public class DnsServiceOptions + extends ServiceOptions { + + private static final long serialVersionUID = -5311219368450107146L; + + // TODO(mderka) Finish implementation. Created issue #595. + + public static class DefaultDnsServiceFactory implements DnsServiceFactory { + private static final DnsServiceFactory INSTANCE = new DefaultDnsServiceFactory(); + + @Override + public DnsService create(DnsServiceOptions options) { + // TODO(mderka) Implement. Created issue #595. + return null; + } + } + + public static class Builder extends ServiceOptions.Builder { + + private Builder() { + } + + private Builder(DnsServiceOptions options) { + super(options); + } + + @Override + public DnsServiceOptions build() { + return new DnsServiceOptions(this); + } + } + + private DnsServiceOptions(Builder builder) { + super(DnsServiceFactory.class, DnsServiceRpcFactory.class, builder); + } + + @Override + protected DnsServiceFactory defaultServiceFactory() { + return DefaultDnsServiceFactory.INSTANCE; + } + + @Override + protected DnsServiceRpcFactory defaultRpcFactory() { + return null; + } + + @Override + protected Set scopes() { + return null; + } + + @Override + public Builder toBuilder() { + return new Builder(this); + } + + public static Builder builder() { + return new Builder(); + } +} diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpcFactory.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpcFactory.java new file mode 100644 index 000000000000..13ec9fe881c8 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpcFactory.java @@ -0,0 +1,26 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.spi; + +import com.google.gcloud.dns.DnsServiceOptions; + +/** + * An interface for DnsServiceRpc factory. Implementation will be loaded via {@link + * java.util.ServiceLoader}. + */ +public interface DnsServiceRpcFactory extends ServiceRpcFactory { +} From 465f5327d81035666a12c1ef37bab0a1bfd55300 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 28 Jan 2016 18:15:47 -0800 Subject: [PATCH 027/203] Modified DnsException to pass tests. --- .../main/java/com/google/gcloud/dns/DnsException.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java index ab4a3df0f457..d18f6163a881 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java @@ -18,6 +18,8 @@ import com.google.gcloud.BaseServiceException; +import java.io.IOException; + /** * DNS service exception. */ @@ -25,12 +27,8 @@ public class DnsException extends BaseServiceException { private static final long serialVersionUID = 490302380416260252L; - public DnsException(int code, String message, boolean retryable) { - super(code, message, retryable); - } - - public DnsException(int code, String message, boolean retryable, Exception cause) { - super(code, message, retryable, cause); + public DnsException(IOException exception, boolean idempotent) { + super(exception, idempotent); } //TODO(mderka) Add translation and retry functionality. Created issue #593. From a8bee9c1e07337d1e710d378d7a600215e26c1ba Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 29 Jan 2016 16:10:25 -0800 Subject: [PATCH 028/203] Implements comments by @aozarov. --- .../com/google/gcloud/dns/AbstractOption.java | 17 +- .../gcloud/dns/{DnsService.java => Dns.java} | 229 +++++++----------- ...DnsServiceFactory.java => DnsFactory.java} | 4 +- ...DnsServiceOptions.java => DnsOptions.java} | 38 +-- .../spi/{DnsServiceRpc.java => DnsRpc.java} | 3 +- ...viceRpcFactory.java => DnsRpcFactory.java} | 6 +- 6 files changed, 120 insertions(+), 177 deletions(-) rename gcloud-java-dns/src/main/java/com/google/gcloud/dns/{DnsService.java => Dns.java} (51%) rename gcloud-java-dns/src/main/java/com/google/gcloud/dns/{DnsServiceFactory.java => DnsFactory.java} (84%) rename gcloud-java-dns/src/main/java/com/google/gcloud/dns/{DnsServiceOptions.java => DnsOptions.java} (59%) rename gcloud-java-dns/src/main/java/com/google/gcloud/spi/{DnsServiceRpc.java => DnsRpc.java} (96%) rename gcloud-java-dns/src/main/java/com/google/gcloud/spi/{DnsServiceRpcFactory.java => DnsRpcFactory.java} (74%) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java index 6b6fbbf0606e..a148468d14b5 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.MoreObjects; -import com.google.gcloud.spi.DnsServiceRpc; +import com.google.gcloud.spi.DnsRpc; import java.io.Serializable; import java.util.Objects; @@ -27,13 +27,13 @@ /** * A base class for options. */ -public abstract class AbstractOption implements Serializable { +abstract class AbstractOption implements Serializable { - private static final long serialVersionUID = 201601261704L; + private static final long serialVersionUID = -5912727967831484228L; private final Object value; - private final DnsServiceRpc.Option rpcOption; + private final DnsRpc.Option rpcOption; - AbstractOption(DnsServiceRpc.Option rpcOption, Object value) { + AbstractOption(DnsRpc.Option rpcOption, Object value) { this.rpcOption = checkNotNull(rpcOption); this.value = value; } @@ -42,7 +42,7 @@ Object value() { return value; } - DnsServiceRpc.Option rpcOption() { + DnsRpc.Option rpcOption() { return rpcOption; } @@ -52,18 +52,19 @@ public boolean equals(Object obj) { return false; } AbstractOption other = (AbstractOption) obj; - return Objects.equals(value, other.value); + return Objects.equals(value, other.value) && Objects.equals(rpcOption, other.rpcOption); } @Override public int hashCode() { - return Objects.hash(value); + return Objects.hash(value, rpcOption); } @Override public String toString() { return MoreObjects.toStringHelper(this) .add("value", value) + .add("rpcOption", rpcOption) .toString(); } } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java similarity index 51% rename from gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 9cbd60eccf5a..737ec1a38699 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsService.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -19,7 +19,7 @@ import com.google.common.base.Joiner; import com.google.common.collect.Sets; import com.google.gcloud.Service; -import com.google.gcloud.spi.DnsServiceRpc; +import com.google.gcloud.spi.DnsRpc; import java.io.Serializable; import java.util.Set; @@ -29,13 +29,13 @@ * * @see Google Cloud DNS */ -public interface DnsService extends Service { +public interface Dns extends Service { /** * The fields of a project. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code DnsService#getProjectInfo(ProjectOptions...)}. Project ID is always returned, even if + * {@code Dns#getProjectInfo(ProjectGetOption...)}. Project ID is always returned, even if * not specified. */ enum ProjectField { @@ -49,7 +49,7 @@ enum ProjectField { this.selector = selector; } - public String selector() { + String selector() { return selector; } @@ -67,9 +67,8 @@ static String selector(ProjectField... fields) { * The fields of a zone. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code DnsService#getZone(BigInteger, ZoneFieldOptions...)} or {@code - * DnsService#getZone(String, ZoneFieldOptions...)}. The ID is always returned, even if not - * specified. + * {@code Dns#getZone(BigInteger, ZoneFieldOption...)} or {@code Dns#getZone(String, + * ZoneFieldOption...)}. The ID is always returned, even if not specified. */ enum ZoneField { CREATION_TIME("creationTime"), @@ -86,7 +85,7 @@ enum ZoneField { this.selector = selector; } - public String selector() { + String selector() { return selector; } @@ -104,8 +103,8 @@ static String selector(ZoneField... fields) { * The fields of a DNS record. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code DnsService#listDnsRecords(BigInteger, DnsRecordOptions...)} or {@code - * DnsService#listDnsRecords(String, DnsRecordOptions...)}. The name is always returned even if + * {@code Dns#listDnsRecords(BigInteger, DnsRecordListOption...)} or {@code + * Dns#listDnsRecords(String, DnsRecordListOption...)}. The name is always returned even if * not selected. */ enum DnsRecordField { @@ -120,7 +119,7 @@ enum DnsRecordField { this.selector = selector; } - public String selector() { + String selector() { return selector; } @@ -138,8 +137,8 @@ static String selector(DnsRecordField... fields) { * The fields of a change request. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code DnsService#applyChangeRequest(ChangeRequest, BigInteger, ChangeRequestFieldOptions...)} - * or {@code DnsService#applyChangeRequest(ChangeRequest, String, ChangeRequestFieldOptions...)} + * {@code Dns#applyChangeRequest(ChangeRequest, BigInteger, ChangeRequestOption...)} + * or {@code Dns#applyChangeRequest(ChangeRequest, String, ChangeRequestOption...)} * The ID is always returned even if not selected. */ enum ChangeRequestField { @@ -155,7 +154,7 @@ enum ChangeRequestField { this.selector = selector; } - public String selector() { + String selector() { return selector; } @@ -171,10 +170,10 @@ static String selector(ChangeRequestField... fields) { /** * The sorting keys for listing change requests. The only currently supported sorting key is the - * change sequence. + * when the change request was created. */ enum ChangeRequestSortingKey { - CHANGE_SEQUENCE("changeSequence"); + TIME_CREATED("changeSequence"); private final String selector; @@ -182,15 +181,15 @@ enum ChangeRequestSortingKey { this.selector = selector; } - public String selector() { + String selector() { return selector; } } /** - * The sorting order for listing change requests. + * The sorting order for listing. */ - enum ChangeRequestSortingOrder { + enum SortingOrder { DESCENDING, ASCENDING; public String selector() { @@ -201,11 +200,11 @@ public String selector() { /** * Class that for specifying DNS record options. */ - class DnsRecordOptions extends AbstractOption implements Serializable { + class DnsRecordListOption extends AbstractOption implements Serializable { - private static final long serialVersionUID = 201601261646L; + private static final long serialVersionUID = 1009627025381096098L; - DnsRecordOptions(DnsServiceRpc.Option option, Object value) { + DnsRecordListOption(DnsRpc.Option option, Object value) { super(option, value); } @@ -217,10 +216,10 @@ class DnsRecordOptions extends AbstractOption implements Serializable { * DNS record always returned, even if not specified. {@link DnsRecordField} provides a list of * fields that can be used. */ - public static DnsRecordOptions fields(DnsRecordField... fields) { + public static DnsRecordListOption fields(DnsRecordField... fields) { StringBuilder builder = new StringBuilder(); - builder.append("rrsets(").append(DnsRecordField.selector(fields)).append(")"); - return new DnsRecordOptions(DnsServiceRpc.Option.FIELDS, builder.toString()); + builder.append("rrsets(").append(DnsRecordField.selector(fields)).append(')'); + return new DnsRecordListOption(DnsRpc.Option.FIELDS, builder.toString()); } /** @@ -229,8 +228,8 @@ public static DnsRecordOptions fields(DnsRecordField... fields) { *

The page token (returned from a previous call to list) indicates from where listing should * continue. */ - public static DnsRecordOptions pageToken(String pageToken) { - return new DnsRecordOptions(DnsServiceRpc.Option.PAGE_TOKEN, pageToken); + public static DnsRecordListOption pageToken(String pageToken) { + return new DnsRecordListOption(DnsRpc.Option.PAGE_TOKEN, pageToken); } /** @@ -239,26 +238,34 @@ public static DnsRecordOptions pageToken(String pageToken) { *

The server can return fewer records than requested. When there are more results than the * page size, the server will return a page token that can be used to fetch other results. */ - public static DnsRecordOptions pageSize(int pageSize) { - return new DnsRecordOptions(DnsServiceRpc.Option.PAGE_SIZE, pageSize); + public static DnsRecordListOption pageSize(int pageSize) { + return new DnsRecordListOption(DnsRpc.Option.PAGE_SIZE, pageSize); } /** - * Restricts the list to return only zones with this fully qualified domain name. + * Restricts the list to only DNS records with this fully qualified domain name. */ - public static DnsRecordOptions dnsName(String dnsName) { - return new DnsRecordOptions(DnsServiceRpc.Option.DNS_NAME, dnsName); + public static DnsRecordListOption dnsName(String dnsName) { + return new DnsRecordListOption(DnsRpc.Option.DNS_NAME, dnsName); + } + + /** + * Restricts the list to return only records of this type. If present, {@link + * Dns.DnsRecordListOption#dnsName(String)} must also be present. + */ + public static DnsRecordListOption type(DnsRecord.Type type) { + return new DnsRecordListOption(DnsRpc.Option.DNS_TYPE, type); } } /** * Class for specifying zone field options. */ - class ZoneFieldOptions extends AbstractOption implements Serializable { + class ZoneFieldOption extends AbstractOption implements Serializable { - private static final long serialVersionUID = -7294186261285469986L; + private static final long serialVersionUID = -8065564464895945037L; - ZoneFieldOptions(DnsServiceRpc.Option option, Object value) { + ZoneFieldOption(DnsRpc.Option option, Object value) { super(option, value); } @@ -266,23 +273,23 @@ class ZoneFieldOptions extends AbstractOption implements Serializable { * Returns an option to specify the zones's fields to be returned by the RPC call. * *

If this option is not provided all zone fields are returned. {@code - * ZoneFieldOptions.fields} can be used to specify only the fields of interest. Zone ID is - * always returned, even if not specified. {@link ZoneField} provides a list of fields that can - * be used. + * ZoneFieldOption.fields} can be used to specify only the fields of interest. Zone ID is always + * returned, even if not specified. {@link ZoneField} provides a list of fields that can be + * used. */ - public static ZoneFieldOptions fields(ZoneField... fields) { - return new ZoneFieldOptions(DnsServiceRpc.Option.FIELDS, ZoneField.selector(fields)); + public static ZoneFieldOption fields(ZoneField... fields) { + return new ZoneFieldOption(DnsRpc.Option.FIELDS, ZoneField.selector(fields)); } } /** * Class for specifying zone listing options. */ - class ZoneListOptions extends AbstractOption implements Serializable { + class ZoneListOption extends AbstractOption implements Serializable { - private static final long serialVersionUID = -7922038132321229290L; + private static final long serialVersionUID = -2830645032124504717L; - ZoneListOptions(DnsServiceRpc.Option option, Object value) { + ZoneListOption(DnsRpc.Option option, Object value) { super(option, value); } @@ -290,12 +297,12 @@ class ZoneListOptions extends AbstractOption implements Serializable { * Returns an option to specify the zones's fields to be returned by the RPC call. * *

If this option is not provided all zone fields are returned. {@code - * ZoneFieldOptions.fields} can be used to specify only the fields of interest. Zone ID is - * always returned, even if not specified. {@link ZoneField} provides a list of fields that can - * be used. + * ZoneFieldOption.fields} can be used to specify only the fields of interest. Zone ID is always + * returned, even if not specified. {@link ZoneField} provides a list of fields that can be + * used. */ - public static ZoneListOptions fields(ZoneField... fields) { - return new ZoneListOptions(DnsServiceRpc.Option.FIELDS, ZoneField.selector(fields)); + public static ZoneListOption fields(ZoneField... fields) { + return new ZoneListOption(DnsRpc.Option.FIELDS, ZoneField.selector(fields)); } /** @@ -304,8 +311,8 @@ public static ZoneListOptions fields(ZoneField... fields) { *

The page token (returned from a previous call to list) indicates from where listing should * continue. */ - public static ZoneListOptions pageToken(String pageToken) { - return new ZoneListOptions(DnsServiceRpc.Option.PAGE_TOKEN, pageToken); + public static ZoneListOption pageToken(String pageToken) { + return new ZoneListOption(DnsRpc.Option.PAGE_TOKEN, pageToken); } /** @@ -314,26 +321,19 @@ public static ZoneListOptions pageToken(String pageToken) { *

The server can return fewer zones than requested. When there are more results than the * page size, the server will return a page token that can be used to fetch other results. */ - public static ZoneListOptions pageSize(int pageSize) { - return new ZoneListOptions(DnsServiceRpc.Option.PAGE_SIZE, pageSize); - } - - /** - * Restricts the list to return only zones with this fully qualified domain name. - */ - public static ZoneListOptions dnsName(String dnsName) { - return new ZoneListOptions(DnsServiceRpc.Option.DNS_NAME, dnsName); + public static ZoneListOption pageSize(int pageSize) { + return new ZoneListOption(DnsRpc.Option.PAGE_SIZE, pageSize); } } /** * Class for specifying project options. */ - class ProjectOptions extends AbstractOption implements Serializable { + class ProjectGetOption extends AbstractOption implements Serializable { private static final long serialVersionUID = 6817937338218847748L; - ProjectOptions(DnsServiceRpc.Option option, Object value) { + ProjectGetOption(DnsRpc.Option option, Object value) { super(option, value); } @@ -341,69 +341,38 @@ class ProjectOptions extends AbstractOption implements Serializable { * Returns an option to specify the project's fields to be returned by the RPC call. * *

If this option is not provided all project fields are returned. {@code - * ProjectOptions.fields} can be used to specify only the fields of interest. Project ID is + * ProjectGetOption.fields} can be used to specify only the fields of interest. Project ID is * always returned, even if not specified. {@link ProjectField} provides a list of fields that * can be used. */ - public static ProjectOptions fields(ProjectField... fields) { - return new ProjectOptions(DnsServiceRpc.Option.FIELDS, ProjectField.selector(fields)); + public static ProjectGetOption fields(ProjectField... fields) { + return new ProjectGetOption(DnsRpc.Option.FIELDS, ProjectField.selector(fields)); } } /** * Class for specifying change request field options. */ - class ChangeRequestFieldOptions extends AbstractOption implements Serializable { + class ChangeRequestOption extends AbstractOption implements Serializable { private static final long serialVersionUID = 1067273695061077782L; - ChangeRequestFieldOptions(DnsServiceRpc.Option option, Object value) { + ChangeRequestOption(DnsRpc.Option option, Object value) { super(option, value); } - /** - * Returns an option to specify which fields of DNS records to be added by the {@link - * ChangeRequest} should be returned by the service. - * - *

If this option is not provided, all record fields are returned. {@code - * ChangeRequestFieldOptions.additionsFields} can be used to specify only the fields of - * interest. The name of the DNS record always returned, even if not specified. {@link - * DnsRecordField} provides a list of fields that can be used. - */ - public static ChangeRequestFieldOptions additionsFields(DnsRecordField... fields) { - StringBuilder builder = new StringBuilder(); - builder.append("additions(").append(DnsRecordField.selector(fields)).append(")"); - return new ChangeRequestFieldOptions(DnsServiceRpc.Option.FIELDS, builder.toString()); - } - - /** - * Returns an option to specify which fields of DNS records to be deleted by the {@link - * ChangeRequest} should be returned by the service. - * - *

If this option is not provided, all record fields are returned. {@code - * ChangeRequestFieldOptions.deletionsFields} can be used to specify only the fields of - * interest. The name of the DNS record always returned, even if not specified. {@link - * DnsRecordField} provides a list of fields that can be used. - */ - public static ChangeRequestFieldOptions deletionsFields(DnsRecordField... fields) { - StringBuilder builder = new StringBuilder(); - builder.append("deletions(").append(DnsRecordField.selector(fields)).append(")"); - return new ChangeRequestFieldOptions(DnsServiceRpc.Option.FIELDS, builder.toString()); - - } - /** * Returns an option to specify which fields of {@link ChangeRequest} should be returned by the * service. * *

If this option is not provided all change request fields are returned. {@code - * ChangeRequestFieldOptions.fields} can be used to specify only the fields of interest. The ID + * ChangeRequestOption.fields} can be used to specify only the fields of interest. The ID * of the change request is always returned, even if not specified. {@link ChangeRequestField} * provides a list of fields that can be used. */ - public static ChangeRequestFieldOptions fields(ChangeRequestField... fields) { - return new ChangeRequestFieldOptions( - DnsServiceRpc.Option.FIELDS, + public static ChangeRequestOption fields(ChangeRequestField... fields) { + return new ChangeRequestOption( + DnsRpc.Option.FIELDS, ChangeRequestField.selector(fields) ); } @@ -412,56 +381,26 @@ public static ChangeRequestFieldOptions fields(ChangeRequestField... fields) { /** * Class for specifying change request listing options. */ - class ChangeRequestListOptions extends AbstractOption implements Serializable { + class ChangeRequestListOption extends AbstractOption implements Serializable { private static final long serialVersionUID = -900209143895376089L; - ChangeRequestListOptions(DnsServiceRpc.Option option, Object value) { + ChangeRequestListOption(DnsRpc.Option option, Object value) { super(option, value); } - /** - * Returns an option to specify which fields of DNS records to be added by the {@link - * ChangeRequest} should be returned by the service. - * - *

If this option is not provided, all record fields are returned. {@code - * ChangeRequestFieldOptions.additionsFields} can be used to specify only the fields of - * interest. The name of the DNS record always returned, even if not specified. {@link - * DnsRecordField} provides a list of fields that can be used. - */ - public static ChangeRequestListOptions additionsFields(DnsRecordField... fields) { - StringBuilder builder = new StringBuilder(); - builder.append("changes(additions(").append(DnsRecordField.selector(fields)).append("))"); - return new ChangeRequestListOptions(DnsServiceRpc.Option.FIELDS, builder.toString()); - } - - /** - * Returns an option to specify which fields of DNS records to be deleted by the {@link - * ChangeRequest} should be returned by the service. - * - *

If this option is not provided, all record fields are returned. {@code - * ChangeRequestFieldOptions.deletionsFields} can be used to specify only the fields of - * interest. The name of the DNS record always returned, even if not specified. {@link - * DnsRecordField} provides a list of fields that can be used. - */ - public static ChangeRequestListOptions deletionsFields(DnsRecordField... fields) { - StringBuilder builder = new StringBuilder(); - builder.append("changes(deletions(").append(DnsRecordField.selector(fields)).append("))"); - return new ChangeRequestListOptions(DnsServiceRpc.Option.FIELDS, builder.toString()); - } - /** * Returns an option to specify which fields of{@link ChangeRequest} should be returned by the * service. * *

If this option is not provided all change request fields are returned. {@code - * ChangeRequestFieldOptions.fields} can be used to specify only the fields of interest. The ID + * ChangeRequestOption.fields} can be used to specify only the fields of interest. The ID * of the change request is always returned, even if not specified. {@link ChangeRequestField} * provides a list of fields that can be used. */ - public static ChangeRequestListOptions fields(ChangeRequestField... fields) { - return new ChangeRequestListOptions( - DnsServiceRpc.Option.FIELDS, + public static ChangeRequestListOption fields(ChangeRequestField... fields) { + return new ChangeRequestListOption( + DnsRpc.Option.FIELDS, ChangeRequestField.selector(fields) ); } @@ -472,8 +411,8 @@ public static ChangeRequestListOptions fields(ChangeRequestField... fields) { *

The page token (returned from a previous call to list) indicates from where listing should * continue. */ - public static ChangeRequestListOptions pageToken(String pageToken) { - return new ChangeRequestListOptions(DnsServiceRpc.Option.PAGE_TOKEN, pageToken); + public static ChangeRequestListOption pageToken(String pageToken) { + return new ChangeRequestListOption(DnsRpc.Option.PAGE_TOKEN, pageToken); } /** @@ -483,24 +422,24 @@ public static ChangeRequestListOptions pageToken(String pageToken) { * than the page size, the server will return a page token that can be used to fetch other * results. */ - public static ChangeRequestListOptions pageSize(int pageSize) { - return new ChangeRequestListOptions(DnsServiceRpc.Option.PAGE_SIZE, pageSize); + public static ChangeRequestListOption pageSize(int pageSize) { + return new ChangeRequestListOption(DnsRpc.Option.PAGE_SIZE, pageSize); } /** * Returns an option for specifying the sorting criterion of change requests. Note the the only * currently supported criterion is the change sequence. */ - public static ChangeRequestListOptions sortBy(ChangeRequestSortingKey key) { - return new ChangeRequestListOptions(DnsServiceRpc.Option.SORTING_KEY, key.selector()); + public static ChangeRequestListOption sortBy(ChangeRequestSortingKey key) { + return new ChangeRequestListOption(DnsRpc.Option.SORTING_KEY, key.selector()); } /** * Returns an option to specify whether the the change requests should be listed in ascending or * descending order. */ - public static ChangeRequestListOptions sortOrder(ChangeRequestSortingOrder order) { - return new ChangeRequestListOptions(DnsServiceRpc.Option.SORTING_ORDER, order.selector()); + public static ChangeRequestListOption sortOrder(SortingOrder order) { + return new ChangeRequestListOption(DnsRpc.Option.SORTING_ORDER, order.selector()); } } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceFactory.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsFactory.java similarity index 84% rename from gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceFactory.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsFactory.java index aaa0dfb68e1b..734652afb24d 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceFactory.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsFactory.java @@ -19,7 +19,7 @@ import com.google.gcloud.ServiceFactory; /** - * An interface for DnsService factories. + * An interface for Dns factories. */ -public interface DnsServiceFactory extends ServiceFactory { +public interface DnsFactory extends ServiceFactory { } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceOptions.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java similarity index 59% rename from gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceOptions.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java index 84eb9c33dcaa..3663211d3b41 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsServiceOptions.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java @@ -16,62 +16,64 @@ package com.google.gcloud.dns; +import com.google.common.collect.Sets; import com.google.gcloud.ServiceOptions; -import com.google.gcloud.spi.DnsServiceRpc; -import com.google.gcloud.spi.DnsServiceRpcFactory; +import com.google.gcloud.spi.DnsRpc; +import com.google.gcloud.spi.DnsRpcFactory; import java.util.Set; -public class DnsServiceOptions - extends ServiceOptions { +public class DnsOptions + extends ServiceOptions { private static final long serialVersionUID = -5311219368450107146L; // TODO(mderka) Finish implementation. Created issue #595. - public static class DefaultDnsServiceFactory implements DnsServiceFactory { - private static final DnsServiceFactory INSTANCE = new DefaultDnsServiceFactory(); + public static class DefaultDnsFactory implements DnsFactory { + private static final DnsFactory INSTANCE = new DefaultDnsFactory(); @Override - public DnsService create(DnsServiceOptions options) { + public Dns create(DnsOptions options) { // TODO(mderka) Implement. Created issue #595. return null; } } - public static class Builder extends ServiceOptions.Builder { + public static class Builder extends ServiceOptions.Builder { private Builder() { } - private Builder(DnsServiceOptions options) { + private Builder(DnsOptions options) { super(options); } @Override - public DnsServiceOptions build() { - return new DnsServiceOptions(this); + public DnsOptions build() { + return new DnsOptions(this); } } - private DnsServiceOptions(Builder builder) { - super(DnsServiceFactory.class, DnsServiceRpcFactory.class, builder); + private DnsOptions(Builder builder) { + super(DnsFactory.class, DnsRpcFactory.class, builder); } @Override - protected DnsServiceFactory defaultServiceFactory() { - return DefaultDnsServiceFactory.INSTANCE; + protected DnsFactory defaultServiceFactory() { + return DefaultDnsFactory.INSTANCE; } @Override - protected DnsServiceRpcFactory defaultRpcFactory() { + protected DnsRpcFactory defaultRpcFactory() { return null; } @Override protected Set scopes() { - return null; + // TODO(mderka) Verify. + return Sets.newHashSet("ndev.clouddns.readwrite"); } @Override diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java similarity index 96% rename from gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpc.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java index e97ee9a1b001..02afb7309c6a 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java @@ -18,13 +18,14 @@ import java.util.Map; -public interface DnsServiceRpc { +public interface DnsRpc { enum Option { FIELDS("fields"), PAGE_SIZE("maxSize"), PAGE_TOKEN("pageToken"), DNS_NAME("dnsName"), + DNS_TYPE("type"), SORTING_KEY("sortBy"), SORTING_ORDER("sortOrder"); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpcFactory.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpcFactory.java similarity index 74% rename from gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpcFactory.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpcFactory.java index 13ec9fe881c8..3d25f09bb1e5 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsServiceRpcFactory.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpcFactory.java @@ -16,11 +16,11 @@ package com.google.gcloud.spi; -import com.google.gcloud.dns.DnsServiceOptions; +import com.google.gcloud.dns.DnsOptions; /** - * An interface for DnsServiceRpc factory. Implementation will be loaded via {@link + * An interface for DnsRpc factory. Implementation will be loaded via {@link * java.util.ServiceLoader}. */ -public interface DnsServiceRpcFactory extends ServiceRpcFactory { +public interface DnsRpcFactory extends ServiceRpcFactory { } From 762483b94f6c95aa3f860803ead53a962f41d336 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 29 Jan 2016 16:11:13 -0800 Subject: [PATCH 029/203] Makes ProjectInfo.Quota serializable. Fixed #599. --- .../src/main/java/com/google/gcloud/dns/ProjectInfo.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java index 4db0497946b1..f7b12b94bae8 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java @@ -44,8 +44,9 @@ public class ProjectInfo implements Serializable { * @see Google Cloud DNS * documentation */ - public static class Quota { + public static class Quota implements Serializable { + private static final long serialVersionUID = 6854685970605363639L; private final int zones; private final int resourceRecordsPerRrset; private final int rrsetAdditionsPerChange; From e17bedb4640e6d5c434670eb03a4ea6b2f9028c9 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 29 Jan 2016 17:50:18 -0800 Subject: [PATCH 030/203] Implemented DnsOptions up to two unavailable classes. --- .../com/google/gcloud/dns/DnsOptions.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java index 3663211d3b41..a5c689f4c719 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java @@ -16,7 +16,7 @@ package com.google.gcloud.dns; -import com.google.common.collect.Sets; +import com.google.common.collect.ImmutableSet; import com.google.gcloud.ServiceOptions; import com.google.gcloud.spi.DnsRpc; import com.google.gcloud.spi.DnsRpcFactory; @@ -26,16 +26,28 @@ public class DnsOptions extends ServiceOptions { - private static final long serialVersionUID = -5311219368450107146L; - - // TODO(mderka) Finish implementation. Created issue #595. + private static final long serialVersionUID = -519128051411747771L; + private static final String GC_DNS_RW = "https://www.googleapis.com/auth/ndev.clouddns.readwrite"; + private static final String GC_DNS_R = "https://www.googleapis.com/auth/ndev.clouddns.readonly"; + private static final Set SCOPES = ImmutableSet.of(GC_DNS_RW, GC_DNS_R); public static class DefaultDnsFactory implements DnsFactory { private static final DnsFactory INSTANCE = new DefaultDnsFactory(); @Override public Dns create(DnsOptions options) { - // TODO(mderka) Implement. Created issue #595. + // TODO(mderka) Implement when DnsImpl is available. Created issue #595. + return null; + } + } + + public static class DefaultDnsRpcFactory implements DnsRpcFactory { + + private static final DnsRpcFactory INSTANCE = new DefaultDnsRpcFactory(); + + @Override + public DnsRpc create(DnsOptions options) { + // TODO(mderka) Implement when DefaultDnsRpc is available. Created issue #595. return null; } } @@ -60,11 +72,13 @@ private DnsOptions(Builder builder) { super(DnsFactory.class, DnsRpcFactory.class, builder); } + @SuppressWarnings("unchecked") @Override protected DnsFactory defaultServiceFactory() { return DefaultDnsFactory.INSTANCE; } + @SuppressWarnings("unchecked") @Override protected DnsRpcFactory defaultRpcFactory() { return null; @@ -72,10 +86,10 @@ protected DnsRpcFactory defaultRpcFactory() { @Override protected Set scopes() { - // TODO(mderka) Verify. - return Sets.newHashSet("ndev.clouddns.readwrite"); + return SCOPES; } + @SuppressWarnings("unchecked") @Override public Builder toBuilder() { return new Builder(this); From adf5c1cda7b849d7e1064dba7dae24e1fea5061d Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 1 Feb 2016 09:12:51 -0800 Subject: [PATCH 031/203] Added test for AbstractOption. --- .../main/java/com/google/gcloud/dns/Dns.java | 2 +- .../google/gcloud/dns/AbstractOptionTest.java | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 737ec1a38699..76b11972bb7e 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -193,7 +193,7 @@ enum SortingOrder { DESCENDING, ASCENDING; public String selector() { - return this.name().toLowerCase(); + return name().toLowerCase(); } } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java new file mode 100644 index 000000000000..3c578c53d0d1 --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; + +import com.google.gcloud.spi.DnsRpc; + +import org.junit.Test; + +public class AbstractOptionTest { + + private static final DnsRpc.Option RPC_OPTION = DnsRpc.Option.DNS_TYPE; + private static final DnsRpc.Option ANOTHER_RPC_OPTION = DnsRpc.Option.DNS_NAME; + private static final String VALUE = "some value"; + private static final String OTHER_VALUE = "another value"; + private static final AbstractOption OPTION = new AbstractOption(RPC_OPTION, VALUE) { + }; + private static final AbstractOption OPTION_EQUALS = new AbstractOption(RPC_OPTION, VALUE) { + }; + private static final AbstractOption OPTION_NOT_EQUALS1 = + new AbstractOption(RPC_OPTION, OTHER_VALUE) { + }; + private static final AbstractOption OPTION_NOT_EQUALS2 = + new AbstractOption(ANOTHER_RPC_OPTION, VALUE) { + }; + + @Test + public void testEquals() { + assertEquals(OPTION, OPTION_EQUALS); + assertNotEquals(OPTION, OPTION_NOT_EQUALS1); + assertNotEquals(OPTION, OPTION_NOT_EQUALS2); + } + + @Test + public void testHashCode() { + assertEquals(OPTION.hashCode(), OPTION_EQUALS.hashCode()); + } + + @Test + public void testConstructor() { + assertEquals(RPC_OPTION, OPTION.rpcOption()); + assertEquals(VALUE, OPTION.value()); + try { + new AbstractOption(null, VALUE) { + }; + fail("Cannot build with empty option."); + } catch (NullPointerException e) { + // expected + } + new AbstractOption(RPC_OPTION, null) { + }; // null value is ok + } +} From a9cc927e002277face656af9f059175192d31c3d Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 1 Feb 2016 14:20:33 -0800 Subject: [PATCH 032/203] Implemented comments by @aozarov. Added test for option accessors. --- .../main/java/com/google/gcloud/dns/Dns.java | 86 ++++------- .../com/google/gcloud/dns/DnsOptions.java | 3 +- .../java/com/google/gcloud/spi/DnsRpc.java | 1 - .../java/com/google/gcloud/dns/DnsTest.java | 141 ++++++++++++++++++ 4 files changed, 173 insertions(+), 58 deletions(-) create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 76b11972bb7e..352c7791e18d 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -31,12 +31,14 @@ */ public interface Dns extends Service { + + /** * The fields of a project. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code Dns#getProjectInfo(ProjectGetOption...)}. Project ID is always returned, even if - * not specified. + * {@code Dns#getProjectInfo(ProjectGetOption...)}. Project ID is always returned, even if not + * specified. */ enum ProjectField { PROJECT_ID("id"), @@ -67,8 +69,8 @@ static String selector(ProjectField... fields) { * The fields of a zone. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code Dns#getZone(BigInteger, ZoneFieldOption...)} or {@code Dns#getZone(String, - * ZoneFieldOption...)}. The ID is always returned, even if not specified. + * {@code Dns#getZone(BigInteger, ZoneOption...)} or {@code Dns#getZone(String, ZoneOption...)}. + * The ID is always returned, even if not specified. */ enum ZoneField { CREATION_TIME("creationTime"), @@ -104,8 +106,8 @@ static String selector(ZoneField... fields) { * *

These values can be used to specify the fields to include in a partial response when calling * {@code Dns#listDnsRecords(BigInteger, DnsRecordListOption...)} or {@code - * Dns#listDnsRecords(String, DnsRecordListOption...)}. The name is always returned even if - * not selected. + * Dns#listDnsRecords(String, DnsRecordListOption...)}. The name is always returned even if not + * selected. */ enum DnsRecordField { DNS_RECORDS("rrdatas"), @@ -137,9 +139,9 @@ static String selector(DnsRecordField... fields) { * The fields of a change request. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code Dns#applyChangeRequest(ChangeRequest, BigInteger, ChangeRequestOption...)} - * or {@code Dns#applyChangeRequest(ChangeRequest, String, ChangeRequestOption...)} - * The ID is always returned even if not selected. + * {@code Dns#applyChangeRequest(ChangeRequest, BigInteger, ChangeRequestOption...)} or {@code + * Dns#applyChangeRequest(ChangeRequest, String, ChangeRequestOption...)} The ID is always + * returned even if not selected. */ enum ChangeRequestField { ID("id"), @@ -168,24 +170,6 @@ static String selector(ChangeRequestField... fields) { } } - /** - * The sorting keys for listing change requests. The only currently supported sorting key is the - * when the change request was created. - */ - enum ChangeRequestSortingKey { - TIME_CREATED("changeSequence"); - - private final String selector; - - ChangeRequestSortingKey(String selector) { - this.selector = selector; - } - - String selector() { - return selector; - } - } - /** * The sorting order for listing. */ @@ -261,24 +245,23 @@ public static DnsRecordListOption type(DnsRecord.Type type) { /** * Class for specifying zone field options. */ - class ZoneFieldOption extends AbstractOption implements Serializable { + class ZoneOption extends AbstractOption implements Serializable { private static final long serialVersionUID = -8065564464895945037L; - ZoneFieldOption(DnsRpc.Option option, Object value) { + ZoneOption(DnsRpc.Option option, Object value) { super(option, value); } /** * Returns an option to specify the zones's fields to be returned by the RPC call. * - *

If this option is not provided all zone fields are returned. {@code - * ZoneFieldOption.fields} can be used to specify only the fields of interest. Zone ID is always - * returned, even if not specified. {@link ZoneField} provides a list of fields that can be - * used. + *

If this option is not provided all zone fields are returned. {@code ZoneOption.fields} can + * be used to specify only the fields of interest. Zone ID is always returned, even if not + * specified. {@link ZoneField} provides a list of fields that can be used. */ - public static ZoneFieldOption fields(ZoneField... fields) { - return new ZoneFieldOption(DnsRpc.Option.FIELDS, ZoneField.selector(fields)); + public static ZoneOption fields(ZoneField... fields) { + return new ZoneOption(DnsRpc.Option.FIELDS, ZoneField.selector(fields)); } } @@ -296,10 +279,9 @@ class ZoneListOption extends AbstractOption implements Serializable { /** * Returns an option to specify the zones's fields to be returned by the RPC call. * - *

If this option is not provided all zone fields are returned. {@code - * ZoneFieldOption.fields} can be used to specify only the fields of interest. Zone ID is always - * returned, even if not specified. {@link ZoneField} provides a list of fields that can be - * used. + *

If this option is not provided all zone fields are returned. {@code ZoneOption.fields} can + * be used to specify only the fields of interest. Zone ID is always returned, even if not + * specified. {@link ZoneField} provides a list of fields that can be used. */ public static ZoneListOption fields(ZoneField... fields) { return new ZoneListOption(DnsRpc.Option.FIELDS, ZoneField.selector(fields)); @@ -366,9 +348,9 @@ class ChangeRequestOption extends AbstractOption implements Serializable { * service. * *

If this option is not provided all change request fields are returned. {@code - * ChangeRequestOption.fields} can be used to specify only the fields of interest. The ID - * of the change request is always returned, even if not specified. {@link ChangeRequestField} - * provides a list of fields that can be used. + * ChangeRequestOption.fields} can be used to specify only the fields of interest. The ID of the + * change request is always returned, even if not specified. {@link ChangeRequestField} provides + * a list of fields that can be used. */ public static ChangeRequestOption fields(ChangeRequestField... fields) { return new ChangeRequestOption( @@ -394,9 +376,9 @@ class ChangeRequestListOption extends AbstractOption implements Serializable { * service. * *

If this option is not provided all change request fields are returned. {@code - * ChangeRequestOption.fields} can be used to specify only the fields of interest. The ID - * of the change request is always returned, even if not specified. {@link ChangeRequestField} - * provides a list of fields that can be used. + * ChangeRequestOption.fields} can be used to specify only the fields of interest. The ID of the + * change request is always returned, even if not specified. {@link ChangeRequestField} provides + * a list of fields that can be used. */ public static ChangeRequestListOption fields(ChangeRequestField... fields) { return new ChangeRequestListOption( @@ -427,16 +409,10 @@ public static ChangeRequestListOption pageSize(int pageSize) { } /** - * Returns an option for specifying the sorting criterion of change requests. Note the the only - * currently supported criterion is the change sequence. - */ - public static ChangeRequestListOption sortBy(ChangeRequestSortingKey key) { - return new ChangeRequestListOption(DnsRpc.Option.SORTING_KEY, key.selector()); - } - - /** - * Returns an option to specify whether the the change requests should be listed in ascending or - * descending order. + * Returns an option to specify whether the the change requests should be listed in ascending + * (most-recent last) or descending (most-recent first) order with respect to when the change + * request was accepted by the server. If this option is not provided, the listing order is + * undefined. */ public static ChangeRequestListOption sortOrder(SortingOrder order) { return new ChangeRequestListOption(DnsRpc.Option.SORTING_ORDER, order.selector()); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java index a5c689f4c719..1845467c2537 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java @@ -28,8 +28,7 @@ public class DnsOptions private static final long serialVersionUID = -519128051411747771L; private static final String GC_DNS_RW = "https://www.googleapis.com/auth/ndev.clouddns.readwrite"; - private static final String GC_DNS_R = "https://www.googleapis.com/auth/ndev.clouddns.readonly"; - private static final Set SCOPES = ImmutableSet.of(GC_DNS_RW, GC_DNS_R); + private static final Set SCOPES = ImmutableSet.of(GC_DNS_RW); public static class DefaultDnsFactory implements DnsFactory { private static final DnsFactory INSTANCE = new DefaultDnsFactory(); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java index 02afb7309c6a..f6a0f330a327 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java @@ -26,7 +26,6 @@ enum Option { PAGE_TOKEN("pageToken"), DNS_NAME("dnsName"), DNS_TYPE("type"), - SORTING_KEY("sortBy"), SORTING_ORDER("sortOrder"); private final String value; diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java new file mode 100644 index 000000000000..2e98dbd46de4 --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java @@ -0,0 +1,141 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.gcloud.spi.DnsRpc; + +import org.junit.Test; + +public class DnsTest { + + private static final Integer PAGE_SIZE = 20; + private static final String PAGE_TOKEN = "page token"; + + @Test + public void testDnsRecordListOption() { + // dns name + String dnsName = "some name"; + Dns.DnsRecordListOption dnsRecordListOption = Dns.DnsRecordListOption.dnsName(dnsName); + assertEquals(dnsName, dnsRecordListOption.value()); + assertEquals(DnsRpc.Option.DNS_NAME, dnsRecordListOption.rpcOption()); + // page token + dnsRecordListOption = Dns.DnsRecordListOption.pageToken(PAGE_TOKEN); + assertEquals(PAGE_TOKEN, dnsRecordListOption.value()); + assertEquals(DnsRpc.Option.PAGE_TOKEN, dnsRecordListOption.rpcOption()); + // page size + dnsRecordListOption = Dns.DnsRecordListOption.pageSize(PAGE_SIZE); + assertEquals(PAGE_SIZE, dnsRecordListOption.value()); + assertEquals(DnsRpc.Option.PAGE_SIZE, dnsRecordListOption.rpcOption()); + // record type + DnsRecord.Type recordType = DnsRecord.Type.AAAA; + dnsRecordListOption = Dns.DnsRecordListOption.type(recordType); + assertEquals(recordType, dnsRecordListOption.value()); + assertEquals(DnsRpc.Option.DNS_TYPE, dnsRecordListOption.rpcOption()); + // fields + dnsRecordListOption = Dns.DnsRecordListOption.fields(Dns.DnsRecordField.NAME, + Dns.DnsRecordField.TTL); + assertEquals(DnsRpc.Option.FIELDS, dnsRecordListOption.rpcOption()); + assertTrue(dnsRecordListOption.value() instanceof String); + assertTrue(((String) dnsRecordListOption.value()).contains( + Dns.DnsRecordField.NAME.selector())); + assertTrue(((String) dnsRecordListOption.value()).contains( + Dns.DnsRecordField.TTL.selector())); + assertTrue(((String) dnsRecordListOption.value()).contains( + Dns.DnsRecordField.NAME.selector())); + } + + @Test + public void testZoneOption() { + Dns.ZoneOption fields = Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME, + Dns.ZoneField.DESCRIPTION); + assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); + assertTrue(fields.value() instanceof String); + assertTrue(((String) fields.value()).contains(Dns.ZoneField.CREATION_TIME.selector())); + assertTrue(((String) fields.value()).contains(Dns.ZoneField.DESCRIPTION.selector())); + } + + @Test + public void testZoneList() { + // fields + Dns.ZoneListOption fields = Dns.ZoneListOption.fields(Dns.ZoneField.CREATION_TIME, + Dns.ZoneField.DESCRIPTION); + assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); + assertTrue(fields.value() instanceof String); + assertTrue(((String) fields.value()).contains(Dns.ZoneField.CREATION_TIME.selector())); + assertTrue(((String) fields.value()).contains(Dns.ZoneField.DESCRIPTION.selector())); + assertTrue(((String) fields.value()).contains(Dns.ZoneField.ZONE_ID.selector())); + // page token + Dns.ZoneListOption option = Dns.ZoneListOption.pageToken(PAGE_TOKEN); + assertEquals(PAGE_TOKEN, option.value()); + assertEquals(DnsRpc.Option.PAGE_TOKEN, option.rpcOption()); + // page size + option = Dns.ZoneListOption.pageSize(PAGE_SIZE); + assertEquals(PAGE_SIZE, option.value()); + assertEquals(DnsRpc.Option.PAGE_SIZE, option.rpcOption()); + } + + @Test + public void testProjectGetOption() { + // fields + Dns.ProjectGetOption fields = Dns.ProjectGetOption.fields(Dns.ProjectField.QUOTA); + assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); + assertTrue(fields.value() instanceof String); + assertTrue(((String) fields.value()).contains(Dns.ProjectField.QUOTA.selector())); + assertTrue(((String) fields.value()).contains(Dns.ProjectField.PROJECT_ID.selector())); + } + + @Test + public void testChangeRequestOption() { + // fields + Dns.ChangeRequestOption fields = Dns.ChangeRequestOption.fields( + Dns.ChangeRequestField.START_TIME, Dns.ChangeRequestField.STATUS); + assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); + assertTrue(fields.value() instanceof String); + assertTrue(((String) fields.value()).contains( + Dns.ChangeRequestField.START_TIME.selector())); + assertTrue(((String) fields.value()).contains(Dns.ChangeRequestField.STATUS.selector())); + assertTrue(((String) fields.value()).contains(Dns.ChangeRequestField.ID.selector())); + } + + @Test + public void testChangeRequestListOption() { + // fields + Dns.ChangeRequestListOption fields = Dns.ChangeRequestListOption.fields( + Dns.ChangeRequestField.START_TIME, Dns.ChangeRequestField.STATUS); + assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); + assertTrue(fields.value() instanceof String); + assertTrue(((String) fields.value()).contains( + Dns.ChangeRequestField.START_TIME.selector())); + assertTrue(((String) fields.value()).contains(Dns.ChangeRequestField.STATUS.selector())); + assertTrue(((String) fields.value()).contains(Dns.ChangeRequestField.ID.selector())); + // page token + Dns.ChangeRequestListOption option = Dns.ChangeRequestListOption.pageToken(PAGE_TOKEN); + assertEquals(PAGE_TOKEN, option.value()); + assertEquals(DnsRpc.Option.PAGE_TOKEN, option.rpcOption()); + // page size + option = Dns.ChangeRequestListOption.pageSize(PAGE_SIZE); + assertEquals(PAGE_SIZE, option.value()); + assertEquals(DnsRpc.Option.PAGE_SIZE, option.rpcOption()); + // sort order + option = Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING); + assertEquals(DnsRpc.Option.SORTING_ORDER, option.rpcOption()); + assertEquals(Dns.SortingOrder.ASCENDING.selector(), option.value()); + } +} From 6ecde35c355ca8e38e726044e9a0012f5a3935ab Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 1 Feb 2016 16:07:24 -0800 Subject: [PATCH 033/203] Comments by @aozarov second round. --- .../main/java/com/google/gcloud/dns/Dns.java | 15 ++++++----- .../google/gcloud/dns/AbstractOptionTest.java | 26 +++++++------------ 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 352c7791e18d..28e79104cf58 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -24,6 +24,8 @@ import java.io.Serializable; import java.util.Set; +import static com.google.gcloud.dns.Dns.ZoneField.selector; + /** * An interface for the Google Cloud DNS service. * @@ -31,8 +33,6 @@ */ public interface Dns extends Service { - - /** * The fields of a project. * @@ -284,7 +284,9 @@ class ZoneListOption extends AbstractOption implements Serializable { * specified. {@link ZoneField} provides a list of fields that can be used. */ public static ZoneListOption fields(ZoneField... fields) { - return new ZoneListOption(DnsRpc.Option.FIELDS, ZoneField.selector(fields)); + StringBuilder builder = new StringBuilder(); + builder.append("managedZones(").append(selector(fields)).append(')'); + return new ZoneListOption(DnsRpc.Option.FIELDS, builder.toString()); } /** @@ -381,10 +383,9 @@ class ChangeRequestListOption extends AbstractOption implements Serializable { * a list of fields that can be used. */ public static ChangeRequestListOption fields(ChangeRequestField... fields) { - return new ChangeRequestListOption( - DnsRpc.Option.FIELDS, - ChangeRequestField.selector(fields) - ); + StringBuilder builder = new StringBuilder(); + builder.append("changes(").append(ChangeRequestField.selector(fields)).append(')'); + return new ChangeRequestListOption(DnsRpc.Option.FIELDS, builder.toString()); } /** diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java index 3c578c53d0d1..e3f2896bd10b 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java @@ -16,30 +16,26 @@ package com.google.gcloud.dns; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.fail; - import com.google.gcloud.spi.DnsRpc; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; + public class AbstractOptionTest { private static final DnsRpc.Option RPC_OPTION = DnsRpc.Option.DNS_TYPE; private static final DnsRpc.Option ANOTHER_RPC_OPTION = DnsRpc.Option.DNS_NAME; private static final String VALUE = "some value"; private static final String OTHER_VALUE = "another value"; - private static final AbstractOption OPTION = new AbstractOption(RPC_OPTION, VALUE) { - }; - private static final AbstractOption OPTION_EQUALS = new AbstractOption(RPC_OPTION, VALUE) { - }; + private static final AbstractOption OPTION = new AbstractOption(RPC_OPTION, VALUE) {}; + private static final AbstractOption OPTION_EQUALS = new AbstractOption(RPC_OPTION, VALUE) {}; private static final AbstractOption OPTION_NOT_EQUALS1 = - new AbstractOption(RPC_OPTION, OTHER_VALUE) { - }; + new AbstractOption(RPC_OPTION, OTHER_VALUE) {}; private static final AbstractOption OPTION_NOT_EQUALS2 = - new AbstractOption(ANOTHER_RPC_OPTION, VALUE) { - }; + new AbstractOption(ANOTHER_RPC_OPTION, VALUE) {}; @Test public void testEquals() { @@ -58,13 +54,11 @@ public void testConstructor() { assertEquals(RPC_OPTION, OPTION.rpcOption()); assertEquals(VALUE, OPTION.value()); try { - new AbstractOption(null, VALUE) { - }; + new AbstractOption(null, VALUE) {}; fail("Cannot build with empty option."); } catch (NullPointerException e) { // expected } - new AbstractOption(RPC_OPTION, null) { - }; // null value is ok + new AbstractOption(RPC_OPTION, null) {}; // null value is ok } } From a69101a80df1637361b02a93233d0ad3e5d69098 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 1 Feb 2016 16:18:16 -0800 Subject: [PATCH 034/203] Added Dns methods. Fixes #596. Added Zone and ZoneTest --- .../main/java/com/google/gcloud/dns/Dns.java | 194 ++++- .../main/java/com/google/gcloud/dns/Zone.java | 256 ++++++ .../google/gcloud/dns/AbstractOptionTest.java | 8 +- .../java/com/google/gcloud/dns/ZoneTest.java | 750 ++++++++++++++++++ 4 files changed, 1200 insertions(+), 8 deletions(-) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 28e79104cf58..b48e4b0a90f2 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -18,14 +18,14 @@ import com.google.common.base.Joiner; import com.google.common.collect.Sets; +import com.google.gcloud.Page; import com.google.gcloud.Service; import com.google.gcloud.spi.DnsRpc; import java.io.Serializable; +import java.math.BigInteger; import java.util.Set; -import static com.google.gcloud.dns.Dns.ZoneField.selector; - /** * An interface for the Google Cloud DNS service. * @@ -285,7 +285,7 @@ class ZoneListOption extends AbstractOption implements Serializable { */ public static ZoneListOption fields(ZoneField... fields) { StringBuilder builder = new StringBuilder(); - builder.append("managedZones(").append(selector(fields)).append(')'); + builder.append("managedZones(").append(ZoneField.selector(fields)).append(')'); return new ZoneListOption(DnsRpc.Option.FIELDS, builder.toString()); } @@ -420,5 +420,191 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { } } - // TODO(mderka) Add methods. Created issue #596. + /** + * Creates a new zone. + * + * @return ZoneInfo object representing the new zone's metadata. In addition to the name, dns name + * and description (supplied by the user within the {@code zoneInfo} parameter, the returned + * object will include the following read-only fields supplied by the server: creation time, id, + * and list of name servers. + * @throws DnsException upon failure + * @see Cloud DNS Managed Zones: + * create + */ + ZoneInfo create(ZoneInfo zoneInfo); + + /** + * Retrieves the zone by the specified zone name. Returns {@code null} is the zone is not found. + * The returned fields can be optionally restricted by specifying {@code ZoneFieldOptions}. + * + * @throws DnsException upon failure + * @see Cloud DNS Managed Zones: + * get + */ + ZoneInfo getZone(String zoneName, ZoneOption... options); + + /** + * Retrieves the zone by the specified zone name. Returns {@code null} is the zone is not found. + * The returned fields can be optionally restricted by specifying {@code ZoneFieldOptions}. + * + * @throws DnsException upon failure + * @see Cloud DNS Managed Zones: + * get + */ + ZoneInfo getZone(BigInteger zoneId, ZoneOption... options); + + /** + * Lists the zoned inside the project. + * + *

This method returns zone in an unspecified order. New zones do not necessarily appear at the + * end of the list. Use {@link ZoneListOption} to restrict the listing to a domain name, set page + * size, and set page tokens. + * + * @return {@code Page}, a page of zones + * @throws DnsException upon failure + * @see Cloud DNS Managed Zones: + * list + */ + Page listZones(ZoneListOption... options); + + /** + * Deletes an existing zone identified by name. Returns true if the zone was successfully deleted + * and false otherwise. + * + * @return {@code true} if zone was found and deleted and false otherwise + * @throws DnsException upon failure + * @see Cloud DNS Managed Zones: + * delete + */ + boolean delete(String zoneName); // delete does not admit any options + + /** + * Deletes an existing zone identified by id. Returns true if the zone was successfully deleted + * and false otherwise. + * + * @return {@code true} if zone was found and deleted and false otherwise + * @throws DnsException upon failure + * @see Cloud DNS Managed Zones: + * delete + */ + boolean delete(BigInteger zoneId); // delete does not admit any options + + /** + * Lists the DNS records in the zone identified by name. + * + *

The fields to be returned, page size and page tokens can be specified using {@code + * DnsRecordOptions}. Returns null if the zone cannot be found. + * + * @throws DnsException upon failure + * @see Cloud DNS + * ResourceRecordSets: list + */ + Page listDnsRecords(String zoneName, DnsRecordListOption... options); + + /** + * Lists the DNS records in the zone identified by ID. + * + *

The fields to be returned, page size and page tokens can be specified using {@code + * DnsRecordOptions}. Returns null if the zone cannot be found. + * + * @throws DnsException upon failure + * @see Cloud DNS + * ResourceRecordSets: list + */ + Page listDnsRecords(BigInteger zoneId, DnsRecordListOption... options); + + /** + * Retrieves the metadata about the current project. The returned fields can be optionally + * restricted by specifying {@code ProjectOptions}. + * + * @throws DnsException upon failure + * @see Cloud DNS Projects: get + */ + ProjectInfo getProjectInfo(ProjectGetOption... fields); + + /** + * Returns the current project id. + */ + String getProjectId(); + + /** + * Returns the current project number. + */ + BigInteger getProjectNumber(); + + /** + * Submits a change requests for applying to the zone identified by ID to the service. The + * returned object contains the following read-only fields supplied by the server: id, start time + * and status. time, id, and list of name servers. The returned fields can be modified by {@code + * ChangeRequestFieldOptions}. Returns null if the zone is not found. + * + * @return ChangeRequest object representing the new change request or null if zone is not found + * @throws DnsException upon failure + * @see Cloud DNS Changes: create + */ + ChangeRequest applyChangeRequest(ChangeRequest changeRequest, BigInteger zoneId, + ChangeRequestOption... options); + + /** + * Submits a change requests for applying to the zone identified by name to the service. The + * returned object contains the following read-only fields supplied by the server: id, start time + * and status. time, id, and list of name servers. The returned fields can be modified by {@code + * ChangeRequestFieldOptions}. Returns null if the zone is not found. + * + * @return ChangeRequest object representing the new change request or null if zone is not found + * @throws DnsException upon failure + * @see Cloud DNS Changes: create + */ + ChangeRequest applyChangeRequest(ChangeRequest changeRequest, String zoneName, + ChangeRequestOption... options); + + /** + * Retrieves updated information about a change request previously submitted for a zone identified + * by ID. Returns null if the zone or request cannot be found. + * + *

The fields to be returned using {@code ChangeRequestFieldOptions}. + * + * @throws DnsException upon failure + * @see Cloud DNS Chages: get + */ + ChangeRequest getChangeRequest(ChangeRequest changeRequest, BigInteger zoneId, + ChangeRequestOption... options); + + /** + * Retrieves updated information about a change request previously submitted for a zone identified + * by name. Returns null if the zone or request cannot be found. + * + *

The fields to be returned using {@code ChangeRequestFieldOptions}. + * + * @throws DnsException upon failure + * @see Cloud DNS Chages: get + */ + ChangeRequest getChangeRequest(ChangeRequest changeRequest, String zoneName, + ChangeRequestOption... options); + + /** + * Lists the change requests for the zone identified by ID that were submitted to the service. + * + *

The sorting key for changes, fields to be returned, page and page tokens can be specified + * using {@code ChangeRequestListOptions}. Note that the only sorting key currently supported is + * the timestamp of submitting the change request to the service. + * + * @return {@code Page}, a page of change requests + * @throws DnsException upon failure + * @see Cloud DNS Chages: list + */ + Page listChangeRequests(BigInteger zoneId, ChangeRequestListOption... options); + + /** + * Lists the change requests for the zone identified by name that were submitted to the service. + * + *

The sorting key for changes, fields to be returned, page and page tokens can be specified + * using {@code ChangeRequestListOptions}. Note that the only sorting key currently supported is + * the timestamp of submitting the change request to the service. + * + * @return {@code Page}, a page of change requests + * @throws DnsException upon failure + * @see Cloud DNS Chages: list + */ + Page listChangeRequests(String zoneName, ChangeRequestListOption... options); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java new file mode 100644 index 000000000000..f4d9702ba12f --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -0,0 +1,256 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.gcloud.Page; + +import java.io.Serializable; +import java.math.BigInteger; + +/** + * A Google Cloud DNS Zone object. + * + *

A zone is the container for all of your DNS records that share the same DNS name prefix, for + * example, example.com. Zones are automatically assigned a set of name servers when they are + * created to handle responding to DNS queries for that zone. A zone has quotas for the number of + * resource records that it can include. + * + * @see Google Cloud DNS managed zone + * documentation + */ +public class Zone implements Serializable { + + // TODO(mderka) Zone and zoneInfo to be merged. Opened issue #605. + + private static final long serialVersionUID = -4012581571095484813L; + private final ZoneInfo zoneInfo; + private final Dns dns; + + /** + * Constructs a {@code Zone} object that contains the given {@code zoneInfo}. + */ + public Zone(Dns dns, ZoneInfo zoneInfo) { + this.zoneInfo = checkNotNull(zoneInfo); + this.dns = checkNotNull(dns); + } + + /** + * Constructs a {@code Zone} object that contains meta information received from the Google Cloud + * DNS service for the provided zoneName. + * + * @param zoneName Name of the zone to be searched for + * @param options Optional restriction on what fields should be returned by the service + * @return Zone object containing metadata or null if not not found + * @throws DnsException upon failure + */ + public static Zone get(Dns dnsService, String zoneName, + Dns.ZoneOption... options) { + checkNotNull(zoneName); + checkNotNull(dnsService); + ZoneInfo zoneInfo = dnsService.getZone(zoneName, options); + return zoneInfo == null ? null : new Zone(dnsService, zoneInfo); + } + + /** + * Constructs a {@code Zone} object that contains meta information received from the Google Cloud + * DNS service for the provided zoneName. + * + * @param zoneId ID of the zone to be searched for + * @param options Optional restriction on what fields should be returned by the service + * @return Zone object containing metadata or null if not not found + * @throws DnsException upon failure + */ + public static Zone get(Dns dnsService, BigInteger zoneId, + Dns.ZoneOption... options) { + checkNotNull(zoneId); + checkNotNull(dnsService); + ZoneInfo zoneInfo = dnsService.getZone(zoneId, options); + return zoneInfo == null ? null : new Zone(dnsService, zoneInfo); + } + + /** + * Retrieves the latest information about the zone. The method first attempts to retrieve the zone + * by ID and if not set or zone is not found, it searches by name. + * + * @param options Optional restriction on what fields should be fetched + * @return Zone object containing updated metadata or null if not not found + * @throws DnsException upon failure + * @throws NullPointerException if both zone ID and name are not initialized + */ + public Zone reload(Dns.ZoneOption... options) { + checkNameOrIdNotNull(); + Zone zone = null; + if (zoneInfo.id() != null) { + zone = Zone.get(dns, zoneInfo.id(), options); + } + if (zone == null && zoneInfo.name() != null) { + // zone was not found by id or id is not set at all + zone = Zone.get(dns, zoneInfo.name(), options); + } + return zone; + } + + /** + * Deletes the zone. The method first attempts to delete the zone by ID. If the zone is not found + * or id is not set, it attempts to delete by name. + * + * @return true is zone was found and deleted and false otherwise + * @throws DnsException upon failure + * @throws NullPointerException if both zone ID and name are not initialized + */ + public boolean delete() { + checkNameOrIdNotNull(); + boolean deleted = false; + if (zoneInfo.id() != null) { + deleted = dns.delete(zoneInfo.id()); + } + if (!deleted && zoneInfo.name() != null) { + // zone was not found by id or id is not set at all + deleted = dns.delete(zoneInfo.name()); + } + return deleted; + } + + /** + * Lists all {@link DnsRecord}s associated with this zone. First searches for zone by ID and if + * not found then by name. + * + * @param options Optional restriction on listing and on what fields of {@link DnsRecord} should + * be returned by the service + * @return {@code Page}, a page of DNS records, or null if the zone is not found + * @throws DnsException upon failure + * @throws NullPointerException if both zone ID and name are not initialized + */ + public Page listDnsRecords(Dns.DnsRecordListOption... options) { + checkNameOrIdNotNull(); + Page page = null; + if (zoneInfo.id() != null) { + page = dns.listDnsRecords(zoneInfo.id(), options); + } + if (page == null && zoneInfo.name() != null) { + // zone was not found by id or id is not set at all + page = dns.listDnsRecords(zoneInfo.name(), options); + } + return page; + } + + /** + * Submits {@link ChangeRequest} to the service for it to applied to this zone. First searches for + * the zone by ID and if not found then by name. Returns a {@link ChangeRequest} with + * server-assigned ID or null if the zone was not found. + * + * @param options Optional restriction on what fields of {@link ChangeRequest} should be returned + * by the service + * @return ChangeRequest with server-assigned ID or null if the zone was not found. + * @throws DnsException upon failure + * @throws NullPointerException if both zone ID and name are not initialized + */ + public ChangeRequest applyChangeRequest(ChangeRequest changeRequest, + Dns.ChangeRequestOption... options) { + checkNameOrIdNotNull(); + checkNotNull(changeRequest); + ChangeRequest updated = null; + if (zoneInfo.id() != null) { + updated = dns.applyChangeRequest(changeRequest, zoneInfo.id(), options); + } + if (updated == null && zoneInfo.name() != null) { + // zone was not found by id or id is not set at all + updated = dns.applyChangeRequest(changeRequest, zoneInfo.name(), options); + } + return updated; + } + + /** + * Retrieves an updated information about a change request previously submitted to be applied to + * this zone. First searches for the zone by ID and if not found then by name. Returns a {@link + * ChangeRequest} if found and null is the zone or the change request was not found. + * + * @param options Optional restriction on what fields of {@link ChangeRequest} should be returned + * by the service + * @return ChangeRequest with updated information of null if the change request or zone was not + * found. + * @throws DnsException upon failure + * @throws NullPointerException if both zone ID and name are not initialized + * @throws NullPointerException if the change request does not have initialized id + */ + public ChangeRequest getChangeRequest(ChangeRequest changeRequest, + Dns.ChangeRequestOption... options) { + checkNameOrIdNotNull(); + checkNotNull(changeRequest); + checkNotNull(changeRequest.id()); + ChangeRequest updated = null; + if (zoneInfo.id() != null) { + updated = dns.getChangeRequest(changeRequest, zoneInfo.id(), options); + } + if (updated == null && zoneInfo.name() != null) { + // zone was not found by id or id is not set at all + updated = dns.getChangeRequest(changeRequest, zoneInfo.name(), options); + } + return updated; + } + + /** + * Retrieves all change requests for this zone. First searches for the zone by ID and if not found + * then by name. Returns a page of {@link ChangeRequest}s or null if the zone is not found. + * + * @param options Optional restriction on listing and on what fields of {@link ChangeRequest}s + * should be returned by the service + * @return {@code Page}, a page of change requests, or null if the zone is not + * found + * @throws DnsException upon failure + * @throws NullPointerException if both zone ID and name are not initialized + */ + public Page listChangeRequests(Dns.ChangeRequestListOption... options) { + checkNameOrIdNotNull(); + Page changeRequests = null; + if (zoneInfo.id() != null) { + changeRequests = dns.listChangeRequests(zoneInfo.id(), options); + } + if (changeRequests == null && zoneInfo.name() != null) { + // zone was not found by id or id is not set at all + changeRequests = dns.listChangeRequests(zoneInfo.name(), options); + } + return changeRequests; + } + + /** + * Check that at least one of name and ID are initialized and throw and exception if not. + */ + private void checkNameOrIdNotNull() { + if (zoneInfo != null && zoneInfo.id() == null && zoneInfo.name() == null) { + throw new NullPointerException("Both zoneInfo.id and zoneInfo.name are null. " + + "This is an inconsistent state which should never happen."); + } + } + + /** + * Returns the {@link ZoneInfo} object containing meta information about this managed zone. + */ + public ZoneInfo info() { + return this.zoneInfo; + } + + /** + * Returns the {@link Dns} service object associated with this managed zone. + */ + public Dns dns() { + return this.dns; + } + +} diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java index e3f2896bd10b..09e35527879b 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java @@ -16,14 +16,14 @@ package com.google.gcloud.dns; -import com.google.gcloud.spi.DnsRpc; - -import org.junit.Test; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.fail; +import com.google.gcloud.spi.DnsRpc; + +import org.junit.Test; + public class AbstractOptionTest { private static final DnsRpc.Option RPC_OPTION = DnsRpc.Option.DNS_TYPE; diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java new file mode 100644 index 000000000000..5f9d119e6150 --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -0,0 +1,750 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static org.easymock.EasyMock.createStrictMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.gcloud.Page; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.math.BigInteger; + +public class ZoneTest { + + private static final String ZONE_NAME = "dns-zone-name"; + private static final BigInteger ZONE_ID = new BigInteger("123"); + private static final ZoneInfo ZONE_INFO = ZoneInfo.builder(ZONE_NAME, ZONE_ID) + .dnsName("example.com") + .creationTimeMillis(123478946464L) + .build(); + private static final ZoneInfo NO_ID_INFO = ZoneInfo.builder(ZONE_NAME) + .dnsName("anoter-example.com") + .creationTimeMillis(893123464L) + .build(); + private static final ZoneInfo NO_NAME_INFO = ZoneInfo.builder(ZONE_ID) + .dnsName("one-more-example.com") + .creationTimeMillis(875221546464L) + .build(); + private static final Dns.ZoneOption ZONE_FIELD_OPTIONS = + Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME); + private static final Dns.DnsRecordListOption DNS_RECORD_OPTIONS = + Dns.DnsRecordListOption.dnsName("some-dns"); + private static final Dns.ChangeRequestOption CHANGE_REQUEST_FIELD_OPTIONS = + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME); + private static final Dns.ChangeRequestListOption CHANGE_REQUEST_LIST_OPTIONS = + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.START_TIME); + private static final ChangeRequest CHANGE_REQUEST = ChangeRequest.builder().id("someid").build(); + private static final ChangeRequest CHANGE_REQUEST_AFTER = CHANGE_REQUEST.toBuilder() + .startTimeMillis(123465L).build(); + private static final ChangeRequest CHANGE_REQUEST_NO_ID = ChangeRequest.builder().build(); + + private Dns dns; + private Zone zone; + private Zone zoneNoName; + private Zone zoneNoId; + + @Before + public void setUp() throws Exception { + dns = createStrictMock(Dns.class); + zone = new Zone(dns, ZONE_INFO); + zoneNoId = new Zone(dns, NO_ID_INFO); + zoneNoName = new Zone(dns, NO_NAME_INFO); + } + + @After + public void tearDown() throws Exception { + verify(dns); + } + + @Test + public void testConstructor() { + replay(dns); + assertNotNull(zone.info()); + assertEquals(ZONE_INFO, zone.info()); + assertNotNull(zone.dns()); + assertEquals(dns, zone.dns()); + } + + @Test + public void testGetById() { + expect(dns.getZone(ZONE_ID)).andReturn(ZONE_INFO); + expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(ZONE_INFO); // for options + replay(dns); + Zone retrieved = Zone.get(dns, ZONE_ID); + assertSame(dns, retrieved.dns()); + assertEquals(ZONE_INFO, retrieved.info()); + BigInteger id = null; + try { + Zone.get(dns, id); + fail("Cannot get null zone."); + } catch (NullPointerException e) { + // expected + } + try { + Zone.get(null, id); + fail("Cannot get null zone."); + } catch (NullPointerException e) { + // expected + } + // test passing options + Zone.get(dns, ZONE_ID, ZONE_FIELD_OPTIONS); + } + + @Test + public void testGetByName() { + expect(dns.getZone(ZONE_NAME)).andReturn(ZONE_INFO); + expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(ZONE_INFO); // for options + replay(dns); + Zone retrieved = Zone.get(dns, ZONE_NAME); + assertSame(dns, retrieved.dns()); + assertEquals(ZONE_INFO, retrieved.info()); + String name = null; + try { + Zone.get(dns, name); + fail("Cannot get null zone."); + } catch (NullPointerException e) { + // expected + } + try { + Zone.get(null, name); + fail("Cannot get null zone."); + } catch (NullPointerException e) { + // expected + } + // test passing options + Zone.get(dns, ZONE_ID, ZONE_FIELD_OPTIONS); + } + + @Test + public void deleteByIdAndFound() { + expect(dns.delete(ZONE_ID)).andReturn(true); + replay(dns); + boolean result = zone.delete(); + assertTrue(result); + } + + @Test + public void deleteByIdAndNotFoundAndNameSetAndFound() { + expect(dns.delete(ZONE_ID)).andReturn(false); + expect(dns.delete(ZONE_NAME)).andReturn(true); + replay(dns); + boolean result = zone.delete(); + assertTrue(result); + } + + @Test + public void deleteByIdAndNotFoundAndNameSetAndNotFound() { + expect(dns.delete(ZONE_ID)).andReturn(false); + expect(dns.delete(ZONE_NAME)).andReturn(false); + replay(dns); + boolean result = zone.delete(); + assertFalse(result); + } + + @Test + public void deleteByIdAndNotFoundAndNameNotSet() { + expect(dns.delete(ZONE_ID)).andReturn(false); + replay(dns); + boolean result = zoneNoName.delete(); + assertFalse(result); + } + + @Test + public void deleteByNameAndFound() { + expect(dns.delete(ZONE_NAME)).andReturn(true); + replay(dns); + boolean result = zoneNoId.delete(); + assertTrue(result); + } + + @Test + public void deleteByNameAndNotFound() { + expect(dns.delete(ZONE_NAME)).andReturn(true); + replay(dns); + boolean result = zoneNoId.delete(); + assertTrue(result); + } + + @Test + public void listDnsRecordsByIdAndFound() { + Page pageMock = createStrictMock(Page.class); + replay(pageMock); + expect(dns.listDnsRecords(ZONE_ID)).andReturn(pageMock); + // again for options + expect(dns.listDnsRecords(ZONE_ID, DNS_RECORD_OPTIONS)).andReturn(pageMock); + replay(dns); + Page result = zone.listDnsRecords(); + assertSame(pageMock, result); + verify(pageMock); + // verify options + zone.listDnsRecords(DNS_RECORD_OPTIONS); + } + + @Test + public void listDnsRecordsByIdAndNotFoundAndNameSetAndFound() { + Page pageMock = createStrictMock(Page.class); + replay(pageMock); + expect(dns.listDnsRecords(ZONE_ID)).andReturn(null); + expect(dns.listDnsRecords(ZONE_NAME)).andReturn(pageMock); + // again for options + expect(dns.listDnsRecords(ZONE_ID, DNS_RECORD_OPTIONS)).andReturn(null); + expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); + replay(dns); + Page result = zone.listDnsRecords(); + assertSame(pageMock, result); + verify(pageMock); + // verify options + zone.listDnsRecords(DNS_RECORD_OPTIONS); + } + + @Test + public void listDnsRecordsByIdAndNotFoundAndNameSetAndNotFound() { + expect(dns.listDnsRecords(ZONE_ID)).andReturn(null); + expect(dns.listDnsRecords(ZONE_NAME)).andReturn(null); + // again for options + expect(dns.listDnsRecords(ZONE_ID, DNS_RECORD_OPTIONS)).andReturn(null); + expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(null); + replay(dns); + Page result = zone.listDnsRecords(); + assertNull(result); + // check options + zone.listDnsRecords(DNS_RECORD_OPTIONS); + } + + @Test + public void listDnsRecordsByIdAndNotFoundAndNameNotSet() { + expect(dns.listDnsRecords(ZONE_ID)).andReturn(null); + expect(dns.listDnsRecords(ZONE_ID, DNS_RECORD_OPTIONS)).andReturn(null); // for options + replay(dns); + Page result = zoneNoName.listDnsRecords(); + assertNull(result); + zoneNoName.listDnsRecords(DNS_RECORD_OPTIONS); // check options + } + + @Test + public void listDnsRecordsByNameAndFound() { + Page pageMock = createStrictMock(Page.class); + replay(pageMock); + expect(dns.listDnsRecords(ZONE_NAME)).andReturn(pageMock); + // again for options + expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); + replay(dns); + Page result = zoneNoId.listDnsRecords(); + assertSame(pageMock, result); + verify(pageMock); + zoneNoId.listDnsRecords(DNS_RECORD_OPTIONS); // check options + } + + @Test + public void listDnsRecordsByNameAndNotFound() { + expect(dns.listDnsRecords(ZONE_NAME)).andReturn(null); + // again for options + expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(null); + replay(dns); + Page result = zoneNoId.listDnsRecords(); + assertNull(result); + zoneNoId.listDnsRecords(DNS_RECORD_OPTIONS); // check options + } + + @Test + public void reloadByIdAndFound() { + expect(dns.getZone(ZONE_ID)).andReturn(zone.info()); + expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(zone.info()); // for options + replay(dns); + Zone result = zone.reload(); + assertSame(zone.dns(), result.dns()); + assertEquals(zone.info(), result.info()); + zone.reload(ZONE_FIELD_OPTIONS); // for options + } + + @Test + public void reloadByIdAndNotFoundAndNameSetAndFound() { + expect(dns.getZone(ZONE_ID)).andReturn(null); + expect(dns.getZone(ZONE_NAME)).andReturn(zone.info()); + // again for options + expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(null); + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zone.info()); + replay(dns); + Zone result = zone.reload(); + assertSame(zone.dns(), result.dns()); + assertEquals(zone.info(), result.info()); + zone.reload(ZONE_FIELD_OPTIONS); // for options + } + + @Test + public void reloadByIdAndNotFoundAndNameSetAndNotFound() { + expect(dns.getZone(ZONE_ID)).andReturn(null); + expect(dns.getZone(ZONE_NAME)).andReturn(null); + // again with options + expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(null); + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(null); + replay(dns); + Zone result = zone.reload(); + assertNull(result); + // again for options + zone.reload(ZONE_FIELD_OPTIONS); + } + + @Test + public void reloadByIdAndNotFoundAndNameNotSet() { + expect(dns.getZone(ZONE_ID)).andReturn(null); + expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(null); // for options + replay(dns); + Zone result = zoneNoName.reload(); + assertNull(result); + zoneNoName.reload(ZONE_FIELD_OPTIONS); // for options + } + + @Test + public void reloadByNameAndFound() { + expect(dns.getZone(ZONE_NAME)).andReturn(zoneNoId.info()); + // again for options + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zoneNoId.info()); + replay(dns); + Zone result = zoneNoId.reload(); + assertSame(zoneNoId.dns(), result.dns()); + assertEquals(zoneNoId.info(), result.info()); + zoneNoId.reload(ZONE_FIELD_OPTIONS); // check options + } + + @Test + public void reloadByNameAndNotFound() { + expect(dns.getZone(ZONE_NAME)).andReturn(null); + // again for options + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(null); + replay(dns); + Zone result = zoneNoId.reload(); + assertNull(result); + zoneNoId.reload(ZONE_FIELD_OPTIONS); // for options + } + + @Test + public void applyChangeByIdAndFound() { + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(CHANGE_REQUEST_AFTER); + // again for options + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(CHANGE_REQUEST_AFTER); + replay(dns); + ChangeRequest result = zone.applyChangeRequest(CHANGE_REQUEST); + assertNotEquals(CHANGE_REQUEST, result); + assertEquals(CHANGE_REQUEST_AFTER, result); + // for options + result = zone.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertNotEquals(CHANGE_REQUEST, result); + assertEquals(CHANGE_REQUEST_AFTER, result); + } + + @Test + public void applyChangeByIdAndNotFoundAndNameSetAndFound() { + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME)) + .andReturn(CHANGE_REQUEST_AFTER); + // again for options + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(CHANGE_REQUEST_AFTER); + replay(dns); + ChangeRequest result = zone.applyChangeRequest(CHANGE_REQUEST); + assertNotEquals(CHANGE_REQUEST, result); + assertEquals(CHANGE_REQUEST_AFTER, result); + // for options + result = zone.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertNotEquals(CHANGE_REQUEST, result); + assertEquals(CHANGE_REQUEST_AFTER, result); + } + + @Test + public void applyChangeIdAndNotFoundAndNameSetAndNotFound() { + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME)).andReturn(null); + // again with options + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); + replay(dns); + ChangeRequest result = zone.applyChangeRequest(CHANGE_REQUEST); + assertNull(result); + // again for options + result = zone.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertNull(result); + } + + @Test + public void applyChangeRequestByIdAndNotFoundAndNameNotSet() { + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); // for options + replay(dns); + ChangeRequest result = zoneNoName.applyChangeRequest(CHANGE_REQUEST); + assertNull(result); + // again for options + result = zoneNoName.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertNull(result); + } + + @Test + public void applyChangeByNameAndFound() { + // ID is not set + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME)) + .andReturn(CHANGE_REQUEST_AFTER); + // again for options + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(CHANGE_REQUEST_AFTER); + replay(dns); + ChangeRequest result = zoneNoId.applyChangeRequest(CHANGE_REQUEST); + assertEquals(CHANGE_REQUEST_AFTER, result); + // check options + result = zoneNoId.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertEquals(CHANGE_REQUEST_AFTER, result); + } + + @Test + public void applyChangeByNameAndNotFound() { + // ID is not set + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME)).andReturn(null); + // again for options + expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); + replay(dns); + ChangeRequest result = zoneNoId.applyChangeRequest(CHANGE_REQUEST); + assertNull(result); + // check options + result = zoneNoId.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertNull(result); + } + + @Test + public void applyNullChangeRequest() { + replay(dns); // no calls expected + try { + zone.applyChangeRequest(null); + fail("Cannot apply null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + try { + zone.applyChangeRequest(null, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot apply null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoId.applyChangeRequest(null); + fail("Cannot apply null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoId.applyChangeRequest(null, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot apply null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoName.applyChangeRequest(null); + fail("Cannot apply null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoName.applyChangeRequest(null, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot apply null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + } + + @Test + public void getChangeByIdAndFound() { + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(CHANGE_REQUEST_AFTER); + // again for options + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(CHANGE_REQUEST_AFTER); + replay(dns); + ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST); + assertNotEquals(CHANGE_REQUEST, result); + assertEquals(CHANGE_REQUEST_AFTER, result); + // for options + result = zone.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertNotEquals(CHANGE_REQUEST, result); + assertEquals(CHANGE_REQUEST_AFTER, result); + // test no id + } + + @Test + public void getChangeByIdAndNotFoundAndNameSetAndFound() { + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME)) + .andReturn(CHANGE_REQUEST_AFTER); + // again for options + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(CHANGE_REQUEST_AFTER); + replay(dns); + ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST); + assertNotEquals(CHANGE_REQUEST, result); + assertEquals(CHANGE_REQUEST_AFTER, result); + // for options + result = zone.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertNotEquals(CHANGE_REQUEST, result); + assertEquals(CHANGE_REQUEST_AFTER, result); + } + + @Test + public void getChangeIdAndNotFoundAndNameSetAndNotFound() { + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME)).andReturn(null); + // again with options + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); + replay(dns); + ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST); + assertNull(result); + // again for options + result = zone.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertNull(result); + } + + @Test + public void getChangeRequestByIdAndNotFoundAndNameNotSet() { + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); // for options + replay(dns); + ChangeRequest result = zoneNoName.getChangeRequest(CHANGE_REQUEST); + assertNull(result); + // again for options + result = zoneNoName.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertNull(result); + } + + @Test + public void getChangeByNameAndFound() { + // ID is not set + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME)) + .andReturn(CHANGE_REQUEST_AFTER); + // again for options + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(CHANGE_REQUEST_AFTER); + replay(dns); + ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST); + assertEquals(CHANGE_REQUEST_AFTER, result); + // check options + result = zoneNoId.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertEquals(CHANGE_REQUEST_AFTER, result); + } + + @Test + public void getChangeByNameAndNotFound() { + // ID is not set + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME)).andReturn(null); + // again for options + expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); + replay(dns); + ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST); + assertNull(result); + // check options + result = zoneNoId.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertNull(result); + } + + @Test + public void getNullChangeRequest() { + replay(dns); // no calls expected + try { + zone.getChangeRequest(null); + fail("Cannot get null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + try { + zone.getChangeRequest(null, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot get null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoId.getChangeRequest(null); + fail("Cannot get null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoId.getChangeRequest(null, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot get null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoName.getChangeRequest(null); + fail("Cannot get null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoName.getChangeRequest(null, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot get null ChangeRequest."); + } catch (NullPointerException e) { + // expected + } + } + + @Test + public void getChangeRequestWithNoId() { + replay(dns); // no calls expected + try { + zone.getChangeRequest(CHANGE_REQUEST_NO_ID); + fail("Cannot get ChangeRequest with no id."); + } catch (NullPointerException e) { + // expected + } + try { + zone.getChangeRequest(CHANGE_REQUEST_NO_ID, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot get ChangeRequest with no id."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID); + fail("Cannot get ChangeRequest with no id."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot get ChangeRequest with no id."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoName.getChangeRequest(CHANGE_REQUEST_NO_ID); + fail("Cannot get ChangeRequest with no id."); + } catch (NullPointerException e) { + // expected + } + try { + zoneNoName.getChangeRequest(CHANGE_REQUEST_NO_ID, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot get ChangeRequest with no id."); + } catch (NullPointerException e) { + // expected + } + } + + @Test + public void listChangeRequestsByIdAndFound() { + Page pageMock = createStrictMock(Page.class); + replay(pageMock); + expect(dns.listChangeRequests(ZONE_ID)).andReturn(pageMock); + // again for options + expect(dns.listChangeRequests(ZONE_ID, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(pageMock); + replay(dns); + Page result = zone.listChangeRequests(); + assertSame(pageMock, result); + verify(pageMock); + // verify options + zone.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); + } + + @Test + public void listChangeRequestsByIdAndNotFoundAndNameSetAndFound() { + Page pageMock = createStrictMock(Page.class); + replay(pageMock); + expect(dns.listChangeRequests(ZONE_ID)).andReturn(null); + expect(dns.listChangeRequests(ZONE_NAME)).andReturn(pageMock); + // again for options + expect(dns.listChangeRequests(ZONE_ID, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(null); + expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)) + .andReturn(pageMock); + replay(dns); + Page result = zone.listChangeRequests(); + assertSame(pageMock, result); + verify(pageMock); + // verify options + zone.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); + } + + @Test + public void listChangeRequestsByIdAndNotFoundAndNameSetAndNotFound() { + expect(dns.listChangeRequests(ZONE_ID)).andReturn(null); + expect(dns.listChangeRequests(ZONE_NAME)).andReturn(null); + // again for options + expect(dns.listChangeRequests(ZONE_ID, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(null); + expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(null); + replay(dns); + Page result = zone.listChangeRequests(); + assertNull(result); + // check options + zone.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); + } + + @Test + public void listChangeRequestsByIdAndNotFoundAndNameNotSet() { + expect(dns.listChangeRequests(ZONE_ID)).andReturn(null); + // again for options + expect(dns.listChangeRequests(ZONE_ID, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(null); + replay(dns); + Page result = zoneNoName.listChangeRequests(); + assertNull(result); + zoneNoName.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); // check options + } + + @Test + public void listChangeRequestsByNameAndFound() { + Page pageMock = createStrictMock(Page.class); + replay(pageMock); + expect(dns.listChangeRequests(ZONE_NAME)).andReturn(pageMock); + // again for options + expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)) + .andReturn(pageMock); + replay(dns); + Page result = zoneNoId.listChangeRequests(); + assertSame(pageMock, result); + verify(pageMock); + zoneNoId.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); // check options + } + + @Test + public void listChangeRequestsByNameAndNotFound() { + expect(dns.listChangeRequests(ZONE_NAME)).andReturn(null); + // again for options + expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(null); + replay(dns); + Page result = zoneNoId.listChangeRequests(); + assertNull(result); + zoneNoId.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); // check options + } +} From e083dfd87052a3231067cf0b0535e899d279d5c3 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 2 Feb 2016 12:39:08 -0800 Subject: [PATCH 035/203] Fixed documentation and some code formatting. Declared exceptions to be thrown when parent objects do not exist. Changed contracts of applyChangeRequest and getChangeRequest methods. Adjusted tests. --- .../main/java/com/google/gcloud/dns/Dns.java | 147 +++++++++--------- .../main/java/com/google/gcloud/dns/Zone.java | 92 +++++------ .../java/com/google/gcloud/dns/DnsTest.java | 2 +- .../java/com/google/gcloud/dns/ZoneTest.java | 112 ++++++------- 4 files changed, 171 insertions(+), 182 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index b48e4b0a90f2..130e8bb99f5e 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -37,7 +37,7 @@ public interface Dns extends Service { * The fields of a project. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code Dns#getProjectInfo(ProjectGetOption...)}. Project ID is always returned, even if not + * {@link Dns#getProjectInfo(ProjectOption...)}. Project ID is always returned, even if not * specified. */ enum ProjectField { @@ -69,7 +69,7 @@ static String selector(ProjectField... fields) { * The fields of a zone. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code Dns#getZone(BigInteger, ZoneOption...)} or {@code Dns#getZone(String, ZoneOption...)}. + * {@link Dns#getZone(BigInteger, ZoneOption...)} or {@link Dns#getZone(String, ZoneOption...)}. * The ID is always returned, even if not specified. */ enum ZoneField { @@ -105,7 +105,7 @@ static String selector(ZoneField... fields) { * The fields of a DNS record. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code Dns#listDnsRecords(BigInteger, DnsRecordListOption...)} or {@code + * {@link Dns#listDnsRecords(BigInteger, DnsRecordListOption...)} or {@link * Dns#listDnsRecords(String, DnsRecordListOption...)}. The name is always returned even if not * selected. */ @@ -139,8 +139,8 @@ static String selector(DnsRecordField... fields) { * The fields of a change request. * *

These values can be used to specify the fields to include in a partial response when calling - * {@code Dns#applyChangeRequest(ChangeRequest, BigInteger, ChangeRequestOption...)} or {@code - * Dns#applyChangeRequest(ChangeRequest, String, ChangeRequestOption...)} The ID is always + * {@link Dns#applyChangeRequest(BigInteger, ChangeRequest, ChangeRequestOption...)} or {@link + * Dns#applyChangeRequest(String, ChangeRequest, ChangeRequestOption...)} The ID is always * returned even if not selected. */ enum ChangeRequestField { @@ -313,11 +313,11 @@ public static ZoneListOption pageSize(int pageSize) { /** * Class for specifying project options. */ - class ProjectGetOption extends AbstractOption implements Serializable { + class ProjectOption extends AbstractOption implements Serializable { private static final long serialVersionUID = 6817937338218847748L; - ProjectGetOption(DnsRpc.Option option, Object value) { + ProjectOption(DnsRpc.Option option, Object value) { super(option, value); } @@ -325,12 +325,12 @@ class ProjectGetOption extends AbstractOption implements Serializable { * Returns an option to specify the project's fields to be returned by the RPC call. * *

If this option is not provided all project fields are returned. {@code - * ProjectGetOption.fields} can be used to specify only the fields of interest. Project ID is + * ProjectOption.fields} can be used to specify only the fields of interest. Project ID is * always returned, even if not specified. {@link ProjectField} provides a list of fields that * can be used. */ - public static ProjectGetOption fields(ProjectField... fields) { - return new ProjectGetOption(DnsRpc.Option.FIELDS, ProjectField.selector(fields)); + public static ProjectOption fields(ProjectField... fields) { + return new ProjectOption(DnsRpc.Option.FIELDS, ProjectField.selector(fields)); } } @@ -423,10 +423,11 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { /** * Creates a new zone. * - * @return ZoneInfo object representing the new zone's metadata. In addition to the name, dns name - * and description (supplied by the user within the {@code zoneInfo} parameter, the returned - * object will include the following read-only fields supplied by the server: creation time, id, - * and list of name servers. + *

Returns {@link ZoneInfo} object representing the new zone's information. In addition to the + * name, dns name and description (supplied by the user within the {@code zoneInfo} parameter), + * the returned object will include the following read-only fields supplied by the server: + * creation time, id, and list of name servers. + * * @throws DnsException upon failure * @see Cloud DNS Managed Zones: * create @@ -434,8 +435,8 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { ZoneInfo create(ZoneInfo zoneInfo); /** - * Retrieves the zone by the specified zone name. Returns {@code null} is the zone is not found. - * The returned fields can be optionally restricted by specifying {@code ZoneFieldOptions}. + * Returns the zone by the specified zone name. Returns {@code null} if the zone is not found. The + * returned fields can be optionally restricted by specifying {@link ZoneOption}s. * * @throws DnsException upon failure * @see Cloud DNS Managed Zones: @@ -444,8 +445,8 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { ZoneInfo getZone(String zoneName, ZoneOption... options); /** - * Retrieves the zone by the specified zone name. Returns {@code null} is the zone is not found. - * The returned fields can be optionally restricted by specifying {@code ZoneFieldOptions}. + * Returns the zone by the specified zone id. Returns {@code null} if the zone is not found. The + * returned fields can be optionally restricted by specifying {@link ZoneOption}s. * * @throws DnsException upon failure * @see Cloud DNS Managed Zones: @@ -454,13 +455,13 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { ZoneInfo getZone(BigInteger zoneId, ZoneOption... options); /** - * Lists the zoned inside the project. + * Lists the zones inside the project. * - *

This method returns zone in an unspecified order. New zones do not necessarily appear at the - * end of the list. Use {@link ZoneListOption} to restrict the listing to a domain name, set page - * size, and set page tokens. + *

This method returns zones in an unspecified order. New zones do not necessarily appear at + * the end of the list. Use {@link ZoneListOption} to restrict the listing to a domain name, set + * page size, and set page token. * - * @return {@code Page}, a page of zones + * @return a page of zones * @throws DnsException upon failure * @see Cloud DNS Managed Zones: * list @@ -468,10 +469,10 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { Page listZones(ZoneListOption... options); /** - * Deletes an existing zone identified by name. Returns true if the zone was successfully deleted - * and false otherwise. + * Deletes an existing zone identified by name. Returns {@code true} if the zone was successfully + * deleted and {@code false} otherwise. * - * @return {@code true} if zone was found and deleted and false otherwise + * @return {@code true} if zone was found and deleted and {@code false} otherwise * @throws DnsException upon failure * @see Cloud DNS Managed Zones: * delete @@ -479,10 +480,10 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { boolean delete(String zoneName); // delete does not admit any options /** - * Deletes an existing zone identified by id. Returns true if the zone was successfully deleted - * and false otherwise. + * Deletes an existing zone identified by id. Returns {@code true} if the zone was successfully + * deleted and {@code false} otherwise. * - * @return {@code true} if zone was found and deleted and false otherwise + * @return {@code true} if zone was found and deleted and {@code false} otherwise * @throws DnsException upon failure * @see Cloud DNS Managed Zones: * delete @@ -492,10 +493,10 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { /** * Lists the DNS records in the zone identified by name. * - *

The fields to be returned, page size and page tokens can be specified using {@code - * DnsRecordOptions}. Returns null if the zone cannot be found. + *

The fields to be returned, page size and page tokens can be specified using {@link + * DnsRecordListOption}s. * - * @throws DnsException upon failure + * @throws DnsException upon failure or if the zone cannot be found * @see Cloud DNS * ResourceRecordSets: list */ @@ -504,23 +505,23 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { /** * Lists the DNS records in the zone identified by ID. * - *

The fields to be returned, page size and page tokens can be specified using {@code - * DnsRecordOptions}. Returns null if the zone cannot be found. + *

The fields to be returned, page size and page tokens can be specified using {@link + * DnsRecordListOption}s. * - * @throws DnsException upon failure + * @throws DnsException upon failure or if the zone cannot be found * @see Cloud DNS * ResourceRecordSets: list */ Page listDnsRecords(BigInteger zoneId, DnsRecordListOption... options); /** - * Retrieves the metadata about the current project. The returned fields can be optionally - * restricted by specifying {@code ProjectOptions}. + * Retrieves the information about the current project. The returned fields can be optionally + * restricted by specifying {@link ProjectOption}s. * * @throws DnsException upon failure * @see Cloud DNS Projects: get */ - ProjectInfo getProjectInfo(ProjectGetOption... fields); + ProjectInfo getProjectInfo(ProjectOption... fields); /** * Returns the current project id. @@ -533,64 +534,61 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { BigInteger getProjectNumber(); /** - * Submits a change requests for applying to the zone identified by ID to the service. The - * returned object contains the following read-only fields supplied by the server: id, start time - * and status. time, id, and list of name servers. The returned fields can be modified by {@code - * ChangeRequestFieldOptions}. Returns null if the zone is not found. + * Submits a change request for the specified zone. The returned object contains the following + * read-only fields supplied by the server: id, start time and status. time, id, and list of name + * servers. The fields to be returned can be selected by {@link ChangeRequestOption}s. * - * @return ChangeRequest object representing the new change request or null if zone is not found + * @return the new {@link ChangeRequest} or {@code null} if zone is not found * @throws DnsException upon failure * @see Cloud DNS Changes: create */ - ChangeRequest applyChangeRequest(ChangeRequest changeRequest, BigInteger zoneId, - ChangeRequestOption... options); + ChangeRequest applyChangeRequest(BigInteger zoneId, ChangeRequest changeRequest, + ChangeRequestOption... options); /** - * Submits a change requests for applying to the zone identified by name to the service. The - * returned object contains the following read-only fields supplied by the server: id, start time - * and status. time, id, and list of name servers. The returned fields can be modified by {@code - * ChangeRequestFieldOptions}. Returns null if the zone is not found. + * Submits a change request for the specified zone. The returned object contains the following + * read-only fields supplied by the server: id, start time and status. time, id, and list of name + * servers. The fields to be returned can be selected by {@link ChangeRequestOption}s. * - * @return ChangeRequest object representing the new change request or null if zone is not found - * @throws DnsException upon failure + * @return the new {@link ChangeRequest} + * @throws DnsException upon failure if zone is not found * @see Cloud DNS Changes: create */ - ChangeRequest applyChangeRequest(ChangeRequest changeRequest, String zoneName, - ChangeRequestOption... options); + ChangeRequest applyChangeRequest(String zoneName, ChangeRequest changeRequest, + ChangeRequestOption... options); /** * Retrieves updated information about a change request previously submitted for a zone identified - * by ID. Returns null if the zone or request cannot be found. - * - *

The fields to be returned using {@code ChangeRequestFieldOptions}. + * by ID. Returns {@code null} if the request cannot be found and throws an exception if the zone + * does not exist. The fields to be returned using can be specified using {@link + * ChangeRequestOption}s. * - * @throws DnsException upon failure + * @throws DnsException upon failure or if the zone cannot be found * @see Cloud DNS Chages: get */ - ChangeRequest getChangeRequest(ChangeRequest changeRequest, BigInteger zoneId, - ChangeRequestOption... options); + ChangeRequest getChangeRequest(String changeRequestId, BigInteger zoneId, + ChangeRequestOption... options); /** * Retrieves updated information about a change request previously submitted for a zone identified - * by name. Returns null if the zone or request cannot be found. - * - *

The fields to be returned using {@code ChangeRequestFieldOptions}. + * by ID. Returns {@code null} if the request cannot be found and throws an exception if the zone + * does not exist. The fields to be returned using can be specified using {@link + * ChangeRequestOption}s. * - * @throws DnsException upon failure + * @throws DnsException upon failure or if the zone cannot be found * @see Cloud DNS Chages: get */ - ChangeRequest getChangeRequest(ChangeRequest changeRequest, String zoneName, - ChangeRequestOption... options); + ChangeRequest getChangeRequest(String changeRequestId, String zoneName, + ChangeRequestOption... options); /** * Lists the change requests for the zone identified by ID that were submitted to the service. * - *

The sorting key for changes, fields to be returned, page and page tokens can be specified - * using {@code ChangeRequestListOptions}. Note that the only sorting key currently supported is - * the timestamp of submitting the change request to the service. + *

The sorting order for changes (based on when they were received by the server), fields to be + * returned, page size and page token can be specified using {@link ChangeRequestListOption}s. * - * @return {@code Page}, a page of change requests - * @throws DnsException upon failure + * @return A page of change requests + * @throws DnsException upon failure or if the zone cannot be found * @see Cloud DNS Chages: list */ Page listChangeRequests(BigInteger zoneId, ChangeRequestListOption... options); @@ -598,12 +596,11 @@ ChangeRequest getChangeRequest(ChangeRequest changeRequest, String zoneName, /** * Lists the change requests for the zone identified by name that were submitted to the service. * - *

The sorting key for changes, fields to be returned, page and page tokens can be specified - * using {@code ChangeRequestListOptions}. Note that the only sorting key currently supported is - * the timestamp of submitting the change request to the service. + *

The sorting order for changes (based on when they were received by the server), fields to be + * returned, page size and page token can be specified using {@link ChangeRequestListOption}s. * - * @return {@code Page}, a page of change requests - * @throws DnsException upon failure + * @return A page of change requests + * @throws DnsException upon failure or if the zone cannot be found * @see Cloud DNS Chages: list */ Page listChangeRequests(String zoneName, ChangeRequestListOption... options); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index f4d9702ba12f..dc0be8b94b44 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -16,6 +16,7 @@ package com.google.gcloud.dns; +import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.google.gcloud.Page; @@ -52,15 +53,14 @@ public Zone(Dns dns, ZoneInfo zoneInfo) { /** * Constructs a {@code Zone} object that contains meta information received from the Google Cloud - * DNS service for the provided zoneName. + * DNS service for the provided {@code zoneName}. * - * @param zoneName Name of the zone to be searched for - * @param options Optional restriction on what fields should be returned by the service - * @return Zone object containing metadata or null if not not found + * @param zoneName name of the zone to be searched for + * @param options optional restriction on what fields should be returned by the service + * @return zone object containing metadata or {@code null} if not not found * @throws DnsException upon failure */ - public static Zone get(Dns dnsService, String zoneName, - Dns.ZoneOption... options) { + public static Zone get(Dns dnsService, String zoneName, Dns.ZoneOption... options) { checkNotNull(zoneName); checkNotNull(dnsService); ZoneInfo zoneInfo = dnsService.getZone(zoneName, options); @@ -68,16 +68,15 @@ public static Zone get(Dns dnsService, String zoneName, } /** - * Constructs a {@code Zone} object that contains meta information received from the Google Cloud - * DNS service for the provided zoneName. + * Constructs a {@code Zone} object that contains information received from the Google Cloud DNS + * service for the provided {@code zoneId}. * * @param zoneId ID of the zone to be searched for - * @param options Optional restriction on what fields should be returned by the service - * @return Zone object containing metadata or null if not not found + * @param options optional restriction on what fields should be returned by the service + * @return zone object containing zone's information or {@code null} if not not found * @throws DnsException upon failure */ - public static Zone get(Dns dnsService, BigInteger zoneId, - Dns.ZoneOption... options) { + public static Zone get(Dns dnsService, BigInteger zoneId, Dns.ZoneOption... options) { checkNotNull(zoneId); checkNotNull(dnsService); ZoneInfo zoneInfo = dnsService.getZone(zoneId, options); @@ -88,8 +87,8 @@ public static Zone get(Dns dnsService, BigInteger zoneId, * Retrieves the latest information about the zone. The method first attempts to retrieve the zone * by ID and if not set or zone is not found, it searches by name. * - * @param options Optional restriction on what fields should be fetched - * @return Zone object containing updated metadata or null if not not found + * @param options optional restriction on what fields should be fetched + * @return zone object containing updated information or {@code null} if not not found * @throws DnsException upon failure * @throws NullPointerException if both zone ID and name are not initialized */ @@ -110,7 +109,7 @@ public Zone reload(Dns.ZoneOption... options) { * Deletes the zone. The method first attempts to delete the zone by ID. If the zone is not found * or id is not set, it attempts to delete by name. * - * @return true is zone was found and deleted and false otherwise + * @return {@code true} is zone was found and deleted and {@code false} otherwise * @throws DnsException upon failure * @throws NullPointerException if both zone ID and name are not initialized */ @@ -131,10 +130,10 @@ public boolean delete() { * Lists all {@link DnsRecord}s associated with this zone. First searches for zone by ID and if * not found then by name. * - * @param options Optional restriction on listing and on what fields of {@link DnsRecord} should + * @param options optional restriction on listing and on what fields of {@link DnsRecord} should * be returned by the service - * @return {@code Page}, a page of DNS records, or null if the zone is not found - * @throws DnsException upon failure + * @return a page of DNS records + * @throws DnsException upon failure or if the zone is not found * @throws NullPointerException if both zone ID and name are not initialized */ public Page listDnsRecords(Dns.DnsRecordListOption... options) { @@ -153,25 +152,24 @@ public Page listDnsRecords(Dns.DnsRecordListOption... options) { /** * Submits {@link ChangeRequest} to the service for it to applied to this zone. First searches for * the zone by ID and if not found then by name. Returns a {@link ChangeRequest} with - * server-assigned ID or null if the zone was not found. + * server-assigned ID or {@code null} if the zone was not found. * - * @param options Optional restriction on what fields of {@link ChangeRequest} should be returned - * by the service - * @return ChangeRequest with server-assigned ID or null if the zone was not found. - * @throws DnsException upon failure + * @param options optional restriction on what fields of {@link ChangeRequest} should be returned + * @return ChangeRequest with server-assigned ID + * @throws DnsException upon failure or if the zone is not found * @throws NullPointerException if both zone ID and name are not initialized */ public ChangeRequest applyChangeRequest(ChangeRequest changeRequest, - Dns.ChangeRequestOption... options) { + Dns.ChangeRequestOption... options) { checkNameOrIdNotNull(); checkNotNull(changeRequest); ChangeRequest updated = null; if (zoneInfo.id() != null) { - updated = dns.applyChangeRequest(changeRequest, zoneInfo.id(), options); + updated = dns.applyChangeRequest(zoneInfo.id(), changeRequest, options); } if (updated == null && zoneInfo.name() != null) { // zone was not found by id or id is not set at all - updated = dns.applyChangeRequest(changeRequest, zoneInfo.name(), options); + updated = dns.applyChangeRequest(zoneInfo.name(), changeRequest, options); } return updated; } @@ -179,41 +177,38 @@ public ChangeRequest applyChangeRequest(ChangeRequest changeRequest, /** * Retrieves an updated information about a change request previously submitted to be applied to * this zone. First searches for the zone by ID and if not found then by name. Returns a {@link - * ChangeRequest} if found and null is the zone or the change request was not found. + * ChangeRequest} if found and {@code null} is the zone or the change request was not found. * - * @param options Optional restriction on what fields of {@link ChangeRequest} should be returned - * by the service - * @return ChangeRequest with updated information of null if the change request or zone was not - * found. - * @throws DnsException upon failure + * @param options optional restriction on what fields of {@link ChangeRequest} should be returned + * @return updated ChangeRequest + * @throws DnsException upon failure or if the zone is not found * @throws NullPointerException if both zone ID and name are not initialized * @throws NullPointerException if the change request does not have initialized id */ - public ChangeRequest getChangeRequest(ChangeRequest changeRequest, - Dns.ChangeRequestOption... options) { + public ChangeRequest getChangeRequest(String changeRequestId, + Dns.ChangeRequestOption... options) { checkNameOrIdNotNull(); - checkNotNull(changeRequest); - checkNotNull(changeRequest.id()); + checkNotNull(changeRequestId); ChangeRequest updated = null; if (zoneInfo.id() != null) { - updated = dns.getChangeRequest(changeRequest, zoneInfo.id(), options); + updated = dns.getChangeRequest(changeRequestId, zoneInfo.id(), options); } if (updated == null && zoneInfo.name() != null) { // zone was not found by id or id is not set at all - updated = dns.getChangeRequest(changeRequest, zoneInfo.name(), options); + updated = dns.getChangeRequest(changeRequestId, zoneInfo.name(), options); } return updated; } /** * Retrieves all change requests for this zone. First searches for the zone by ID and if not found - * then by name. Returns a page of {@link ChangeRequest}s or null if the zone is not found. + * then by name. Returns a page of {@link ChangeRequest}s or {@code null} if the zone is not + * found. * - * @param options Optional restriction on listing and on what fields of {@link ChangeRequest}s + * @param options optional restriction on listing and on what fields of {@link ChangeRequest}s * should be returned by the service - * @return {@code Page}, a page of change requests, or null if the zone is not - * found - * @throws DnsException upon failure + * @return a page of change requests + * @throws DnsException upon failure or if the zone is not found * @throws NullPointerException if both zone ID and name are not initialized */ public Page listChangeRequests(Dns.ChangeRequestListOption... options) { @@ -233,24 +228,21 @@ public Page listChangeRequests(Dns.ChangeRequestListOption... opt * Check that at least one of name and ID are initialized and throw and exception if not. */ private void checkNameOrIdNotNull() { - if (zoneInfo != null && zoneInfo.id() == null && zoneInfo.name() == null) { - throw new NullPointerException("Both zoneInfo.id and zoneInfo.name are null. " - + "This is an inconsistent state which should never happen."); - } + checkArgument(zoneInfo != null && (zoneInfo.id() != null || zoneInfo.name() != null), + "Both zoneInfo.id and zoneInfo.name are null. This is should never happen."); } /** - * Returns the {@link ZoneInfo} object containing meta information about this managed zone. + * Returns the {@link ZoneInfo} object containing information about this zone. */ public ZoneInfo info() { return this.zoneInfo; } /** - * Returns the {@link Dns} service object associated with this managed zone. + * Returns the {@link Dns} service object associated with this zone. */ public Dns dns() { return this.dns; } - } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java index 2e98dbd46de4..a60cae1d1793 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java @@ -94,7 +94,7 @@ public void testZoneList() { @Test public void testProjectGetOption() { // fields - Dns.ProjectGetOption fields = Dns.ProjectGetOption.fields(Dns.ProjectField.QUOTA); + Dns.ProjectOption fields = Dns.ProjectOption.fields(Dns.ProjectField.QUOTA); assertEquals(DnsRpc.Option.FIELDS, fields.rpcOption()); assertTrue(fields.value() instanceof String); assertTrue(((String) fields.value()).contains(Dns.ProjectField.QUOTA.selector())); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index 5f9d119e6150..a87bb969855b 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -348,9 +348,9 @@ public void reloadByNameAndNotFound() { @Test public void applyChangeByIdAndFound() { - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(CHANGE_REQUEST_AFTER); + expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST)).andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); ChangeRequest result = zone.applyChangeRequest(CHANGE_REQUEST); @@ -364,13 +364,13 @@ public void applyChangeByIdAndFound() { @Test public void applyChangeByIdAndNotFoundAndNameSetAndFound() { - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME)) + expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST)).andReturn(null); + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)) .andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); ChangeRequest result = zone.applyChangeRequest(CHANGE_REQUEST); @@ -384,12 +384,12 @@ public void applyChangeByIdAndNotFoundAndNameSetAndFound() { @Test public void applyChangeIdAndNotFoundAndNameSetAndNotFound() { - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME)).andReturn(null); + expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST)).andReturn(null); + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)).andReturn(null); // again with options - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); replay(dns); ChangeRequest result = zone.applyChangeRequest(CHANGE_REQUEST); @@ -401,8 +401,8 @@ public void applyChangeIdAndNotFoundAndNameSetAndNotFound() { @Test public void applyChangeRequestByIdAndNotFoundAndNameNotSet() { - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST)).andReturn(null); + expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); // for options replay(dns); ChangeRequest result = zoneNoName.applyChangeRequest(CHANGE_REQUEST); @@ -415,10 +415,10 @@ public void applyChangeRequestByIdAndNotFoundAndNameNotSet() { @Test public void applyChangeByNameAndFound() { // ID is not set - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME)) + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)) .andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); ChangeRequest result = zoneNoId.applyChangeRequest(CHANGE_REQUEST); @@ -431,9 +431,9 @@ public void applyChangeByNameAndFound() { @Test public void applyChangeByNameAndNotFound() { // ID is not set - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME)).andReturn(null); + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)).andReturn(null); // again for options - expect(dns.applyChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); replay(dns); ChangeRequest result = zoneNoId.applyChangeRequest(CHANGE_REQUEST); @@ -486,16 +486,16 @@ public void applyNullChangeRequest() { @Test public void getChangeByIdAndFound() { - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(CHANGE_REQUEST_AFTER); + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); - ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST); + ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); assertNotEquals(CHANGE_REQUEST, result); assertEquals(CHANGE_REQUEST_AFTER, result); // for options - result = zone.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + result = zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); assertNotEquals(CHANGE_REQUEST, result); assertEquals(CHANGE_REQUEST_AFTER, result); // test no id @@ -503,82 +503,82 @@ public void getChangeByIdAndFound() { @Test public void getChangeByIdAndNotFoundAndNameSetAndFound() { - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME)) + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(null); + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME)) .andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); - ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST); + ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); assertNotEquals(CHANGE_REQUEST, result); assertEquals(CHANGE_REQUEST_AFTER, result); // for options - result = zone.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + result = zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); assertNotEquals(CHANGE_REQUEST, result); assertEquals(CHANGE_REQUEST_AFTER, result); } @Test public void getChangeIdAndNotFoundAndNameSetAndNotFound() { - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME)).andReturn(null); + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(null); + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME)).andReturn(null); // again with options - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); replay(dns); - ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST); + ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); assertNull(result); // again for options - result = zone.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + result = zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); assertNull(result); } @Test public void getChangeRequestByIdAndNotFoundAndNameNotSet() { - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID)).andReturn(null); - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(null); + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); // for options replay(dns); - ChangeRequest result = zoneNoName.getChangeRequest(CHANGE_REQUEST); + ChangeRequest result = zoneNoName.getChangeRequest(CHANGE_REQUEST.id()); assertNull(result); // again for options - result = zoneNoName.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + result = zoneNoName.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); assertNull(result); } @Test public void getChangeByNameAndFound() { // ID is not set - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME)) + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME)) .andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); - ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST); + ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); assertEquals(CHANGE_REQUEST_AFTER, result); // check options - result = zoneNoId.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); assertEquals(CHANGE_REQUEST_AFTER, result); } @Test public void getChangeByNameAndNotFound() { // ID is not set - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME)).andReturn(null); + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME)).andReturn(null); // again for options - expect(dns.getChangeRequest(CHANGE_REQUEST, ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); replay(dns); - ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST); + ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); assertNull(result); // check options - result = zoneNoId.getChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); assertNull(result); } @@ -627,38 +627,38 @@ public void getNullChangeRequest() { public void getChangeRequestWithNoId() { replay(dns); // no calls expected try { - zone.getChangeRequest(CHANGE_REQUEST_NO_ID); - fail("Cannot get ChangeRequest with no id."); + zone.getChangeRequest(CHANGE_REQUEST_NO_ID.id()); + fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zone.getChangeRequest(CHANGE_REQUEST_NO_ID, CHANGE_REQUEST_FIELD_OPTIONS); - fail("Cannot get ChangeRequest with no id."); + zone.getChangeRequest(CHANGE_REQUEST_NO_ID.id(), CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID); - fail("Cannot get ChangeRequest with no id."); + zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID.id()); + fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID, CHANGE_REQUEST_FIELD_OPTIONS); - fail("Cannot get ChangeRequest with no id."); + zoneNoId.getChangeRequest(CHANGE_REQUEST_NO_ID.id(), CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zoneNoName.getChangeRequest(CHANGE_REQUEST_NO_ID); - fail("Cannot get ChangeRequest with no id."); + zoneNoName.getChangeRequest(CHANGE_REQUEST_NO_ID.id()); + fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } try { - zoneNoName.getChangeRequest(CHANGE_REQUEST_NO_ID, CHANGE_REQUEST_FIELD_OPTIONS); - fail("Cannot get ChangeRequest with no id."); + zoneNoName.getChangeRequest(CHANGE_REQUEST_NO_ID.id(), CHANGE_REQUEST_FIELD_OPTIONS); + fail("Cannot get ChangeRequest by null id."); } catch (NullPointerException e) { // expected } From d6daf0956ff0975bed3115f9b09a1381bc1cf137 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 2 Feb 2016 16:17:31 -0800 Subject: [PATCH 036/203] Adjusted documentation, removed getProjectId and getProjectNumber --- .../main/java/com/google/gcloud/dns/Dns.java | 14 +---- .../main/java/com/google/gcloud/dns/Zone.java | 12 ++-- .../java/com/google/gcloud/dns/ZoneTest.java | 56 ++++++++++--------- 3 files changed, 37 insertions(+), 45 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 130e8bb99f5e..644814fa201b 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -523,16 +523,6 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { */ ProjectInfo getProjectInfo(ProjectOption... fields); - /** - * Returns the current project id. - */ - String getProjectId(); - - /** - * Returns the current project number. - */ - BigInteger getProjectNumber(); - /** * Submits a change request for the specified zone. The returned object contains the following * read-only fields supplied by the server: id, start time and status. time, id, and list of name @@ -566,7 +556,7 @@ ChangeRequest applyChangeRequest(String zoneName, ChangeRequest changeRequest, * @throws DnsException upon failure or if the zone cannot be found * @see Cloud DNS Chages: get */ - ChangeRequest getChangeRequest(String changeRequestId, BigInteger zoneId, + ChangeRequest getChangeRequest(BigInteger zoneId, String changeRequestId, ChangeRequestOption... options); /** @@ -578,7 +568,7 @@ ChangeRequest getChangeRequest(String changeRequestId, BigInteger zoneId, * @throws DnsException upon failure or if the zone cannot be found * @see Cloud DNS Chages: get */ - ChangeRequest getChangeRequest(String changeRequestId, String zoneName, + ChangeRequest getChangeRequest(String zoneName, String changeRequestId, ChangeRequestOption... options); /** diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index dc0be8b94b44..86fc86bc3688 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -130,8 +130,7 @@ public boolean delete() { * Lists all {@link DnsRecord}s associated with this zone. First searches for zone by ID and if * not found then by name. * - * @param options optional restriction on listing and on what fields of {@link DnsRecord} should - * be returned by the service + * @param options optional restriction on listing and fields of {@link DnsRecord}s returned * @return a page of DNS records * @throws DnsException upon failure or if the zone is not found * @throws NullPointerException if both zone ID and name are not initialized @@ -191,11 +190,11 @@ public ChangeRequest getChangeRequest(String changeRequestId, checkNotNull(changeRequestId); ChangeRequest updated = null; if (zoneInfo.id() != null) { - updated = dns.getChangeRequest(changeRequestId, zoneInfo.id(), options); + updated = dns.getChangeRequest(zoneInfo.id(), changeRequestId, options); } if (updated == null && zoneInfo.name() != null) { // zone was not found by id or id is not set at all - updated = dns.getChangeRequest(changeRequestId, zoneInfo.name(), options); + updated = dns.getChangeRequest(zoneInfo.name(), changeRequestId, options); } return updated; } @@ -205,8 +204,7 @@ public ChangeRequest getChangeRequest(String changeRequestId, * then by name. Returns a page of {@link ChangeRequest}s or {@code null} if the zone is not * found. * - * @param options optional restriction on listing and on what fields of {@link ChangeRequest}s - * should be returned by the service + * @param options optional restriction on listing and fields to be returned * @return a page of change requests * @throws DnsException upon failure or if the zone is not found * @throws NullPointerException if both zone ID and name are not initialized @@ -236,7 +234,7 @@ private void checkNameOrIdNotNull() { * Returns the {@link ZoneInfo} object containing information about this zone. */ public ZoneInfo info() { - return this.zoneInfo; + return zoneInfo; } /** diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index a87bb969855b..c746140ce599 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -101,16 +101,15 @@ public void testGetById() { Zone retrieved = Zone.get(dns, ZONE_ID); assertSame(dns, retrieved.dns()); assertEquals(ZONE_INFO, retrieved.info()); - BigInteger id = null; try { - Zone.get(dns, id); - fail("Cannot get null zone."); + Zone.get(dns, (BigInteger) null); + fail("Cannot get by null id."); } catch (NullPointerException e) { // expected } try { - Zone.get(null, id); - fail("Cannot get null zone."); + Zone.get(null, new BigInteger("12")); + fail("Cannot get anything from null service."); } catch (NullPointerException e) { // expected } @@ -126,16 +125,15 @@ public void testGetByName() { Zone retrieved = Zone.get(dns, ZONE_NAME); assertSame(dns, retrieved.dns()); assertEquals(ZONE_INFO, retrieved.info()); - String name = null; try { - Zone.get(dns, name); - fail("Cannot get null zone."); + Zone.get(dns, (String) null); + fail("Cannot get by null name."); } catch (NullPointerException e) { // expected } try { - Zone.get(null, name); - fail("Cannot get null zone."); + Zone.get(null, "Not null"); + fail("Cannot get anything from null service."); } catch (NullPointerException e) { // expected } @@ -195,6 +193,7 @@ public void deleteByNameAndNotFound() { @Test public void listDnsRecordsByIdAndFound() { + @SuppressWarnings("unchecked") Page pageMock = createStrictMock(Page.class); replay(pageMock); expect(dns.listDnsRecords(ZONE_ID)).andReturn(pageMock); @@ -210,6 +209,7 @@ public void listDnsRecordsByIdAndFound() { @Test public void listDnsRecordsByIdAndNotFoundAndNameSetAndFound() { + @SuppressWarnings("unchecked") Page pageMock = createStrictMock(Page.class); replay(pageMock); expect(dns.listDnsRecords(ZONE_ID)).andReturn(null); @@ -251,6 +251,7 @@ public void listDnsRecordsByIdAndNotFoundAndNameNotSet() { @Test public void listDnsRecordsByNameAndFound() { + @SuppressWarnings("unchecked") Page pageMock = createStrictMock(Page.class); replay(pageMock); expect(dns.listDnsRecords(ZONE_NAME)).andReturn(pageMock); @@ -486,9 +487,9 @@ public void applyNullChangeRequest() { @Test public void getChangeByIdAndFound() { - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(CHANGE_REQUEST_AFTER); + expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); @@ -503,13 +504,13 @@ public void getChangeByIdAndFound() { @Test public void getChangeByIdAndNotFoundAndNameSetAndFound() { - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(null); - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME)) + expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(null); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())) .andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); @@ -523,12 +524,12 @@ public void getChangeByIdAndNotFoundAndNameSetAndFound() { @Test public void getChangeIdAndNotFoundAndNameSetAndNotFound() { - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(null); - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME)).andReturn(null); + expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(null); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null); // again with options - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); replay(dns); ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); @@ -540,8 +541,8 @@ public void getChangeIdAndNotFoundAndNameSetAndNotFound() { @Test public void getChangeRequestByIdAndNotFoundAndNameNotSet() { - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(null); - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(null); + expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); // for options replay(dns); ChangeRequest result = zoneNoName.getChangeRequest(CHANGE_REQUEST.id()); @@ -554,10 +555,10 @@ public void getChangeRequestByIdAndNotFoundAndNameNotSet() { @Test public void getChangeByNameAndFound() { // ID is not set - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME)) + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())) .andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); @@ -570,9 +571,9 @@ public void getChangeByNameAndFound() { @Test public void getChangeByNameAndNotFound() { // ID is not set - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME)).andReturn(null); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null); // again for options - expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS)) + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); replay(dns); ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); @@ -666,6 +667,7 @@ public void getChangeRequestWithNoId() { @Test public void listChangeRequestsByIdAndFound() { + @SuppressWarnings("unchecked") Page pageMock = createStrictMock(Page.class); replay(pageMock); expect(dns.listChangeRequests(ZONE_ID)).andReturn(pageMock); @@ -681,6 +683,7 @@ public void listChangeRequestsByIdAndFound() { @Test public void listChangeRequestsByIdAndNotFoundAndNameSetAndFound() { + @SuppressWarnings("unchecked") Page pageMock = createStrictMock(Page.class); replay(pageMock); expect(dns.listChangeRequests(ZONE_ID)).andReturn(null); @@ -724,6 +727,7 @@ public void listChangeRequestsByIdAndNotFoundAndNameNotSet() { @Test public void listChangeRequestsByNameAndFound() { + @SuppressWarnings("unchecked") Page pageMock = createStrictMock(Page.class); replay(pageMock); expect(dns.listChangeRequests(ZONE_NAME)).andReturn(pageMock); From 0338ead2661b9099da81adb11ebb6e18553ef2e4 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 3 Feb 2016 09:01:39 -0800 Subject: [PATCH 037/203] Completes DnsRpc interface by adding methods and doc. Closes #594. --- .../java/com/google/gcloud/spi/DnsRpc.java | 117 +++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java index f6a0f330a327..9c0f7f3809df 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java @@ -16,6 +16,12 @@ package com.google.gcloud.spi; +import com.google.api.services.dns.model.Change; +import com.google.api.services.dns.model.ManagedZone; +import com.google.api.services.dns.model.Project; +import com.google.api.services.dns.model.ResourceRecordSet; +import com.google.gcloud.dns.DnsException; + import java.util.Map; public interface DnsRpc { @@ -52,5 +58,114 @@ Integer getInt(Map options) { } } - //TODO(mderka) add supported operations. Created issue #594. + class Tuple { + + private final X x; + private final Y y; + + private Tuple(X x, Y y) { + this.x = x; + this.y = y; + } + + public static Tuple of(X x, Y y) { + return new Tuple<>(x, y); + } + + public X x() { + return x; + } + + public Y y() { + return y; + } + } + + /** + * Creates a new zone. + * + * @param zone a zone to be created + * @return Updated {@link ManagedZone} object + * @throws DnsException upon failure + */ + ManagedZone create(ManagedZone zone) throws DnsException; + + /** + * Retrieves and returns an existing zone. + * + * @param zoneName name of the zone to be returned + * @param options a map of options for the service call + * @return a zone or {@code null} if not found + * @throws DnsException upon failure + */ + ManagedZone getZone(String zoneName, Map options) throws DnsException; + + /** + * Lists the zones that exist within the project. + * + * @param options a map of options for the service call + * @throws DnsException upon failure + */ + Tuple> listZones(Map options) throws DnsException; + + /** + * Deletes the zone identified by the name. + * + * @return {@code true} if the zone was deleted and {@code false} otherwise + * @throws DnsException upon failure + */ + boolean deleteZone(String zoneName) throws DnsException; + + /** + * Lists DNS records for a given zone. + * + * @param zoneName name of the zone to be listed + * @param options a map of options for the service call + * @throws DnsException upon failure or if zone not found + */ + Tuple> listDnsRecords(String zoneName, + Map options) throws DnsException; + + /** + * Returns information about the current project. + * + * @param options a map of options for the service call + * @return up-to-date project information + * @throws DnsException upon failure + */ + Project getProject(Map options) throws DnsException; + + /** + * Applies change request to a zone. + * + * @param zoneName the name of a zone to which the {@link Change} should be applied + * @param changeRequest change to be applied + * @param options a map of options for the service call + * @return updated change object with server-assigned ID + * @throws DnsException upon failure or if zone not found + */ + Change applyChangeRequest(String zoneName, Change changeRequest, Map options) + throws DnsException; + + /** + * Returns an existing change request. + * + * @param zoneName the name of a zone to which the {@link Change} was be applied + * @param changeRequestId the unique id assigned to the change by the server + * @param options a map of options for the service call + * @return up-to-date change object + * @throws DnsException upon failure or if zone not found + */ + Change getChangeRequest(String zoneName, String changeRequestId, Map options) + throws DnsException; + + /** + * List an existing change requests for a zone. + * + * @param zoneName the name of a zone to which the {@link Change}s were be applied + * @param options a map of options for the service call + * @throws DnsException upon failure or if zone not found + */ + Tuple> listChangeRequests(String zoneName, Map options) + throws DnsException; } From bc4b8204093d92782d04319c8efda9aae424b9cc Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 3 Feb 2016 10:46:44 -0800 Subject: [PATCH 038/203] Implements DefaultDnsRpc. Progress in #595. --- .../com/google/gcloud/dns/DnsException.java | 4 +- .../com/google/gcloud/dns/DnsOptions.java | 6 +- .../com/google/gcloud/spi/DefaultDnsRpc.java | 178 ++++++++++++++++++ 3 files changed, 183 insertions(+), 5 deletions(-) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java index d18f6163a881..73c546759260 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java @@ -27,8 +27,8 @@ public class DnsException extends BaseServiceException { private static final long serialVersionUID = 490302380416260252L; - public DnsException(IOException exception, boolean idempotent) { - super(exception, idempotent); + public DnsException(IOException exception) { + super(exception, true); } //TODO(mderka) Add translation and retry functionality. Created issue #593. diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java index 1845467c2537..248fd164a55f 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java @@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableSet; import com.google.gcloud.ServiceOptions; +import com.google.gcloud.spi.DefaultDnsRpc; import com.google.gcloud.spi.DnsRpc; import com.google.gcloud.spi.DnsRpcFactory; @@ -46,8 +47,7 @@ public static class DefaultDnsRpcFactory implements DnsRpcFactory { @Override public DnsRpc create(DnsOptions options) { - // TODO(mderka) Implement when DefaultDnsRpc is available. Created issue #595. - return null; + return new DefaultDnsRpc(options); } } @@ -80,7 +80,7 @@ protected DnsFactory defaultServiceFactory() { @SuppressWarnings("unchecked") @Override protected DnsRpcFactory defaultRpcFactory() { - return null; + return DefaultDnsRpcFactory.INSTANCE; } @Override diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java new file mode 100644 index 000000000000..77eb36e3b5ed --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java @@ -0,0 +1,178 @@ +package com.google.gcloud.spi; + +import static com.google.gcloud.spi.DnsRpc.Option.DNS_NAME; +import static com.google.gcloud.spi.DnsRpc.Option.DNS_TYPE; +import static com.google.gcloud.spi.DnsRpc.Option.FIELDS; +import static com.google.gcloud.spi.DnsRpc.Option.PAGE_SIZE; +import static com.google.gcloud.spi.DnsRpc.Option.PAGE_TOKEN; +import static com.google.gcloud.spi.DnsRpc.Option.SORTING_ORDER; +import static java.net.HttpURLConnection.HTTP_NOT_FOUND; + +import com.google.api.client.http.HttpRequestInitializer; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.json.jackson.JacksonFactory; +import com.google.api.services.dns.Dns; +import com.google.api.services.dns.model.Change; +import com.google.api.services.dns.model.ChangesListResponse; +import com.google.api.services.dns.model.ManagedZone; +import com.google.api.services.dns.model.ManagedZonesListResponse; +import com.google.api.services.dns.model.Project; +import com.google.api.services.dns.model.ResourceRecordSet; +import com.google.api.services.dns.model.ResourceRecordSetsListResponse; +import com.google.gcloud.dns.DnsException; +import com.google.gcloud.dns.DnsOptions; + +import java.io.IOException; +import java.util.Map; + +/** + * A default implementation of the DnsRpc interface. + */ +public class DefaultDnsRpc implements DnsRpc { + + private final Dns dns; + private final DnsOptions options; + + private static DnsException translate(IOException exception) { + return new DnsException(exception); + } + + /** + * Constructs an instance of this rpc client with provided {@link DnsOptions}. + */ + public DefaultDnsRpc(DnsOptions options) { + HttpTransport transport = options.httpTransportFactory().create(); + HttpRequestInitializer initializer = options.httpRequestInitializer(); + this.dns = new Dns.Builder(transport, new JacksonFactory(), initializer) + .setRootUrl(options.host()) + .setApplicationName(options.applicationName()) + .build(); + this.options = options; + } + + @Override + public ManagedZone create(ManagedZone zone) throws DnsException { + try { + return dns.managedZones().create(this.options.projectId(), zone).execute(); + } catch (IOException ex) { + throw translate(ex); + } + } + + @Override + public ManagedZone getZone(String zoneName, Map options) throws DnsException { + // just fields option + try { + return dns.managedZones().get(this.options.projectId(), zoneName) + .setFields(FIELDS.getString(options)).execute(); + } catch (IOException ex) { + throw translate(ex); + } + } + + @Override + public Tuple> listZones(Map options) + throws DnsException { + // fields, page token, page size + try { + ManagedZonesListResponse zoneList = dns.managedZones().list(this.options.projectId()) + .setFields(FIELDS.getString(options)) + .setMaxResults(PAGE_SIZE.getInt(options)) + .setPageToken(PAGE_TOKEN.getString(options)) + .execute(); + return Tuple.>of(zoneList.getNextPageToken(), + zoneList.getManagedZones()); + } catch (IOException ex) { + throw translate(ex); + } + } + + @Override + public boolean deleteZone(String zoneName) throws DnsException { + try { + dns.managedZones().delete(this.options.projectId(), zoneName).execute(); + return true; + } catch (IOException ex) { + DnsException serviceException = translate(ex); + if (serviceException.code() == HTTP_NOT_FOUND) { + return false; + } + throw serviceException; + } + } + + @Override + public Tuple> listDnsRecords(String zoneName, + Map options) throws DnsException { + // options are fields, page token, dns name, type + try { + ResourceRecordSetsListResponse response = dns.resourceRecordSets() + .list(this.options.projectId(), zoneName) + .setFields(FIELDS.getString(options)) + .setPageToken(PAGE_TOKEN.getString(options)) + .setMaxResults(PAGE_SIZE.getInt(options)) + .setName(DNS_NAME.getString(options)) + .setType(DNS_TYPE.getString(options)) + .execute(); + return Tuple.>of(response.getNextPageToken(), + response.getRrsets()); + } catch (IOException ex) { + throw translate(ex); + } + } + + @Override + public Project getProject(Map options) throws DnsException { + try { + return dns.projects().get(this.options.projectId()) + .setFields(FIELDS.getString(options)).execute(); + } catch (IOException ex) { + throw translate(ex); + } + } + + @Override + public Change applyChangeRequest(String zoneName, Change changeRequest, Map options) + throws DnsException { + try { + return dns.changes().create(this.options.projectId(), zoneName, changeRequest) + .setFields(FIELDS.getString(options)) + .execute(); + } catch (IOException ex) { + throw translate(ex); + } + } + + @Override + public Change getChangeRequest(String zoneName, String changeRequestId, Map options) + throws DnsException { + try { + return dns.changes().get(this.options.projectId(), zoneName, changeRequestId) + .setFields(FIELDS.getString(options)) + .execute(); + } catch (IOException ex) { + throw translate(ex); + } + } + + @Override + public Tuple> listChangeRequests(String zoneName, Map options) + throws DnsException { + // options are fields, page token, page size, sort order + try { + Dns.Changes.List request = dns.changes().list(this.options.projectId(), zoneName) + .setFields(FIELDS.getString(options)) + .setMaxResults(PAGE_SIZE.getInt(options)) + .setPageToken(PAGE_TOKEN.getString(options)); + if (SORTING_ORDER.getString(options) != null) { + // this needs to be checked and changed if more sorting options are implemented, issue #604 + String key = "changeSequence"; + request = request.setSortBy(key).setSortOrder(SORTING_ORDER.getString(options)); + } + ChangesListResponse response = request.execute(); + return Tuple.>of(response.getNextPageToken(), response.getChanges()); + } catch (IOException ex) { + throw translate(ex); + } + } +} From 896de75d1cad86e1b2cc2e82bb20700c240fd4ec Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 3 Feb 2016 14:34:38 -0800 Subject: [PATCH 039/203] Fixed documentation and null returns from rpc. --- .../com/google/gcloud/spi/DefaultDnsRpc.java | 26 ++++++++++++++----- .../java/com/google/gcloud/spi/DnsRpc.java | 22 ++++++++-------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java index 77eb36e3b5ed..85783d0fdcb6 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java @@ -30,6 +30,7 @@ */ public class DefaultDnsRpc implements DnsRpc { + private static final String SORTING_KEY = "changeSequence"; private final Dns dns; private final DnsOptions options; @@ -64,9 +65,14 @@ public ManagedZone getZone(String zoneName, Map options) throws DnsEx // just fields option try { return dns.managedZones().get(this.options.projectId(), zoneName) - .setFields(FIELDS.getString(options)).execute(); + .setFields(FIELDS.getString(options)) + .execute(); } catch (IOException ex) { - throw translate(ex); + DnsException serviceException = translate(ex); + if (serviceException.code() == HTTP_NOT_FOUND) { + return null; + } + throw serviceException; } } @@ -151,7 +157,16 @@ public Change getChangeRequest(String zoneName, String changeRequestId, Map> listChangeRequests(String zoneName, Map>of(response.getNextPageToken(), response.getChanges()); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java index 9c0f7f3809df..bff396dedfab 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java @@ -85,7 +85,7 @@ public Y y() { * Creates a new zone. * * @param zone a zone to be created - * @return Updated {@link ManagedZone} object + * @return Updated {@code ManagedZone} object * @throws DnsException upon failure */ ManagedZone create(ManagedZone zone) throws DnsException; @@ -121,7 +121,7 @@ public Y y() { * * @param zoneName name of the zone to be listed * @param options a map of options for the service call - * @throws DnsException upon failure or if zone not found + * @throws DnsException upon failure or if zone was not found */ Tuple> listDnsRecords(String zoneName, Map options) throws DnsException; @@ -131,18 +131,18 @@ Tuple> listDnsRecords(String zoneName, * * @param options a map of options for the service call * @return up-to-date project information - * @throws DnsException upon failure + * @throws DnsException upon failure or if the project is not found */ Project getProject(Map options) throws DnsException; /** * Applies change request to a zone. * - * @param zoneName the name of a zone to which the {@link Change} should be applied + * @param zoneName the name of a zone to which the {@code Change} should be applied * @param changeRequest change to be applied * @param options a map of options for the service call * @return updated change object with server-assigned ID - * @throws DnsException upon failure or if zone not found + * @throws DnsException upon failure or if zone was not found */ Change applyChangeRequest(String zoneName, Change changeRequest, Map options) throws DnsException; @@ -150,21 +150,21 @@ Change applyChangeRequest(String zoneName, Change changeRequest, Map /** * Returns an existing change request. * - * @param zoneName the name of a zone to which the {@link Change} was be applied + * @param zoneName the name of a zone to which the {@code Change} was be applied * @param changeRequestId the unique id assigned to the change by the server * @param options a map of options for the service call - * @return up-to-date change object - * @throws DnsException upon failure or if zone not found + * @return up-to-date change object or {@code null} if change was not found + * @throws DnsException upon failure or if zone was not found */ Change getChangeRequest(String zoneName, String changeRequestId, Map options) throws DnsException; /** - * List an existing change requests for a zone. + * List existing change requests for a zone. * - * @param zoneName the name of a zone to which the {@link Change}s were be applied + * @param zoneName the name of a zone to which the {@code Change}s were be applied * @param options a map of options for the service call - * @throws DnsException upon failure or if zone not found + * @throws DnsException upon failure or if zone was not found */ Tuple> listChangeRequests(String zoneName, Map options) throws DnsException; From 3ae0f215d990f21b0c95fa1da07bbd8f8594fe1b Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 4 Feb 2016 09:11:09 -0800 Subject: [PATCH 040/203] Change Tuple into ListResult, added NAME option. --- .../main/java/com/google/gcloud/dns/Dns.java | 2 +- .../com/google/gcloud/spi/DefaultDnsRpc.java | 29 ++++++------ .../java/com/google/gcloud/spi/DnsRpc.java | 44 ++++++++++--------- .../java/com/google/gcloud/dns/DnsTest.java | 2 +- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 644814fa201b..1227a9e3b323 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -230,7 +230,7 @@ public static DnsRecordListOption pageSize(int pageSize) { * Restricts the list to only DNS records with this fully qualified domain name. */ public static DnsRecordListOption dnsName(String dnsName) { - return new DnsRecordListOption(DnsRpc.Option.DNS_NAME, dnsName); + return new DnsRecordListOption(DnsRpc.Option.NAME, dnsName); } /** diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java index 85783d0fdcb6..73e6ab4036ec 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java @@ -1,6 +1,8 @@ package com.google.gcloud.spi; +import static com.google.gcloud.spi.DnsRpc.ListResult.of; import static com.google.gcloud.spi.DnsRpc.Option.DNS_NAME; +import static com.google.gcloud.spi.DnsRpc.Option.NAME; import static com.google.gcloud.spi.DnsRpc.Option.DNS_TYPE; import static com.google.gcloud.spi.DnsRpc.Option.FIELDS; import static com.google.gcloud.spi.DnsRpc.Option.PAGE_SIZE; @@ -30,7 +32,7 @@ */ public class DefaultDnsRpc implements DnsRpc { - private static final String SORTING_KEY = "changeSequence"; + private static final String SORT_BY = "changeSequence"; private final Dns dns; private final DnsOptions options; @@ -77,17 +79,16 @@ public ManagedZone getZone(String zoneName, Map options) throws DnsEx } @Override - public Tuple> listZones(Map options) - throws DnsException { + public ListResult listZones(Map options) throws DnsException { // fields, page token, page size try { ManagedZonesListResponse zoneList = dns.managedZones().list(this.options.projectId()) .setFields(FIELDS.getString(options)) .setMaxResults(PAGE_SIZE.getInt(options)) + .setDnsName(DNS_NAME.getString(options)) .setPageToken(PAGE_TOKEN.getString(options)) .execute(); - return Tuple.>of(zoneList.getNextPageToken(), - zoneList.getManagedZones()); + return of(zoneList.getNextPageToken(), zoneList.getManagedZones()); } catch (IOException ex) { throw translate(ex); } @@ -108,8 +109,8 @@ public boolean deleteZone(String zoneName) throws DnsException { } @Override - public Tuple> listDnsRecords(String zoneName, - Map options) throws DnsException { + public ListResult listDnsRecords(String zoneName, Map options) + throws DnsException { // options are fields, page token, dns name, type try { ResourceRecordSetsListResponse response = dns.resourceRecordSets() @@ -117,11 +118,10 @@ public Tuple> listDnsRecords(String zoneName .setFields(FIELDS.getString(options)) .setPageToken(PAGE_TOKEN.getString(options)) .setMaxResults(PAGE_SIZE.getInt(options)) - .setName(DNS_NAME.getString(options)) + .setName(NAME.getString(options)) .setType(DNS_TYPE.getString(options)) .execute(); - return Tuple.>of(response.getNextPageToken(), - response.getRrsets()); + return of(response.getNextPageToken(), response.getRrsets()); } catch (IOException ex) { throw translate(ex); } @@ -159,8 +159,7 @@ public Change getChangeRequest(String zoneName, String changeRequestId, Map> listChangeRequests(String zoneName, Map options) + public ListResult listChangeRequests(String zoneName, Map options) throws DnsException { // options are fields, page token, page size, sort order try { @@ -181,10 +180,10 @@ public Tuple> listChangeRequests(String zoneName, Map>of(response.getNextPageToken(), response.getChanges()); + return ListResult.of(response.getNextPageToken(), response.getChanges()); } catch (IOException ex) { throw translate(ex); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java index bff396dedfab..c3cd3c690177 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java @@ -20,6 +20,7 @@ import com.google.api.services.dns.model.ManagedZone; import com.google.api.services.dns.model.Project; import com.google.api.services.dns.model.ResourceRecordSet; +import com.google.common.collect.ImmutableList; import com.google.gcloud.dns.DnsException; import java.util.Map; @@ -28,9 +29,10 @@ public interface DnsRpc { enum Option { FIELDS("fields"), - PAGE_SIZE("maxSize"), + PAGE_SIZE("maxResults"), PAGE_TOKEN("pageToken"), DNS_NAME("dnsName"), + NAME("name"), DNS_TYPE("type"), SORTING_ORDER("sortOrder"); @@ -58,26 +60,26 @@ Integer getInt(Map options) { } } - class Tuple { + class ListResult { - private final X x; - private final Y y; + private final Iterable results; + private final String pageToken; - private Tuple(X x, Y y) { - this.x = x; - this.y = y; + public ListResult(String pageToken, Iterable results) { + this.results = ImmutableList.copyOf(results); + this.pageToken = pageToken; } - public static Tuple of(X x, Y y) { - return new Tuple<>(x, y); + public static ListResult of(String pageToken, Iterable list) { + return new ListResult<>(pageToken, list); } - public X x() { - return x; + public Iterable results() { + return results; } - public Y y() { - return y; + public String pageToken() { + return pageToken; } } @@ -106,7 +108,7 @@ public Y y() { * @param options a map of options for the service call * @throws DnsException upon failure */ - Tuple> listZones(Map options) throws DnsException; + ListResult listZones(Map options) throws DnsException; /** * Deletes the zone identified by the name. @@ -123,12 +125,12 @@ public Y y() { * @param options a map of options for the service call * @throws DnsException upon failure or if zone was not found */ - Tuple> listDnsRecords(String zoneName, - Map options) throws DnsException; + ListResult listDnsRecords(String zoneName, Map options) + throws DnsException; /** * Returns information about the current project. - * + * * @param options a map of options for the service call * @return up-to-date project information * @throws DnsException upon failure or if the project is not found @@ -136,7 +138,7 @@ Tuple> listDnsRecords(String zoneName, Project getProject(Map options) throws DnsException; /** - * Applies change request to a zone. + * Applies change request to a zone. * * @param zoneName the name of a zone to which the {@code Change} should be applied * @param changeRequest change to be applied @@ -144,7 +146,7 @@ Tuple> listDnsRecords(String zoneName, * @return updated change object with server-assigned ID * @throws DnsException upon failure or if zone was not found */ - Change applyChangeRequest(String zoneName, Change changeRequest, Map options) + Change applyChangeRequest(String zoneName, Change changeRequest, Map options) throws DnsException; /** @@ -156,7 +158,7 @@ Change applyChangeRequest(String zoneName, Change changeRequest, Map * @return up-to-date change object or {@code null} if change was not found * @throws DnsException upon failure or if zone was not found */ - Change getChangeRequest(String zoneName, String changeRequestId, Map options) + Change getChangeRequest(String zoneName, String changeRequestId, Map options) throws DnsException; /** @@ -166,6 +168,6 @@ Change getChangeRequest(String zoneName, String changeRequestId, Map * @param options a map of options for the service call * @throws DnsException upon failure or if zone was not found */ - Tuple> listChangeRequests(String zoneName, Map options) + ListResult listChangeRequests(String zoneName, Map options) throws DnsException; } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java index a60cae1d1793..c2be251cea9e 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java @@ -34,7 +34,7 @@ public void testDnsRecordListOption() { String dnsName = "some name"; Dns.DnsRecordListOption dnsRecordListOption = Dns.DnsRecordListOption.dnsName(dnsName); assertEquals(dnsName, dnsRecordListOption.value()); - assertEquals(DnsRpc.Option.DNS_NAME, dnsRecordListOption.rpcOption()); + assertEquals(DnsRpc.Option.NAME, dnsRecordListOption.rpcOption()); // page token dnsRecordListOption = Dns.DnsRecordListOption.pageToken(PAGE_TOKEN); assertEquals(PAGE_TOKEN, dnsRecordListOption.value()); From 71f5ae22187569bf20461bcb6021761bc9864856 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 4 Feb 2016 13:54:44 -0800 Subject: [PATCH 041/203] Makes name of Zone mandatory and removes id-based methods. Also makes id a read-only string instead of BigInteger. Includes rewriting testsfor Zone. --- .../main/java/com/google/gcloud/dns/Dns.java | 81 +-- .../main/java/com/google/gcloud/dns/Zone.java | 127 +--- .../java/com/google/gcloud/dns/ZoneInfo.java | 35 +- .../com/google/gcloud/spi/DefaultDnsRpc.java | 2 +- .../com/google/gcloud/dns/ZoneInfoTest.java | 44 +- .../java/com/google/gcloud/dns/ZoneTest.java | 608 +++++------------- 6 files changed, 223 insertions(+), 674 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 1227a9e3b323..af0868ec17d6 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -23,7 +23,6 @@ import com.google.gcloud.spi.DnsRpc; import java.io.Serializable; -import java.math.BigInteger; import java.util.Set; /** @@ -69,8 +68,7 @@ static String selector(ProjectField... fields) { * The fields of a zone. * *

These values can be used to specify the fields to include in a partial response when calling - * {@link Dns#getZone(BigInteger, ZoneOption...)} or {@link Dns#getZone(String, ZoneOption...)}. - * The ID is always returned, even if not specified. + * {@link Dns#getZone(String, ZoneOption...)}. The ID is always returned, even if not specified. */ enum ZoneField { CREATION_TIME("creationTime"), @@ -105,9 +103,8 @@ static String selector(ZoneField... fields) { * The fields of a DNS record. * *

These values can be used to specify the fields to include in a partial response when calling - * {@link Dns#listDnsRecords(BigInteger, DnsRecordListOption...)} or {@link - * Dns#listDnsRecords(String, DnsRecordListOption...)}. The name is always returned even if not - * selected. + * {@link Dns#listDnsRecords(String, DnsRecordListOption...)}. The name is always returned even if + * not selected. */ enum DnsRecordField { DNS_RECORDS("rrdatas"), @@ -139,8 +136,7 @@ static String selector(DnsRecordField... fields) { * The fields of a change request. * *

These values can be used to specify the fields to include in a partial response when calling - * {@link Dns#applyChangeRequest(BigInteger, ChangeRequest, ChangeRequestOption...)} or {@link - * Dns#applyChangeRequest(String, ChangeRequest, ChangeRequestOption...)} The ID is always + * {@link Dns#applyChangeRequest(String, ChangeRequest, ChangeRequestOption...)} The ID is always * returned even if not selected. */ enum ChangeRequestField { @@ -444,16 +440,6 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { */ ZoneInfo getZone(String zoneName, ZoneOption... options); - /** - * Returns the zone by the specified zone id. Returns {@code null} if the zone is not found. The - * returned fields can be optionally restricted by specifying {@link ZoneOption}s. - * - * @throws DnsException upon failure - * @see Cloud DNS Managed Zones: - * get - */ - ZoneInfo getZone(BigInteger zoneId, ZoneOption... options); - /** * Lists the zones inside the project. * @@ -479,17 +465,6 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { */ boolean delete(String zoneName); // delete does not admit any options - /** - * Deletes an existing zone identified by id. Returns {@code true} if the zone was successfully - * deleted and {@code false} otherwise. - * - * @return {@code true} if zone was found and deleted and {@code false} otherwise - * @throws DnsException upon failure - * @see Cloud DNS Managed Zones: - * delete - */ - boolean delete(BigInteger zoneId); // delete does not admit any options - /** * Lists the DNS records in the zone identified by name. * @@ -502,18 +477,6 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { */ Page listDnsRecords(String zoneName, DnsRecordListOption... options); - /** - * Lists the DNS records in the zone identified by ID. - * - *

The fields to be returned, page size and page tokens can be specified using {@link - * DnsRecordListOption}s. - * - * @throws DnsException upon failure or if the zone cannot be found - * @see Cloud DNS - * ResourceRecordSets: list - */ - Page listDnsRecords(BigInteger zoneId, DnsRecordListOption... options); - /** * Retrieves the information about the current project. The returned fields can be optionally * restricted by specifying {@link ProjectOption}s. @@ -523,18 +486,6 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { */ ProjectInfo getProjectInfo(ProjectOption... fields); - /** - * Submits a change request for the specified zone. The returned object contains the following - * read-only fields supplied by the server: id, start time and status. time, id, and list of name - * servers. The fields to be returned can be selected by {@link ChangeRequestOption}s. - * - * @return the new {@link ChangeRequest} or {@code null} if zone is not found - * @throws DnsException upon failure - * @see Cloud DNS Changes: create - */ - ChangeRequest applyChangeRequest(BigInteger zoneId, ChangeRequest changeRequest, - ChangeRequestOption... options); - /** * Submits a change request for the specified zone. The returned object contains the following * read-only fields supplied by the server: id, start time and status. time, id, and list of name @@ -547,18 +498,6 @@ ChangeRequest applyChangeRequest(BigInteger zoneId, ChangeRequest changeRequest, ChangeRequest applyChangeRequest(String zoneName, ChangeRequest changeRequest, ChangeRequestOption... options); - /** - * Retrieves updated information about a change request previously submitted for a zone identified - * by ID. Returns {@code null} if the request cannot be found and throws an exception if the zone - * does not exist. The fields to be returned using can be specified using {@link - * ChangeRequestOption}s. - * - * @throws DnsException upon failure or if the zone cannot be found - * @see Cloud DNS Chages: get - */ - ChangeRequest getChangeRequest(BigInteger zoneId, String changeRequestId, - ChangeRequestOption... options); - /** * Retrieves updated information about a change request previously submitted for a zone identified * by ID. Returns {@code null} if the request cannot be found and throws an exception if the zone @@ -571,18 +510,6 @@ ChangeRequest getChangeRequest(BigInteger zoneId, String changeRequestId, ChangeRequest getChangeRequest(String zoneName, String changeRequestId, ChangeRequestOption... options); - /** - * Lists the change requests for the zone identified by ID that were submitted to the service. - * - *

The sorting order for changes (based on when they were received by the server), fields to be - * returned, page size and page token can be specified using {@link ChangeRequestListOption}s. - * - * @return A page of change requests - * @throws DnsException upon failure or if the zone cannot be found - * @see Cloud DNS Chages: list - */ - Page listChangeRequests(BigInteger zoneId, ChangeRequestListOption... options); - /** * Lists the change requests for the zone identified by name that were submitted to the service. * diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index 86fc86bc3688..04edf332115d 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -16,13 +16,11 @@ package com.google.gcloud.dns; -import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.google.gcloud.Page; import java.io.Serializable; -import java.math.BigInteger; /** * A Google Cloud DNS Zone object. @@ -39,7 +37,7 @@ public class Zone implements Serializable { // TODO(mderka) Zone and zoneInfo to be merged. Opened issue #605. - private static final long serialVersionUID = -4012581571095484813L; + private static final long serialVersionUID = 6847890192129375500L; private final ZoneInfo zoneInfo; private final Dns dns; @@ -68,166 +66,81 @@ public static Zone get(Dns dnsService, String zoneName, Dns.ZoneOption... option } /** - * Constructs a {@code Zone} object that contains information received from the Google Cloud DNS - * service for the provided {@code zoneId}. - * - * @param zoneId ID of the zone to be searched for - * @param options optional restriction on what fields should be returned by the service - * @return zone object containing zone's information or {@code null} if not not found - * @throws DnsException upon failure - */ - public static Zone get(Dns dnsService, BigInteger zoneId, Dns.ZoneOption... options) { - checkNotNull(zoneId); - checkNotNull(dnsService); - ZoneInfo zoneInfo = dnsService.getZone(zoneId, options); - return zoneInfo == null ? null : new Zone(dnsService, zoneInfo); - } - - /** - * Retrieves the latest information about the zone. The method first attempts to retrieve the zone - * by ID and if not set or zone is not found, it searches by name. + * Retrieves the latest information about the zone. The method retrieves the zone by name which + * must always be initialized. * * @param options optional restriction on what fields should be fetched * @return zone object containing updated information or {@code null} if not not found * @throws DnsException upon failure - * @throws NullPointerException if both zone ID and name are not initialized */ public Zone reload(Dns.ZoneOption... options) { - checkNameOrIdNotNull(); - Zone zone = null; - if (zoneInfo.id() != null) { - zone = Zone.get(dns, zoneInfo.id(), options); - } - if (zone == null && zoneInfo.name() != null) { - // zone was not found by id or id is not set at all - zone = Zone.get(dns, zoneInfo.name(), options); - } - return zone; + return Zone.get(dns, zoneInfo.name(), options); } /** - * Deletes the zone. The method first attempts to delete the zone by ID. If the zone is not found - * or id is not set, it attempts to delete by name. + * Deletes the zone. The method first deletes the zone by name which must always be initialized. * * @return {@code true} is zone was found and deleted and {@code false} otherwise * @throws DnsException upon failure - * @throws NullPointerException if both zone ID and name are not initialized */ public boolean delete() { - checkNameOrIdNotNull(); - boolean deleted = false; - if (zoneInfo.id() != null) { - deleted = dns.delete(zoneInfo.id()); - } - if (!deleted && zoneInfo.name() != null) { - // zone was not found by id or id is not set at all - deleted = dns.delete(zoneInfo.name()); - } - return deleted; + return dns.delete(zoneInfo.name()); } /** - * Lists all {@link DnsRecord}s associated with this zone. First searches for zone by ID and if - * not found then by name. + * Lists all {@link DnsRecord}s associated with this zone. The method searches for zone by name + * which must always be initialized. * * @param options optional restriction on listing and fields of {@link DnsRecord}s returned * @return a page of DNS records * @throws DnsException upon failure or if the zone is not found - * @throws NullPointerException if both zone ID and name are not initialized */ public Page listDnsRecords(Dns.DnsRecordListOption... options) { - checkNameOrIdNotNull(); - Page page = null; - if (zoneInfo.id() != null) { - page = dns.listDnsRecords(zoneInfo.id(), options); - } - if (page == null && zoneInfo.name() != null) { - // zone was not found by id or id is not set at all - page = dns.listDnsRecords(zoneInfo.name(), options); - } - return page; + return dns.listDnsRecords(zoneInfo.name(), options); } /** - * Submits {@link ChangeRequest} to the service for it to applied to this zone. First searches for - * the zone by ID and if not found then by name. Returns a {@link ChangeRequest} with - * server-assigned ID or {@code null} if the zone was not found. + * Submits {@link ChangeRequest} to the service for it to applied to this zone. The method + * searches for zone by name which must always be initialized. * * @param options optional restriction on what fields of {@link ChangeRequest} should be returned * @return ChangeRequest with server-assigned ID * @throws DnsException upon failure or if the zone is not found - * @throws NullPointerException if both zone ID and name are not initialized */ public ChangeRequest applyChangeRequest(ChangeRequest changeRequest, Dns.ChangeRequestOption... options) { - checkNameOrIdNotNull(); checkNotNull(changeRequest); - ChangeRequest updated = null; - if (zoneInfo.id() != null) { - updated = dns.applyChangeRequest(zoneInfo.id(), changeRequest, options); - } - if (updated == null && zoneInfo.name() != null) { - // zone was not found by id or id is not set at all - updated = dns.applyChangeRequest(zoneInfo.name(), changeRequest, options); - } - return updated; + return dns.applyChangeRequest(zoneInfo.name(), changeRequest, options); } /** * Retrieves an updated information about a change request previously submitted to be applied to - * this zone. First searches for the zone by ID and if not found then by name. Returns a {@link - * ChangeRequest} if found and {@code null} is the zone or the change request was not found. + * this zone. The method searches for zone by name which must always be initialized. Returns a + * {@link ChangeRequest} if and {@code null} if the change request was not found. Throws {@link + * DnsException} if the zone is not found. * * @param options optional restriction on what fields of {@link ChangeRequest} should be returned * @return updated ChangeRequest * @throws DnsException upon failure or if the zone is not found - * @throws NullPointerException if both zone ID and name are not initialized * @throws NullPointerException if the change request does not have initialized id */ public ChangeRequest getChangeRequest(String changeRequestId, Dns.ChangeRequestOption... options) { - checkNameOrIdNotNull(); checkNotNull(changeRequestId); - ChangeRequest updated = null; - if (zoneInfo.id() != null) { - updated = dns.getChangeRequest(zoneInfo.id(), changeRequestId, options); - } - if (updated == null && zoneInfo.name() != null) { - // zone was not found by id or id is not set at all - updated = dns.getChangeRequest(zoneInfo.name(), changeRequestId, options); - } - return updated; + return dns.getChangeRequest(zoneInfo.name(), changeRequestId, options); } /** - * Retrieves all change requests for this zone. First searches for the zone by ID and if not found - * then by name. Returns a page of {@link ChangeRequest}s or {@code null} if the zone is not - * found. + * Retrieves all change requests for this zone. The method searches for zone by name which must + * always be initialized. Returns a page of {@link ChangeRequest}s. Throws a {@link DnsException} + * if the zone is not found. * * @param options optional restriction on listing and fields to be returned * @return a page of change requests * @throws DnsException upon failure or if the zone is not found - * @throws NullPointerException if both zone ID and name are not initialized */ public Page listChangeRequests(Dns.ChangeRequestListOption... options) { - checkNameOrIdNotNull(); - Page changeRequests = null; - if (zoneInfo.id() != null) { - changeRequests = dns.listChangeRequests(zoneInfo.id(), options); - } - if (changeRequests == null && zoneInfo.name() != null) { - // zone was not found by id or id is not set at all - changeRequests = dns.listChangeRequests(zoneInfo.name(), options); - } - return changeRequests; - } - - /** - * Check that at least one of name and ID are initialized and throw and exception if not. - */ - private void checkNameOrIdNotNull() { - checkArgument(zoneInfo != null && (zoneInfo.id() != null || zoneInfo.name() != null), - "Both zoneInfo.id and zoneInfo.name are null. This is should never happen."); + return dns.listChangeRequests(zoneInfo.name(), options); } /** diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java index 524309eaa8e9..09945fb72138 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java @@ -41,7 +41,7 @@ public class ZoneInfo implements Serializable { private static final long serialVersionUID = 201601191647L; private final String name; - private final BigInteger id; + private final String id; private final Long creationTimeMillis; private final String dnsName; private final String description; @@ -53,7 +53,7 @@ public class ZoneInfo implements Serializable { */ public static class Builder { private String name; - private BigInteger id; + private String id; private Long creationTimeMillis; private String dnsName; private String description; @@ -66,19 +66,10 @@ public static class Builder { private Builder() { } - private Builder(BigInteger id) { - this.id = checkNotNull(id); - } - private Builder(String name) { this.name = checkNotNull(name); } - private Builder(String name, BigInteger id) { - this.name = checkNotNull(name); - this.id = checkNotNull(id); - } - /** * Creates a builder from an existing ZoneInfo object. */ @@ -103,7 +94,7 @@ public Builder name(String name) { /** * Sets an id for the zone which is assigned to the zone by the server. */ - Builder id(BigInteger id) { + Builder id(String id) { this.id = id; return this; } @@ -178,20 +169,6 @@ public static Builder builder(String name) { return new Builder(name); } - /** - * Returns a builder for {@code ZoneInfo} with an assigned {@code id}. - */ - public static Builder builder(BigInteger id) { - return new Builder(id); - } - - /** - * Returns a builder for {@code ZoneInfo} with an assigned {@code name} and {@code id}. - */ - public static Builder builder(String name, BigInteger id) { - return new Builder(name, id); - } - /** * Returns the user-defined name of the zone. */ @@ -202,7 +179,7 @@ public String name() { /** * Returns the read-only zone id assigned by the server. */ - public BigInteger id() { + public String id() { return id; } @@ -255,7 +232,7 @@ com.google.api.services.dns.model.ManagedZone toPb() { pb.setDescription(this.description()); pb.setDnsName(this.dnsName()); if (this.id() != null) { - pb.setId(this.id()); + pb.setId(new BigInteger(this.id())); } pb.setName(this.name()); pb.setNameServers(this.nameServers()); @@ -277,7 +254,7 @@ static ZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) { builder.dnsName(pb.getDnsName()); } if (pb.getId() != null) { - builder.id(pb.getId()); + builder.id(pb.getId().toString()); } if (pb.getName() != null) { builder.name(pb.getName()); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java index 73e6ab4036ec..12596da02bf6 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java @@ -2,9 +2,9 @@ import static com.google.gcloud.spi.DnsRpc.ListResult.of; import static com.google.gcloud.spi.DnsRpc.Option.DNS_NAME; -import static com.google.gcloud.spi.DnsRpc.Option.NAME; import static com.google.gcloud.spi.DnsRpc.Option.DNS_TYPE; import static com.google.gcloud.spi.DnsRpc.Option.FIELDS; +import static com.google.gcloud.spi.DnsRpc.Option.NAME; import static com.google.gcloud.spi.DnsRpc.Option.PAGE_SIZE; import static com.google.gcloud.spi.DnsRpc.Option.PAGE_TOKEN; import static com.google.gcloud.spi.DnsRpc.Option.SORTING_ORDER; diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java index 2c9fea8f7bde..227916b46f96 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java @@ -26,14 +26,13 @@ import org.junit.Test; -import java.math.BigInteger; import java.util.LinkedList; import java.util.List; public class ZoneInfoTest { private static final String NAME = "mz-example.com"; - private static final BigInteger ID = BigInteger.valueOf(123L); + private static final String ID = "123456"; private static final Long CREATION_TIME_MILLIS = 1123468321321L; private static final String DNS_NAME = "example.com."; private static final String DESCRIPTION = "description for the zone"; @@ -42,8 +41,9 @@ public class ZoneInfoTest { private static final String NS2 = "name server 2"; private static final String NS3 = "name server 3"; private static final List NAME_SERVERS = ImmutableList.of(NS1, NS2, NS3); - private static final ZoneInfo INFO = ZoneInfo.builder(NAME, ID) + private static final ZoneInfo INFO = ZoneInfo.builder(NAME) .creationTimeMillis(CREATION_TIME_MILLIS) + .id(ID) .dnsName(DNS_NAME) .description(DESCRIPTION) .nameServerSet(NAME_SERVER_SET) @@ -52,30 +52,14 @@ public class ZoneInfoTest { @Test public void testDefaultBuilders() { - ZoneInfo withName = ZoneInfo.builder(NAME).build(); - assertTrue(withName.nameServers().isEmpty()); - assertEquals(NAME, withName.name()); - assertNull(withName.id()); - assertNull(withName.creationTimeMillis()); - assertNull(withName.nameServerSet()); - assertNull(withName.description()); - assertNull(withName.dnsName()); - ZoneInfo withId = ZoneInfo.builder(ID).build(); - assertTrue(withId.nameServers().isEmpty()); - assertEquals(ID, withId.id()); - assertNull(withId.name()); - assertNull(withId.creationTimeMillis()); - assertNull(withId.nameServerSet()); - assertNull(withId.description()); - assertNull(withId.dnsName()); - ZoneInfo withBoth = ZoneInfo.builder(NAME, ID).build(); - assertTrue(withBoth.nameServers().isEmpty()); - assertEquals(ID, withBoth.id()); - assertEquals(NAME, withBoth.name()); - assertNull(withBoth.creationTimeMillis()); - assertNull(withBoth.nameServerSet()); - assertNull(withBoth.description()); - assertNull(withBoth.dnsName()); + ZoneInfo zone = ZoneInfo.builder(NAME).build(); + assertTrue(zone.nameServers().isEmpty()); + assertEquals(NAME, zone.name()); + assertNull(zone.id()); + assertNull(zone.creationTimeMillis()); + assertNull(zone.nameServerSet()); + assertNull(zone.description()); + assertNull(zone.dnsName()); } @Test @@ -109,7 +93,7 @@ public void testEqualsAndNotEquals() { assertNotEquals(INFO, clone); clone = INFO.toBuilder().dnsName(differentName).build(); assertNotEquals(INFO, clone); - clone = INFO.toBuilder().id(INFO.id().add(BigInteger.ONE)).build(); + clone = INFO.toBuilder().id(INFO.id() + "1111").build(); assertNotEquals(INFO, clone); clone = INFO.toBuilder().nameServerSet(INFO.nameServerSet() + "salt").build(); assertNotEquals(INFO, clone); @@ -127,7 +111,7 @@ public void testToBuilder() { assertEquals(INFO, INFO.toBuilder().build()); ZoneInfo partial = ZoneInfo.builder(NAME).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ZoneInfo.builder(ID).build(); + partial = ZoneInfo.builder(NAME).id(ID).build(); assertEquals(partial, partial.toBuilder().build()); partial = ZoneInfo.builder(NAME).description(DESCRIPTION).build(); assertEquals(partial, partial.toBuilder().build()); @@ -148,7 +132,7 @@ public void testToAndFromPb() { assertEquals(INFO, ZoneInfo.fromPb(INFO.toPb())); ZoneInfo partial = ZoneInfo.builder(NAME).build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); - partial = ZoneInfo.builder(ID).build(); + partial = ZoneInfo.builder(NAME).id(ID).build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); partial = ZoneInfo.builder(NAME).description(DESCRIPTION).build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index c746140ce599..59cb642167ed 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -22,7 +22,6 @@ import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; @@ -35,24 +34,19 @@ import org.junit.Before; import org.junit.Test; -import java.math.BigInteger; - public class ZoneTest { private static final String ZONE_NAME = "dns-zone-name"; - private static final BigInteger ZONE_ID = new BigInteger("123"); - private static final ZoneInfo ZONE_INFO = ZoneInfo.builder(ZONE_NAME, ZONE_ID) + private static final String ZONE_ID = "123"; + private static final ZoneInfo ZONE_INFO = ZoneInfo.builder(ZONE_NAME) + .id(ZONE_ID) .dnsName("example.com") .creationTimeMillis(123478946464L) .build(); private static final ZoneInfo NO_ID_INFO = ZoneInfo.builder(ZONE_NAME) - .dnsName("anoter-example.com") + .dnsName("another-example.com") .creationTimeMillis(893123464L) .build(); - private static final ZoneInfo NO_NAME_INFO = ZoneInfo.builder(ZONE_ID) - .dnsName("one-more-example.com") - .creationTimeMillis(875221546464L) - .build(); private static final Dns.ZoneOption ZONE_FIELD_OPTIONS = Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME); private static final Dns.DnsRecordListOption DNS_RECORD_OPTIONS = @@ -65,10 +59,10 @@ public class ZoneTest { private static final ChangeRequest CHANGE_REQUEST_AFTER = CHANGE_REQUEST.toBuilder() .startTimeMillis(123465L).build(); private static final ChangeRequest CHANGE_REQUEST_NO_ID = ChangeRequest.builder().build(); + private static final DnsException EXCEPTION = createStrictMock(DnsException.class); private Dns dns; private Zone zone; - private Zone zoneNoName; private Zone zoneNoId; @Before @@ -76,7 +70,6 @@ public void setUp() throws Exception { dns = createStrictMock(Dns.class); zone = new Zone(dns, ZONE_INFO); zoneNoId = new Zone(dns, NO_ID_INFO); - zoneNoName = new Zone(dns, NO_NAME_INFO); } @After @@ -93,40 +86,18 @@ public void testConstructor() { assertEquals(dns, zone.dns()); } - @Test - public void testGetById() { - expect(dns.getZone(ZONE_ID)).andReturn(ZONE_INFO); - expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(ZONE_INFO); // for options - replay(dns); - Zone retrieved = Zone.get(dns, ZONE_ID); - assertSame(dns, retrieved.dns()); - assertEquals(ZONE_INFO, retrieved.info()); - try { - Zone.get(dns, (BigInteger) null); - fail("Cannot get by null id."); - } catch (NullPointerException e) { - // expected - } - try { - Zone.get(null, new BigInteger("12")); - fail("Cannot get anything from null service."); - } catch (NullPointerException e) { - // expected - } - // test passing options - Zone.get(dns, ZONE_ID, ZONE_FIELD_OPTIONS); - } - @Test public void testGetByName() { expect(dns.getZone(ZONE_NAME)).andReturn(ZONE_INFO); - expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(ZONE_INFO); // for options + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(ZONE_INFO); // for options replay(dns); Zone retrieved = Zone.get(dns, ZONE_NAME); assertSame(dns, retrieved.dns()); assertEquals(ZONE_INFO, retrieved.info()); + // test passing options + Zone.get(dns, ZONE_NAME, ZONE_FIELD_OPTIONS); try { - Zone.get(dns, (String) null); + Zone.get(dns, null); fail("Cannot get by null name."); } catch (NullPointerException e) { // expected @@ -137,311 +108,177 @@ public void testGetByName() { } catch (NullPointerException e) { // expected } - // test passing options - Zone.get(dns, ZONE_ID, ZONE_FIELD_OPTIONS); } @Test - public void deleteByIdAndFound() { - expect(dns.delete(ZONE_ID)).andReturn(true); - replay(dns); - boolean result = zone.delete(); - assertTrue(result); - } - - @Test - public void deleteByIdAndNotFoundAndNameSetAndFound() { - expect(dns.delete(ZONE_ID)).andReturn(false); + public void deleteByNameAndFound() { + expect(dns.delete(ZONE_NAME)).andReturn(true); expect(dns.delete(ZONE_NAME)).andReturn(true); replay(dns); boolean result = zone.delete(); assertTrue(result); - } - - @Test - public void deleteByIdAndNotFoundAndNameSetAndNotFound() { - expect(dns.delete(ZONE_ID)).andReturn(false); - expect(dns.delete(ZONE_NAME)).andReturn(false); - replay(dns); - boolean result = zone.delete(); - assertFalse(result); - } - - @Test - public void deleteByIdAndNotFoundAndNameNotSet() { - expect(dns.delete(ZONE_ID)).andReturn(false); - replay(dns); - boolean result = zoneNoName.delete(); - assertFalse(result); - } - - @Test - public void deleteByNameAndFound() { - expect(dns.delete(ZONE_NAME)).andReturn(true); - replay(dns); - boolean result = zoneNoId.delete(); + result = zoneNoId.delete(); assertTrue(result); } @Test public void deleteByNameAndNotFound() { - expect(dns.delete(ZONE_NAME)).andReturn(true); + expect(dns.delete(ZONE_NAME)).andReturn(false); + expect(dns.delete(ZONE_NAME)).andReturn(false); replay(dns); boolean result = zoneNoId.delete(); - assertTrue(result); - } - - @Test - public void listDnsRecordsByIdAndFound() { - @SuppressWarnings("unchecked") - Page pageMock = createStrictMock(Page.class); - replay(pageMock); - expect(dns.listDnsRecords(ZONE_ID)).andReturn(pageMock); - // again for options - expect(dns.listDnsRecords(ZONE_ID, DNS_RECORD_OPTIONS)).andReturn(pageMock); - replay(dns); - Page result = zone.listDnsRecords(); - assertSame(pageMock, result); - verify(pageMock); - // verify options - zone.listDnsRecords(DNS_RECORD_OPTIONS); + assertFalse(result); + result = zone.delete(); + assertFalse(result); } @Test - public void listDnsRecordsByIdAndNotFoundAndNameSetAndFound() { + public void listDnsRecordsByNameAndFound() { @SuppressWarnings("unchecked") Page pageMock = createStrictMock(Page.class); replay(pageMock); - expect(dns.listDnsRecords(ZONE_ID)).andReturn(null); + expect(dns.listDnsRecords(ZONE_NAME)).andReturn(pageMock); expect(dns.listDnsRecords(ZONE_NAME)).andReturn(pageMock); // again for options - expect(dns.listDnsRecords(ZONE_ID, DNS_RECORD_OPTIONS)).andReturn(null); + expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); replay(dns); Page result = zone.listDnsRecords(); assertSame(pageMock, result); - verify(pageMock); - // verify options - zone.listDnsRecords(DNS_RECORD_OPTIONS); - } - - @Test - public void listDnsRecordsByIdAndNotFoundAndNameSetAndNotFound() { - expect(dns.listDnsRecords(ZONE_ID)).andReturn(null); - expect(dns.listDnsRecords(ZONE_NAME)).andReturn(null); - // again for options - expect(dns.listDnsRecords(ZONE_ID, DNS_RECORD_OPTIONS)).andReturn(null); - expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(null); - replay(dns); - Page result = zone.listDnsRecords(); - assertNull(result); - // check options - zone.listDnsRecords(DNS_RECORD_OPTIONS); - } - - @Test - public void listDnsRecordsByIdAndNotFoundAndNameNotSet() { - expect(dns.listDnsRecords(ZONE_ID)).andReturn(null); - expect(dns.listDnsRecords(ZONE_ID, DNS_RECORD_OPTIONS)).andReturn(null); // for options - replay(dns); - Page result = zoneNoName.listDnsRecords(); - assertNull(result); - zoneNoName.listDnsRecords(DNS_RECORD_OPTIONS); // check options - } - - @Test - public void listDnsRecordsByNameAndFound() { - @SuppressWarnings("unchecked") - Page pageMock = createStrictMock(Page.class); - replay(pageMock); - expect(dns.listDnsRecords(ZONE_NAME)).andReturn(pageMock); - // again for options - expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); - replay(dns); - Page result = zoneNoId.listDnsRecords(); + result = zoneNoId.listDnsRecords(); assertSame(pageMock, result); verify(pageMock); + zone.listDnsRecords(DNS_RECORD_OPTIONS); // check options zoneNoId.listDnsRecords(DNS_RECORD_OPTIONS); // check options } @Test public void listDnsRecordsByNameAndNotFound() { - expect(dns.listDnsRecords(ZONE_NAME)).andReturn(null); - // again for options - expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(null); - replay(dns); - Page result = zoneNoId.listDnsRecords(); - assertNull(result); - zoneNoId.listDnsRecords(DNS_RECORD_OPTIONS); // check options - } - - @Test - public void reloadByIdAndFound() { - expect(dns.getZone(ZONE_ID)).andReturn(zone.info()); - expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(zone.info()); // for options - replay(dns); - Zone result = zone.reload(); - assertSame(zone.dns(), result.dns()); - assertEquals(zone.info(), result.info()); - zone.reload(ZONE_FIELD_OPTIONS); // for options - } - - @Test - public void reloadByIdAndNotFoundAndNameSetAndFound() { - expect(dns.getZone(ZONE_ID)).andReturn(null); - expect(dns.getZone(ZONE_NAME)).andReturn(zone.info()); - // again for options - expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(null); - expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zone.info()); - replay(dns); - Zone result = zone.reload(); - assertSame(zone.dns(), result.dns()); - assertEquals(zone.info(), result.info()); - zone.reload(ZONE_FIELD_OPTIONS); // for options - } - - @Test - public void reloadByIdAndNotFoundAndNameSetAndNotFound() { - expect(dns.getZone(ZONE_ID)).andReturn(null); - expect(dns.getZone(ZONE_NAME)).andReturn(null); - // again with options - expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(null); - expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(null); - replay(dns); - Zone result = zone.reload(); - assertNull(result); + expect(dns.listDnsRecords(ZONE_NAME)).andThrow(EXCEPTION); + expect(dns.listDnsRecords(ZONE_NAME)).andThrow(EXCEPTION); // again for options - zone.reload(ZONE_FIELD_OPTIONS); - } - - @Test - public void reloadByIdAndNotFoundAndNameNotSet() { - expect(dns.getZone(ZONE_ID)).andReturn(null); - expect(dns.getZone(ZONE_ID, ZONE_FIELD_OPTIONS)).andReturn(null); // for options + expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andThrow(EXCEPTION); + expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andThrow(EXCEPTION); replay(dns); - Zone result = zoneNoName.reload(); - assertNull(result); - zoneNoName.reload(ZONE_FIELD_OPTIONS); // for options + try { + zoneNoId.listDnsRecords(); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } + try { + zone.listDnsRecords(); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } + try { + zoneNoId.listDnsRecords(DNS_RECORD_OPTIONS); // check options + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } + try { + zone.listDnsRecords(DNS_RECORD_OPTIONS); // check options + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } } @Test public void reloadByNameAndFound() { expect(dns.getZone(ZONE_NAME)).andReturn(zoneNoId.info()); + expect(dns.getZone(ZONE_NAME)).andReturn(zone.info()); // again for options expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zoneNoId.info()); + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zone.info()); replay(dns); Zone result = zoneNoId.reload(); assertSame(zoneNoId.dns(), result.dns()); assertEquals(zoneNoId.info(), result.info()); + result = zone.reload(); + assertSame(zone.dns(), result.dns()); + assertEquals(zone.info(), result.info()); zoneNoId.reload(ZONE_FIELD_OPTIONS); // check options + zone.reload(ZONE_FIELD_OPTIONS); // check options } @Test public void reloadByNameAndNotFound() { + expect(dns.getZone(ZONE_NAME)).andReturn(null); expect(dns.getZone(ZONE_NAME)).andReturn(null); // again for options expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(null); + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(null); replay(dns); Zone result = zoneNoId.reload(); assertNull(result); + result = zone.reload(); + assertNull(result); zoneNoId.reload(ZONE_FIELD_OPTIONS); // for options + zone.reload(ZONE_FIELD_OPTIONS); // for options } @Test - public void applyChangeByIdAndFound() { - expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST)).andReturn(CHANGE_REQUEST_AFTER); - // again for options - expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) + public void applyChangeByNameAndFound() { + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)) .andReturn(CHANGE_REQUEST_AFTER); - replay(dns); - ChangeRequest result = zone.applyChangeRequest(CHANGE_REQUEST); - assertNotEquals(CHANGE_REQUEST, result); - assertEquals(CHANGE_REQUEST_AFTER, result); - // for options - result = zone.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); - assertNotEquals(CHANGE_REQUEST, result); - assertEquals(CHANGE_REQUEST_AFTER, result); - } - - @Test - public void applyChangeByIdAndNotFoundAndNameSetAndFound() { - expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST)).andReturn(null); expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)) .andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); - replay(dns); - ChangeRequest result = zone.applyChangeRequest(CHANGE_REQUEST); - assertNotEquals(CHANGE_REQUEST, result); - assertEquals(CHANGE_REQUEST_AFTER, result); - // for options - result = zone.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); - assertNotEquals(CHANGE_REQUEST, result); - assertEquals(CHANGE_REQUEST_AFTER, result); - } - - @Test - public void applyChangeIdAndNotFoundAndNameSetAndNotFound() { - expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST)).andReturn(null); - expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)).andReturn(null); - // again with options - expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); - expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); - replay(dns); - ChangeRequest result = zone.applyChangeRequest(CHANGE_REQUEST); - assertNull(result); - // again for options - result = zone.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); - assertNull(result); - } - - @Test - public void applyChangeRequestByIdAndNotFoundAndNameNotSet() { - expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST)).andReturn(null); - expect(dns.applyChangeRequest(ZONE_ID, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); // for options - replay(dns); - ChangeRequest result = zoneNoName.applyChangeRequest(CHANGE_REQUEST); - assertNull(result); - // again for options - result = zoneNoName.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); - assertNull(result); - } - - @Test - public void applyChangeByNameAndFound() { - // ID is not set - expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)) - .andReturn(CHANGE_REQUEST_AFTER); - // again for options expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); ChangeRequest result = zoneNoId.applyChangeRequest(CHANGE_REQUEST); assertEquals(CHANGE_REQUEST_AFTER, result); + result = zone.applyChangeRequest(CHANGE_REQUEST); + assertEquals(CHANGE_REQUEST_AFTER, result); // check options result = zoneNoId.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); assertEquals(CHANGE_REQUEST_AFTER, result); + result = zone.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + assertEquals(CHANGE_REQUEST_AFTER, result); } @Test public void applyChangeByNameAndNotFound() { // ID is not set - expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)).andReturn(null); + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)).andThrow(EXCEPTION); + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)).andThrow(EXCEPTION); // again for options expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); + .andThrow(EXCEPTION); + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) + .andThrow(EXCEPTION); replay(dns); - ChangeRequest result = zoneNoId.applyChangeRequest(CHANGE_REQUEST); - assertNull(result); + try { + zoneNoId.applyChangeRequest(CHANGE_REQUEST); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } + try { + zone.applyChangeRequest(CHANGE_REQUEST); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } // check options - result = zoneNoId.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); - assertNull(result); + try { + zoneNoId.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } + try { + zone.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } } @Test @@ -471,116 +308,82 @@ public void applyNullChangeRequest() { } catch (NullPointerException e) { // expected } - try { - zoneNoName.applyChangeRequest(null); - fail("Cannot apply null ChangeRequest."); - } catch (NullPointerException e) { - // expected - } - try { - zoneNoName.applyChangeRequest(null, CHANGE_REQUEST_FIELD_OPTIONS); - fail("Cannot apply null ChangeRequest."); - } catch (NullPointerException e) { - // expected - } } @Test - public void getChangeByIdAndFound() { - expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(CHANGE_REQUEST_AFTER); - // again for options - expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) + public void getChangeAndZoneFoundByName() { + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())) .andReturn(CHANGE_REQUEST_AFTER); - replay(dns); - ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); - assertNotEquals(CHANGE_REQUEST, result); - assertEquals(CHANGE_REQUEST_AFTER, result); - // for options - result = zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); - assertNotEquals(CHANGE_REQUEST, result); - assertEquals(CHANGE_REQUEST_AFTER, result); - // test no id - } - - @Test - public void getChangeByIdAndNotFoundAndNameSetAndFound() { - expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(null); expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())) .andReturn(CHANGE_REQUEST_AFTER); // again for options - expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(CHANGE_REQUEST_AFTER); expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(CHANGE_REQUEST_AFTER); replay(dns); - ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); - assertNotEquals(CHANGE_REQUEST, result); + ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); assertEquals(CHANGE_REQUEST_AFTER, result); - // for options - result = zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); - assertNotEquals(CHANGE_REQUEST, result); + result = zone.getChangeRequest(CHANGE_REQUEST.id()); + assertEquals(CHANGE_REQUEST_AFTER, result); + // check options + result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); assertEquals(CHANGE_REQUEST_AFTER, result); - } - - @Test - public void getChangeIdAndNotFoundAndNameSetAndNotFound() { - expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(null); - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null); - // again with options - expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); - replay(dns); - ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); - assertNull(result); - // again for options result = zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); - assertNull(result); - } - - @Test - public void getChangeRequestByIdAndNotFoundAndNameNotSet() { - expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(null); - expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); // for options - replay(dns); - ChangeRequest result = zoneNoName.getChangeRequest(CHANGE_REQUEST.id()); - assertNull(result); - // again for options - result = zoneNoName.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); - assertNull(result); + assertEquals(CHANGE_REQUEST_AFTER, result); } @Test - public void getChangeByNameAndFound() { - // ID is not set - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())) - .andReturn(CHANGE_REQUEST_AFTER); + public void getChangeAndZoneNotFoundByName() { + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andThrow(EXCEPTION); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andThrow(EXCEPTION); // again for options expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(CHANGE_REQUEST_AFTER); + .andThrow(EXCEPTION); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) + .andThrow(EXCEPTION); replay(dns); - ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); - assertEquals(CHANGE_REQUEST_AFTER, result); + try { + ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } + try { + ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } // check options - result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); - assertEquals(CHANGE_REQUEST_AFTER, result); + try { + zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } + try { + zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } } @Test - public void getChangeByNameAndNotFound() { - // ID is not set + public void getChangedWhichDoesNotExistZoneFound() { + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null); expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null); // again for options + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) + .andReturn(null); expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) .andReturn(null); replay(dns); - ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); - assertNull(result); - // check options - result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); - assertNull(result); + assertNull(zoneNoId.getChangeRequest(CHANGE_REQUEST.id())); + assertNull(zone.getChangeRequest(CHANGE_REQUEST.id())); + assertNull(zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)); + assertNull(zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)); } @Test @@ -610,18 +413,6 @@ public void getNullChangeRequest() { } catch (NullPointerException e) { // expected } - try { - zoneNoName.getChangeRequest(null); - fail("Cannot get null ChangeRequest."); - } catch (NullPointerException e) { - // expected - } - try { - zoneNoName.getChangeRequest(null, CHANGE_REQUEST_FIELD_OPTIONS); - fail("Cannot get null ChangeRequest."); - } catch (NullPointerException e) { - // expected - } } @Test @@ -651,104 +442,61 @@ public void getChangeRequestWithNoId() { } catch (NullPointerException e) { // expected } - try { - zoneNoName.getChangeRequest(CHANGE_REQUEST_NO_ID.id()); - fail("Cannot get ChangeRequest by null id."); - } catch (NullPointerException e) { - // expected - } - try { - zoneNoName.getChangeRequest(CHANGE_REQUEST_NO_ID.id(), CHANGE_REQUEST_FIELD_OPTIONS); - fail("Cannot get ChangeRequest by null id."); - } catch (NullPointerException e) { - // expected - } - } - - @Test - public void listChangeRequestsByIdAndFound() { - @SuppressWarnings("unchecked") - Page pageMock = createStrictMock(Page.class); - replay(pageMock); - expect(dns.listChangeRequests(ZONE_ID)).andReturn(pageMock); - // again for options - expect(dns.listChangeRequests(ZONE_ID, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(pageMock); - replay(dns); - Page result = zone.listChangeRequests(); - assertSame(pageMock, result); - verify(pageMock); - // verify options - zone.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); } @Test - public void listChangeRequestsByIdAndNotFoundAndNameSetAndFound() { + public void listChangeRequestsAndZoneFound() { @SuppressWarnings("unchecked") Page pageMock = createStrictMock(Page.class); replay(pageMock); - expect(dns.listChangeRequests(ZONE_ID)).andReturn(null); + expect(dns.listChangeRequests(ZONE_NAME)).andReturn(pageMock); expect(dns.listChangeRequests(ZONE_NAME)).andReturn(pageMock); // again for options - expect(dns.listChangeRequests(ZONE_ID, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(null); expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)) .andReturn(pageMock); - replay(dns); - Page result = zone.listChangeRequests(); - assertSame(pageMock, result); - verify(pageMock); - // verify options - zone.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); - } - - @Test - public void listChangeRequestsByIdAndNotFoundAndNameSetAndNotFound() { - expect(dns.listChangeRequests(ZONE_ID)).andReturn(null); - expect(dns.listChangeRequests(ZONE_NAME)).andReturn(null); - // again for options - expect(dns.listChangeRequests(ZONE_ID, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(null); - expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(null); - replay(dns); - Page result = zone.listChangeRequests(); - assertNull(result); - // check options - zone.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); - } - - @Test - public void listChangeRequestsByIdAndNotFoundAndNameNotSet() { - expect(dns.listChangeRequests(ZONE_ID)).andReturn(null); - // again for options - expect(dns.listChangeRequests(ZONE_ID, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(null); - replay(dns); - Page result = zoneNoName.listChangeRequests(); - assertNull(result); - zoneNoName.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); // check options - } - - @Test - public void listChangeRequestsByNameAndFound() { - @SuppressWarnings("unchecked") - Page pageMock = createStrictMock(Page.class); - replay(pageMock); - expect(dns.listChangeRequests(ZONE_NAME)).andReturn(pageMock); - // again for options expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)) .andReturn(pageMock); replay(dns); Page result = zoneNoId.listChangeRequests(); assertSame(pageMock, result); + result = zone.listChangeRequests(); + assertSame(pageMock, result); verify(pageMock); zoneNoId.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); // check options + zone.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); // check options } @Test - public void listChangeRequestsByNameAndNotFound() { - expect(dns.listChangeRequests(ZONE_NAME)).andReturn(null); + public void listChangeRequestsAndZoneNotFound() { + expect(dns.listChangeRequests(ZONE_NAME)).andThrow(EXCEPTION); + expect(dns.listChangeRequests(ZONE_NAME)).andThrow(EXCEPTION); // again for options - expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)).andReturn(null); + expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)).andThrow(EXCEPTION); + expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)).andThrow(EXCEPTION); replay(dns); - Page result = zoneNoId.listChangeRequests(); - assertNull(result); - zoneNoId.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); // check options + try { + zoneNoId.listChangeRequests(); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } + try { + zone.listChangeRequests(); + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } + try { + zoneNoId.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); // check options + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } + try { + zone.listChangeRequests(CHANGE_REQUEST_LIST_OPTIONS); // check options + fail("Parent container not found, should throw an exception."); + } catch (DnsException e) { + // expected + } } } From 3183f4a7445dcb5e8992132ec5463bbced65c07b Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 4 Feb 2016 14:04:45 -0800 Subject: [PATCH 042/203] Added field options for zone create method. --- .../src/main/java/com/google/gcloud/dns/Dns.java | 7 ++++--- .../src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java | 7 +++++-- .../src/main/java/com/google/gcloud/spi/DnsRpc.java | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index af0868ec17d6..f6649c28680c 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -421,14 +421,15 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { * *

Returns {@link ZoneInfo} object representing the new zone's information. In addition to the * name, dns name and description (supplied by the user within the {@code zoneInfo} parameter), - * the returned object will include the following read-only fields supplied by the server: - * creation time, id, and list of name servers. + * the returned object can include the following read-only fields supplied by the server: creation + * time, id, and list of name servers. The returned fields can be optionally restricted by + * specifying {@link ZoneOption}s. * * @throws DnsException upon failure * @see Cloud DNS Managed Zones: * create */ - ZoneInfo create(ZoneInfo zoneInfo); + ZoneInfo create(ZoneInfo zoneInfo, ZoneOption... options); /** * Returns the zone by the specified zone name. Returns {@code null} if the zone is not found. The diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java index 12596da02bf6..6ed9c7e0f216 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java @@ -54,9 +54,12 @@ public DefaultDnsRpc(DnsOptions options) { } @Override - public ManagedZone create(ManagedZone zone) throws DnsException { + public ManagedZone create(ManagedZone zone, Map options) throws DnsException { try { - return dns.managedZones().create(this.options.projectId(), zone).execute(); + return dns.managedZones() + .create(this.options.projectId(), zone) + .setFields(FIELDS.getString(options)) + .execute(); } catch (IOException ex) { throw translate(ex); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java index c3cd3c690177..addb69d24b40 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java @@ -87,10 +87,11 @@ public String pageToken() { * Creates a new zone. * * @param zone a zone to be created + * @param options a map of options for the service call * @return Updated {@code ManagedZone} object * @throws DnsException upon failure */ - ManagedZone create(ManagedZone zone) throws DnsException; + ManagedZone create(ManagedZone zone, Map options) throws DnsException; /** * Retrieves and returns an existing zone. From 4057dcd93d2dee27c0a7f51e51723ca414daa5fd Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 4 Feb 2016 18:19:27 -0800 Subject: [PATCH 043/203] Fixed doc after refactoring. Made zone name mandatory in fields. --- .../src/main/java/com/google/gcloud/dns/Dns.java | 4 ++-- .../src/main/java/com/google/gcloud/dns/Zone.java | 15 ++++++--------- .../main/java/com/google/gcloud/dns/ZoneInfo.java | 11 +---------- .../test/java/com/google/gcloud/dns/DnsTest.java | 2 +- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index f6649c28680c..040a97e5b253 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -68,7 +68,7 @@ static String selector(ProjectField... fields) { * The fields of a zone. * *

These values can be used to specify the fields to include in a partial response when calling - * {@link Dns#getZone(String, ZoneOption...)}. The ID is always returned, even if not specified. + * {@link Dns#getZone(String, ZoneOption...)}. The name is always returned, even if not specified. */ enum ZoneField { CREATION_TIME("creationTime"), @@ -91,7 +91,7 @@ String selector() { static String selector(ZoneField... fields) { Set fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1); - fieldStrings.add(ZONE_ID.selector()); + fieldStrings.add(NAME.selector()); for (ZoneField field : fields) { fieldStrings.add(field.selector()); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index 04edf332115d..f5e0a8b4a63b 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -78,7 +78,7 @@ public Zone reload(Dns.ZoneOption... options) { } /** - * Deletes the zone. The method first deletes the zone by name which must always be initialized. + * Deletes the zone. The method deletes the zone by name. * * @return {@code true} is zone was found and deleted and {@code false} otherwise * @throws DnsException upon failure @@ -88,8 +88,7 @@ public boolean delete() { } /** - * Lists all {@link DnsRecord}s associated with this zone. The method searches for zone by name - * which must always be initialized. + * Lists all {@link DnsRecord}s associated with this zone. The method searches for zone by name. * * @param options optional restriction on listing and fields of {@link DnsRecord}s returned * @return a page of DNS records @@ -115,14 +114,13 @@ public ChangeRequest applyChangeRequest(ChangeRequest changeRequest, /** * Retrieves an updated information about a change request previously submitted to be applied to - * this zone. The method searches for zone by name which must always be initialized. Returns a - * {@link ChangeRequest} if and {@code null} if the change request was not found. Throws {@link - * DnsException} if the zone is not found. + * this zone. Returns a {@link ChangeRequest} or {@code null} if the change request was not + * found. Throws {@link DnsException} if the zone is not found. * * @param options optional restriction on what fields of {@link ChangeRequest} should be returned * @return updated ChangeRequest * @throws DnsException upon failure or if the zone is not found - * @throws NullPointerException if the change request does not have initialized id + * @throws NullPointerException if {@code changeRequestId} is null */ public ChangeRequest getChangeRequest(String changeRequestId, Dns.ChangeRequestOption... options) { @@ -132,8 +130,7 @@ public ChangeRequest getChangeRequest(String changeRequestId, /** * Retrieves all change requests for this zone. The method searches for zone by name which must - * always be initialized. Returns a page of {@link ChangeRequest}s. Throws a {@link DnsException} - * if the zone is not found. + * always be initialized. Returns a page of {@link ChangeRequest}s. * * @param options optional restriction on listing and fields to be returned * @return a page of change requests diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java index 09945fb72138..a15518ae166f 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java @@ -60,12 +60,6 @@ public static class Builder { private String nameServerSet; private List nameServers = new LinkedList<>(); - /** - * Returns an empty builder for {@code ZoneInfo}. We use it internally in {@code toPb()}. - */ - private Builder() { - } - private Builder(String name) { this.name = checkNotNull(name); } @@ -246,7 +240,7 @@ com.google.api.services.dns.model.ManagedZone toPb() { } static ZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) { - Builder builder = new Builder(); + Builder builder = new Builder(pb.getName()); if (pb.getDescription() != null) { builder.description(pb.getDescription()); } @@ -256,9 +250,6 @@ static ZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) { if (pb.getId() != null) { builder.id(pb.getId().toString()); } - if (pb.getName() != null) { - builder.name(pb.getName()); - } if (pb.getNameServers() != null) { builder.nameServers(pb.getNameServers()); } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java index c2be251cea9e..74faca329884 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java @@ -80,7 +80,7 @@ public void testZoneList() { assertTrue(fields.value() instanceof String); assertTrue(((String) fields.value()).contains(Dns.ZoneField.CREATION_TIME.selector())); assertTrue(((String) fields.value()).contains(Dns.ZoneField.DESCRIPTION.selector())); - assertTrue(((String) fields.value()).contains(Dns.ZoneField.ZONE_ID.selector())); + assertTrue(((String) fields.value()).contains(Dns.ZoneField.NAME.selector())); // page token Dns.ZoneListOption option = Dns.ZoneListOption.pageToken(PAGE_TOKEN); assertEquals(PAGE_TOKEN, option.value()); From d7226350faa112b2f2e5310e7268ba61176729ee Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 5 Feb 2016 08:45:53 -0800 Subject: [PATCH 044/203] Javadoc fixed. --- .../src/main/java/com/google/gcloud/dns/Zone.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index f5e0a8b4a63b..3f4ea8cab3e4 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -66,8 +66,7 @@ public static Zone get(Dns dnsService, String zoneName, Dns.ZoneOption... option } /** - * Retrieves the latest information about the zone. The method retrieves the zone by name which - * must always be initialized. + * Retrieves the latest information about the zone. The method retrieves the zone by name. * * @param options optional restriction on what fields should be fetched * @return zone object containing updated information or {@code null} if not not found @@ -100,7 +99,7 @@ public Page listDnsRecords(Dns.DnsRecordListOption... options) { /** * Submits {@link ChangeRequest} to the service for it to applied to this zone. The method - * searches for zone by name which must always be initialized. + * searches for zone by name. * * @param options optional restriction on what fields of {@link ChangeRequest} should be returned * @return ChangeRequest with server-assigned ID @@ -114,8 +113,8 @@ public ChangeRequest applyChangeRequest(ChangeRequest changeRequest, /** * Retrieves an updated information about a change request previously submitted to be applied to - * this zone. Returns a {@link ChangeRequest} or {@code null} if the change request was not - * found. Throws {@link DnsException} if the zone is not found. + * this zone. Returns a {@link ChangeRequest} or {@code null} if the change request was not found. + * Throws {@link DnsException} if the zone is not found. * * @param options optional restriction on what fields of {@link ChangeRequest} should be returned * @return updated ChangeRequest @@ -129,8 +128,8 @@ public ChangeRequest getChangeRequest(String changeRequestId, } /** - * Retrieves all change requests for this zone. The method searches for zone by name which must - * always be initialized. Returns a page of {@link ChangeRequest}s. + * Retrieves all change requests for this zone. The method searches for zone by name. Returns a + * page of {@link ChangeRequest}s. * * @param options optional restriction on listing and fields to be returned * @return a page of change requests From 5be58b3e91cade1d349014122484a29e254ba8f3 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Sun, 7 Feb 2016 14:01:52 -0800 Subject: [PATCH 045/203] Makes Zone subclass of ZoneInfo. Fixes #605. --- .../main/java/com/google/gcloud/dns/Dns.java | 2 +- .../main/java/com/google/gcloud/dns/Zone.java | 121 ++++++++++++++---- .../java/com/google/gcloud/dns/ZoneInfo.java | 98 ++++++++------ .../java/com/google/gcloud/dns/ZoneTest.java | 61 +++++++-- 4 files changed, 209 insertions(+), 73 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 040a97e5b253..3ea505b5e09b 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -439,7 +439,7 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { * @see Cloud DNS Managed Zones: * get */ - ZoneInfo getZone(String zoneName, ZoneOption... options); + Zone getZone(String zoneName, ZoneOption... options); /** * Lists the zones inside the project. diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index 3f4ea8cab3e4..2da67a8e9a01 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -20,7 +20,8 @@ import com.google.gcloud.Page; -import java.io.Serializable; +import java.util.List; +import java.util.Objects; /** * A Google Cloud DNS Zone object. @@ -33,20 +34,87 @@ * @see Google Cloud DNS managed zone * documentation */ -public class Zone implements Serializable { +public class Zone extends ZoneInfo { - // TODO(mderka) Zone and zoneInfo to be merged. Opened issue #605. + private static final long serialVersionUID = 564454483894599281L; + private transient Dns dns; - private static final long serialVersionUID = 6847890192129375500L; - private final ZoneInfo zoneInfo; - private final Dns dns; + /** + * Builder for {@code Zone}. + */ + public static class Builder extends ZoneInfo.Builder { + private final Dns dns; + private final ZoneInfo.BuilderImpl infoBuilder; + + private Builder(Zone zone) { + this.dns = zone.dns; + this.infoBuilder = new ZoneInfo.BuilderImpl(zone); + } + + @Override + public Builder name(String name) { + infoBuilder.name(name); + return this; + } + + @Override + Builder id(String id) { + infoBuilder.id(id); + return this; + } + + @Override + Builder creationTimeMillis(long creationTimeMillis) { + infoBuilder.creationTimeMillis(creationTimeMillis); + return this; + } + + @Override + public Builder dnsName(String dnsName) { + infoBuilder.dnsName(dnsName); + return this; + } + + @Override + public Builder description(String description) { + infoBuilder.description(description); + return this; + } + + @Override + public Builder nameServerSet(String nameServerSet) { + infoBuilder.nameServerSet(nameServerSet); + return this; + } + + @Override + Builder nameServers(List nameServers) { + infoBuilder.nameServers(nameServers); // infoBuilder makes a copy + return this; + } + + @Override + public Zone build() { + return new Zone(dns, infoBuilder); + } + } + + Zone(Dns dns, ZoneInfo.BuilderImpl infoBuilder) { + super(infoBuilder); + this.dns = dns; + } + + @Override + public Builder toBuilder() { + return new Builder(this); + } /** * Constructs a {@code Zone} object that contains the given {@code zoneInfo}. */ public Zone(Dns dns, ZoneInfo zoneInfo) { - this.zoneInfo = checkNotNull(zoneInfo); - this.dns = checkNotNull(dns); + super(new BuilderImpl(zoneInfo)); + this.dns = dns; } /** @@ -61,8 +129,7 @@ public Zone(Dns dns, ZoneInfo zoneInfo) { public static Zone get(Dns dnsService, String zoneName, Dns.ZoneOption... options) { checkNotNull(zoneName); checkNotNull(dnsService); - ZoneInfo zoneInfo = dnsService.getZone(zoneName, options); - return zoneInfo == null ? null : new Zone(dnsService, zoneInfo); + return dnsService.getZone(zoneName, options); } /** @@ -73,7 +140,7 @@ public static Zone get(Dns dnsService, String zoneName, Dns.ZoneOption... option * @throws DnsException upon failure */ public Zone reload(Dns.ZoneOption... options) { - return Zone.get(dns, zoneInfo.name(), options); + return dns.getZone(name(), options); } /** @@ -83,7 +150,7 @@ public Zone reload(Dns.ZoneOption... options) { * @throws DnsException upon failure */ public boolean delete() { - return dns.delete(zoneInfo.name()); + return dns.delete(name()); } /** @@ -94,7 +161,7 @@ public boolean delete() { * @throws DnsException upon failure or if the zone is not found */ public Page listDnsRecords(Dns.DnsRecordListOption... options) { - return dns.listDnsRecords(zoneInfo.name(), options); + return dns.listDnsRecords(name(), options); } /** @@ -108,7 +175,7 @@ public Page listDnsRecords(Dns.DnsRecordListOption... options) { public ChangeRequest applyChangeRequest(ChangeRequest changeRequest, Dns.ChangeRequestOption... options) { checkNotNull(changeRequest); - return dns.applyChangeRequest(zoneInfo.name(), changeRequest, options); + return dns.applyChangeRequest(name(), changeRequest, options); } /** @@ -124,7 +191,7 @@ public ChangeRequest applyChangeRequest(ChangeRequest changeRequest, public ChangeRequest getChangeRequest(String changeRequestId, Dns.ChangeRequestOption... options) { checkNotNull(changeRequestId); - return dns.getChangeRequest(zoneInfo.name(), changeRequestId, options); + return dns.getChangeRequest(name(), changeRequestId, options); } /** @@ -136,14 +203,7 @@ public ChangeRequest getChangeRequest(String changeRequestId, * @throws DnsException upon failure or if the zone is not found */ public Page listChangeRequests(Dns.ChangeRequestListOption... options) { - return dns.listChangeRequests(zoneInfo.name(), options); - } - - /** - * Returns the {@link ZoneInfo} object containing information about this zone. - */ - public ZoneInfo info() { - return zoneInfo; + return dns.listChangeRequests(name(), options); } /** @@ -152,4 +212,19 @@ public ZoneInfo info() { public Dns dns() { return this.dns; } + + @Override + public boolean equals(Object obj) { + return obj instanceof Zone && Objects.equals(toPb(), ((Zone) obj).toPb()); + } + + @Override + public int hashCode() { + return super.hashCode(); + } + + static Zone fromPb(Dns dns, com.google.api.services.dns.model.ManagedZone zone) { + ZoneInfo info = ZoneInfo.fromPb(zone); + return new Zone(dns, info); + } } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java index a15518ae166f..e397e37a7fbf 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java @@ -49,9 +49,55 @@ public class ZoneInfo implements Serializable { private final List nameServers; /** - * A builder for {@code ZoneInfo}. + * Builder for {@code ZoneInfo}. */ - public static class Builder { + public abstract static class Builder { + /** + * Sets a mandatory user-provided name for the zone. It must be unique within the project. + */ + public abstract Builder name(String name); + + /** + * Sets an id for the zone which is assigned to the zone by the server. + */ + abstract Builder id(String id); + + /** + * Sets the time when this zone was created. + */ + abstract Builder creationTimeMillis(long creationTimeMillis); + + /** + * Sets a mandatory DNS name of this zone, for instance "example.com.". + */ + public abstract Builder dnsName(String dnsName); + + /** + * Sets a mandatory description for this zone. The value is a string of at most 1024 characters + * which has no effect on the zone's function. + */ + public abstract Builder description(String description); + + /** + * Optionally specifies the NameServerSet for this zone. A NameServerSet is a set of DNS name + * servers that all host the same zones. Most users will not need to specify this value. + */ + public abstract Builder nameServerSet(String nameServerSet); + // todo(mderka) add more to the doc when questions are answered by the service owner + + /** + * Sets a list of servers that hold the information about the zone. This information is provided + * by Google Cloud DNS and is read only. + */ + abstract Builder nameServers(List nameServers); + + /** + * Builds the instance of {@code ZoneInfo} based on the information set by this builder. + */ + public abstract ZoneInfo build(); + } + + public static class BuilderImpl extends Builder { private String name; private String id; private Long creationTimeMillis; @@ -60,14 +106,14 @@ public static class Builder { private String nameServerSet; private List nameServers = new LinkedList<>(); - private Builder(String name) { + private BuilderImpl(String name) { this.name = checkNotNull(name); } /** * Creates a builder from an existing ZoneInfo object. */ - Builder(ZoneInfo info) { + BuilderImpl(ZoneInfo info) { this.name = info.name; this.id = info.id; this.creationTimeMillis = info.creationTimeMillis; @@ -77,76 +123,56 @@ private Builder(String name) { this.nameServers.addAll(info.nameServers); } - /** - * Sets a mandatory user-provided name for the zone. It must be unique within the project. - */ + @Override public Builder name(String name) { this.name = checkNotNull(name); return this; } - /** - * Sets an id for the zone which is assigned to the zone by the server. - */ + @Override Builder id(String id) { this.id = id; return this; } - /** - * Sets the time when this zone was created. - */ + @Override Builder creationTimeMillis(long creationTimeMillis) { this.creationTimeMillis = creationTimeMillis; return this; } - /** - * Sets a mandatory DNS name of this zone, for instance "example.com.". - */ + @Override public Builder dnsName(String dnsName) { this.dnsName = checkNotNull(dnsName); return this; } - /** - * Sets a mandatory description for this zone. The value is a string of at most 1024 characters - * which has no effect on the zone's function. - */ + @Override public Builder description(String description) { this.description = checkNotNull(description); return this; } - /** - * Optionally specifies the NameServerSet for this zone. A NameServerSet is a set of DNS name - * servers that all host the same zones. Most users will not need to specify this value. - */ + @Override public Builder nameServerSet(String nameServerSet) { - // todo(mderka) add more to the doc when questions are answered by the service owner this.nameServerSet = checkNotNull(nameServerSet); return this; } - /** - * Sets a list of servers that hold the information about the zone. This information is provided - * by Google Cloud DNS and is read only. - */ + @Override Builder nameServers(List nameServers) { checkNotNull(nameServers); this.nameServers = Lists.newLinkedList(nameServers); return this; } - /** - * Builds the instance of {@code ZoneInfo} based on the information set by this builder. - */ + @Override public ZoneInfo build() { return new ZoneInfo(this); } } - private ZoneInfo(Builder builder) { + ZoneInfo(BuilderImpl builder) { this.name = builder.name; this.id = builder.id; this.creationTimeMillis = builder.creationTimeMillis; @@ -160,7 +186,7 @@ private ZoneInfo(Builder builder) { * Returns a builder for {@code ZoneInfo} with an assigned {@code name}. */ public static Builder builder(String name) { - return new Builder(name); + return new BuilderImpl(name); } /** @@ -217,7 +243,7 @@ public List nameServers() { * Returns a builder for {@code ZoneInfo} prepopulated with the metadata of this zone. */ public Builder toBuilder() { - return new Builder(this); + return new BuilderImpl(this); } com.google.api.services.dns.model.ManagedZone toPb() { @@ -240,7 +266,7 @@ com.google.api.services.dns.model.ManagedZone toPb() { } static ZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) { - Builder builder = new Builder(pb.getName()); + Builder builder = new BuilderImpl(pb.getName()); if (pb.getDescription() != null) { builder.description(pb.getDescription()); } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index 59cb642167ed..1b09dca715a4 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -22,23 +22,27 @@ import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import com.google.common.collect.ImmutableList; import com.google.gcloud.Page; import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.math.BigInteger; + public class ZoneTest { private static final String ZONE_NAME = "dns-zone-name"; private static final String ZONE_ID = "123"; - private static final ZoneInfo ZONE_INFO = ZoneInfo.builder(ZONE_NAME) + private static final ZoneInfo ZONE_INFO = Zone.builder(ZONE_NAME) .id(ZONE_ID) .dnsName("example.com") .creationTimeMillis(123478946464L) @@ -80,20 +84,19 @@ public void tearDown() throws Exception { @Test public void testConstructor() { replay(dns); - assertNotNull(zone.info()); - assertEquals(ZONE_INFO, zone.info()); + assertEquals(ZONE_INFO.toPb(), zone.toPb()); assertNotNull(zone.dns()); assertEquals(dns, zone.dns()); } @Test public void testGetByName() { - expect(dns.getZone(ZONE_NAME)).andReturn(ZONE_INFO); - expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(ZONE_INFO); // for options + expect(dns.getZone(ZONE_NAME)).andReturn(zone); + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zone); // for options replay(dns); Zone retrieved = Zone.get(dns, ZONE_NAME); assertSame(dns, retrieved.dns()); - assertEquals(ZONE_INFO, retrieved.info()); + assertEquals(zone, retrieved); // test passing options Zone.get(dns, ZONE_NAME, ZONE_FIELD_OPTIONS); try { @@ -188,18 +191,18 @@ public void listDnsRecordsByNameAndNotFound() { @Test public void reloadByNameAndFound() { - expect(dns.getZone(ZONE_NAME)).andReturn(zoneNoId.info()); - expect(dns.getZone(ZONE_NAME)).andReturn(zone.info()); + expect(dns.getZone(ZONE_NAME)).andReturn(zone); + expect(dns.getZone(ZONE_NAME)).andReturn(zone); // again for options - expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zoneNoId.info()); - expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zone.info()); + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zoneNoId); + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zone); replay(dns); Zone result = zoneNoId.reload(); - assertSame(zoneNoId.dns(), result.dns()); - assertEquals(zoneNoId.info(), result.info()); + assertSame(zone.dns(), result.dns()); + assertEquals(zone, result); result = zone.reload(); assertSame(zone.dns(), result.dns()); - assertEquals(zone.info(), result.info()); + assertEquals(zone, result); zoneNoId.reload(ZONE_FIELD_OPTIONS); // check options zone.reload(ZONE_FIELD_OPTIONS); // check options } @@ -499,4 +502,36 @@ public void listChangeRequestsAndZoneNotFound() { // expected } } + + @Test + public void testFromPb() { + replay(dns); + assertEquals(Zone.fromPb(dns, zone.toPb()), zone); + } + + @Test + public void testEqualsAndToBuilder() { + replay(dns); + assertEquals(zone, zone.toBuilder().build()); + } + + @Test + public void testBuilder() { + replay(dns); + assertNotEquals(zone, zone.toBuilder() + .id((new BigInteger(zone.id())).add(BigInteger.ONE).toString()) + .build()); + assertNotEquals(zone, zone.toBuilder().dnsName(zone.name() + "aaaa").build()); + assertNotEquals(zone, zone.toBuilder().nameServerSet(zone.nameServerSet() + "aaaa").build()); + assertNotEquals(zone, zone.toBuilder().nameServers(ImmutableList.of("nameserverpppp")).build()); + assertNotEquals(zone, zone.toBuilder().dnsName(zone.dnsName() + "aaaa").build()); + assertNotEquals(zone, zone.toBuilder().creationTimeMillis(zone.creationTimeMillis() + 1) + .build()); + Zone.Builder builder = zone.toBuilder(); + builder.id(ZONE_ID) + .dnsName("example.com") + .creationTimeMillis(123478946464L) + .build(); + assertEquals(zone, builder.build()); + } } From d1c45124dffd0a5a3bfdc2a4abe5c6483f32c295 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Sun, 7 Feb 2016 10:32:02 -0800 Subject: [PATCH 046/203] Added implementation of Dns and test. Renamed getProjectInfo. Fixed #619. --- .../main/java/com/google/gcloud/dns/Dns.java | 6 +- .../com/google/gcloud/dns/DnsException.java | 18 + .../java/com/google/gcloud/dns/DnsImpl.java | 335 ++++++++++++++++ .../com/google/gcloud/dns/DnsOptions.java | 2 +- .../com/google/gcloud/dns/DnsImplTest.java | 370 ++++++++++++++++++ 5 files changed, 727 insertions(+), 4 deletions(-) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 3ea505b5e09b..88e0d7a08591 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -36,7 +36,7 @@ public interface Dns extends Service { * The fields of a project. * *

These values can be used to specify the fields to include in a partial response when calling - * {@link Dns#getProjectInfo(ProjectOption...)}. Project ID is always returned, even if not + * {@link Dns#getProject(ProjectOption...)}. Project ID is always returned, even if not * specified. */ enum ProjectField { @@ -429,7 +429,7 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { * @see Cloud DNS Managed Zones: * create */ - ZoneInfo create(ZoneInfo zoneInfo, ZoneOption... options); + Zone create(ZoneInfo zoneInfo, ZoneOption... options); /** * Returns the zone by the specified zone name. Returns {@code null} if the zone is not found. The @@ -485,7 +485,7 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { * @throws DnsException upon failure * @see Cloud DNS Projects: get */ - ProjectInfo getProjectInfo(ProjectOption... fields); + ProjectInfo getProject(ProjectOption... fields); /** * Submits a change request for the specified zone. The returned object contains the following diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java index 73c546759260..2092d5909d37 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java @@ -17,6 +17,8 @@ package com.google.gcloud.dns; import com.google.gcloud.BaseServiceException; +import com.google.gcloud.RetryHelper.RetryHelperException; +import com.google.gcloud.RetryHelper.RetryInterruptedException; import java.io.IOException; @@ -31,5 +33,21 @@ public DnsException(IOException exception) { super(exception, true); } + public DnsException(int code, String message) { + super(code, message, null, true); + } + + /** + * Translate RetryHelperException to the DnsException that caused the error. This method will + * always throw an exception. + * + * @throws DnsException when {@code ex} was caused by a {@code DnsException} + * @throws RetryInterruptedException when {@code ex} is a {@code RetryInterruptedException} + */ + static DnsException translateAndThrow(RetryHelperException ex) { + BaseServiceException.translateAndPropagateIfPossible(ex); + throw new DnsException(UNKNOWN_CODE, ex.getMessage()); + } + //TODO(mderka) Add translation and retry functionality. Created issue #593. } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java new file mode 100644 index 000000000000..b3ae73fd7e93 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java @@ -0,0 +1,335 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.gcloud.RetryHelper.RetryHelperException; +import static com.google.gcloud.RetryHelper.runWithRetries; +import static com.google.gcloud.dns.ChangeRequest.fromPb; + +import com.google.api.services.dns.model.Change; +import com.google.api.services.dns.model.ManagedZone; +import com.google.api.services.dns.model.ResourceRecordSet; +import com.google.common.base.Function; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Maps; +import com.google.gcloud.BaseService; +import com.google.gcloud.Page; +import com.google.gcloud.PageImpl; +import com.google.gcloud.RetryHelper; +import com.google.gcloud.spi.DnsRpc; + +import java.util.Map; +import java.util.concurrent.Callable; + +/** + * A default implementation of Dns. + */ +final class DnsImpl extends BaseService implements Dns { + + private final DnsRpc dnsRpc; + + private static class ZonePageFetcher implements PageImpl.NextPageFetcher { + + private static final long serialVersionUID = 2158209410430566961L; + private final Map requestOptions; + private final DnsOptions serviceOptions; + + ZonePageFetcher(DnsOptions serviceOptions, String cursor, + Map optionMap) { + this.requestOptions = + PageImpl.nextRequestOptions(DnsRpc.Option.PAGE_TOKEN, cursor, optionMap); + this.serviceOptions = serviceOptions; + } + + @Override + public Page nextPage() { + return listZones(serviceOptions, requestOptions); + } + } + + private static class ChangeRequestPageFetcher implements PageImpl.NextPageFetcher { + + private static final Function PB_TO_CHANGE_REQUEST = + new Function() { + @Override + public ChangeRequest apply(com.google.api.services.dns.model.Change changePb) { + return fromPb(changePb); + } + }; + private static final long serialVersionUID = -8737501076674042014L; + private final String zoneName; + private final Map requestOptions; + private final DnsOptions serviceOptions; + + ChangeRequestPageFetcher(String zoneName, DnsOptions serviceOptions, String cursor, + Map optionMap) { + this.zoneName = zoneName; + this.requestOptions = + PageImpl.nextRequestOptions(DnsRpc.Option.PAGE_TOKEN, cursor, optionMap); + this.serviceOptions = serviceOptions; + } + + @Override + public Page nextPage() { + return listChangeRequests(zoneName, serviceOptions, requestOptions, PB_TO_CHANGE_REQUEST); + } + } + + private static class DnsRecordPageFetcher implements PageImpl.NextPageFetcher { + + private static final Function PB_TO_DNS_RECORD = + new Function() { + @Override + public DnsRecord apply(com.google.api.services.dns.model.ResourceRecordSet pb) { + return DnsRecord.fromPb(pb); + } + }; + private static final long serialVersionUID = 670996349097667660L; + private final Map requestOptions; + private final DnsOptions serviceOptions; + private final String zoneName; + + DnsRecordPageFetcher(String zoneName, DnsOptions serviceOptions, String cursor, + Map optionMap) { + this.zoneName = zoneName; + this.requestOptions = + PageImpl.nextRequestOptions(DnsRpc.Option.PAGE_TOKEN, cursor, optionMap); + this.serviceOptions = serviceOptions; + } + + @Override + public Page nextPage() { + return listDnsRecords(zoneName, serviceOptions, requestOptions, PB_TO_DNS_RECORD); + } + } + + private static Page listZones(final DnsOptions serviceOptions, + final Map optionsMap) { + // define transformation function + // this differs from the other list operations since zone is functional and requires dns service + Function pbToZoneFunction = new Function() { + @Override + public Zone apply( + com.google.api.services.dns.model.ManagedZone zonePb) { + return new Zone(serviceOptions.service(), ZoneInfo.fromPb(zonePb)); + } + }; + try { + // get a list of managed zones + DnsRpc.ListResult result = + runWithRetries(new Callable>() { + @Override + public DnsRpc.ListResult call() { + return serviceOptions.rpc().listZones(optionsMap); + } + }, serviceOptions.retryParams(), EXCEPTION_HANDLER); + String cursor = result.pageToken(); + // transform that list into zone objects + Iterable zones = result.results() == null + ? ImmutableList.of() : Iterables.transform(result.results(), pbToZoneFunction); + return new PageImpl<>(new ZonePageFetcher(serviceOptions, cursor, optionsMap), + cursor, zones); + } catch (RetryHelperException e) { + throw DnsException.translateAndThrow(e); + } + } + + private static Page listChangeRequests(final String zoneName, + final DnsOptions serviceOptions, final Map optionsMap, + Function TRANSFORM_FUNCTION) { + try { + // get a list of changes + DnsRpc.ListResult result = runWithRetries(new Callable>() { + @Override + public DnsRpc.ListResult call() { + return serviceOptions.rpc().listChangeRequests(zoneName, optionsMap); + } + }, serviceOptions.retryParams(), EXCEPTION_HANDLER); + String cursor = result.pageToken(); + // transform that list into change request objects + Iterable changes = result.results() == null + ? ImmutableList.of() + : Iterables.transform(result.results(), TRANSFORM_FUNCTION); + return new PageImpl<>(new ChangeRequestPageFetcher(zoneName, serviceOptions, cursor, + optionsMap), cursor, changes); + } catch (RetryHelperException e) { + throw DnsException.translateAndThrow(e); + } + } + + private static Page listDnsRecords(final String zoneName, + final DnsOptions serviceOptions, final Map optionsMap, + Function TRANSFORM_FUNCTION) { + try { + // get a list of resource record sets + DnsRpc.ListResult result = runWithRetries( + new Callable>() { + @Override + public DnsRpc.ListResult call() { + return serviceOptions.rpc().listDnsRecords(zoneName, optionsMap); + } + }, serviceOptions.retryParams(), EXCEPTION_HANDLER); + String cursor = result.pageToken(); + // transform that list into dns records + Iterable records = result.results() == null + ? ImmutableList.of() + : Iterables.transform(result.results(), TRANSFORM_FUNCTION); + return new PageImpl<>(new DnsRecordPageFetcher(zoneName, serviceOptions, cursor, optionsMap), + cursor, records); + } catch (RetryHelperException e) { + throw DnsException.translateAndThrow(e); + } + } + + DnsImpl(DnsOptions options) { + super(options); + dnsRpc = options.rpc(); + } + + @Override + public Page listZones(ZoneListOption... options) { + return listZones(options(), optionMap(options)); + } + + @Override + public Page listChangeRequests(String zoneName, + ChangeRequestListOption... options) { + return listChangeRequests(zoneName, options(), optionMap(options), + ChangeRequestPageFetcher.PB_TO_CHANGE_REQUEST); + } + + @Override + public Page listDnsRecords(String zoneName, DnsRecordListOption... options) { + return listDnsRecords(zoneName, options(), optionMap(options), + DnsRecordPageFetcher.PB_TO_DNS_RECORD); + } + + @Override + public Zone create(final ZoneInfo zoneInfo, Dns.ZoneOption... options) { + final Map optionsMap = optionMap(options); + try { + com.google.api.services.dns.model.ManagedZone answer = runWithRetries( + new Callable() { + @Override + public com.google.api.services.dns.model.ManagedZone call() { + return dnsRpc.create(zoneInfo.toPb(), optionsMap); + } + }, options().retryParams(), EXCEPTION_HANDLER); + return answer == null ? null : Zone.fromPb(this, answer); + } catch (RetryHelper.RetryHelperException ex) { + throw DnsException.translateAndThrow(ex); + } + } + + @Override + public Zone getZone(final String zoneName, Dns.ZoneOption... options) { + final Map optionsMap = optionMap(options); + try { + com.google.api.services.dns.model.ManagedZone answer = runWithRetries( + new Callable() { + @Override + public com.google.api.services.dns.model.ManagedZone call() { + return dnsRpc.getZone(zoneName, optionsMap); + } + }, options().retryParams(), EXCEPTION_HANDLER); + return answer == null ? null : Zone.fromPb(this, answer); + } catch (RetryHelper.RetryHelperException ex) { + throw DnsException.translateAndThrow(ex); + } + } + + @Override + public boolean delete(final String zoneName) { + try { + return runWithRetries(new Callable() { + @Override + public Boolean call() { + return dnsRpc.deleteZone(zoneName); + } + }, options().retryParams(), EXCEPTION_HANDLER); + } catch (RetryHelper.RetryHelperException ex) { + throw DnsException.translateAndThrow(ex); + } + } + + @Override + public ProjectInfo getProject(Dns.ProjectOption... fields) { + final Map optionsMap = optionMap(fields); + try { + com.google.api.services.dns.model.Project answer = runWithRetries( + new Callable() { + @Override + public com.google.api.services.dns.model.Project call() { + return dnsRpc.getProject(optionsMap); + } + }, options().retryParams(), EXCEPTION_HANDLER); + return answer == null ? null : ProjectInfo.fromPb(answer); // should never be null + } catch (RetryHelper.RetryHelperException ex) { + throw DnsException.translateAndThrow(ex); + } + } + + @Override + public ChangeRequest applyChangeRequest(final String zoneName, final ChangeRequest changeRequest, + Dns.ChangeRequestOption... options) { + final Map optionsMap = optionMap(options); + try { + com.google.api.services.dns.model.Change answer = + runWithRetries( + new Callable() { + @Override + public com.google.api.services.dns.model.Change call() { + return dnsRpc.applyChangeRequest(zoneName, changeRequest.toPb(), optionsMap); + } + }, options().retryParams(), EXCEPTION_HANDLER); + return answer == null ? null : fromPb(answer); // should never be null + } catch (RetryHelper.RetryHelperException ex) { + throw DnsException.translateAndThrow(ex); + } + } + + @Override + public ChangeRequest getChangeRequest(final String zoneName, final String changeRequestId, + Dns.ChangeRequestOption... options) { + final Map optionsMap = optionMap(options); + try { + com.google.api.services.dns.model.Change answer = + runWithRetries( + new Callable() { + @Override + public com.google.api.services.dns.model.Change call() { + return dnsRpc.getChangeRequest(zoneName, changeRequestId, optionsMap); + } + }, options().retryParams(), EXCEPTION_HANDLER); + return answer == null ? null : fromPb(answer); // should never be null + } catch (RetryHelper.RetryHelperException ex) { + throw DnsException.translateAndThrow(ex); + } + } + + private Map optionMap(AbstractOption... options) { + Map temp = Maps.newEnumMap(DnsRpc.Option.class); + for (AbstractOption option : options) { + Object prev = temp.put(option.rpcOption(), option.value()); + checkArgument(prev == null, "Duplicate option %s", option); + } + return ImmutableMap.copyOf(temp); + } +} diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java index 248fd164a55f..1ce4425366e5 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java @@ -37,7 +37,7 @@ public static class DefaultDnsFactory implements DnsFactory { @Override public Dns create(DnsOptions options) { // TODO(mderka) Implement when DnsImpl is available. Created issue #595. - return null; + return new DnsImpl(options); } } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java new file mode 100644 index 000000000000..8e063c9bb096 --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java @@ -0,0 +1,370 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.api.services.dns.model.Change; +import com.google.api.services.dns.model.ManagedZone; +import com.google.api.services.dns.model.ResourceRecordSet; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.gcloud.Page; +import com.google.gcloud.RetryParams; +import com.google.gcloud.ServiceOptions; +import com.google.gcloud.spi.DnsRpc; +import com.google.gcloud.spi.DnsRpcFactory; + +import org.easymock.Capture; +import org.easymock.EasyMock; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.util.Map; + +public class DnsImplTest { + + // Dns entities + private static final String ZONE_NAME = "some zone name"; + private static final String DNS_NAME = "example.com."; + private static final String CHANGE_ID = "some change id"; + private static final DnsRecord DNS_RECORD1 = DnsRecord.builder("Something", DnsRecord.Type.AAAA) + .build(); + private static final DnsRecord DNS_RECORD2 = DnsRecord.builder("Different", DnsRecord.Type.AAAA) + .build(); + private static final Integer MAX_SIZE = 20; + private static final String PAGE_TOKEN = "some token"; + private static final ZoneInfo ZONE_INFO = ZoneInfo.builder(ZONE_NAME).build(); + private static final ProjectInfo PROJECT_INFO = ProjectInfo.builder().build(); + private static final ChangeRequest CHANGE_REQUEST_PARTIAL = ChangeRequest.builder() + .add(DNS_RECORD1) + .build(); + private static final ChangeRequest CHANGE_REQUEST_COMPLETE = ChangeRequest.builder() + .add(DNS_RECORD1) + .startTimeMillis(123L) + .status(ChangeRequest.Status.PENDING) + .id(CHANGE_ID) + .build(); + + // Result lists + private static final DnsRpc.ListResult LIST_RESULT_OF_PB_CHANGES = + DnsRpc.ListResult.of("cursor", ImmutableList.of(CHANGE_REQUEST_COMPLETE.toPb(), + CHANGE_REQUEST_PARTIAL.toPb())); + private static final DnsRpc.ListResult LIST_RESULT_OF_PB_ZONES = + DnsRpc.ListResult.of("cursor", ImmutableList.of(ZONE_INFO.toPb())); + private static final DnsRpc.ListResult LIST_OF_PB_DNS_RECORDS = + DnsRpc.ListResult.of("cursor", ImmutableList.of(DNS_RECORD1.toPb(), DNS_RECORD2.toPb())); + + // Field options + private static final Dns.ZoneOption ZONE_FIELDS = + Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME); + private static final Dns.ProjectOption PROJECT_FIELDS = + Dns.ProjectOption.fields(Dns.ProjectField.QUOTA); + private static final Dns.ChangeRequestOption CHANGE_GET_FIELDS = + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS); + + // Listing options + private static final Dns.ZoneListOption[] ZONE_LIST_OPTIONS = + {Dns.ZoneListOption.pageSize(MAX_SIZE), Dns.ZoneListOption.pageToken(PAGE_TOKEN), + Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION)}; + private static final Dns.ChangeRequestListOption[] CHANGE_LIST_OPTIONS = + {Dns.ChangeRequestListOption.pageSize(MAX_SIZE), + Dns.ChangeRequestListOption.pageToken(PAGE_TOKEN), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)}; + private static final Dns.DnsRecordListOption[] DNS_RECORD_LIST_OPTIONS = + {Dns.DnsRecordListOption.pageSize(MAX_SIZE), + Dns.DnsRecordListOption.pageToken(PAGE_TOKEN), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL), + Dns.DnsRecordListOption.dnsName(DNS_NAME), + Dns.DnsRecordListOption.type(DnsRecord.Type.AAAA)}; + + // Other + private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); + private static final ServiceOptions.Clock TIME_SOURCE = new ServiceOptions.Clock() { + @Override + public long millis() { + return 42000L; + } + }; + + private DnsOptions options; + private DnsRpcFactory rpcFactoryMock; + private DnsRpc dnsRpcMock; + private Dns dns; + + @Before + public void setUp() { + rpcFactoryMock = EasyMock.createMock(DnsRpcFactory.class); + dnsRpcMock = EasyMock.createMock(DnsRpc.class); + EasyMock.expect(rpcFactoryMock.create(EasyMock.anyObject(DnsOptions.class))) + .andReturn(dnsRpcMock); + EasyMock.replay(rpcFactoryMock); + options = DnsOptions.builder() + .projectId("projectId") + .clock(TIME_SOURCE) + .serviceRpcFactory(rpcFactoryMock) + .retryParams(RetryParams.noRetries()) + .build(); + } + + @After + public void tearDown() throws Exception { + EasyMock.verify(rpcFactoryMock); + } + + @Test + public void testCreateZone() { + EasyMock.expect(dnsRpcMock.create(ZONE_INFO.toPb(), EMPTY_RPC_OPTIONS)) + .andReturn(ZONE_INFO.toPb()); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + ZoneInfo zoneInfo = dns.create(ZONE_INFO); + assertEquals(ZONE_INFO, zoneInfo); + } + + @Test + public void testCreateZoneWithOptions() { + Capture> capturedOptions = Capture.newInstance(); + EasyMock.expect(dnsRpcMock.create(EasyMock.eq(ZONE_INFO.toPb()), + EasyMock.capture(capturedOptions))).andReturn(ZONE_INFO.toPb()); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + Zone zone = dns.create(ZONE_INFO, ZONE_FIELDS); + String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.rpcOption()); + assertEquals(ZONE_INFO, zone); + assertTrue(selector.contains(Dns.ZoneField.CREATION_TIME.selector())); + assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); + } + + @Test + public void testGetZone() { + EasyMock.expect(dnsRpcMock.getZone(ZONE_INFO.name(), EMPTY_RPC_OPTIONS)) + .andReturn(ZONE_INFO.toPb()); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + ZoneInfo zoneInfo = dns.getZone(ZONE_INFO.name()); + assertEquals(ZONE_INFO, zoneInfo); + } + + @Test + public void testGetZoneWithOptions() { + Capture> capturedOptions = Capture.newInstance(); + EasyMock.expect(dnsRpcMock.getZone(EasyMock.eq(ZONE_INFO.name()), + EasyMock.capture(capturedOptions))).andReturn(ZONE_INFO.toPb()); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + ZoneInfo zoneInfo = dns.getZone(ZONE_INFO.name(), ZONE_FIELDS); + String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.rpcOption()); + assertEquals(ZONE_INFO, zoneInfo); + assertTrue(selector.contains(Dns.ZoneField.CREATION_TIME.selector())); + assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); + } + + @Test + public void testDeleteZone() { + EasyMock.expect(dnsRpcMock.deleteZone(ZONE_INFO.name())) + .andReturn(true); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + assertTrue(dns.delete(ZONE_INFO.name())); + } + + @Test + public void testGetProject() { + EasyMock.expect(dnsRpcMock.getProject(EMPTY_RPC_OPTIONS)) + .andReturn(PROJECT_INFO.toPb()); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + ProjectInfo projectInfo = dns.getProject(); + assertEquals(PROJECT_INFO, projectInfo); + } + + @Test + public void testProjectGetWithOptions() { + Capture> capturedOptions = Capture.newInstance(); + EasyMock.expect(dnsRpcMock.getProject(EasyMock.capture(capturedOptions))) + .andReturn(PROJECT_INFO.toPb()); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + ProjectInfo projectInfo = dns.getProject(PROJECT_FIELDS); + String selector = (String) capturedOptions.getValue().get(PROJECT_FIELDS.rpcOption()); + assertEquals(PROJECT_INFO, projectInfo); + assertTrue(selector.contains(Dns.ProjectField.QUOTA.selector())); + assertTrue(selector.contains(Dns.ProjectField.PROJECT_ID.selector())); + } + + @Test + public void testGetChangeRequest() { + EasyMock.expect(dnsRpcMock.getChangeRequest(ZONE_INFO.name(), CHANGE_REQUEST_COMPLETE.id(), + EMPTY_RPC_OPTIONS)).andReturn(CHANGE_REQUEST_COMPLETE.toPb()); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + ChangeRequest changeRequest = dns.getChangeRequest(ZONE_INFO.name(), + CHANGE_REQUEST_COMPLETE.id()); + assertEquals(CHANGE_REQUEST_COMPLETE, changeRequest); + } + + @Test + public void testGetChangeRequestWithOptions() { + Capture> capturedOptions = Capture.newInstance(); + EasyMock.expect(dnsRpcMock.getChangeRequest(EasyMock.eq(ZONE_INFO.name()), + EasyMock.eq(CHANGE_REQUEST_COMPLETE.id()), EasyMock.capture(capturedOptions))) + .andReturn(CHANGE_REQUEST_COMPLETE.toPb()); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + ChangeRequest changeRequest = dns.getChangeRequest(ZONE_INFO.name(), + CHANGE_REQUEST_COMPLETE.id(), CHANGE_GET_FIELDS); + String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.rpcOption()); + assertEquals(CHANGE_REQUEST_COMPLETE, changeRequest); + assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); + assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); + } + + @Test + public void testApplyChangeRequest() { + EasyMock.expect(dnsRpcMock.applyChangeRequest(ZONE_INFO.name(), CHANGE_REQUEST_PARTIAL.toPb(), + EMPTY_RPC_OPTIONS)).andReturn(CHANGE_REQUEST_COMPLETE.toPb()); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + ChangeRequest changeRequest = dns.applyChangeRequest(ZONE_INFO.name(), + CHANGE_REQUEST_PARTIAL); + assertEquals(CHANGE_REQUEST_COMPLETE, changeRequest); + } + + @Test + public void testApplyChangeRequestWithOptions() { + Capture> capturedOptions = Capture.newInstance(); + EasyMock.expect(dnsRpcMock.applyChangeRequest(EasyMock.eq(ZONE_INFO.name()), + EasyMock.eq(CHANGE_REQUEST_PARTIAL.toPb()), EasyMock.capture(capturedOptions))) + .andReturn(CHANGE_REQUEST_COMPLETE.toPb()); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + ChangeRequest changeRequest = dns.applyChangeRequest(ZONE_INFO.name(), + CHANGE_REQUEST_PARTIAL, CHANGE_GET_FIELDS); + String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.rpcOption()); + assertEquals(CHANGE_REQUEST_COMPLETE, changeRequest); + assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); + assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); + } + + // lists + @Test + public void testListChangeRequests() { + EasyMock.expect(dnsRpcMock.listChangeRequests(ZONE_INFO.name(), EMPTY_RPC_OPTIONS)) + .andReturn(LIST_RESULT_OF_PB_CHANGES); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + Page changeRequestPage = dns.listChangeRequests(ZONE_INFO.name()); + assertTrue(Lists.newArrayList(changeRequestPage.values()).contains(CHANGE_REQUEST_COMPLETE)); + assertTrue(Lists.newArrayList(changeRequestPage.values()).contains(CHANGE_REQUEST_PARTIAL)); + assertEquals(2, Lists.newArrayList(changeRequestPage.values()).size()); + } + + @Test + public void testListChangeRequestsWithOptions() { + Capture> capturedOptions = Capture.newInstance(); + EasyMock.expect(dnsRpcMock.listChangeRequests(EasyMock.eq(ZONE_NAME), + EasyMock.capture(capturedOptions))).andReturn(LIST_RESULT_OF_PB_CHANGES); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + Page changeRequestPage = dns.listChangeRequests(ZONE_NAME, CHANGE_LIST_OPTIONS); + assertTrue(Lists.newArrayList(changeRequestPage.values()).contains(CHANGE_REQUEST_COMPLETE)); + assertTrue(Lists.newArrayList(changeRequestPage.values()).contains(CHANGE_REQUEST_PARTIAL)); + assertEquals(2, Lists.newArrayList(changeRequestPage.values()).size()); + Integer size = (Integer) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[0].rpcOption()); + assertEquals(MAX_SIZE, size); + String selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[1].rpcOption()); + assertEquals(PAGE_TOKEN, selector); + selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[2].rpcOption()); + assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); + assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); + selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[3].rpcOption()); + assertTrue(selector.contains(Dns.SortingOrder.ASCENDING.selector())); + } + + @Test + public void testListZones() { + EasyMock.expect(dnsRpcMock.listZones(EMPTY_RPC_OPTIONS)) + .andReturn(LIST_RESULT_OF_PB_ZONES); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + Page zonePage = dns.listZones(); + assertEquals(1, Lists.newArrayList(zonePage.values()).size()); + assertEquals(ZONE_INFO, Lists.newArrayList(zonePage.values()).get(0)); + } + + @Test + public void testListZonesWithOptions() { + Capture> capturedOptions = Capture.newInstance(); + EasyMock.expect(dnsRpcMock.listZones(EasyMock.capture(capturedOptions))) + .andReturn(LIST_RESULT_OF_PB_ZONES); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + Page zonePage = dns.listZones(ZONE_LIST_OPTIONS); + assertEquals(1, Lists.newArrayList(zonePage.values()).size()); + assertEquals(ZONE_INFO, Lists.newArrayList(zonePage.values()).get(0)); + Integer size = (Integer) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[0].rpcOption()); + assertEquals(MAX_SIZE, size); + String selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[1].rpcOption()); + assertEquals(PAGE_TOKEN, selector); + selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[2].rpcOption()); + assertTrue(selector.contains(Dns.ZoneField.DESCRIPTION.selector())); + assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); + } + + @Test + public void testListDnsRecords() { + EasyMock.expect(dnsRpcMock.listDnsRecords(ZONE_INFO.name(), EMPTY_RPC_OPTIONS)) + .andReturn(LIST_OF_PB_DNS_RECORDS); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + Page dnsPage = dns.listDnsRecords(ZONE_INFO.name()); + assertEquals(2, Lists.newArrayList(dnsPage.values()).size()); + assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD1)); + assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD2)); + } + + @Test + public void testListDnsRecordsWithOptions() { + Capture> capturedOptions = Capture.newInstance(); + EasyMock.expect(dnsRpcMock.listDnsRecords(EasyMock.eq(ZONE_NAME), + EasyMock.capture(capturedOptions))).andReturn(LIST_OF_PB_DNS_RECORDS); + EasyMock.replay(dnsRpcMock); + dns = options.service(); // creates DnsImpl + Page dnsPage = dns.listDnsRecords(ZONE_NAME, DNS_RECORD_LIST_OPTIONS); + assertEquals(2, Lists.newArrayList(dnsPage.values()).size()); + assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD1)); + assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD2)); + Integer size = (Integer) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[0].rpcOption()); + assertEquals(MAX_SIZE, size); + String selector = (String) capturedOptions.getValue() + .get(DNS_RECORD_LIST_OPTIONS[1].rpcOption()); + assertEquals(PAGE_TOKEN, selector); + selector = (String) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[2].rpcOption()); + assertTrue(selector.contains(Dns.DnsRecordField.NAME.selector())); + assertTrue(selector.contains(Dns.DnsRecordField.TTL.selector())); + selector = (String) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[3].rpcOption()); + assertEquals(DNS_RECORD_LIST_OPTIONS[3].value(), selector); + DnsRecord.Type type = (DnsRecord.Type) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[4] + .rpcOption()); + assertEquals(DNS_RECORD_LIST_OPTIONS[4].value(), type); + } +} From c0c5451d286675248e32fdf3a37c7c9293cd3f4a Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 8 Feb 2016 11:34:41 -0800 Subject: [PATCH 047/203] Included options attribute to Zone. Fixed symmetry of toPb and fromPb. Finished DnsOptions. Fixed #595. --- .../java/com/google/gcloud/dns/DnsImpl.java | 44 +++++++++---------- .../com/google/gcloud/dns/DnsOptions.java | 4 +- .../main/java/com/google/gcloud/dns/Zone.java | 17 +++++-- .../java/com/google/gcloud/dns/ZoneInfo.java | 19 ++++---- .../com/google/gcloud/dns/DnsImplTest.java | 18 ++++---- .../java/com/google/gcloud/dns/ZoneTest.java | 24 +++++++++- 6 files changed, 79 insertions(+), 47 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java index b3ae73fd7e93..c93409554dd8 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java @@ -120,6 +120,11 @@ public Page nextPage() { } } + @Override + public Page listZones(ZoneListOption... options) { + return listZones(options(), optionMap(options)); + } + private static Page listZones(final DnsOptions serviceOptions, final Map optionsMap) { // define transformation function @@ -151,9 +156,16 @@ public DnsRpc.ListResult call() { } } + @Override + public Page listChangeRequests(String zoneName, + ChangeRequestListOption... options) { + return listChangeRequests(zoneName, options(), optionMap(options), + ChangeRequestPageFetcher.PB_TO_CHANGE_REQUEST); + } + private static Page listChangeRequests(final String zoneName, final DnsOptions serviceOptions, final Map optionsMap, - Function TRANSFORM_FUNCTION) { + Function transformFunction) { try { // get a list of changes DnsRpc.ListResult result = runWithRetries(new Callable>() { @@ -166,7 +178,7 @@ public DnsRpc.ListResult call() { // transform that list into change request objects Iterable changes = result.results() == null ? ImmutableList.of() - : Iterables.transform(result.results(), TRANSFORM_FUNCTION); + : Iterables.transform(result.results(), transformFunction); return new PageImpl<>(new ChangeRequestPageFetcher(zoneName, serviceOptions, cursor, optionsMap), cursor, changes); } catch (RetryHelperException e) { @@ -174,9 +186,15 @@ public DnsRpc.ListResult call() { } } + @Override + public Page listDnsRecords(String zoneName, DnsRecordListOption... options) { + return listDnsRecords(zoneName, options(), optionMap(options), + DnsRecordPageFetcher.PB_TO_DNS_RECORD); + } + private static Page listDnsRecords(final String zoneName, final DnsOptions serviceOptions, final Map optionsMap, - Function TRANSFORM_FUNCTION) { + Function transformFunction) { try { // get a list of resource record sets DnsRpc.ListResult result = runWithRetries( @@ -190,7 +208,7 @@ public DnsRpc.ListResult call() { // transform that list into dns records Iterable records = result.results() == null ? ImmutableList.of() - : Iterables.transform(result.results(), TRANSFORM_FUNCTION); + : Iterables.transform(result.results(), transformFunction); return new PageImpl<>(new DnsRecordPageFetcher(zoneName, serviceOptions, cursor, optionsMap), cursor, records); } catch (RetryHelperException e) { @@ -203,24 +221,6 @@ public DnsRpc.ListResult call() { dnsRpc = options.rpc(); } - @Override - public Page listZones(ZoneListOption... options) { - return listZones(options(), optionMap(options)); - } - - @Override - public Page listChangeRequests(String zoneName, - ChangeRequestListOption... options) { - return listChangeRequests(zoneName, options(), optionMap(options), - ChangeRequestPageFetcher.PB_TO_CHANGE_REQUEST); - } - - @Override - public Page listDnsRecords(String zoneName, DnsRecordListOption... options) { - return listDnsRecords(zoneName, options(), optionMap(options), - DnsRecordPageFetcher.PB_TO_DNS_RECORD); - } - @Override public Zone create(final ZoneInfo zoneInfo, Dns.ZoneOption... options) { final Map optionsMap = optionMap(options); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java index 1ce4425366e5..b47532146b3a 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java @@ -24,8 +24,7 @@ import java.util.Set; -public class DnsOptions - extends ServiceOptions { +public class DnsOptions extends ServiceOptions { private static final long serialVersionUID = -519128051411747771L; private static final String GC_DNS_RW = "https://www.googleapis.com/auth/ndev.clouddns.readwrite"; @@ -36,7 +35,6 @@ public static class DefaultDnsFactory implements DnsFactory { @Override public Dns create(DnsOptions options) { - // TODO(mderka) Implement when DnsImpl is available. Created issue #595. return new DnsImpl(options); } } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index 2da67a8e9a01..d53909b0f084 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -20,6 +20,8 @@ import com.google.gcloud.Page; +import java.io.IOException; +import java.io.ObjectInputStream; import java.util.List; import java.util.Objects; @@ -36,7 +38,8 @@ */ public class Zone extends ZoneInfo { - private static final long serialVersionUID = 564454483894599281L; + private static final long serialVersionUID = -5817771337847861598L; + private final DnsOptions options; private transient Dns dns; /** @@ -102,6 +105,7 @@ public Zone build() { Zone(Dns dns, ZoneInfo.BuilderImpl infoBuilder) { super(infoBuilder); this.dns = dns; + this.options = dns.options(); } @Override @@ -115,6 +119,7 @@ public Builder toBuilder() { public Zone(Dns dns, ZoneInfo zoneInfo) { super(new BuilderImpl(zoneInfo)); this.dns = dns; + this.options = dns.options(); } /** @@ -215,12 +220,18 @@ public Dns dns() { @Override public boolean equals(Object obj) { - return obj instanceof Zone && Objects.equals(toPb(), ((Zone) obj).toPb()); + return obj instanceof Zone && Objects.equals(toPb(), ((Zone) obj).toPb()) + && Objects.equals(options, ((Zone) obj).options); } @Override public int hashCode() { - return super.hashCode(); + return Objects.hash(super.hashCode(), options); + } + + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + this.dns = options.service(); } static Zone fromPb(Dns dns, com.google.api.services.dns.model.ManagedZone zone) { diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java index e397e37a7fbf..e26dcde70a83 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java @@ -27,7 +27,6 @@ import java.io.Serializable; import java.math.BigInteger; -import java.util.LinkedList; import java.util.List; import java.util.Objects; @@ -97,14 +96,14 @@ public abstract static class Builder { public abstract ZoneInfo build(); } - public static class BuilderImpl extends Builder { + static class BuilderImpl extends Builder { private String name; private String id; private Long creationTimeMillis; private String dnsName; private String description; private String nameServerSet; - private List nameServers = new LinkedList<>(); + private List nameServers; private BuilderImpl(String name) { this.name = checkNotNull(name); @@ -120,7 +119,9 @@ private BuilderImpl(String name) { this.dnsName = info.dnsName; this.description = info.description; this.nameServerSet = info.nameServerSet; - this.nameServers.addAll(info.nameServers); + if (info.nameServers != null) { + this.nameServers = ImmutableList.copyOf(info.nameServers); + } } @Override @@ -179,7 +180,8 @@ public ZoneInfo build() { this.dnsName = builder.dnsName; this.description = builder.description; this.nameServerSet = builder.nameServerSet; - this.nameServers = ImmutableList.copyOf(builder.nameServers); + this.nameServers = builder.nameServers == null + ? null : ImmutableList.copyOf(builder.nameServers); } /** @@ -236,7 +238,7 @@ public String nameServerSet() { * The nameservers that the zone should be delegated to. This is defined by the Google DNS cloud. */ public List nameServers() { - return nameServers; + return nameServers == null ? ImmutableList.of() : nameServers; } /** @@ -255,7 +257,7 @@ com.google.api.services.dns.model.ManagedZone toPb() { pb.setId(new BigInteger(this.id())); } pb.setName(this.name()); - pb.setNameServers(this.nameServers()); + pb.setNameServers(this.nameServers); // do use real attribute value which may be null pb.setNameServerSet(this.nameServerSet()); if (this.creationTimeMillis() != null) { pb.setCreationTime(ISODateTimeFormat.dateTime() @@ -290,7 +292,8 @@ static ZoneInfo fromPb(com.google.api.services.dns.model.ManagedZone pb) { @Override public boolean equals(Object obj) { - return obj instanceof ZoneInfo && Objects.equals(toPb(), ((ZoneInfo) obj).toPb()); + return obj != null && obj.getClass().equals(ZoneInfo.class) + && Objects.equals(toPb(), ((ZoneInfo) obj).toPb()); } @Override diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java index 8e063c9bb096..62e96b05dda5 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java @@ -136,8 +136,8 @@ public void testCreateZone() { .andReturn(ZONE_INFO.toPb()); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - ZoneInfo zoneInfo = dns.create(ZONE_INFO); - assertEquals(ZONE_INFO, zoneInfo); + Zone zone = dns.create(ZONE_INFO); + assertEquals(new Zone(dns, ZONE_INFO), zone); } @Test @@ -149,7 +149,7 @@ public void testCreateZoneWithOptions() { dns = options.service(); // creates DnsImpl Zone zone = dns.create(ZONE_INFO, ZONE_FIELDS); String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.rpcOption()); - assertEquals(ZONE_INFO, zone); + assertEquals(new Zone(dns, ZONE_INFO), zone); assertTrue(selector.contains(Dns.ZoneField.CREATION_TIME.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); } @@ -160,8 +160,8 @@ public void testGetZone() { .andReturn(ZONE_INFO.toPb()); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - ZoneInfo zoneInfo = dns.getZone(ZONE_INFO.name()); - assertEquals(ZONE_INFO, zoneInfo); + Zone zone = dns.getZone(ZONE_INFO.name()); + assertEquals(new Zone(dns, ZONE_INFO), zone); } @Test @@ -171,9 +171,9 @@ public void testGetZoneWithOptions() { EasyMock.capture(capturedOptions))).andReturn(ZONE_INFO.toPb()); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - ZoneInfo zoneInfo = dns.getZone(ZONE_INFO.name(), ZONE_FIELDS); + Zone zone = dns.getZone(ZONE_INFO.name(), ZONE_FIELDS); String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.rpcOption()); - assertEquals(ZONE_INFO, zoneInfo); + assertEquals(new Zone(dns, ZONE_INFO), zone); assertTrue(selector.contains(Dns.ZoneField.CREATION_TIME.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); } @@ -308,7 +308,7 @@ public void testListZones() { dns = options.service(); // creates DnsImpl Page zonePage = dns.listZones(); assertEquals(1, Lists.newArrayList(zonePage.values()).size()); - assertEquals(ZONE_INFO, Lists.newArrayList(zonePage.values()).get(0)); + assertEquals(new Zone(dns, ZONE_INFO), Lists.newArrayList(zonePage.values()).get(0)); } @Test @@ -320,7 +320,7 @@ public void testListZonesWithOptions() { dns = options.service(); // creates DnsImpl Page zonePage = dns.listZones(ZONE_LIST_OPTIONS); assertEquals(1, Lists.newArrayList(zonePage.values()).size()); - assertEquals(ZONE_INFO, Lists.newArrayList(zonePage.values()).get(0)); + assertEquals(new Zone(dns, ZONE_INFO), Lists.newArrayList(zonePage.values()).get(0)); Integer size = (Integer) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[0].rpcOption()); assertEquals(MAX_SIZE, size); String selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[1].rpcOption()); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index 1b09dca715a4..b28847a4e046 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -19,6 +19,7 @@ import static org.easymock.EasyMock.createStrictMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.reset; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -64,16 +65,22 @@ public class ZoneTest { .startTimeMillis(123465L).build(); private static final ChangeRequest CHANGE_REQUEST_NO_ID = ChangeRequest.builder().build(); private static final DnsException EXCEPTION = createStrictMock(DnsException.class); + private static final DnsOptions OPTIONS = createStrictMock(DnsOptions.class); private Dns dns; private Zone zone; private Zone zoneNoId; + @Before public void setUp() throws Exception { dns = createStrictMock(Dns.class); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + replay(dns); zone = new Zone(dns, ZONE_INFO); zoneNoId = new Zone(dns, NO_ID_INFO); + reset(dns); } @After @@ -347,13 +354,13 @@ public void getChangeAndZoneNotFoundByName() { .andThrow(EXCEPTION); replay(dns); try { - ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); + zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected } try { - ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id()); + zone.getChangeRequest(CHANGE_REQUEST.id()); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected @@ -505,18 +512,31 @@ public void listChangeRequestsAndZoneNotFound() { @Test public void testFromPb() { + expect(dns.options()).andReturn(OPTIONS); replay(dns); assertEquals(Zone.fromPb(dns, zone.toPb()), zone); } @Test public void testEqualsAndToBuilder() { + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); replay(dns); assertEquals(zone, zone.toBuilder().build()); + assertEquals(zone.hashCode(), zone.toBuilder().build().hashCode()); } @Test public void testBuilder() { + // one for each build() call because it invokes a constructor + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); replay(dns); assertNotEquals(zone, zone.toBuilder() .id((new BigInteger(zone.id())).add(BigInteger.ONE).toString()) From ee5bb8f1db07dd6a3fb125c16acfd27f8e0c7325 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 8 Feb 2016 16:35:07 -0800 Subject: [PATCH 048/203] Removed zone.get() and optimized retries. --- .../com/google/gcloud/dns/ChangeRequest.java | 27 +++----- .../main/java/com/google/gcloud/dns/Dns.java | 2 +- .../java/com/google/gcloud/dns/DnsImpl.java | 61 +++++++------------ .../java/com/google/gcloud/dns/DnsRecord.java | 18 +++++- .../main/java/com/google/gcloud/dns/Zone.java | 26 +------- .../java/com/google/gcloud/dns/ZoneInfo.java | 2 +- .../com/google/gcloud/dns/DnsImplTest.java | 42 +++++++------ .../java/com/google/gcloud/dns/ZoneTest.java | 28 +-------- 8 files changed, 77 insertions(+), 129 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java index 582dd2b2e05b..76d231b704c4 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java @@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkNotNull; -import com.google.api.services.dns.model.ResourceRecordSet; +import com.google.api.services.dns.model.Change; import com.google.common.base.Function; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; @@ -40,21 +40,14 @@ */ public class ChangeRequest implements Serializable { - private static final Function FROM_PB_FUNCTION = - new Function() { + static final Function FROM_PB_FUNCTION = + new Function() { @Override - public DnsRecord apply(com.google.api.services.dns.model.ResourceRecordSet pb) { - return DnsRecord.fromPb(pb); + public ChangeRequest apply(com.google.api.services.dns.model.Change pb) { + return ChangeRequest.fromPb(pb); } }; - private static final Function TO_PB_FUNCTION = - new Function() { - @Override - public com.google.api.services.dns.model.ResourceRecordSet apply(DnsRecord error) { - return error.toPb(); - } - }; - private static final long serialVersionUID = -8703939628990291682L; + private static final long serialVersionUID = -9027378042756366333L; private final List additions; private final List deletions; private final String id; @@ -274,9 +267,9 @@ com.google.api.services.dns.model.Change toPb() { pb.setStatus(status().name().toLowerCase()); } // set a list of additions - pb.setAdditions(Lists.transform(additions(), TO_PB_FUNCTION)); + pb.setAdditions(Lists.transform(additions(), DnsRecord.TO_PB_FUNCTION)); // set a list of deletions - pb.setDeletions(Lists.transform(deletions(), TO_PB_FUNCTION)); + pb.setDeletions(Lists.transform(deletions(), DnsRecord.TO_PB_FUNCTION)); return pb; } @@ -293,10 +286,10 @@ static ChangeRequest fromPb(com.google.api.services.dns.model.Change pb) { builder.status(ChangeRequest.Status.valueOf(pb.getStatus().toUpperCase())); } if (pb.getDeletions() != null) { - builder.deletions(Lists.transform(pb.getDeletions(), FROM_PB_FUNCTION)); + builder.deletions(Lists.transform(pb.getDeletions(), DnsRecord.FROM_PB_FUNCTION)); } if (pb.getAdditions() != null) { - builder.additions(Lists.transform(pb.getAdditions(), FROM_PB_FUNCTION)); + builder.additions(Lists.transform(pb.getAdditions(), DnsRecord.FROM_PB_FUNCTION)); } return builder.build(); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 88e0d7a08591..e724e1cbf1ad 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -419,7 +419,7 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { /** * Creates a new zone. * - *

Returns {@link ZoneInfo} object representing the new zone's information. In addition to the + *

Returns {@link Zone} object representing the new zone's information. In addition to the * name, dns name and description (supplied by the user within the {@code zoneInfo} parameter), * the returned object can include the following read-only fields supplied by the server: creation * time, id, and list of name servers. The returned fields can be optionally restricted by diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java index c93409554dd8..17521c13c625 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java @@ -66,14 +66,7 @@ public Page nextPage() { private static class ChangeRequestPageFetcher implements PageImpl.NextPageFetcher { - private static final Function PB_TO_CHANGE_REQUEST = - new Function() { - @Override - public ChangeRequest apply(com.google.api.services.dns.model.Change changePb) { - return fromPb(changePb); - } - }; - private static final long serialVersionUID = -8737501076674042014L; + private static final long serialVersionUID = 4473265130673029139L; private final String zoneName; private final Map requestOptions; private final DnsOptions serviceOptions; @@ -88,20 +81,13 @@ public ChangeRequest apply(com.google.api.services.dns.model.Change changePb) { @Override public Page nextPage() { - return listChangeRequests(zoneName, serviceOptions, requestOptions, PB_TO_CHANGE_REQUEST); + return listChangeRequests(zoneName, serviceOptions, requestOptions); } } private static class DnsRecordPageFetcher implements PageImpl.NextPageFetcher { - private static final Function PB_TO_DNS_RECORD = - new Function() { - @Override - public DnsRecord apply(com.google.api.services.dns.model.ResourceRecordSet pb) { - return DnsRecord.fromPb(pb); - } - }; - private static final long serialVersionUID = 670996349097667660L; + private static final long serialVersionUID = -6039369212511530846L; private final Map requestOptions; private final DnsOptions serviceOptions; private final String zoneName; @@ -116,10 +102,15 @@ public DnsRecord apply(com.google.api.services.dns.model.ResourceRecordSet pb) { @Override public Page nextPage() { - return listDnsRecords(zoneName, serviceOptions, requestOptions, PB_TO_DNS_RECORD); + return listDnsRecords(zoneName, serviceOptions, requestOptions); } } + DnsImpl(DnsOptions options) { + super(options); + dnsRpc = options.rpc(); + } + @Override public Page listZones(ZoneListOption... options) { return listZones(options(), optionMap(options)); @@ -133,16 +124,17 @@ private static Page listZones(final DnsOptions serviceOptions, @Override public Zone apply( com.google.api.services.dns.model.ManagedZone zonePb) { - return new Zone(serviceOptions.service(), ZoneInfo.fromPb(zonePb)); + return Zone.fromPb(serviceOptions.service(), zonePb); } }; try { // get a list of managed zones + final DnsRpc rpc = serviceOptions.rpc(); DnsRpc.ListResult result = runWithRetries(new Callable>() { @Override public DnsRpc.ListResult call() { - return serviceOptions.rpc().listZones(optionsMap); + return rpc.listZones(optionsMap); } }, serviceOptions.retryParams(), EXCEPTION_HANDLER); String cursor = result.pageToken(); @@ -159,26 +151,25 @@ public DnsRpc.ListResult call() { @Override public Page listChangeRequests(String zoneName, ChangeRequestListOption... options) { - return listChangeRequests(zoneName, options(), optionMap(options), - ChangeRequestPageFetcher.PB_TO_CHANGE_REQUEST); + return listChangeRequests(zoneName, options(), optionMap(options)); } private static Page listChangeRequests(final String zoneName, - final DnsOptions serviceOptions, final Map optionsMap, - Function transformFunction) { + final DnsOptions serviceOptions, final Map optionsMap) { try { // get a list of changes + final DnsRpc rpc = serviceOptions.rpc(); DnsRpc.ListResult result = runWithRetries(new Callable>() { @Override public DnsRpc.ListResult call() { - return serviceOptions.rpc().listChangeRequests(zoneName, optionsMap); + return rpc.listChangeRequests(zoneName, optionsMap); } }, serviceOptions.retryParams(), EXCEPTION_HANDLER); String cursor = result.pageToken(); // transform that list into change request objects Iterable changes = result.results() == null ? ImmutableList.of() - : Iterables.transform(result.results(), transformFunction); + : Iterables.transform(result.results(), ChangeRequest.FROM_PB_FUNCTION); return new PageImpl<>(new ChangeRequestPageFetcher(zoneName, serviceOptions, cursor, optionsMap), cursor, changes); } catch (RetryHelperException e) { @@ -188,27 +179,26 @@ public DnsRpc.ListResult call() { @Override public Page listDnsRecords(String zoneName, DnsRecordListOption... options) { - return listDnsRecords(zoneName, options(), optionMap(options), - DnsRecordPageFetcher.PB_TO_DNS_RECORD); + return listDnsRecords(zoneName, options(), optionMap(options)); } private static Page listDnsRecords(final String zoneName, - final DnsOptions serviceOptions, final Map optionsMap, - Function transformFunction) { + final DnsOptions serviceOptions, final Map optionsMap) { try { // get a list of resource record sets + final DnsRpc rpc = serviceOptions.rpc(); DnsRpc.ListResult result = runWithRetries( new Callable>() { @Override public DnsRpc.ListResult call() { - return serviceOptions.rpc().listDnsRecords(zoneName, optionsMap); + return rpc.listDnsRecords(zoneName, optionsMap); } }, serviceOptions.retryParams(), EXCEPTION_HANDLER); String cursor = result.pageToken(); // transform that list into dns records Iterable records = result.results() == null ? ImmutableList.of() - : Iterables.transform(result.results(), transformFunction); + : Iterables.transform(result.results(), DnsRecord.FROM_PB_FUNCTION); return new PageImpl<>(new DnsRecordPageFetcher(zoneName, serviceOptions, cursor, optionsMap), cursor, records); } catch (RetryHelperException e) { @@ -216,11 +206,6 @@ public DnsRpc.ListResult call() { } } - DnsImpl(DnsOptions options) { - super(options); - dnsRpc = options.rpc(); - } - @Override public Zone create(final ZoneInfo zoneInfo, Dns.ZoneOption... options) { final Map optionsMap = optionMap(options); @@ -318,7 +303,7 @@ public com.google.api.services.dns.model.Change call() { return dnsRpc.getChangeRequest(zoneName, changeRequestId, optionsMap); } }, options().retryParams(), EXCEPTION_HANDLER); - return answer == null ? null : fromPb(answer); // should never be null + return answer == null ? null : fromPb(answer); } catch (RetryHelper.RetryHelperException ex) { throw DnsException.translateAndThrow(ex); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java index 99ca20386419..c4e710bd0365 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java @@ -19,6 +19,8 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import com.google.api.services.dns.model.ResourceRecordSet; +import com.google.common.base.Function; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -43,7 +45,21 @@ */ public class DnsRecord implements Serializable { - private static final long serialVersionUID = 2016011914302204L; + static final Function FROM_PB_FUNCTION = + new Function() { + @Override + public DnsRecord apply(com.google.api.services.dns.model.ResourceRecordSet pb) { + return DnsRecord.fromPb(pb); + } + }; + static final Function TO_PB_FUNCTION = + new Function() { + @Override + public com.google.api.services.dns.model.ResourceRecordSet apply(DnsRecord error) { + return error.toPb(); + } + }; + private static final long serialVersionUID = 8148009870800115261L; private final String name; private final List rrdatas; private final Integer ttl; // this is in seconds diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index d53909b0f084..323b0eb8c439 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -113,30 +113,6 @@ public Builder toBuilder() { return new Builder(this); } - /** - * Constructs a {@code Zone} object that contains the given {@code zoneInfo}. - */ - public Zone(Dns dns, ZoneInfo zoneInfo) { - super(new BuilderImpl(zoneInfo)); - this.dns = dns; - this.options = dns.options(); - } - - /** - * Constructs a {@code Zone} object that contains meta information received from the Google Cloud - * DNS service for the provided {@code zoneName}. - * - * @param zoneName name of the zone to be searched for - * @param options optional restriction on what fields should be returned by the service - * @return zone object containing metadata or {@code null} if not not found - * @throws DnsException upon failure - */ - public static Zone get(Dns dnsService, String zoneName, Dns.ZoneOption... options) { - checkNotNull(zoneName); - checkNotNull(dnsService); - return dnsService.getZone(zoneName, options); - } - /** * Retrieves the latest information about the zone. The method retrieves the zone by name. * @@ -236,6 +212,6 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE static Zone fromPb(Dns dns, com.google.api.services.dns.model.ManagedZone zone) { ZoneInfo info = ZoneInfo.fromPb(zone); - return new Zone(dns, info); + return new Zone(dns, new ZoneInfo.BuilderImpl(info)); } } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java index e26dcde70a83..f02f9f2c5226 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java @@ -81,7 +81,7 @@ public abstract static class Builder { * Optionally specifies the NameServerSet for this zone. A NameServerSet is a set of DNS name * servers that all host the same zones. Most users will not need to specify this value. */ - public abstract Builder nameServerSet(String nameServerSet); + abstract Builder nameServerSet(String nameServerSet); // todo(mderka) add more to the doc when questions are answered by the service owner /** diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java index 62e96b05dda5..726a455418d8 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java @@ -81,20 +81,20 @@ public class DnsImplTest { Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS); // Listing options - private static final Dns.ZoneListOption[] ZONE_LIST_OPTIONS = - {Dns.ZoneListOption.pageSize(MAX_SIZE), Dns.ZoneListOption.pageToken(PAGE_TOKEN), - Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION)}; - private static final Dns.ChangeRequestListOption[] CHANGE_LIST_OPTIONS = - {Dns.ChangeRequestListOption.pageSize(MAX_SIZE), - Dns.ChangeRequestListOption.pageToken(PAGE_TOKEN), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)}; - private static final Dns.DnsRecordListOption[] DNS_RECORD_LIST_OPTIONS = - {Dns.DnsRecordListOption.pageSize(MAX_SIZE), - Dns.DnsRecordListOption.pageToken(PAGE_TOKEN), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL), - Dns.DnsRecordListOption.dnsName(DNS_NAME), - Dns.DnsRecordListOption.type(DnsRecord.Type.AAAA)}; + private static final Dns.ZoneListOption[] ZONE_LIST_OPTIONS = { + Dns.ZoneListOption.pageSize(MAX_SIZE), Dns.ZoneListOption.pageToken(PAGE_TOKEN), + Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION)}; + private static final Dns.ChangeRequestListOption[] CHANGE_LIST_OPTIONS = { + Dns.ChangeRequestListOption.pageSize(MAX_SIZE), + Dns.ChangeRequestListOption.pageToken(PAGE_TOKEN), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)}; + private static final Dns.DnsRecordListOption[] DNS_RECORD_LIST_OPTIONS = { + Dns.DnsRecordListOption.pageSize(MAX_SIZE), + Dns.DnsRecordListOption.pageToken(PAGE_TOKEN), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL), + Dns.DnsRecordListOption.dnsName(DNS_NAME), + Dns.DnsRecordListOption.type(DnsRecord.Type.AAAA)}; // Other private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); @@ -137,7 +137,7 @@ public void testCreateZone() { EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl Zone zone = dns.create(ZONE_INFO); - assertEquals(new Zone(dns, ZONE_INFO), zone); + assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), zone); } @Test @@ -149,7 +149,7 @@ public void testCreateZoneWithOptions() { dns = options.service(); // creates DnsImpl Zone zone = dns.create(ZONE_INFO, ZONE_FIELDS); String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.rpcOption()); - assertEquals(new Zone(dns, ZONE_INFO), zone); + assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), zone); assertTrue(selector.contains(Dns.ZoneField.CREATION_TIME.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); } @@ -161,7 +161,7 @@ public void testGetZone() { EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl Zone zone = dns.getZone(ZONE_INFO.name()); - assertEquals(new Zone(dns, ZONE_INFO), zone); + assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), zone); } @Test @@ -173,7 +173,7 @@ public void testGetZoneWithOptions() { dns = options.service(); // creates DnsImpl Zone zone = dns.getZone(ZONE_INFO.name(), ZONE_FIELDS); String selector = (String) capturedOptions.getValue().get(ZONE_FIELDS.rpcOption()); - assertEquals(new Zone(dns, ZONE_INFO), zone); + assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), zone); assertTrue(selector.contains(Dns.ZoneField.CREATION_TIME.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); } @@ -308,7 +308,8 @@ public void testListZones() { dns = options.service(); // creates DnsImpl Page zonePage = dns.listZones(); assertEquals(1, Lists.newArrayList(zonePage.values()).size()); - assertEquals(new Zone(dns, ZONE_INFO), Lists.newArrayList(zonePage.values()).get(0)); + assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), + Lists.newArrayList(zonePage.values()).get(0)); } @Test @@ -320,7 +321,8 @@ public void testListZonesWithOptions() { dns = options.service(); // creates DnsImpl Page zonePage = dns.listZones(ZONE_LIST_OPTIONS); assertEquals(1, Lists.newArrayList(zonePage.values()).size()); - assertEquals(new Zone(dns, ZONE_INFO), Lists.newArrayList(zonePage.values()).get(0)); + assertEquals(new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)), + Lists.newArrayList(zonePage.values()).get(0)); Integer size = (Integer) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[0].rpcOption()); assertEquals(MAX_SIZE, size); String selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[1].rpcOption()); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index b28847a4e046..5164dfb6001c 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -78,8 +78,8 @@ public void setUp() throws Exception { expect(dns.options()).andReturn(OPTIONS); expect(dns.options()).andReturn(OPTIONS); replay(dns); - zone = new Zone(dns, ZONE_INFO); - zoneNoId = new Zone(dns, NO_ID_INFO); + zone = new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)); + zoneNoId = new Zone(dns, new ZoneInfo.BuilderImpl(NO_ID_INFO)); reset(dns); } @@ -96,30 +96,6 @@ public void testConstructor() { assertEquals(dns, zone.dns()); } - @Test - public void testGetByName() { - expect(dns.getZone(ZONE_NAME)).andReturn(zone); - expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zone); // for options - replay(dns); - Zone retrieved = Zone.get(dns, ZONE_NAME); - assertSame(dns, retrieved.dns()); - assertEquals(zone, retrieved); - // test passing options - Zone.get(dns, ZONE_NAME, ZONE_FIELD_OPTIONS); - try { - Zone.get(dns, null); - fail("Cannot get by null name."); - } catch (NullPointerException e) { - // expected - } - try { - Zone.get(null, "Not null"); - fail("Cannot get anything from null service."); - } catch (NullPointerException e) { - // expected - } - } - @Test public void deleteByNameAndFound() { expect(dns.delete(ZONE_NAME)).andReturn(true); From db52e09aaae1101fb80e9e6abcfb55233b1ed57b Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 9 Feb 2016 08:37:41 -0800 Subject: [PATCH 049/203] Made nameServerSet read only and setters package private. Adds dnsName filter for Zone listing and tests. Adds serialization test. Fixes #630, #602 and #631. --- .../main/java/com/google/gcloud/dns/Dns.java | 8 ++ .../com/google/gcloud/dns/DnsOptions.java | 10 ++ .../main/java/com/google/gcloud/dns/Zone.java | 2 +- .../java/com/google/gcloud/dns/ZoneInfo.java | 8 +- .../com/google/gcloud/dns/DnsImplTest.java | 5 +- .../java/com/google/gcloud/dns/DnsTest.java | 5 + .../google/gcloud/dns/SerializationTest.java | 118 ++++++++++++++++++ 7 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index e724e1cbf1ad..3ad2094ec2e3 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -295,6 +295,14 @@ public static ZoneListOption pageToken(String pageToken) { return new ZoneListOption(DnsRpc.Option.PAGE_TOKEN, pageToken); } + /** + * Restricts the list to only zone with this fully qualified domain name. + */ + public static ZoneListOption dnsName(String dnsName) { + StringBuilder builder = new StringBuilder(); + return new ZoneListOption(DnsRpc.Option.DNS_NAME, dnsName); + } + /** * The maximum number of zones to return per RPC. * diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java index b47532146b3a..d9317546cea0 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java @@ -95,4 +95,14 @@ public Builder toBuilder() { public static Builder builder() { return new Builder(); } + + @Override + public boolean equals(Object obj) { + return obj instanceof DnsOptions && baseEquals((DnsOptions) obj); + } + + @Override + public int hashCode() { + return baseHashCode(); + } } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index 323b0eb8c439..41507647543a 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -85,7 +85,7 @@ public Builder description(String description) { } @Override - public Builder nameServerSet(String nameServerSet) { + Builder nameServerSet(String nameServerSet) { infoBuilder.nameServerSet(nameServerSet); return this; } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java index f02f9f2c5226..7dffbcdd365c 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java @@ -82,7 +82,7 @@ public abstract static class Builder { * servers that all host the same zones. Most users will not need to specify this value. */ abstract Builder nameServerSet(String nameServerSet); - // todo(mderka) add more to the doc when questions are answered by the service owner + // this should not be included in tooling as per the service owners /** * Sets a list of servers that hold the information about the zone. This information is provided @@ -155,7 +155,7 @@ public Builder description(String description) { } @Override - public Builder nameServerSet(String nameServerSet) { + Builder nameServerSet(String nameServerSet) { this.nameServerSet = checkNotNull(nameServerSet); return this; } @@ -227,10 +227,10 @@ public String description() { } /** - * Returns the optionally specified set of DNS name servers that all host this zone. + * Returns the optionally specified set of DNS name servers that all host this zone. This value is + * set only for specific use cases and is left empty for vast majority of users. */ public String nameServerSet() { - // todo(mderka) update this doc after finding out more about this from the service owners return nameServerSet; } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java index 726a455418d8..89ad90f27654 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java @@ -83,7 +83,8 @@ public class DnsImplTest { // Listing options private static final Dns.ZoneListOption[] ZONE_LIST_OPTIONS = { Dns.ZoneListOption.pageSize(MAX_SIZE), Dns.ZoneListOption.pageToken(PAGE_TOKEN), - Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION)}; + Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION), + Dns.ZoneListOption.dnsName(DNS_NAME)}; private static final Dns.ChangeRequestListOption[] CHANGE_LIST_OPTIONS = { Dns.ChangeRequestListOption.pageSize(MAX_SIZE), Dns.ChangeRequestListOption.pageToken(PAGE_TOKEN), @@ -330,6 +331,8 @@ public void testListZonesWithOptions() { selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[2].rpcOption()); assertTrue(selector.contains(Dns.ZoneField.DESCRIPTION.selector())); assertTrue(selector.contains(Dns.ZoneField.NAME.selector())); + selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[3].rpcOption()); + assertEquals(DNS_NAME, selector); } @Test diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java index 74faca329884..92a18ad9c1e7 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java @@ -27,6 +27,7 @@ public class DnsTest { private static final Integer PAGE_SIZE = 20; private static final String PAGE_TOKEN = "page token"; + private static final String DNS_NAME = "www.example.com."; @Test public void testDnsRecordListOption() { @@ -89,6 +90,10 @@ public void testZoneList() { option = Dns.ZoneListOption.pageSize(PAGE_SIZE); assertEquals(PAGE_SIZE, option.value()); assertEquals(DnsRpc.Option.PAGE_SIZE, option.rpcOption()); + // dnsName filter + option = Dns.ZoneListOption.dnsName(DNS_NAME); + assertEquals(DNS_NAME, option.value()); + assertEquals(DnsRpc.Option.DNS_NAME, option.rpcOption()); } @Test diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java new file mode 100644 index 000000000000..adf5744d854e --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java @@ -0,0 +1,118 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; + +import com.google.common.collect.ImmutableList; +import com.google.gcloud.RetryParams; + +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.math.BigInteger; +import java.util.concurrent.TimeUnit; + +public class SerializationTest { + + private static final ZoneInfo FULL_ZONE_INFO = Zone.builder("some zone name") + .creationTimeMillis(132L) + .description("some descriptions") + .dnsName("www.example.com") + .id("123333") + .nameServers(ImmutableList.of("server 1", "server 2")) + .nameServerSet("specificationstring") + .build(); + private static final ZoneInfo PARTIAL_ZONE_INFO = Zone.builder("some zone name") + .build(); + private static final ProjectInfo PARTIAL_PROJECT_INFO = ProjectInfo.builder().id("13").build(); + private static final ProjectInfo FULL_PROJECT_INFO = ProjectInfo.builder() + .id("342") + .number(new BigInteger("2343245")) + .quota(new ProjectInfo.Quota(12, 13, 14, 15, 16, 17)) + .build(); + private static final Dns.ZoneListOption ZONE_LIST_OPTION = + Dns.ZoneListOption.dnsName("www.example.com."); + private static final Dns.DnsRecordListOption DNS_REOCRD_LIST_OPTION = + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL); + private static final Dns.ChangeRequestListOption CHANGE_REQUEST_LIST_OPTION = + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS); + private static final Dns.ZoneOption ZONE_OPTION = + Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME); + private static final Dns.ChangeRequestOption CHANGE_REQUEST_OPTION = + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS); + private static final Dns.ProjectOption PROJECT_OPTION = + Dns.ProjectOption.fields(Dns.ProjectField.QUOTA); + private static final DnsOptions OPTIONS = DnsOptions.builder() + .projectId("some-unnecessary-project-ID") + .retryParams(RetryParams.defaultInstance()) + .build(); + private static final Dns DNS = OPTIONS.service(); + private static final Zone FULL_ZONE = new Zone(DNS, new ZoneInfo.BuilderImpl(FULL_ZONE_INFO)); + private static final Zone PARTIAL_ZONE = + new Zone(DNS, new ZoneInfo.BuilderImpl(PARTIAL_ZONE_INFO)); + private static final ChangeRequest CHANGE_REQUEST_PARTIAL = ChangeRequest.builder().build(); + private static final DnsRecord DNS_RECORD_PARTIAL = + DnsRecord.builder("www.www.com", DnsRecord.Type.AAAA).build(); + private static final DnsRecord DNS_RECORD_COMPLETE = + DnsRecord.builder("www.sadfa.com", DnsRecord.Type.A) + .ttl(12, TimeUnit.HOURS) + .addRecord("record") + .build(); + private static final ChangeRequest CHANGE_REQUEST_COMPLETE = ChangeRequest.builder() + .add(DNS_RECORD_COMPLETE) + .delete(DNS_RECORD_PARTIAL) + .status(ChangeRequest.Status.PENDING) + .id("some id") + .startTimeMillis(132L) + .build(); + + + @Test + public void testModelAndRequests() throws Exception { + Serializable[] objects = {FULL_ZONE_INFO, PARTIAL_ZONE_INFO, ZONE_LIST_OPTION, + DNS_REOCRD_LIST_OPTION, CHANGE_REQUEST_LIST_OPTION, ZONE_OPTION, CHANGE_REQUEST_OPTION, + PROJECT_OPTION, PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, OPTIONS, FULL_ZONE, PARTIAL_ZONE, + OPTIONS, CHANGE_REQUEST_PARTIAL, DNS_RECORD_PARTIAL, DNS_RECORD_COMPLETE, + CHANGE_REQUEST_COMPLETE}; + for (Serializable obj : objects) { + Object copy = serializeAndDeserialize(obj); + assertEquals(obj, obj); + assertEquals(obj, copy); + assertNotSame(obj, copy); + assertEquals(copy, copy); + } + } + + @SuppressWarnings("unchecked") + private T serializeAndDeserialize(T obj) throws IOException, ClassNotFoundException { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { + output.writeObject(obj); + } + try (ObjectInputStream input = + new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) { + return (T) input.readObject(); + } + } +} From d1765c7c5ba2cefe99203f22b06bee1d2dd60751 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Wed, 10 Feb 2016 10:38:24 -0800 Subject: [PATCH 050/203] Fix indentation issues in javadoc code samples --- .../gcloud/bigquery/InsertAllRequest.java | 4 +- .../google/gcloud/bigquery/QueryRequest.java | 2 +- .../google/gcloud/bigquery/QueryResponse.java | 2 +- .../java/com/google/gcloud/Restorable.java | 4 +- .../com/google/gcloud/datastore/Batch.java | 16 +++---- .../com/google/gcloud/datastore/GqlQuery.java | 34 +++++++------- .../gcloud/datastore/StructuredQuery.java | 44 +++++++++---------- .../google/gcloud/datastore/Transaction.java | 28 ++++++------ .../com/google/gcloud/storage/CopyWriter.java | 2 +- .../com/google/gcloud/storage/Storage.java | 2 +- 10 files changed, 69 insertions(+), 69 deletions(-) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllRequest.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllRequest.java index 6f39f20e498d..e8828036cddc 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllRequest.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllRequest.java @@ -177,7 +177,7 @@ public Builder addRow(RowToInsert rowToInsert) { * Adds a row to be inserted with associated id. * *

Example usage of adding a row with associated id: - *

    {@code
+     * 
   {@code
      *   InsertAllRequest.Builder builder = InsertAllRequest.builder(tableId);
      *   List repeatedFieldValue = Arrays.asList(1L, 2L);
      *   Map recordContent = new HashMap();
@@ -198,7 +198,7 @@ public Builder addRow(String id, Map content) {
      * Adds a row to be inserted without an associated id.
      *
      * 

Example usage of adding a row without an associated id: - *

    {@code
+     * 
   {@code
      *   InsertAllRequest.Builder builder = InsertAllRequest.builder(tableId);
      *   List repeatedFieldValue = Arrays.asList(1L, 2L);
      *   Map recordContent = new HashMap();
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java
index 0bcfb3d4a9ae..8f2a89484ca4 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java
@@ -35,7 +35,7 @@
  * {@link QueryResponse#jobCompleted()} returns {@code true}.
  *
  * 

Example usage of a query request: - *

    {@code
+ * 
     {@code
  *    // Substitute "field", "table" and "dataset" with real field, table and dataset identifiers
  *    QueryRequest request = QueryRequest.builder("SELECT field FROM table")
  *      .defaultDataset(DatasetId.of("dataset"))
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java
index 77386747754f..d9b61e9b1466 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java
@@ -29,7 +29,7 @@
  * Query Request ({@link BigQuery#query(QueryRequest)}).
  *
  * 

Example usage of a query response: - *

    {@code
+ * 
     {@code
  *    QueryResponse response = bigquery.query(request);
  *    while (!response.jobCompleted()) {
  *      Thread.sleep(1000);
diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/Restorable.java b/gcloud-java-core/src/main/java/com/google/gcloud/Restorable.java
index 90633c70046f..0b573522e370 100644
--- a/gcloud-java-core/src/main/java/com/google/gcloud/Restorable.java
+++ b/gcloud-java-core/src/main/java/com/google/gcloud/Restorable.java
@@ -21,14 +21,14 @@
  *
  * 

* A typical capture usage: - *

  {@code
+ * 
 {@code
  * X restorableObj; // X instanceof Restorable
  * RestorableState state = restorableObj.capture();
  * .. persist state
  * }
* * A typical restore usage: - *
  {@code
+ * 
 {@code
  * RestorableState state = ... // read from persistence
  * X restorableObj = state.restore();
  * ...
diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Batch.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Batch.java
index 75a5d1381403..5306a685195a 100644
--- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Batch.java
+++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Batch.java
@@ -24,14 +24,14 @@
  * to the Datastore upon {@link #submit}.
  * A usage example:
  * 
 {@code
- *   Entity entity1 = datastore.get(key1);
- *   Batch batch = datastore.newBatch();
- *   Entity entity2 = Entity.builder(key2).set("name", "John").build();
- *   entity1 = Entity.builder(entity1).clear().setNull("bla").build();
- *   Entity entity3 = Entity.builder(key3).set("title", "title").build();
- *   batch.update(entity1);
- *   batch.add(entity2, entity3);
- *   batch.submit();
+ * Entity entity1 = datastore.get(key1);
+ * Batch batch = datastore.newBatch();
+ * Entity entity2 = Entity.builder(key2).set("name", "John").build();
+ * entity1 = Entity.builder(entity1).clear().setNull("bla").build();
+ * Entity entity3 = Entity.builder(key3).set("title", "title").build();
+ * batch.update(entity1);
+ * batch.add(entity2, entity3);
+ * batch.submit();
  * } 
*/ public interface Batch extends DatastoreBatchWriter { diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/GqlQuery.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/GqlQuery.java index e6ae166dbf07..7c03b69d9f39 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/GqlQuery.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/GqlQuery.java @@ -43,27 +43,27 @@ *

A usage example:

* *

When the type of the results is known the preferred usage would be: - *

{@code
- *   Query query =
- *       Query.gqlQueryBuilder(Query.ResultType.ENTITY, "select * from kind").build();
- *   QueryResults results = datastore.run(query);
- *   while (results.hasNext()) {
- *     Entity entity = results.next();
- *     ...
- *   }
+ * 
 {@code
+ * Query query =
+ *     Query.gqlQueryBuilder(Query.ResultType.ENTITY, "select * from kind").build();
+ * QueryResults results = datastore.run(query);
+ * while (results.hasNext()) {
+ *   Entity entity = results.next();
+ *   ...
+ * }
  * } 
* *

When the type of the results is unknown you can use this approach: - *

{@code
- *   Query query = Query.gqlQueryBuilder("select __key__ from kind").build();
- *   QueryResults results = datastore.run(query);
- *   if (Key.class.isAssignableFrom(results.resultClass())) {
- *     QueryResults keys = (QueryResults) results;
- *     while (keys.hasNext()) {
- *       Key key = keys.next();
- *       ...
- *     }
+ * 
 {@code
+ * Query query = Query.gqlQueryBuilder("select __key__ from kind").build();
+ * QueryResults results = datastore.run(query);
+ * if (Key.class.isAssignableFrom(results.resultClass())) {
+ *   QueryResults keys = (QueryResults) results;
+ *   while (keys.hasNext()) {
+ *     Key key = keys.next();
+ *     ...
  *   }
+ * }
  * } 
* * @param the type of the result values this query will produce diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/StructuredQuery.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/StructuredQuery.java index 15cca241e250..5892268f859c 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/StructuredQuery.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/StructuredQuery.java @@ -46,35 +46,35 @@ *

A usage example:

* *

A simple query that returns all entities for a specific kind - *

{@code
- *   Query query = Query.entityQueryBuilder().kind(kind).build();
- *   QueryResults results = datastore.run(query);
- *   while (results.hasNext()) {
- *     Entity entity = results.next();
- *     ...
- *   }
+ * 
 {@code
+ * Query query = Query.entityQueryBuilder().kind(kind).build();
+ * QueryResults results = datastore.run(query);
+ * while (results.hasNext()) {
+ *   Entity entity = results.next();
+ *   ...
+ * }
  * } 
* *

A simple key-only query of all entities for a specific kind - *

{@code
- *   Query keyOnlyQuery =  Query.keyQueryBuilder().kind(KIND1).build();
- *   QueryResults results = datastore.run(keyOnlyQuery);
- *   ...
+ * 
 {@code
+ * Query keyOnlyQuery =  Query.keyQueryBuilder().kind(KIND1).build();
+ * QueryResults results = datastore.run(keyOnlyQuery);
+ * ...
  * } 
* *

A less trivial example of a projection query that returns the first 10 results * of "age" and "name" properties (sorted and grouped by "age") with an age greater than 18 - *

{@code
- *   Query query = Query.projectionEntityQueryBuilder()
- *       .kind(kind)
- *       .projection(Projection.property("age"), Projection.first("name"))
- *       .filter(PropertyFilter.gt("age", 18))
- *       .groupBy("age")
- *       .orderBy(OrderBy.asc("age"))
- *       .limit(10)
- *       .build();
- *   QueryResults results = datastore.run(query);
- *   ...
+ * 
 {@code
+ * Query query = Query.projectionEntityQueryBuilder()
+ *     .kind(kind)
+ *     .projection(Projection.property("age"), Projection.first("name"))
+ *     .filter(PropertyFilter.gt("age", 18))
+ *     .groupBy("age")
+ *     .orderBy(OrderBy.asc("age"))
+ *     .limit(10)
+ *     .build();
+ * QueryResults results = datastore.run(query);
+ * ...
  * } 
* * @param the type of the result values this query will produce diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Transaction.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Transaction.java index 8089c0130f5d..78ee217f31e7 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Transaction.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Transaction.java @@ -30,21 +30,21 @@ * the Datastore upon {@code commit}. * A usage example: *
 {@code
- *   Transaction transaction = datastore.newTransaction();
- *   try {
- *     Entity entity = transaction.get(key);
- *     if (!entity.contains("last_name") || entity.isNull("last_name")) {
- *       String[] name = entity.getString("name").split(" ");
- *       entity = Entity.builder(entity).remove("name").set("first_name", name[0])
- *           .set("last_name", name[1]).build();
- *       transaction.update(entity);
- *       transaction.commit();
- *     }
- *   } finally {
- *     if (transaction.active()) {
- *       transaction.rollback();
- *     }
+ * Transaction transaction = datastore.newTransaction();
+ * try {
+ *   Entity entity = transaction.get(key);
+ *   if (!entity.contains("last_name") || entity.isNull("last_name")) {
+ *     String[] name = entity.getString("name").split(" ");
+ *     entity = Entity.builder(entity).remove("name").set("first_name", name[0])
+ *         .set("last_name", name[1]).build();
+ *     transaction.update(entity);
+ *     transaction.commit();
  *   }
+ * } finally {
+ *   if (transaction.active()) {
+ *     transaction.rollback();
+ *   }
+ * }
  * } 
* * @see diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java index 1e5427a847d4..ee70df1e4cc7 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java @@ -57,7 +57,7 @@ public class CopyWriter implements Restorable { * is {@code false} will block until all pending chunks are copied. * *

This method has the same effect of doing: - *

    {@code while (!copyWriter.isDone()) {
+   * 
     {@code while (!copyWriter.isDone()) {
    *        copyWriter.copyChunk();
    *    }}
    * 
diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index d1799daede3e..38795bea5e5b 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -1376,7 +1376,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx *
    {@code BlobInfo blob = service.copy(copyRequest).result();}
    * 
* To explicitly issue chunk copy requests use {@link CopyWriter#copyChunk()} instead: - *
    {@code CopyWriter copyWriter = service.copy(copyRequest);
+   * 
     {@code CopyWriter copyWriter = service.copy(copyRequest);
    *    while (!copyWriter.isDone()) {
    *        copyWriter.copyChunk();
    *    }

From 257e764c002f638c81cf9e3902ca0a5f167a896c Mon Sep 17 00:00:00 2001
From: Ajay Kannan 
Date: Wed, 10 Feb 2016 10:40:32 -0800
Subject: [PATCH 051/203] fix lint errors

---
 .../com/google/gcloud/datastore/DatastoreExceptionTest.java    | 3 ++-
 .../java/com/google/gcloud/datastore/StructuredQueryTest.java  | 3 ++-
 .../com/google/gcloud/resourcemanager/ResourceManagerImpl.java | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreExceptionTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreExceptionTest.java
index 4d62224172f9..f7bdcb89bcec 100644
--- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreExceptionTest.java
+++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreExceptionTest.java
@@ -78,7 +78,8 @@ public void testDatastoreException() throws Exception {
   @Test
   public void testTranslateAndThrow() throws Exception {
     DatastoreException cause = new DatastoreException(503, "message", "UNAVAILABLE");
-    RetryHelper.RetryHelperException exceptionMock = createMock(RetryHelper.RetryHelperException.class);
+    RetryHelper.RetryHelperException exceptionMock =
+        createMock(RetryHelper.RetryHelperException.class);
     expect(exceptionMock.getCause()).andReturn(cause).times(2);
     replay(exceptionMock);
     try {
diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/StructuredQueryTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/StructuredQueryTest.java
index b0d188cae16e..4b6589efd723 100644
--- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/StructuredQueryTest.java
+++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/StructuredQueryTest.java
@@ -40,7 +40,8 @@ public class StructuredQueryTest {
   private static final Cursor END_CURSOR = Cursor.copyFrom(new byte[] {10});
   private static final int OFFSET = 42;
   private static final Integer LIMIT = 43;
-  private static final Filter FILTER = CompositeFilter.and(PropertyFilter.gt("p1", 10), PropertyFilter.eq("a", "v"));
+  private static final Filter FILTER =
+      CompositeFilter.and(PropertyFilter.gt("p1", 10), PropertyFilter.eq("a", "v"));
   private static final OrderBy ORDER_BY_1 = OrderBy.asc("p2");
   private static final OrderBy ORDER_BY_2 = OrderBy.desc("p3");
   private static final List ORDER_BY = ImmutableList.of(ORDER_BY_1, ORDER_BY_2);
diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java
index e087caab5966..4176b4e610ba 100644
--- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java
+++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java
@@ -140,7 +140,8 @@ Iterable> call() {
                     public Project apply(
                         com.google.api.services.cloudresourcemanager.model.Project projectPb) {
                       return new Project(
-                          serviceOptions.service(), new ProjectInfo.BuilderImpl(ProjectInfo.fromPb(projectPb)));
+                          serviceOptions.service(),
+                          new ProjectInfo.BuilderImpl(ProjectInfo.fromPb(projectPb)));
                     }
                   });
       return new PageImpl<>(

From 71ac555a9f0160c6295c1508c91f68a4159317c6 Mon Sep 17 00:00:00 2001
From: Ajay Kannan 
Date: Wed, 10 Feb 2016 10:51:04 -0800
Subject: [PATCH 052/203] Move integration tests to separate package

---
 .../bigquery/{ => it}/ITBigQueryTest.java     | 58 ++++++++++++++-----
 .../storage/{ => it}/ITStorageTest.java       | 13 ++++-
 2 files changed, 55 insertions(+), 16 deletions(-)
 rename gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/{ => it}/ITBigQueryTest.java (95%)
 rename gcloud-java-storage/src/test/java/com/google/gcloud/storage/{ => it}/ITStorageTest.java (98%)

diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/ITBigQueryTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java
similarity index 95%
rename from gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/ITBigQueryTest.java
rename to gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java
index 8021809be6b2..0befeecd4b99 100644
--- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/ITBigQueryTest.java
+++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java
@@ -14,14 +14,8 @@
  * limitations under the License.
  */
 
-package com.google.gcloud.bigquery;
-
-import static com.google.gcloud.bigquery.BigQuery.DatasetField;
-import static com.google.gcloud.bigquery.BigQuery.JobField;
-import static com.google.gcloud.bigquery.BigQuery.JobListOption;
-import static com.google.gcloud.bigquery.BigQuery.JobOption;
-import static com.google.gcloud.bigquery.BigQuery.TableField;
-import static com.google.gcloud.bigquery.BigQuery.TableOption;
+package com.google.gcloud.bigquery.it;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -32,7 +26,42 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.gcloud.Page;
+import com.google.gcloud.WriteChannel;
+import com.google.gcloud.bigquery.BigQuery;
+import com.google.gcloud.bigquery.BigQuery.DatasetField;
 import com.google.gcloud.bigquery.BigQuery.DatasetOption;
+import com.google.gcloud.bigquery.BigQuery.JobField;
+import com.google.gcloud.bigquery.BigQuery.JobListOption;
+import com.google.gcloud.bigquery.BigQuery.JobOption;
+import com.google.gcloud.bigquery.BigQuery.TableField;
+import com.google.gcloud.bigquery.BigQuery.TableOption;
+import com.google.gcloud.bigquery.BigQueryError;
+import com.google.gcloud.bigquery.BigQueryException;
+import com.google.gcloud.bigquery.CopyJobConfiguration;
+import com.google.gcloud.bigquery.Dataset;
+import com.google.gcloud.bigquery.DatasetId;
+import com.google.gcloud.bigquery.DatasetInfo;
+import com.google.gcloud.bigquery.ExternalTableDefinition;
+import com.google.gcloud.bigquery.ExtractJobConfiguration;
+import com.google.gcloud.bigquery.Field;
+import com.google.gcloud.bigquery.FieldValue;
+import com.google.gcloud.bigquery.FormatOptions;
+import com.google.gcloud.bigquery.InsertAllRequest;
+import com.google.gcloud.bigquery.InsertAllResponse;
+import com.google.gcloud.bigquery.Job;
+import com.google.gcloud.bigquery.JobInfo;
+import com.google.gcloud.bigquery.LoadJobConfiguration;
+import com.google.gcloud.bigquery.QueryJobConfiguration;
+import com.google.gcloud.bigquery.QueryRequest;
+import com.google.gcloud.bigquery.QueryResponse;
+import com.google.gcloud.bigquery.Schema;
+import com.google.gcloud.bigquery.StandardTableDefinition;
+import com.google.gcloud.bigquery.Table;
+import com.google.gcloud.bigquery.TableDefinition;
+import com.google.gcloud.bigquery.TableId;
+import com.google.gcloud.bigquery.TableInfo;
+import com.google.gcloud.bigquery.ViewDefinition;
+import com.google.gcloud.bigquery.WriteChannelConfiguration;
 import com.google.gcloud.bigquery.testing.RemoteBigQueryHelper;
 import com.google.gcloud.storage.BlobInfo;
 import com.google.gcloud.storage.BucketInfo;
@@ -45,7 +74,6 @@
 import org.junit.Test;
 import org.junit.rules.Timeout;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
@@ -140,7 +168,7 @@ public class ITBigQueryTest {
   public Timeout globalTimeout = Timeout.seconds(300);
 
   @BeforeClass
-  public static void beforeClass() throws IOException, InterruptedException {
+  public static void beforeClass() throws InterruptedException {
     RemoteBigQueryHelper bigqueryHelper = RemoteBigQueryHelper.create();
     RemoteGcsHelper gcsHelper = RemoteGcsHelper.create();
     bigquery = bigqueryHelper.options().service();
@@ -685,7 +713,7 @@ public void testListJobsWithSelectedFields() {
   }
 
   @Test
-  public void testCreateAndGetJob() throws InterruptedException {
+  public void testCreateAndGetJob() {
     String sourceTableName = "test_create_and_get_job_source_table";
     String destinationTableName = "test_create_and_get_job_destination_table";
     TableId sourceTable = TableId.of(DATASET, sourceTableName);
@@ -717,7 +745,7 @@ public void testCreateAndGetJob() throws InterruptedException {
   }
 
   @Test
-  public void testCreateAndGetJobWithSelectedFields() throws InterruptedException {
+  public void testCreateAndGetJobWithSelectedFields() {
     String sourceTableName = "test_create_and_get_job_with_selected_fields_source_table";
     String destinationTableName = "test_create_and_get_job_with_selected_fields_destination_table";
     TableId sourceTable = TableId.of(DATASET, sourceTableName);
@@ -874,12 +902,12 @@ public void testCancelJob() throws InterruptedException {
   }
 
   @Test
-  public void testCancelNonExistingJob() throws InterruptedException {
+  public void testCancelNonExistingJob() {
     assertFalse(bigquery.cancel("test_cancel_non_existing_job"));
   }
 
   @Test
-  public void testInsertFromFile() throws InterruptedException, FileNotFoundException {
+  public void testInsertFromFile() throws InterruptedException {
     String destinationTableName = "test_insert_from_file_table";
     TableId tableId = TableId.of(DATASET, destinationTableName);
     WriteChannelConfiguration configuration = WriteChannelConfiguration.builder(tableId)
@@ -887,7 +915,7 @@ public void testInsertFromFile() throws InterruptedException, FileNotFoundExcept
         .createDisposition(JobInfo.CreateDisposition.CREATE_IF_NEEDED)
         .schema(TABLE_SCHEMA)
         .build();
-    try (TableDataWriteChannel channel = bigquery.writer(configuration)) {
+    try (WriteChannel channel = bigquery.writer(configuration)) {
       channel.write(ByteBuffer.wrap(JSON_CONTENT.getBytes(StandardCharsets.UTF_8)));
     } catch (IOException e) {
       fail("IOException was not expected");
diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java
similarity index 98%
rename from gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java
rename to gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java
index dffcc366036a..f185bdf8343e 100644
--- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/ITStorageTest.java
+++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.google.gcloud.storage;
+package com.google.gcloud.storage.it;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertArrayEquals;
@@ -32,8 +32,19 @@
 import com.google.gcloud.ReadChannel;
 import com.google.gcloud.RestorableState;
 import com.google.gcloud.WriteChannel;
+import com.google.gcloud.storage.BatchRequest;
+import com.google.gcloud.storage.BatchResponse;
+import com.google.gcloud.storage.Blob;
+import com.google.gcloud.storage.BlobId;
+import com.google.gcloud.storage.BlobInfo;
+import com.google.gcloud.storage.Bucket;
+import com.google.gcloud.storage.BucketInfo;
+import com.google.gcloud.storage.CopyWriter;
+import com.google.gcloud.storage.HttpMethod;
+import com.google.gcloud.storage.Storage;
 import com.google.gcloud.storage.Storage.BlobField;
 import com.google.gcloud.storage.Storage.BucketField;
+import com.google.gcloud.storage.StorageException;
 import com.google.gcloud.storage.testing.RemoteGcsHelper;
 
 import org.junit.AfterClass;

From 4d8d986b2ad0455914f8c95cac72d0900d290378 Mon Sep 17 00:00:00 2001
From: Ajay Kannan 
Date: Wed, 10 Feb 2016 12:49:20 -0800
Subject: [PATCH 053/203] Avoid reading extra output during local gcd shutdown.

---
 .../com/google/gcloud/datastore/testing/LocalGcdHelper.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java
index 7c60da50b0b0..c60035de087f 100644
--- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java
+++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java
@@ -526,6 +526,7 @@ private static void extractFile(ZipInputStream zipIn, File filePath) throws IOEx
 
   public static boolean sendQuitRequest(int port) {
     StringBuilder result = new StringBuilder();
+    String shutdownMsg = "Shutting down local server";
     try {
       URL url = new URL("http", "localhost", port, "/_ah/admin/quit");
       HttpURLConnection con = (HttpURLConnection) url.openConnection();
@@ -537,13 +538,13 @@ public static boolean sendQuitRequest(int port) {
       out.flush();
       InputStream in = con.getInputStream();
       int currByte = 0;
-      while ((currByte = in.read()) != -1) {
+      while ((currByte = in.read()) != -1 && result.length() < shutdownMsg.length()) {
         result.append(((char) currByte));
       }
     } catch (IOException ignore) {
       // ignore
     }
-    return result.toString().startsWith("Shutting down local server");
+    return result.toString().startsWith(shutdownMsg);
   }
 
   public void stop() throws IOException, InterruptedException {

From 9d201a05bcbb7e9f0270ddf8d4cc78bba3f80b1e Mon Sep 17 00:00:00 2001
From: Ajay Kannan 
Date: Wed, 10 Feb 2016 15:28:03 -0800
Subject: [PATCH 054/203] Fix codacy and spacing bugs

---
 .../gcloud/bigquery/InsertAllRequest.java     | 58 +++++++++----------
 .../google/gcloud/bigquery/QueryRequest.java  | 40 ++++++-------
 .../google/gcloud/bigquery/QueryResponse.java | 28 ++++-----
 .../gcloud/bigquery/it/ITBigQueryTest.java    |  7 +--
 .../java/com/google/gcloud/storage/Blob.java  |  4 +-
 .../com/google/gcloud/storage/CopyWriter.java |  7 ++-
 .../com/google/gcloud/storage/Storage.java    | 25 ++++----
 .../gcloud/storage/it/ITStorageTest.java      | 13 ++---
 8 files changed, 91 insertions(+), 91 deletions(-)

diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllRequest.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllRequest.java
index e8828036cddc..f0d61583f83f 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllRequest.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/InsertAllRequest.java
@@ -52,15 +52,15 @@ public class InsertAllRequest implements Serializable {
    * id used by BigQuery to detect duplicate insertion requests on a best-effort basis.
    *
    * 

Example usage of creating a row to insert: - *

    {@code
-   *   List repeatedFieldValue = Arrays.asList(1L, 2L);
-   *   Map recordContent = new HashMap();
-   *   recordContent.put("subfieldName1", "value");
-   *   recordContent.put("subfieldName2", repeatedFieldValue);
-   *   Map rowContent = new HashMap();
-   *   rowContent.put("fieldName1", true);
-   *   rowContent.put("fieldName2", recordContent);
-   *   RowToInsert row = new RowToInsert("rowId", rowContent);
+   * 
 {@code
+   * List repeatedFieldValue = Arrays.asList(1L, 2L);
+   * Map recordContent = new HashMap();
+   * recordContent.put("subfieldName1", "value");
+   * recordContent.put("subfieldName2", repeatedFieldValue);
+   * Map rowContent = new HashMap();
+   * rowContent.put("fieldName1", true);
+   * rowContent.put("fieldName2", recordContent);
+   * RowToInsert row = new RowToInsert("rowId", rowContent);
    * }
* * @see
@@ -177,16 +177,16 @@ public Builder addRow(RowToInsert rowToInsert) { * Adds a row to be inserted with associated id. * *

Example usage of adding a row with associated id: - *

   {@code
-     *   InsertAllRequest.Builder builder = InsertAllRequest.builder(tableId);
-     *   List repeatedFieldValue = Arrays.asList(1L, 2L);
-     *   Map recordContent = new HashMap();
-     *   recordContent.put("subfieldName1", "value");
-     *   recordContent.put("subfieldName2", repeatedFieldValue);
-     *   Map rowContent = new HashMap();
-     *   rowContent.put("fieldName1", true);
-     *   rowContent.put("fieldName2", recordContent);
-     *   builder.addRow("rowId", rowContent);
+     * 
 {@code
+     * InsertAllRequest.Builder builder = InsertAllRequest.builder(tableId);
+     * List repeatedFieldValue = Arrays.asList(1L, 2L);
+     * Map recordContent = new HashMap();
+     * recordContent.put("subfieldName1", "value");
+     * recordContent.put("subfieldName2", repeatedFieldValue);
+     * Map rowContent = new HashMap();
+     * rowContent.put("fieldName1", true);
+     * rowContent.put("fieldName2", recordContent);
+     * builder.addRow("rowId", rowContent);
      * }
*/ public Builder addRow(String id, Map content) { @@ -198,16 +198,16 @@ public Builder addRow(String id, Map content) { * Adds a row to be inserted without an associated id. * *

Example usage of adding a row without an associated id: - *

   {@code
-     *   InsertAllRequest.Builder builder = InsertAllRequest.builder(tableId);
-     *   List repeatedFieldValue = Arrays.asList(1L, 2L);
-     *   Map recordContent = new HashMap();
-     *   recordContent.put("subfieldName1", "value");
-     *   recordContent.put("subfieldName2", repeatedFieldValue);
-     *   Map rowContent = new HashMap();
-     *   rowContent.put("fieldName1", true);
-     *   rowContent.put("fieldName2", recordContent);
-     *   builder.addRow(rowContent);
+     * 
 {@code
+     * InsertAllRequest.Builder builder = InsertAllRequest.builder(tableId);
+     * List repeatedFieldValue = Arrays.asList(1L, 2L);
+     * Map recordContent = new HashMap();
+     * recordContent.put("subfieldName1", "value");
+     * recordContent.put("subfieldName2", repeatedFieldValue);
+     * Map rowContent = new HashMap();
+     * rowContent.put("fieldName1", true);
+     * rowContent.put("fieldName2", recordContent);
+     * builder.addRow(rowContent);
      * }
*/ public Builder addRow(Map content) { diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java index 8f2a89484ca4..5f99f3c5b4ee 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java @@ -35,26 +35,26 @@ * {@link QueryResponse#jobCompleted()} returns {@code true}. * *

Example usage of a query request: - *

     {@code
- *    // Substitute "field", "table" and "dataset" with real field, table and dataset identifiers
- *    QueryRequest request = QueryRequest.builder("SELECT field FROM table")
- *      .defaultDataset(DatasetId.of("dataset"))
- *      .maxWaitTime(60000L)
- *      .maxResults(1000L)
- *      .build();
- *    QueryResponse response = bigquery.query(request);
- *    while (!response.jobCompleted()) {
- *      Thread.sleep(1000);
- *      response = bigquery.getQueryResults(response.jobId());
- *    }
- *    List executionErrors = response.executionErrors();
- *    // look for errors in executionErrors
- *    QueryResult result = response.result();
- *    Iterator> rowIterator = result.iterateAll();
- *    while(rowIterator.hasNext()) {
- *      List row = rowIterator.next();
- *      // do something with row
- *    }
+ * 
 {@code
+ * // Substitute "field", "table" and "dataset" with real field, table and dataset identifiers
+ * QueryRequest request = QueryRequest.builder("SELECT field FROM table")
+ *     .defaultDataset(DatasetId.of("dataset"))
+ *     .maxWaitTime(60000L)
+ *     .maxResults(1000L)
+ *     .build();
+ * QueryResponse response = bigquery.query(request);
+ * while (!response.jobCompleted()) {
+ *   Thread.sleep(1000);
+ *   response = bigquery.getQueryResults(response.jobId());
+ * }
+ * List executionErrors = response.executionErrors();
+ * // look for errors in executionErrors
+ * QueryResult result = response.result();
+ * Iterator> rowIterator = result.iterateAll();
+ * while(rowIterator.hasNext()) {
+ *   List row = rowIterator.next();
+ *   // do something with row
+ * }
  * }
* * @see
Query diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java index d9b61e9b1466..12000cc1cbd2 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java @@ -29,20 +29,20 @@ * Query Request ({@link BigQuery#query(QueryRequest)}). * *

Example usage of a query response: - *

     {@code
- *    QueryResponse response = bigquery.query(request);
- *    while (!response.jobCompleted()) {
- *      Thread.sleep(1000);
- *      response = bigquery.getQueryResults(response.jobId());
- *    }
- *    List executionErrors = response.executionErrors();
- *    // look for errors in executionErrors
- *    QueryResult result = response.result();
- *    Iterator> rowIterator = result.iterateAll();
- *    while(rowIterator.hasNext()) {
- *      List row = rowIterator.next();
- *      // do something with row
- *    }
+ * 
 {@code
+ * QueryResponse response = bigquery.query(request);
+ * while (!response.jobCompleted()) {
+ *   Thread.sleep(1000);
+ *   response = bigquery.getQueryResults(response.jobId());
+ * }
+ * List executionErrors = response.executionErrors();
+ * // look for errors in executionErrors
+ * QueryResult result = response.result();
+ * Iterator> rowIterator = result.iterateAll();
+ * while(rowIterator.hasNext()) {
+ *   List row = rowIterator.next();
+ *   // do something with row
+ * }
  * }
* * @see Get Query diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java index 0befeecd4b99..a91a7e0abc07 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java @@ -197,10 +197,9 @@ public static void afterClass() throws ExecutionException, InterruptedException if (bigquery != null) { RemoteBigQueryHelper.forceDelete(bigquery, DATASET); } - if (storage != null && !RemoteGcsHelper.forceDelete(storage, BUCKET, 10, TimeUnit.SECONDS)) { - if (LOG.isLoggable(Level.WARNING)) { - LOG.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET); - } + if (storage != null && !RemoteGcsHelper.forceDelete(storage, BUCKET, 10, TimeUnit.SECONDS) + && LOG.isLoggable(Level.WARNING)) { + LOG.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET); } } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java index ec8ab361328e..d89f80f1def3 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java @@ -351,8 +351,8 @@ public Blob reload(BlobSourceOption... options) { *

* *

Example usage of replacing blob's metadata: - *

    {@code blob.toBuilder().metadata(null).build().update();}
-   *    {@code blob.toBuilder().metadata(newMetadata).build().update();}
+   * 
 {@code blob.toBuilder().metadata(null).build().update();}
+   * {@code blob.toBuilder().metadata(newMetadata).build().update();}
    * 
* * @param options update options diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java index ee70df1e4cc7..7eb91d0910a2 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java @@ -57,9 +57,10 @@ public class CopyWriter implements Restorable { * is {@code false} will block until all pending chunks are copied. * *

This method has the same effect of doing: - *

     {@code while (!copyWriter.isDone()) {
-   *        copyWriter.copyChunk();
-   *    }}
+   * 
 {@code
+   * while (!copyWriter.isDone()) {
+   *    copyWriter.copyChunk();
+   * }}
    * 
* * @throws StorageException upon failure diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 38795bea5e5b..b43d35da6f5f 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -1300,8 +1300,8 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx * can be done by setting the provided {@code blobInfo}'s metadata to {@code null}. * *

Example usage of replacing blob's metadata: - *

    {@code service.update(BlobInfo.builder("bucket", "name").metadata(null).build());}
-   *    {@code service.update(BlobInfo.builder("bucket", "name").metadata(newMetadata).build());}
+   * 
 {@code service.update(BlobInfo.builder("bucket", "name").metadata(null).build());}
+   * {@code service.update(BlobInfo.builder("bucket", "name").metadata(newMetadata).build());}
    * 
* * @return the updated blob @@ -1315,8 +1315,8 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx * can be done by setting the provided {@code blobInfo}'s metadata to {@code null}. * *

Example usage of replacing blob's metadata: - *

    {@code service.update(BlobInfo.builder("bucket", "name").metadata(null).build());}
-   *    {@code service.update(BlobInfo.builder("bucket", "name").metadata(newMetadata).build());}
+   * 
 {@code service.update(BlobInfo.builder("bucket", "name").metadata(null).build());}
+   * {@code service.update(BlobInfo.builder("bucket", "name").metadata(newMetadata).build());}
    * 
* * @return the updated blob @@ -1373,14 +1373,15 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx * might issue multiple RPC calls depending on blob's size. * *

Example usage of copy: - *

    {@code BlobInfo blob = service.copy(copyRequest).result();}
+   * 
 {@code BlobInfo blob = service.copy(copyRequest).result();}
    * 
* To explicitly issue chunk copy requests use {@link CopyWriter#copyChunk()} instead: - *
     {@code CopyWriter copyWriter = service.copy(copyRequest);
-   *    while (!copyWriter.isDone()) {
-   *        copyWriter.copyChunk();
-   *    }
-   *    BlobInfo blob = copyWriter.result();
+   * 
 {@code
+   * CopyWriter copyWriter = service.copy(copyRequest);
+   * while (!copyWriter.isDone()) {
+   *     copyWriter.copyChunk();
+   * }
+   * BlobInfo blob = copyWriter.result();
    * }
    * 
* @@ -1462,8 +1463,8 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx * accessible blobs, but don't want to require users to explicitly log in. * *

Example usage of creating a signed URL that is valid for 2 weeks: - *

   {@code
-   *     service.signUrl(BlobInfo.builder("bucket", "name").build(), 14, TimeUnit.DAYS);
+   * 
 {@code
+   * service.signUrl(BlobInfo.builder("bucket", "name").build(), 14, TimeUnit.DAYS);
    * }
* * @param blobInfo the blob associated with the signed URL diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index f185bdf8343e..0f560cbe173a 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -88,10 +88,9 @@ public static void beforeClass() { @AfterClass public static void afterClass() throws ExecutionException, InterruptedException { - if (storage != null && !RemoteGcsHelper.forceDelete(storage, BUCKET, 5, TimeUnit.SECONDS)) { - if (log.isLoggable(Level.WARNING)) { - log.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET); - } + if (storage != null && !RemoteGcsHelper.forceDelete(storage, BUCKET, 5, TimeUnit.SECONDS) + && log.isLoggable(Level.WARNING)) { + log.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET); } } @@ -442,7 +441,7 @@ public void testUpdateBlobFail() { @Test public void testDeleteNonExistingBlob() { String blobName = "test-delete-non-existing-blob"; - assertTrue(!storage.delete(BUCKET, blobName)); + assertFalse(storage.delete(BUCKET, blobName)); } @Test @@ -450,7 +449,7 @@ public void testDeleteBlobNonExistingGeneration() { String blobName = "test-delete-blob-non-existing-generation"; BlobInfo blob = BlobInfo.builder(BUCKET, blobName).build(); assertNotNull(storage.create(blob)); - assertTrue(!storage.delete(BlobId.of(BUCKET, blobName, -1L))); + assertFalse(storage.delete(BlobId.of(BUCKET, blobName, -1L))); } @Test @@ -966,7 +965,7 @@ public void testDeleteBlobsFail() { assertNotNull(storage.create(sourceBlob1)); List deleteStatus = storage.delete(sourceBlob1.blobId(), sourceBlob2.blobId()); assertTrue(deleteStatus.get(0)); - assertTrue(!deleteStatus.get(1)); + assertFalse(deleteStatus.get(1)); } @Test From bc66860a5283ae6e596245907739af56d904b590 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 11 Feb 2016 09:22:02 -0800 Subject: [PATCH 055/203] Minor fix in ITs --- .../com/google/gcloud/bigquery/it/ITBigQueryTest.java | 8 +++++--- .../java/com/google/gcloud/storage/it/ITStorageTest.java | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java index a91a7e0abc07..aa89ed89123e 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java @@ -197,9 +197,11 @@ public static void afterClass() throws ExecutionException, InterruptedException if (bigquery != null) { RemoteBigQueryHelper.forceDelete(bigquery, DATASET); } - if (storage != null && !RemoteGcsHelper.forceDelete(storage, BUCKET, 10, TimeUnit.SECONDS) - && LOG.isLoggable(Level.WARNING)) { - LOG.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET); + if (storage != null) { + boolean wasDeleted = RemoteGcsHelper.forceDelete(storage, BUCKET, 10, TimeUnit.SECONDS); + if (!wasDeleted && LOG.isLoggable(Level.WARNING)) { + LOG.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET); + } } } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index 0f560cbe173a..43c2cf6d372b 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -88,9 +88,11 @@ public static void beforeClass() { @AfterClass public static void afterClass() throws ExecutionException, InterruptedException { - if (storage != null && !RemoteGcsHelper.forceDelete(storage, BUCKET, 5, TimeUnit.SECONDS) - && log.isLoggable(Level.WARNING)) { - log.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET); + if (storage != null) { + boolean wasDeleted = RemoteGcsHelper.forceDelete(storage, BUCKET, 5, TimeUnit.SECONDS); + if (!wasDeleted && log.isLoggable(Level.WARNING)) { + log.log(Level.WARNING, "Deletion of bucket {0} timed out, bucket is not empty", BUCKET); + } } } From deb228f0ae407b81b1bf5257755fd2b24da9777c Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 11 Feb 2016 17:08:46 -0800 Subject: [PATCH 056/203] Fix double code tags --- .../main/java/com/google/gcloud/storage/Blob.java | 6 ++++-- .../main/java/com/google/gcloud/storage/Storage.java | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java index d89f80f1def3..aea424ca4063 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java @@ -351,8 +351,10 @@ public Blob reload(BlobSourceOption... options) { *

* *

Example usage of replacing blob's metadata: - *

 {@code blob.toBuilder().metadata(null).build().update();}
-   * {@code blob.toBuilder().metadata(newMetadata).build().update();}
+   * 
 {@code
+   * blob.toBuilder().metadata(null).build().update();
+   * blob.toBuilder().metadata(newMetadata).build().update();
+   * }
    * 
* * @param options update options diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index b43d35da6f5f..0ebe013202b0 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -1300,8 +1300,10 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx * can be done by setting the provided {@code blobInfo}'s metadata to {@code null}. * *

Example usage of replacing blob's metadata: - *

 {@code service.update(BlobInfo.builder("bucket", "name").metadata(null).build());}
-   * {@code service.update(BlobInfo.builder("bucket", "name").metadata(newMetadata).build());}
+   * 
 {@code
+   * service.update(BlobInfo.builder("bucket", "name").metadata(null).build());
+   * service.update(BlobInfo.builder("bucket", "name").metadata(newMetadata).build());
+   * }
    * 
* * @return the updated blob @@ -1315,8 +1317,10 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx * can be done by setting the provided {@code blobInfo}'s metadata to {@code null}. * *

Example usage of replacing blob's metadata: - *

 {@code service.update(BlobInfo.builder("bucket", "name").metadata(null).build());}
-   * {@code service.update(BlobInfo.builder("bucket", "name").metadata(newMetadata).build());}
+   * 
 {@code
+   * service.update(BlobInfo.builder("bucket", "name").metadata(null).build());
+   * service.update(BlobInfo.builder("bucket", "name").metadata(newMetadata).build());
+   * }
    * 
* * @return the updated blob From a68a0b60c09f990073b0d5103b11dcd9596e73ea Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 11 Feb 2016 17:30:35 -0800 Subject: [PATCH 057/203] Add set methods for lists of same type --- .../google/gcloud/datastore/BaseEntity.java | 93 ++++++++++++++++++- .../google/gcloud/datastore/ListValue.java | 11 ++- .../gcloud/datastore/BaseEntityTest.java | 14 ++- 3 files changed, 110 insertions(+), 8 deletions(-) diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java index d674a5e242ad..d2b0748b4a85 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java @@ -33,6 +33,7 @@ import com.google.protobuf.InvalidProtocolBufferException; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; @@ -138,43 +139,120 @@ public B set(String name, String value) { return self(); } + public B set(String name, String first, String second, String... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (String other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + public B set(String name, long value) { properties.put(name, of(value)); return self(); } + public B set(String name, long first, long second, long... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (long other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + public B set(String name, double value) { properties.put(name, of(value)); return self(); } + public B set(String name, double first, double second, double... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (double other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + public B set(String name, boolean value) { properties.put(name, of(value)); return self(); } + public B set(String name, boolean first, boolean second, boolean... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (boolean other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + public B set(String name, DateTime value) { properties.put(name, of(value)); return self(); } + public B set(String name, DateTime first, DateTime second, DateTime... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (DateTime other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + public B set(String name, Key value) { properties.put(name, of(value)); return self(); } + public B set(String name, Key first, Key second, Key... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (Key other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + public B set(String name, FullEntity value) { properties.put(name, of(value)); return self(); } + public B set(String name, FullEntity first, FullEntity second, FullEntity... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (FullEntity other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + public B set(String name, List> values) { properties.put(name, of(values)); return self(); } - public B set(String name, Value value, Value... other) { - properties.put(name, of(value, other)); + public B set(String name, Value first, Value second, Value... other) { + properties.put(name, of(first, second, other)); return self(); } @@ -183,6 +261,17 @@ public B set(String name, Blob value) { return self(); } + public B set(String name, Blob first, Blob second, Blob... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (Blob other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + public B setNull(String name) { properties.put(name, of()); return self(); diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java index 41c7e82788b5..494d8daedfff 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java @@ -77,8 +77,9 @@ public Builder addValue(Value value) { return this; } - public Builder addValue(Value first, Value... other) { + public Builder addValue(Value first, Value second, Value... other) { addValue(first); + addValue(second); for (Value value : other) { addValue(value); } @@ -121,8 +122,8 @@ public ListValue(List> values) { this(builder().set(values)); } - public ListValue(Value first, Value... other) { - this(new Builder().addValue(first, other)); + public ListValue(Value first, Value second, Value... other) { + this(new Builder().addValue(first, second, other)); } private ListValue(Builder builder) { @@ -138,8 +139,8 @@ public static ListValue of(List> values) { return new ListValue(values); } - public static ListValue of(Value first, Value... other) { - return new ListValue(first, other); + public static ListValue of(Value first, Value second, Value... other) { + return new ListValue(first, second, other); } public static Builder builder() { diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java index 5ece01508d3a..691edb70f493 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java @@ -67,6 +67,16 @@ public void setUp() { builder.set("list1", NullValue.of(), StringValue.of("foo")); builder.set("list2", ImmutableList.of(LongValue.of(10), DoubleValue.of(2))); builder.set("list3", Collections.singletonList(BooleanValue.of(true))); + builder.set( + "blobList", BLOB, Blob.copyFrom(new byte[] {3, 4}), Blob.copyFrom(new byte[] {5, 6})); + builder.set("booleanList", true, false, true); + builder.set("dateTimeList", DateTime.now(), DateTime.now(), DateTime.now()); + builder.set("doubleList", 12.3, 4.56, .789); + builder.set("keyList", KEY, Key.builder("ds2", "k2", "n2").build(), + Key.builder("ds3", "k3", "n3").build()); + builder.set("entityList", ENTITY, PARTIAL_ENTITY, ENTITY); + builder.set("stringList", "s1", "s2", "s3"); + builder.set("longList", 1, 23, 456); } @Test @@ -198,7 +208,9 @@ public void testGetBlob() throws Exception { public void testNames() throws Exception { Set names = ImmutableSet.builder() .add("string", "stringValue", "boolean", "double", "long", "list1", "list2", "list3") - .add("entity", "partialEntity", "null", "dateTime", "blob", "key") + .add("entity", "partialEntity", "null", "dateTime", "blob", "key", "blobList") + .add("booleanList", "dateTimeList", "doubleList", "keyList", "entityList", "stringList") + .add("longList") .build(); BaseEntity entity = builder.build(); assertEquals(names, entity.names()); From 8050cca81afee5f6a952cc7c544e3ae5aa616633 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 11 Feb 2016 18:15:24 -0800 Subject: [PATCH 058/203] Cleaner getList return value --- .../com/google/gcloud/datastore/BaseEntity.java | 4 ++-- .../com/google/gcloud/datastore/BaseEntityTest.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java index d2b0748b4a85..af05cb42c315 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java @@ -437,8 +437,8 @@ public FullEntity getEntity(String name) { * @throws ClassCastException if value is not a list of values */ @SuppressWarnings("unchecked") - public List> getList(String name) { - return ((Value>>) getValue(name)).get(); + public > List getList(String name) { + return (List) getValue(name).get(); } /** diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java index 691edb70f493..a69ea5e20e3b 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseEntityTest.java @@ -74,7 +74,7 @@ public void setUp() { builder.set("doubleList", 12.3, 4.56, .789); builder.set("keyList", KEY, Key.builder("ds2", "k2", "n2").build(), Key.builder("ds3", "k3", "n3").build()); - builder.set("entityList", ENTITY, PARTIAL_ENTITY, ENTITY); + builder.set("entityList", ENTITY, PARTIAL_ENTITY); builder.set("stringList", "s1", "s2", "s3"); builder.set("longList", 1, 23, 456); } @@ -193,6 +193,17 @@ public void testGetList() throws Exception { assertEquals(Boolean.TRUE, list.get(0).get()); entity = builder.set("list1", ListValue.of(list)).build(); assertEquals(list, entity.getList("list1")); + List> stringList = entity.getList("stringList"); + assertEquals( + ImmutableList.of(StringValue.of("s1"), StringValue.of("s2"), StringValue.of("s3")), + stringList); + List> doubleList = entity.getList("doubleList"); + assertEquals( + ImmutableList.of(DoubleValue.of(12.3), DoubleValue.of(4.56), DoubleValue.of(.789)), + doubleList); + List entityList = entity.getList("entityList"); + assertEquals( + ImmutableList.of(EntityValue.of(ENTITY), EntityValue.of(PARTIAL_ENTITY)), entityList); } @Test From f9209861f644541c5e8c88a575b37f20da727324 Mon Sep 17 00:00:00 2001 From: Arie Ozarov Date: Thu, 11 Feb 2016 19:56:14 -0800 Subject: [PATCH 059/203] Revert #625 and Fixes ##624 --- .../google/gcloud/bigquery/it/ITBigQueryTest.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java index aa89ed89123e..63a0551ece33 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java @@ -50,6 +50,7 @@ import com.google.gcloud.bigquery.InsertAllResponse; import com.google.gcloud.bigquery.Job; import com.google.gcloud.bigquery.JobInfo; +import com.google.gcloud.bigquery.JobStatistics; import com.google.gcloud.bigquery.LoadJobConfiguration; import com.google.gcloud.bigquery.QueryJobConfiguration; import com.google.gcloud.bigquery.QueryRequest; @@ -683,10 +684,9 @@ public void testQuery() throws InterruptedException { rowCount++; } assertEquals(2, rowCount); - // todo(mziccard) uncomment as soon as #624 is closed - // Job queryJob = bigquery.getJob(response.jobId()); - // JobStatistics.QueryStatistics statistics = queryJob.statistics(); - // assertNotNull(statistics.queryPlan()); + Job queryJob = bigquery.getJob(response.jobId()); + JobStatistics.QueryStatistics statistics = queryJob.statistics(); + assertNotNull(statistics.queryPlan()); } @Test @@ -851,10 +851,9 @@ public void testQueryJob() throws InterruptedException { } assertEquals(2, rowCount); assertTrue(bigquery.delete(DATASET, tableName)); - // todo(mziccard) uncomment as soon as #624 is closed - // Job queryJob = bigquery.getJob(remoteJob.jobId()); - // JobStatistics.QueryStatistics statistics = queryJob.statistics(); - // assertNotNull(statistics.queryPlan()); + Job queryJob = bigquery.getJob(remoteJob.jobId()); + JobStatistics.QueryStatistics statistics = queryJob.statistics(); + assertNotNull(statistics.queryPlan()); } @Test From 4476dcf51507a6cb1dff01736568ac507a1a2adb Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 12 Feb 2016 12:18:02 +0100 Subject: [PATCH 060/203] Update dependencies when possible --- gcloud-java-bigquery/pom.xml | 4 ++-- gcloud-java-core/pom.xml | 16 ++++++++-------- gcloud-java-datastore/pom.xml | 2 +- gcloud-java-resourcemanager/pom.xml | 4 ++-- gcloud-java-storage/pom.xml | 4 ++-- pom.xml | 22 +++++++++++----------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/gcloud-java-bigquery/pom.xml b/gcloud-java-bigquery/pom.xml index 41a51722b7c6..b1e516a2268b 100644 --- a/gcloud-java-bigquery/pom.xml +++ b/gcloud-java-bigquery/pom.xml @@ -30,7 +30,7 @@ com.google.apis google-api-services-bigquery - v2-rev254-1.21.0 + v2-rev261-1.21.0 compile @@ -48,7 +48,7 @@ org.easymock easymock - 3.3 + 3.4 test diff --git a/gcloud-java-core/pom.xml b/gcloud-java-core/pom.xml index bd7f26e0bc3b..3463f40b52bd 100644 --- a/gcloud-java-core/pom.xml +++ b/gcloud-java-core/pom.xml @@ -35,24 +35,24 @@ com.google.http-client google-http-client - 1.20.0 + 1.21.0 compile com.google.oauth-client google-oauth-client - 1.20.0 + 1.21.0 compile com.google.guava guava - 18.0 + 19.0 com.google.api-client google-api-client-appengine - 1.20.0 + 1.21.0 compile @@ -64,7 +64,7 @@ com.google.http-client google-http-client-jackson - 1.20.0 + 1.21.0 compile @@ -82,19 +82,19 @@ joda-time joda-time - 2.8.2 + 2.9.2 compile org.json json - 20090211 + 20151123 compile org.easymock easymock - 3.3 + 3.4 test diff --git a/gcloud-java-datastore/pom.xml b/gcloud-java-datastore/pom.xml index a76e4f9d9cbd..1b74b4b39dbd 100644 --- a/gcloud-java-datastore/pom.xml +++ b/gcloud-java-datastore/pom.xml @@ -42,7 +42,7 @@ org.easymock easymock - 3.3 + 3.4 test diff --git a/gcloud-java-resourcemanager/pom.xml b/gcloud-java-resourcemanager/pom.xml index 0e07d5afbee6..1311e4dc1bb5 100644 --- a/gcloud-java-resourcemanager/pom.xml +++ b/gcloud-java-resourcemanager/pom.xml @@ -24,7 +24,7 @@ com.google.apis google-api-services-cloudresourcemanager - v1beta1-rev6-1.19.0 + v1beta1-rev10-1.21.0 compile @@ -42,7 +42,7 @@ org.easymock easymock - 3.3 + 3.4 test diff --git a/gcloud-java-storage/pom.xml b/gcloud-java-storage/pom.xml index 6b4755d90041..09487467a827 100644 --- a/gcloud-java-storage/pom.xml +++ b/gcloud-java-storage/pom.xml @@ -24,7 +24,7 @@ com.google.apis google-api-services-storage - v1-rev33-1.20.0 + v1-rev60-1.21.0 compile @@ -46,7 +46,7 @@ org.easymock easymock - 3.3 + 3.4 test diff --git a/pom.xml b/pom.xml index 0084fd53d74f..c3c3554d976a 100644 --- a/pom.xml +++ b/pom.xml @@ -133,7 +133,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.18 + 2.19.1 @@ -144,7 +144,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 1.4 + 1.4.1 enforce-maven @@ -186,7 +186,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.18.1 + 2.19.1 @@ -218,7 +218,7 @@ maven-compiler-plugin - 3.2 + 3.5.1 1.7 1.7 @@ -269,7 +269,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.5 + 1.6.6 true sonatype-nexus-staging @@ -280,7 +280,7 @@ org.eluder.coveralls coveralls-maven-plugin - 3.1.0 + 4.1.0 ${basedir}/target/coverage.xml @@ -313,12 +313,12 @@ org.apache.maven.plugins maven-checkstyle-plugin - 2.16 + 2.17 com.puppycrawl.tools checkstyle - 6.8.1 + 6.15 @@ -337,7 +337,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 2.8 + 2.8.1 @@ -394,12 +394,12 @@ org.apache.maven.plugins maven-surefire-report-plugin - 2.18.1 + 2.19.1 org.apache.maven.plugins maven-checkstyle-plugin - 2.16 + 2.17 checkstyle.xml false From 2f77f2d648abda3d85eac8fccb1f2b05d11d780d Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 12 Feb 2016 12:19:04 +0100 Subject: [PATCH 061/203] Add versioneye badge to READMEs --- README.md | 1 + gcloud-java-bigquery/README.md | 1 + gcloud-java-contrib/README.md | 6 ++++++ gcloud-java-core/README.md | 1 + gcloud-java-datastore/README.md | 1 + gcloud-java-examples/README.md | 1 + gcloud-java-resourcemanager/README.md | 1 + gcloud-java-storage/README.md | 1 + gcloud-java/README.md | 1 + 9 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 207009ee6475..d465105dfd41 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Java idiomatic client for [Google Cloud Platform][cloud-platform] services. [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) [![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java.svg) [![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) +[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs) diff --git a/gcloud-java-bigquery/README.md b/gcloud-java-bigquery/README.md index df1058dec024..ba6caa87783a 100644 --- a/gcloud-java-bigquery/README.md +++ b/gcloud-java-bigquery/README.md @@ -7,6 +7,7 @@ Java idiomatic client for [Google Cloud BigQuery] (https://cloud.google.com/bigq [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) [![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-bigquery.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-bigquery.svg) [![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) +[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/bigquery/package-summary.html) diff --git a/gcloud-java-contrib/README.md b/gcloud-java-contrib/README.md index 23713f7450a3..01f455e3a43c 100644 --- a/gcloud-java-contrib/README.md +++ b/gcloud-java-contrib/README.md @@ -3,6 +3,12 @@ Google Cloud Java Contributions Packages that provide higher-level abstraction/functionality for common gcloud-java use cases. +[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) +[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) +[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-bigquery.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-bigquery.svg) +[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) +[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) + Quickstart ---------- If you are using Maven, add this to your pom.xml file diff --git a/gcloud-java-core/README.md b/gcloud-java-core/README.md index 8b91e49f3860..b7e5e05b6ad3 100644 --- a/gcloud-java-core/README.md +++ b/gcloud-java-core/README.md @@ -7,6 +7,7 @@ This module provides common functionality required by service-specific modules o [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) [![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-core.svg)](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-core.svg) [![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) +[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/package-summary.html) diff --git a/gcloud-java-datastore/README.md b/gcloud-java-datastore/README.md index 8c0ae1950e77..7d985e882a44 100644 --- a/gcloud-java-datastore/README.md +++ b/gcloud-java-datastore/README.md @@ -7,6 +7,7 @@ Java idiomatic client for [Google Cloud Datastore] (https://cloud.google.com/dat [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) [![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-datastore.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-datastore.svg) [![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) +[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/datastore/package-summary.html) diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md index 7d24febeac80..0ab9b3ca6924 100644 --- a/gcloud-java-examples/README.md +++ b/gcloud-java-examples/README.md @@ -7,6 +7,7 @@ Examples for gcloud-java (Java idiomatic client for [Google Cloud Platform][clou [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) [![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-examples.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-examples.svg) [![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) +[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html) diff --git a/gcloud-java-resourcemanager/README.md b/gcloud-java-resourcemanager/README.md index 6f7d52386fc0..fc80190ebd05 100644 --- a/gcloud-java-resourcemanager/README.md +++ b/gcloud-java-resourcemanager/README.md @@ -7,6 +7,7 @@ Java idiomatic client for [Google Cloud Resource Manager] (https://cloud.google. [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) [![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-resourcemanager.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-resourcemanager.svg) [![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) +[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/resourcemanager/package-summary.html) diff --git a/gcloud-java-storage/README.md b/gcloud-java-storage/README.md index 554f22b38e7f..80b2ffd0cd67 100644 --- a/gcloud-java-storage/README.md +++ b/gcloud-java-storage/README.md @@ -7,6 +7,7 @@ Java idiomatic client for [Google Cloud Storage] (https://cloud.google.com/stora [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) [![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-storage.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-storage.svg) [![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) +[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/storage/package-summary.html) diff --git a/gcloud-java/README.md b/gcloud-java/README.md index 4a581d56f991..7443bf5e3392 100644 --- a/gcloud-java/README.md +++ b/gcloud-java/README.md @@ -7,6 +7,7 @@ Java idiomatic client for [Google Cloud Platform][cloud-platform] services. [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) [![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java.svg) [![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) +[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs) From e08896cd79eeda392f65205ad16b473e2a61ba3b Mon Sep 17 00:00:00 2001 From: aozarov Date: Fri, 12 Feb 2016 10:00:42 -0800 Subject: [PATCH 062/203] upgrade google-api-services-datastore-protobuf to v1beta2-rev1-4.0.0 and fix test --- gcloud-java-datastore/pom.xml | 2 +- .../gcloud/datastore/DatastoreTest.java | 26 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gcloud-java-datastore/pom.xml b/gcloud-java-datastore/pom.xml index a76e4f9d9cbd..5866500ba0d6 100644 --- a/gcloud-java-datastore/pom.xml +++ b/gcloud-java-datastore/pom.xml @@ -24,7 +24,7 @@ com.google.apis google-api-services-datastore-protobuf - v1beta2-rev1-2.1.2 + v1beta2-rev1-4.0.0 compile diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java index e9eed027e8e0..19f53f525b1a 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java @@ -31,6 +31,7 @@ import com.google.api.services.datastore.DatastoreV1.RunQueryRequest; import com.google.api.services.datastore.DatastoreV1.RunQueryResponse; import com.google.common.collect.Iterators; +import com.google.common.collect.Lists; import com.google.gcloud.RetryParams; import com.google.gcloud.datastore.Query.ResultType; import com.google.gcloud.datastore.StructuredQuery.OrderBy; @@ -89,8 +90,8 @@ public class DatastoreTest { FullEntity.builder(INCOMPLETE_KEY2).set("str", STR_VALUE).set("bool", BOOL_VALUE) .set("list", LIST_VALUE1).build(); private static final FullEntity PARTIAL_ENTITY2 = - FullEntity.builder(PARTIAL_ENTITY1).remove("str").set("bool", true). - set("list", LIST_VALUE1.get()).build(); + FullEntity.builder(PARTIAL_ENTITY1).remove("str").set("bool", true) + .set("list", LIST_VALUE1.get()).build(); private static final FullEntity PARTIAL_ENTITY3 = FullEntity.builder(PARTIAL_ENTITY1).key(IncompleteKey.builder(PROJECT_ID, KIND3).build()) .build(); @@ -471,9 +472,13 @@ public void testQueryPaginationWithLimit() throws DatastoreException { EasyMock.expect(rpcFactoryMock.create(EasyMock.anyObject(DatastoreOptions.class))) .andReturn(rpcMock); List responses = buildResponsesForQueryPaginationWithLimit(); - for (int i = 0; i < responses.size(); i++) { + List endCursors = Lists.newArrayListWithCapacity(responses.size()); + for (RunQueryResponse response: responses) { EasyMock.expect(rpcMock.runQuery(EasyMock.anyObject(RunQueryRequest.class))) - .andReturn(responses.get(i)); + .andReturn(response); + if (response.getBatch().getMoreResults() != QueryResultBatch.MoreResultsType.NOT_FINISHED) { + endCursors.add(response.getBatch().getEndCursor()); + } } EasyMock.replay(rpcFactoryMock, rpcMock); Datastore mockDatastore = options.toBuilder() @@ -483,6 +488,7 @@ public void testQueryPaginationWithLimit() throws DatastoreException { .service(); int limit = 2; int totalCount = 0; + Iterator cursorIter = endCursors.iterator(); StructuredQuery query = Query.entityQueryBuilder().limit(limit).build(); while (true) { QueryResults results = mockDatastore.run(query); @@ -492,6 +498,9 @@ public void testQueryPaginationWithLimit() throws DatastoreException { resultCount++; totalCount++; } + assertTrue(cursorIter.hasNext()); + Cursor expectedEndCursor = Cursor.copyFrom(cursorIter.next().toByteArray()); + assertEquals(expectedEndCursor, results.cursorAfter()); if (resultCount < limit) { break; } @@ -505,19 +514,20 @@ private List buildResponsesForQueryPaginationWithLimit() { Entity entity4 = Entity.builder(KEY4).set("value", StringValue.of("value")).build(); Entity entity5 = Entity.builder(KEY5).set("value", "value").build(); datastore.add(ENTITY3, entity4, entity5); + DatastoreRpc datastoreRpc = datastore.options().rpc(); List responses = new ArrayList<>(); Query query = Query.entityQueryBuilder().build(); RunQueryRequest.Builder requestPb = RunQueryRequest.newBuilder(); query.populatePb(requestPb); QueryResultBatch queryResultBatchPb = RunQueryResponse.newBuilder() - .mergeFrom(((DatastoreImpl) datastore).runQuery(requestPb.build())) + .mergeFrom(datastoreRpc.runQuery(requestPb.build())) .getBatch(); QueryResultBatch queryResultBatchPb1 = QueryResultBatch.newBuilder() .mergeFrom(queryResultBatchPb) .setMoreResults(QueryResultBatch.MoreResultsType.NOT_FINISHED) .clearEntityResult() .addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(0, 1)) - .setEndCursor(queryResultBatchPb.getEntityResultList().get(0).getCursor()) + .setEndCursor(ByteString.copyFromUtf8("a")) .build(); responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb1).build()); QueryResultBatch queryResultBatchPb2 = QueryResultBatch.newBuilder() @@ -534,7 +544,7 @@ private List buildResponsesForQueryPaginationWithLimit() { .setMoreResults(QueryResultBatch.MoreResultsType.MORE_RESULTS_AFTER_LIMIT) .clearEntityResult() .addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(2, 4)) - .setEndCursor(queryResultBatchPb.getEntityResultList().get(3).getCursor()) + .setEndCursor(ByteString.copyFromUtf8("b")) .build(); responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb3).build()); QueryResultBatch queryResultBatchPb4 = QueryResultBatch.newBuilder() @@ -542,7 +552,7 @@ private List buildResponsesForQueryPaginationWithLimit() { .setMoreResults(QueryResultBatch.MoreResultsType.NO_MORE_RESULTS) .clearEntityResult() .addAllEntityResult(queryResultBatchPb.getEntityResultList().subList(4, 5)) - .setEndCursor(queryResultBatchPb.getEntityResultList().get(4).getCursor()) + .setEndCursor(ByteString.copyFromUtf8("c")) .build(); responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb4).build()); return responses; From 2314eeec1bff03fea3719063725cac58f23a464b Mon Sep 17 00:00:00 2001 From: aozarov Date: Fri, 12 Feb 2016 17:36:56 -0800 Subject: [PATCH 063/203] update codacy config --- codacy-conf.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codacy-conf.json b/codacy-conf.json index 61328436cba3..e8c819684c9c 100644 --- a/codacy-conf.json +++ b/codacy-conf.json @@ -1 +1 @@ -{"patterns":[{"patternId":"Custom_Javascript_Scopes","enabled":true},{"patternId":"Custom_Javascript_EvalWith","enabled":true},{"patternId":"Custom_Javascript_TryCatch","enabled":true},{"patternId":"Custom_Scala_NonFatal","enabled":true},{"patternId":"bitwise","enabled":true},{"patternId":"maxparams","enabled":true},{"patternId":"CSSLint_universal_selector","enabled":true},{"patternId":"CSSLint_unqualified_attributes","enabled":true},{"patternId":"CSSLint_zero_units","enabled":true},{"patternId":"CSSLint_overqualified_elements","enabled":true},{"patternId":"CSSLint_shorthand","enabled":true},{"patternId":"CSSLint_duplicate_background_images","enabled":true},{"patternId":"CSSLint_box_model","enabled":true},{"patternId":"CSSLint_compatible_vendor_prefixes","enabled":true},{"patternId":"CSSLint_display_property_grouping","enabled":true},{"patternId":"CSSLint_duplicate_properties","enabled":true},{"patternId":"CSSLint_empty_rules","enabled":true},{"patternId":"CSSLint_errors","enabled":true},{"patternId":"CSSLint_gradients","enabled":true},{"patternId":"CSSLint_important","enabled":true},{"patternId":"CSSLint_known_properties","enabled":true},{"patternId":"CSSLint_text_indent","enabled":true},{"patternId":"CSSLint_unique_headings","enabled":true},{"patternId":"PyLint_E0100","enabled":true},{"patternId":"PyLint_E0101","enabled":true},{"patternId":"PyLint_E0102","enabled":true},{"patternId":"PyLint_E0103","enabled":true},{"patternId":"PyLint_E0104","enabled":true},{"patternId":"PyLint_E0105","enabled":true},{"patternId":"PyLint_E0106","enabled":true},{"patternId":"PyLint_E0107","enabled":true},{"patternId":"PyLint_E0108","enabled":true},{"patternId":"PyLint_E0202","enabled":true},{"patternId":"PyLint_E0203","enabled":true},{"patternId":"PyLint_E0211","enabled":true},{"patternId":"PyLint_E0601","enabled":true},{"patternId":"PyLint_E0603","enabled":true},{"patternId":"PyLint_E0604","enabled":true},{"patternId":"PyLint_E0701","enabled":true},{"patternId":"PyLint_E0702","enabled":true},{"patternId":"PyLint_E0710","enabled":true},{"patternId":"PyLint_E0711","enabled":true},{"patternId":"PyLint_E0712","enabled":true},{"patternId":"PyLint_E1003","enabled":true},{"patternId":"PyLint_E1102","enabled":true},{"patternId":"PyLint_E1111","enabled":true},{"patternId":"PyLint_E1120","enabled":true},{"patternId":"PyLint_E1121","enabled":true},{"patternId":"PyLint_E1123","enabled":true},{"patternId":"PyLint_E1124","enabled":true},{"patternId":"PyLint_E1200","enabled":true},{"patternId":"PyLint_E1201","enabled":true},{"patternId":"PyLint_E1205","enabled":true},{"patternId":"PyLint_E1206","enabled":true},{"patternId":"PyLint_E1300","enabled":true},{"patternId":"PyLint_E1301","enabled":true},{"patternId":"PyLint_E1302","enabled":true},{"patternId":"PyLint_E1303","enabled":true},{"patternId":"PyLint_E1304","enabled":true},{"patternId":"PyLint_E1305","enabled":true},{"patternId":"PyLint_E1306","enabled":true},{"patternId":"rulesets-codesize.xml-CyclomaticComplexity","enabled":true},{"patternId":"rulesets-codesize.xml-NPathComplexity","enabled":true},{"patternId":"rulesets-codesize.xml-ExcessiveMethodLength","enabled":true},{"patternId":"rulesets-codesize.xml-ExcessiveClassLength","enabled":true},{"patternId":"rulesets-codesize.xml-ExcessiveParameterList","enabled":true},{"patternId":"rulesets-codesize.xml-ExcessivePublicCount","enabled":true},{"patternId":"rulesets-codesize.xml-TooManyFields","enabled":true},{"patternId":"rulesets-codesize.xml-TooManyMethods","enabled":true},{"patternId":"rulesets-codesize.xml-ExcessiveClassComplexity","enabled":true},{"patternId":"rulesets-controversial.xml-Superglobals","enabled":true},{"patternId":"rulesets-design.xml-ExitExpression","enabled":true},{"patternId":"rulesets-design.xml-EvalExpression","enabled":true},{"patternId":"rulesets-design.xml-GotoStatement","enabled":true},{"patternId":"rulesets-design.xml-NumberOfChildren","enabled":true},{"patternId":"rulesets-design.xml-DepthOfInheritance","enabled":true},{"patternId":"rulesets-unusedcode.xml-UnusedPrivateField","enabled":true},{"patternId":"rulesets-unusedcode.xml-UnusedLocalVariable","enabled":true},{"patternId":"rulesets-unusedcode.xml-UnusedPrivateMethod","enabled":true},{"patternId":"rulesets-unusedcode.xml-UnusedFormalParameter","enabled":true},{"patternId":"PyLint_C0303","enabled":true},{"patternId":"PyLint_C1001","enabled":true},{"patternId":"rulesets-naming.xml-ShortVariable","enabled":true},{"patternId":"rulesets-naming.xml-LongVariable","enabled":true},{"patternId":"rulesets-naming.xml-ShortMethodName","enabled":true},{"patternId":"rulesets-naming.xml-ConstantNamingConventions","enabled":true},{"patternId":"rulesets-naming.xml-BooleanGetMethodName","enabled":true},{"patternId":"PyLint_W0101","enabled":true},{"patternId":"PyLint_W0102","enabled":true},{"patternId":"PyLint_W0104","enabled":true},{"patternId":"PyLint_W0105","enabled":true},{"patternId":"Custom_Scala_GetCalls","enabled":true},{"patternId":"ScalaStyle_EqualsHashCodeChecker","enabled":true},{"patternId":"ScalaStyle_ParameterNumberChecker","enabled":true},{"patternId":"ScalaStyle_ReturnChecker","enabled":true},{"patternId":"ScalaStyle_NullChecker","enabled":true},{"patternId":"ScalaStyle_NoCloneChecker","enabled":true},{"patternId":"ScalaStyle_NoFinalizeChecker","enabled":true},{"patternId":"ScalaStyle_CovariantEqualsChecker","enabled":true},{"patternId":"ScalaStyle_StructuralTypeChecker","enabled":true},{"patternId":"ScalaStyle_MethodLengthChecker","enabled":true},{"patternId":"ScalaStyle_NumberOfMethodsInTypeChecker","enabled":true},{"patternId":"ScalaStyle_WhileChecker","enabled":true},{"patternId":"ScalaStyle_VarFieldChecker","enabled":true},{"patternId":"ScalaStyle_VarLocalChecker","enabled":true},{"patternId":"ScalaStyle_RedundantIfChecker","enabled":true},{"patternId":"ScalaStyle_DeprecatedJavaChecker","enabled":true},{"patternId":"ScalaStyle_EmptyClassChecker","enabled":true},{"patternId":"ScalaStyle_NotImplementedErrorUsage","enabled":true},{"patternId":"Custom_Scala_GroupImports","enabled":true},{"patternId":"Custom_Scala_ReservedKeywords","enabled":true},{"patternId":"Custom_Scala_ElseIf","enabled":true},{"patternId":"Custom_Scala_CallByNameAsLastArguments","enabled":true},{"patternId":"Custom_Scala_WildcardImportOnMany","enabled":true},{"patternId":"Custom_Scala_UtilTryForTryCatch","enabled":true},{"patternId":"Custom_Scala_ProhibitObjectName","enabled":true},{"patternId":"Custom_Scala_ImportsAtBeginningOfPackage","enabled":true},{"patternId":"Custom_Scala_NameResultsAndParameters","enabled":true},{"patternId":"Custom_Scala_IncompletePatternMatching","enabled":true},{"patternId":"Custom_Scala_UsefulTypeAlias","enabled":true},{"patternId":"Custom_Scala_JavaThreads","enabled":true},{"patternId":"Custom_Scala_DirectPromiseCreation","enabled":true},{"patternId":"Custom_Scala_StructuralTypes","enabled":true},{"patternId":"Custom_Scala_CollectionLastHead","enabled":true},{"patternId":"PyLint_W0106","enabled":true},{"patternId":"PyLint_W0107","enabled":true},{"patternId":"PyLint_W0108","enabled":true},{"patternId":"PyLint_W0109","enabled":true},{"patternId":"PyLint_W0110","enabled":true},{"patternId":"PyLint_W0120","enabled":true},{"patternId":"PyLint_W0122","enabled":true},{"patternId":"PyLint_W0150","enabled":true},{"patternId":"PyLint_W0199","enabled":true},{"patternId":"rulesets-cleancode.xml-ElseExpression","enabled":true},{"patternId":"rulesets-cleancode.xml-StaticAccess","enabled":true},{"patternId":"ScalaStyle_NonASCIICharacterChecker","enabled":true},{"patternId":"ScalaStyle_FieldNamesChecker","enabled":true},{"patternId":"Custom_Scala_WithNameCalls","enabled":true},{"patternId":"braces_IfElseStmtsMustUseBraces","enabled":true},{"patternId":"basic_AvoidDecimalLiteralsInBigDecimalConstructor","enabled":true},{"patternId":"basic_CheckSkipResult","enabled":true},{"patternId":"design_AvoidInstanceofChecksInCatchClause","enabled":true},{"patternId":"j2ee_DoNotCallSystemExit","enabled":true},{"patternId":"unusedcode_UnusedLocalVariable","enabled":true},{"patternId":"basic_DontUseFloatTypeForLoopIndices","enabled":true},{"patternId":"basic_AvoidBranchingStatementAsLastInLoop","enabled":true},{"patternId":"empty_EmptyFinallyBlock","enabled":true},{"patternId":"design_CompareObjectsWithEquals","enabled":true},{"patternId":"junit_UnnecessaryBooleanAssertion","enabled":true},{"patternId":"design_SimplifyBooleanExpressions","enabled":true},{"patternId":"basic_JumbledIncrementer","enabled":true},{"patternId":"design_SwitchStmtsShouldHaveDefault","enabled":true},{"patternId":"strictexception_AvoidThrowingRawExceptionTypes","enabled":true},{"patternId":"design_SimplifyBooleanReturns","enabled":true},{"patternId":"empty_EmptyInitializer","enabled":true},{"patternId":"design_FieldDeclarationsShouldBeAtStartOfClass","enabled":true},{"patternId":"naming_PackageCase","enabled":true},{"patternId":"controversial_UnnecessaryConstructor","enabled":true},{"patternId":"naming_MethodNamingConventions","enabled":true},{"patternId":"basic_UnconditionalIfStatement","enabled":true},{"patternId":"design_SingularField","enabled":true},{"patternId":"design_AssignmentToNonFinalStatic","enabled":true},{"patternId":"strings_UseStringBufferLength","enabled":true},{"patternId":"finalizers_AvoidCallingFinalize","enabled":true},{"patternId":"naming_ClassNamingConventions","enabled":true},{"patternId":"imports_UnnecessaryFullyQualifiedName","enabled":true},{"patternId":"unusedcode_UnusedPrivateField","enabled":true},{"patternId":"strings_UnnecessaryCaseChange","enabled":true},{"patternId":"design_NonStaticInitializer","enabled":true},{"patternId":"design_MissingBreakInSwitch","enabled":true},{"patternId":"design_AvoidReassigningParameters","enabled":true},{"patternId":"basic_AvoidThreadGroup","enabled":true},{"patternId":"codesize_ExcessiveParameterList","parameters":{"minimum":"8","violationSuppressRegex":"\"\"","violationSuppressXPath":"\"\""},"enabled":true},{"patternId":"design_UncommentedEmptyMethodBody","enabled":true},{"patternId":"basic_BrokenNullCheck","enabled":true},{"patternId":"strings_StringInstantiation","enabled":true},{"patternId":"design_EqualsNull","enabled":true},{"patternId":"basic_OverrideBothEqualsAndHashcode","enabled":true},{"patternId":"basic_BooleanInstantiation","enabled":true},{"patternId":"basic_ReturnFromFinallyBlock","enabled":true},{"patternId":"empty_EmptyTryBlock","enabled":true},{"patternId":"basic_ExtendsObject","enabled":true},{"patternId":"strictexception_AvoidThrowingNullPointerException","enabled":true},{"patternId":"empty_EmptySwitchStatements","enabled":true},{"patternId":"basic_MisplacedNullCheck","enabled":true},{"patternId":"strings_StringToString","enabled":true},{"patternId":"naming_MethodWithSameNameAsEnclosingClass","enabled":true},{"patternId":"imports_UnusedImports","enabled":true},{"patternId":"basic_AvoidMultipleUnaryOperators","enabled":true},{"patternId":"junit_SimplifyBooleanAssertion","enabled":true},{"patternId":"braces_IfStmtsMustUseBraces","enabled":true},{"patternId":"naming_NoPackage","enabled":true},{"patternId":"unusedcode_UnusedFormalParameter","enabled":true},{"patternId":"empty_EmptyStatementNotInLoop","enabled":true},{"patternId":"naming_GenericsNaming","enabled":true},{"patternId":"strings_UseEqualsToCompareStrings","enabled":true},{"patternId":"empty_EmptyStaticInitializer","enabled":true},{"patternId":"empty_EmptyStatementBlock","enabled":true},{"patternId":"basic_CollapsibleIfStatements","enabled":true},{"patternId":"design_ImmutableField","enabled":true},{"patternId":"controversial_OneDeclarationPerLine","enabled":true},{"patternId":"unnecessary_UnnecessaryReturn","enabled":true},{"patternId":"codesize_NPathComplexity","enabled":true},{"patternId":"imports_DontImportJavaLang","enabled":true},{"patternId":"empty_EmptySynchronizedBlock","enabled":true},{"patternId":"unnecessary_UselessOperationOnImmutable","enabled":true},{"patternId":"design_PositionLiteralsFirstInComparisons","enabled":true},{"patternId":"junit_JUnitSpelling","enabled":true},{"patternId":"finalizers_EmptyFinalizer","enabled":true},{"patternId":"design_NonCaseLabelInSwitchStatement","enabled":true},{"patternId":"android_DoNotHardCodeSDCard","enabled":true},{"patternId":"design_LogicInversion","enabled":true},{"patternId":"unusedcode_UnusedPrivateMethod","enabled":true},{"patternId":"basic_CheckResultSet","enabled":true},{"patternId":"controversial_AvoidPrefixingMethodParameters","enabled":true},{"patternId":"empty_EmptyIfStmt","enabled":true},{"patternId":"basic_DontCallThreadRun","enabled":true},{"patternId":"junit_JUnitStaticSuite","enabled":true},{"patternId":"codesize_ExcessiveMethodLength","enabled":true},{"patternId":"design_MissingStaticMethodInNonInstantiatableClass","enabled":true},{"patternId":"Style_MethodName","enabled":true},{"patternId":"Metrics_CyclomaticComplexity","enabled":true},{"patternId":"Lint_DuplicateMethods","enabled":true},{"patternId":"Style_Lambda","enabled":true},{"patternId":"Lint_UselessSetterCall","enabled":true},{"patternId":"Style_VariableName","enabled":true},{"patternId":"Lint_AmbiguousOperator","enabled":true},{"patternId":"Style_LeadingCommentSpace","enabled":true},{"patternId":"Style_CaseEquality","enabled":true},{"patternId":"Lint_StringConversionInInterpolation","enabled":true},{"patternId":"Performance_ReverseEach","enabled":true},{"patternId":"Lint_LiteralInCondition","enabled":true},{"patternId":"Performance_Sample","enabled":true},{"patternId":"Style_NonNilCheck","enabled":true},{"patternId":"Lint_RescueException","enabled":true},{"patternId":"Lint_UselessElseWithoutRescue","enabled":true},{"patternId":"Style_ConstantName","enabled":true},{"patternId":"Lint_LiteralInInterpolation","enabled":true},{"patternId":"Lint_NestedMethodDefinition","enabled":true},{"patternId":"Style_DoubleNegation","enabled":true},{"patternId":"Lint_SpaceBeforeFirstArg","enabled":true},{"patternId":"Lint_Debugger","enabled":true},{"patternId":"Style_ClassVars","enabled":true},{"patternId":"Lint_EmptyEnsure","enabled":true},{"patternId":"Style_MultilineBlockLayout","enabled":true},{"patternId":"Lint_UnusedBlockArgument","enabled":true},{"patternId":"Lint_UselessAccessModifier","enabled":true},{"patternId":"Performance_Size","enabled":true},{"patternId":"Lint_EachWithObjectArgument","enabled":true},{"patternId":"Style_Alias","enabled":true},{"patternId":"Lint_Loop","enabled":true},{"patternId":"Style_NegatedWhile","enabled":true},{"patternId":"Style_ColonMethodCall","enabled":true},{"patternId":"Lint_AmbiguousRegexpLiteral","enabled":true},{"patternId":"Lint_UnusedMethodArgument","enabled":true},{"patternId":"Style_MultilineIfThen","enabled":true},{"patternId":"Lint_EnsureReturn","enabled":true},{"patternId":"Style_NegatedIf","enabled":true},{"patternId":"Lint_Eval","enabled":true},{"patternId":"Style_NilComparison","enabled":true},{"patternId":"Style_ArrayJoin","enabled":true},{"patternId":"Lint_ConditionPosition","enabled":true},{"patternId":"Lint_UnreachableCode","enabled":true},{"patternId":"Performance_Count","enabled":true},{"patternId":"Lint_EmptyInterpolation","enabled":true},{"patternId":"Style_LambdaCall","enabled":true},{"patternId":"Lint_HandleExceptions","enabled":true},{"patternId":"Lint_ShadowingOuterLocalVariable","enabled":true},{"patternId":"Lint_EndAlignment","enabled":true},{"patternId":"Style_MultilineTernaryOperator","enabled":true},{"patternId":"Style_AutoResourceCleanup","enabled":true},{"patternId":"Lint_ElseLayout","enabled":true},{"patternId":"Style_NestedTernaryOperator","enabled":true},{"patternId":"Style_OneLineConditional","enabled":true},{"patternId":"Style_EmptyElse","enabled":true},{"patternId":"Lint_UselessComparison","enabled":true},{"patternId":"Metrics_PerceivedComplexity","enabled":true},{"patternId":"Style_InfiniteLoop","enabled":true},{"patternId":"Rails_Date","enabled":true},{"patternId":"Style_EvenOdd","enabled":true},{"patternId":"Style_IndentationConsistency","enabled":true},{"patternId":"Style_ModuleFunction","enabled":true},{"patternId":"Lint_UselessAssignment","enabled":true},{"patternId":"Style_EachWithObject","enabled":true},{"patternId":"Performance_Detect","enabled":true},{"patternId":"duplicate_key","enabled":true},{"patternId":"no_interpolation_in_single_quotes","enabled":true},{"patternId":"no_backticks","enabled":true},{"patternId":"no_unnecessary_fat_arrows","enabled":true},{"patternId":"indentation","enabled":true},{"patternId":"ensure_comprehensions","enabled":true},{"patternId":"no_stand_alone_at","enabled":true},{"patternId":"cyclomatic_complexity","enabled":true},{"patternId":"Deserialize","enabled":true},{"patternId":"SymbolDoS","enabled":true},{"patternId":"SkipBeforeFilter","enabled":true},{"patternId":"SanitizeMethods","enabled":true},{"patternId":"SelectTag","enabled":true},{"patternId":"XMLDoS","enabled":true},{"patternId":"SimpleFormat","enabled":true},{"patternId":"Evaluation","enabled":true},{"patternId":"BasicAuth","enabled":true},{"patternId":"JRubyXML","enabled":true},{"patternId":"RenderInline","enabled":true},{"patternId":"YAMLParsing","enabled":true},{"patternId":"Redirect","enabled":true},{"patternId":"UnsafeReflection","enabled":true},{"patternId":"SSLVerify","enabled":true},{"patternId":"HeaderDoS","enabled":true},{"patternId":"TranslateBug","enabled":true},{"patternId":"Execute","enabled":true},{"patternId":"JSONParsing","enabled":true},{"patternId":"LinkTo","enabled":true},{"patternId":"FileDisclosure","enabled":true},{"patternId":"SafeBufferManipulation","enabled":true},{"patternId":"ModelAttributes","enabled":true},{"patternId":"ResponseSplitting","enabled":true},{"patternId":"DigestDoS","enabled":true},{"patternId":"Send","enabled":true},{"patternId":"MailTo","enabled":true},{"patternId":"SymbolDoSCVE","enabled":true},{"patternId":"StripTags","enabled":true},{"patternId":"MassAssignment","enabled":true},{"patternId":"RegexDoS","enabled":true},{"patternId":"SelectVulnerability","enabled":true},{"patternId":"FileAccess","enabled":true},{"patternId":"ContentTag","enabled":true},{"patternId":"SessionSettings","enabled":true},{"patternId":"FilterSkipping","enabled":true},{"patternId":"CreateWith","enabled":true},{"patternId":"JSONEncoding","enabled":true},{"patternId":"SQLCVEs","enabled":true},{"patternId":"ForgerySetting","enabled":true},{"patternId":"QuoteTableName","enabled":true},{"patternId":"I18nXSS","enabled":true},{"patternId":"WithoutProtection","enabled":true},{"patternId":"CrossSiteScripting","enabled":true},{"patternId":"SingleQuotes","enabled":true},{"patternId":"NestedAttributes","enabled":true},{"patternId":"DetailedExceptions","enabled":true},{"patternId":"LinkToHref","enabled":true},{"patternId":"RenderDoS","enabled":true},{"patternId":"ModelSerialize","enabled":true},{"patternId":"SQL","enabled":true},{"patternId":"Render","enabled":true},{"patternId":"UnscopedFind","enabled":true},{"patternId":"ValidationRegex","enabled":true},{"patternId":"EscapeFunction","enabled":true},{"patternId":"Custom_Scala_FieldNamesChecker","enabled":true},{"patternId":"Custom_Scala_ObjDeserialization","enabled":true},{"patternId":"Custom_Scala_RSAPadding","enabled":true},{"patternId":"ESLint_no-extra-boolean-cast","enabled":true},{"patternId":"ESLint_no-iterator","enabled":true},{"patternId":"ESLint_no-invalid-regexp","enabled":true},{"patternId":"ESLint_no-obj-calls","enabled":true},{"patternId":"ESLint_no-sparse-arrays","enabled":true},{"patternId":"ESLint_no-unreachable","enabled":true},{"patternId":"ESLint_no-dupe-keys","enabled":true},{"patternId":"ESLint_no-multi-str","enabled":true},{"patternId":"ESLint_no-extend-native","enabled":true},{"patternId":"ESLint_guard-for-in","enabled":true},{"patternId":"ESLint_no-func-assign","enabled":true},{"patternId":"ESLint_no-extra-semi","enabled":true},{"patternId":"ESLint_camelcase","enabled":true},{"patternId":"ESLint_no-mixed-spaces-and-tabs","enabled":true},{"patternId":"ESLint_no-undef","enabled":true},{"patternId":"ESLint_semi","enabled":true},{"patternId":"ESLint_no-empty-character-class","enabled":true},{"patternId":"ESLint_complexity","enabled":true},{"patternId":"ESLint_no-dupe-class-members","enabled":true},{"patternId":"ESLint_no-debugger","enabled":true},{"patternId":"ESLint_block-scoped-var","enabled":true},{"patternId":"ESLint_no-loop-func","enabled":true},{"patternId":"ESLint_no-use-before-define","enabled":true},{"patternId":"ESLint_no-console","enabled":true},{"patternId":"ESLint_require-yield","enabled":true},{"patternId":"ESLint_no-redeclare","enabled":true},{"patternId":"ESLint_no-undefined","enabled":true},{"patternId":"ESLint_use-isnan","enabled":true},{"patternId":"ESLint_no-control-regex","enabled":true},{"patternId":"ESLint_no-const-assign","enabled":true},{"patternId":"ESLint_no-new","enabled":true},{"patternId":"ESLint_new-cap","enabled":true},{"patternId":"ESLint_no-irregular-whitespace","enabled":true},{"patternId":"ESLint_object-shorthand","enabled":true},{"patternId":"ESLint_no-ex-assign","enabled":true},{"patternId":"ESLint_wrap-iife","enabled":true},{"patternId":"ESLint_arrow-parens","enabled":true},{"patternId":"ESLint_no-constant-condition","enabled":true},{"patternId":"ESLint_no-octal","enabled":true},{"patternId":"ESLint_no-dupe-args","enabled":true},{"patternId":"ESLint_quotes","enabled":true},{"patternId":"ESLint_no-fallthrough","enabled":true},{"patternId":"ESLint_no-delete-var","enabled":true},{"patternId":"ESLint_no-caller","enabled":true},{"patternId":"ESLint_no-cond-assign","enabled":true},{"patternId":"ESLint_no-this-before-super","enabled":true},{"patternId":"ESLint_no-negated-in-lhs","enabled":true},{"patternId":"ESLint_no-inner-declarations","enabled":true},{"patternId":"ESLint_eqeqeq","enabled":true},{"patternId":"ESLint_curly","enabled":true},{"patternId":"ESLint_arrow-spacing","enabled":true},{"patternId":"ESLint_no-empty","enabled":true},{"patternId":"ESLint_no-unused-vars","enabled":true},{"patternId":"ESLint_generator-star-spacing","enabled":true},{"patternId":"ESLint_no-duplicate-case","enabled":true},{"patternId":"ESLint_valid-typeof","enabled":true},{"patternId":"ESLint_no-regex-spaces","enabled":true},{"patternId":"ESLint_no-class-assign","enabled":true},{"patternId":"PyLint_W0221","enabled":true},{"patternId":"PyLint_E0117","enabled":true},{"patternId":"PyLint_E0001","enabled":true},{"patternId":"PyLint_E0241","enabled":true},{"patternId":"PyLint_W0404","enabled":true},{"patternId":"PyLint_E0704","enabled":true},{"patternId":"PyLint_E0703","enabled":true},{"patternId":"PyLint_E0302","enabled":true},{"patternId":"PyLint_W1301","enabled":true},{"patternId":"PyLint_R0201","enabled":true},{"patternId":"PyLint_E0113","enabled":true},{"patternId":"PyLint_W0410","enabled":true},{"patternId":"PyLint_C0123","enabled":true},{"patternId":"PyLint_E0115","enabled":true},{"patternId":"PyLint_E0114","enabled":true},{"patternId":"PyLint_E1126","enabled":true},{"patternId":"PyLint_W0702","enabled":true},{"patternId":"PyLint_W1303","enabled":true},{"patternId":"PyLint_W0622","enabled":true},{"patternId":"PyLint_W0222","enabled":true},{"patternId":"PyLint_W0233","enabled":true},{"patternId":"PyLint_W1305","enabled":true},{"patternId":"PyLint_E1127","enabled":true},{"patternId":"PyLint_E0112","enabled":true},{"patternId":"PyLint_W0611","enabled":true},{"patternId":"PyLint_W0601","enabled":true},{"patternId":"PyLint_W1300","enabled":true},{"patternId":"PyLint_W0124","enabled":true},{"patternId":"PyLint_R0203","enabled":true},{"patternId":"PyLint_E0236","enabled":true},{"patternId":"PyLint_W0612","enabled":true},{"patternId":"PyLint_W0604","enabled":true},{"patternId":"PyLint_W0705","enabled":true},{"patternId":"PyLint_E0238","enabled":true},{"patternId":"PyLint_W0602","enabled":true},{"patternId":"PyLint_R0102","enabled":true},{"patternId":"PyLint_R0202","enabled":true},{"patternId":"PyLint_E0240","enabled":true},{"patternId":"PyLint_W0623","enabled":true},{"patternId":"PyLint_W0711","enabled":true},{"patternId":"PyLint_E0116","enabled":true},{"patternId":"PyLint_E0239","enabled":true},{"patternId":"PyLint_E1132","enabled":true},{"patternId":"PyLint_W1307","enabled":true},{"patternId":"PyLint_C0200","enabled":true},{"patternId":"PyLint_E0301","enabled":true},{"patternId":"PyLint_W1306","enabled":true},{"patternId":"PyLint_W1302","enabled":true},{"patternId":"PyLint_E0110","enabled":true},{"patternId":"PyLint_E1125","enabled":true}]} \ No newline at end of file +{"patterns":[{"patternId":"Custom_Javascript_Scopes","enabled":true},{"patternId":"Custom_Javascript_EvalWith","enabled":true},{"patternId":"Custom_Javascript_TryCatch","enabled":true},{"patternId":"Custom_Scala_NonFatal","enabled":true},{"patternId":"bitwise","enabled":true},{"patternId":"maxparams","enabled":true},{"patternId":"CSSLint_universal_selector","enabled":true},{"patternId":"CSSLint_unqualified_attributes","enabled":true},{"patternId":"CSSLint_zero_units","enabled":true},{"patternId":"CSSLint_overqualified_elements","enabled":true},{"patternId":"CSSLint_shorthand","enabled":true},{"patternId":"CSSLint_duplicate_background_images","enabled":true},{"patternId":"CSSLint_box_model","enabled":true},{"patternId":"CSSLint_compatible_vendor_prefixes","enabled":true},{"patternId":"CSSLint_display_property_grouping","enabled":true},{"patternId":"CSSLint_duplicate_properties","enabled":true},{"patternId":"CSSLint_empty_rules","enabled":true},{"patternId":"CSSLint_errors","enabled":true},{"patternId":"CSSLint_gradients","enabled":true},{"patternId":"CSSLint_important","enabled":true},{"patternId":"CSSLint_known_properties","enabled":true},{"patternId":"CSSLint_text_indent","enabled":true},{"patternId":"CSSLint_unique_headings","enabled":true},{"patternId":"PyLint_E0100","enabled":true},{"patternId":"PyLint_E0101","enabled":true},{"patternId":"PyLint_E0102","enabled":true},{"patternId":"PyLint_E0103","enabled":true},{"patternId":"PyLint_E0104","enabled":true},{"patternId":"PyLint_E0105","enabled":true},{"patternId":"PyLint_E0106","enabled":true},{"patternId":"PyLint_E0107","enabled":true},{"patternId":"PyLint_E0108","enabled":true},{"patternId":"PyLint_E0202","enabled":true},{"patternId":"PyLint_E0203","enabled":true},{"patternId":"PyLint_E0211","enabled":true},{"patternId":"PyLint_E0601","enabled":true},{"patternId":"PyLint_E0603","enabled":true},{"patternId":"PyLint_E0604","enabled":true},{"patternId":"PyLint_E0701","enabled":true},{"patternId":"PyLint_E0702","enabled":true},{"patternId":"PyLint_E0710","enabled":true},{"patternId":"PyLint_E0711","enabled":true},{"patternId":"PyLint_E0712","enabled":true},{"patternId":"PyLint_E1003","enabled":true},{"patternId":"PyLint_E1102","enabled":true},{"patternId":"PyLint_E1111","enabled":true},{"patternId":"PyLint_E1120","enabled":true},{"patternId":"PyLint_E1121","enabled":true},{"patternId":"PyLint_E1123","enabled":true},{"patternId":"PyLint_E1124","enabled":true},{"patternId":"PyLint_E1200","enabled":true},{"patternId":"PyLint_E1201","enabled":true},{"patternId":"PyLint_E1205","enabled":true},{"patternId":"PyLint_E1206","enabled":true},{"patternId":"PyLint_E1300","enabled":true},{"patternId":"PyLint_E1301","enabled":true},{"patternId":"PyLint_E1302","enabled":true},{"patternId":"PyLint_E1303","enabled":true},{"patternId":"PyLint_E1304","enabled":true},{"patternId":"PyLint_E1305","enabled":true},{"patternId":"PyLint_E1306","enabled":true},{"patternId":"rulesets-codesize.xml-CyclomaticComplexity","enabled":true},{"patternId":"rulesets-codesize.xml-NPathComplexity","enabled":true},{"patternId":"rulesets-codesize.xml-ExcessiveMethodLength","enabled":true},{"patternId":"rulesets-codesize.xml-ExcessiveClassLength","enabled":true},{"patternId":"rulesets-codesize.xml-ExcessiveParameterList","enabled":true},{"patternId":"rulesets-codesize.xml-ExcessivePublicCount","enabled":true},{"patternId":"rulesets-codesize.xml-TooManyFields","enabled":true},{"patternId":"rulesets-codesize.xml-TooManyMethods","enabled":true},{"patternId":"rulesets-codesize.xml-ExcessiveClassComplexity","enabled":true},{"patternId":"rulesets-controversial.xml-Superglobals","enabled":true},{"patternId":"rulesets-design.xml-ExitExpression","enabled":true},{"patternId":"rulesets-design.xml-EvalExpression","enabled":true},{"patternId":"rulesets-design.xml-GotoStatement","enabled":true},{"patternId":"rulesets-design.xml-NumberOfChildren","enabled":true},{"patternId":"rulesets-design.xml-DepthOfInheritance","enabled":true},{"patternId":"rulesets-unusedcode.xml-UnusedPrivateField","enabled":true},{"patternId":"rulesets-unusedcode.xml-UnusedLocalVariable","enabled":true},{"patternId":"rulesets-unusedcode.xml-UnusedPrivateMethod","enabled":true},{"patternId":"rulesets-unusedcode.xml-UnusedFormalParameter","enabled":true},{"patternId":"PyLint_C0303","enabled":true},{"patternId":"PyLint_C1001","enabled":true},{"patternId":"rulesets-naming.xml-ShortVariable","enabled":true},{"patternId":"rulesets-naming.xml-LongVariable","enabled":true},{"patternId":"rulesets-naming.xml-ShortMethodName","enabled":true},{"patternId":"rulesets-naming.xml-ConstantNamingConventions","enabled":true},{"patternId":"rulesets-naming.xml-BooleanGetMethodName","enabled":true},{"patternId":"PyLint_W0101","enabled":true},{"patternId":"PyLint_W0102","enabled":true},{"patternId":"PyLint_W0104","enabled":true},{"patternId":"PyLint_W0105","enabled":true},{"patternId":"Custom_Scala_GetCalls","enabled":true},{"patternId":"ScalaStyle_EqualsHashCodeChecker","enabled":true},{"patternId":"ScalaStyle_ParameterNumberChecker","enabled":true},{"patternId":"ScalaStyle_ReturnChecker","enabled":true},{"patternId":"ScalaStyle_NullChecker","enabled":true},{"patternId":"ScalaStyle_NoCloneChecker","enabled":true},{"patternId":"ScalaStyle_NoFinalizeChecker","enabled":true},{"patternId":"ScalaStyle_CovariantEqualsChecker","enabled":true},{"patternId":"ScalaStyle_StructuralTypeChecker","enabled":true},{"patternId":"ScalaStyle_MethodLengthChecker","enabled":true},{"patternId":"ScalaStyle_NumberOfMethodsInTypeChecker","enabled":true},{"patternId":"ScalaStyle_WhileChecker","enabled":true},{"patternId":"ScalaStyle_VarFieldChecker","enabled":true},{"patternId":"ScalaStyle_VarLocalChecker","enabled":true},{"patternId":"ScalaStyle_RedundantIfChecker","enabled":true},{"patternId":"ScalaStyle_DeprecatedJavaChecker","enabled":true},{"patternId":"ScalaStyle_EmptyClassChecker","enabled":true},{"patternId":"ScalaStyle_NotImplementedErrorUsage","enabled":true},{"patternId":"Custom_Scala_GroupImports","enabled":true},{"patternId":"Custom_Scala_ReservedKeywords","enabled":true},{"patternId":"Custom_Scala_ElseIf","enabled":true},{"patternId":"Custom_Scala_CallByNameAsLastArguments","enabled":true},{"patternId":"Custom_Scala_WildcardImportOnMany","enabled":true},{"patternId":"Custom_Scala_UtilTryForTryCatch","enabled":true},{"patternId":"Custom_Scala_ProhibitObjectName","enabled":true},{"patternId":"Custom_Scala_ImportsAtBeginningOfPackage","enabled":true},{"patternId":"Custom_Scala_NameResultsAndParameters","enabled":true},{"patternId":"Custom_Scala_IncompletePatternMatching","enabled":true},{"patternId":"Custom_Scala_UsefulTypeAlias","enabled":true},{"patternId":"Custom_Scala_JavaThreads","enabled":true},{"patternId":"Custom_Scala_DirectPromiseCreation","enabled":true},{"patternId":"Custom_Scala_StructuralTypes","enabled":true},{"patternId":"Custom_Scala_CollectionLastHead","enabled":true},{"patternId":"PyLint_W0106","enabled":true},{"patternId":"PyLint_W0107","enabled":true},{"patternId":"PyLint_W0108","enabled":true},{"patternId":"PyLint_W0109","enabled":true},{"patternId":"PyLint_W0110","enabled":true},{"patternId":"PyLint_W0120","enabled":true},{"patternId":"PyLint_W0122","enabled":true},{"patternId":"PyLint_W0150","enabled":true},{"patternId":"PyLint_W0199","enabled":true},{"patternId":"rulesets-cleancode.xml-ElseExpression","enabled":true},{"patternId":"rulesets-cleancode.xml-StaticAccess","enabled":true},{"patternId":"ScalaStyle_NonASCIICharacterChecker","enabled":true},{"patternId":"ScalaStyle_FieldNamesChecker","enabled":true},{"patternId":"Custom_Scala_WithNameCalls","enabled":true},{"patternId":"strictexception_AvoidRethrowingException","enabled":true},{"patternId":"strings_AppendCharacterWithChar","enabled":true},{"patternId":"braces_IfElseStmtsMustUseBraces","enabled":true},{"patternId":"basic_AvoidDecimalLiteralsInBigDecimalConstructor","enabled":true},{"patternId":"basic_CheckSkipResult","enabled":true},{"patternId":"javabeans_MissingSerialVersionUID","enabled":true},{"patternId":"migrating_ShortInstantiation","enabled":true},{"patternId":"design_AvoidInstanceofChecksInCatchClause","enabled":true},{"patternId":"naming_LongVariable","enabled":true},{"patternId":"migrating_ReplaceEnumerationWithIterator","enabled":true},{"patternId":"j2ee_DoNotCallSystemExit","enabled":true},{"patternId":"unusedcode_UnusedLocalVariable","enabled":true},{"patternId":"strings_InefficientStringBuffering","enabled":true},{"patternId":"basic_DontUseFloatTypeForLoopIndices","enabled":true},{"patternId":"basic_AvoidBranchingStatementAsLastInLoop","enabled":true},{"patternId":"migrating_JUnit4TestShouldUseTestAnnotation","enabled":true},{"patternId":"optimizations_AddEmptyString","enabled":true},{"patternId":"logging-jakarta-commons_ProperLogger","enabled":true},{"patternId":"optimizations_RedundantFieldInitializer","enabled":true},{"patternId":"logging-java_AvoidPrintStackTrace","enabled":true},{"patternId":"empty_EmptyFinallyBlock","enabled":true},{"patternId":"design_CompareObjectsWithEquals","enabled":true},{"patternId":"basic_ClassCastExceptionWithToArray","enabled":true},{"patternId":"strictexception_DoNotExtendJavaLangError","enabled":true},{"patternId":"junit_UnnecessaryBooleanAssertion","enabled":true},{"patternId":"design_SimplifyBooleanExpressions","enabled":true},{"patternId":"basic_ForLoopShouldBeWhileLoop","enabled":true},{"patternId":"basic_BigIntegerInstantiation","enabled":true},{"patternId":"optimizations_UseArrayListInsteadOfVector","enabled":true},{"patternId":"optimizations_UnnecessaryWrapperObjectCreation","enabled":true},{"patternId":"strings_StringBufferInstantiationWithChar","enabled":true},{"patternId":"basic_JumbledIncrementer","enabled":true},{"patternId":"design_SwitchStmtsShouldHaveDefault","enabled":true},{"patternId":"strictexception_AvoidThrowingRawExceptionTypes","enabled":true},{"patternId":"migrating_LongInstantiation","enabled":true},{"patternId":"design_SimplifyBooleanReturns","enabled":true},{"patternId":"empty_EmptyInitializer","enabled":true},{"patternId":"design_FieldDeclarationsShouldBeAtStartOfClass","enabled":true},{"patternId":"unnecessary_UnnecessaryConversionTemporary","enabled":true},{"patternId":"design_AvoidProtectedFieldInFinalClass","enabled":true},{"patternId":"junit_UseAssertTrueInsteadOfAssertEquals","enabled":true},{"patternId":"naming_PackageCase","enabled":true},{"patternId":"migrating_JUnitUseExpected","enabled":true},{"patternId":"controversial_UnnecessaryConstructor","enabled":true},{"patternId":"naming_MethodNamingConventions","enabled":true},{"patternId":"design_DefaultLabelNotLastInSwitchStmt","enabled":true},{"patternId":"basic_UnconditionalIfStatement","enabled":true},{"patternId":"design_SingularField","enabled":true},{"patternId":"design_AssignmentToNonFinalStatic","enabled":true},{"patternId":"braces_WhileLoopsMustUseBraces","enabled":true},{"patternId":"logging-java_SystemPrintln","enabled":true},{"patternId":"strings_UseStringBufferLength","enabled":true},{"patternId":"controversial_AvoidUsingNativeCode","enabled":true},{"patternId":"strictexception_AvoidLosingExceptionInformation","enabled":true},{"patternId":"imports_ImportFromSamePackage","enabled":true},{"patternId":"finalizers_AvoidCallingFinalize","enabled":true},{"patternId":"finalizers_FinalizeOverloaded","enabled":true},{"patternId":"naming_ClassNamingConventions","enabled":true},{"patternId":"logging-java_LoggerIsNotStaticFinal","enabled":true},{"patternId":"finalizers_FinalizeOnlyCallsSuperFinalize","enabled":true},{"patternId":"unnecessary_UselessOverridingMethod","enabled":true},{"patternId":"naming_SuspiciousConstantFieldName","enabled":true},{"patternId":"design_OptimizableToArrayCall","enabled":true},{"patternId":"imports_UnnecessaryFullyQualifiedName","enabled":true},{"patternId":"migrating_ReplaceHashtableWithMap","enabled":true},{"patternId":"unusedcode_UnusedPrivateField","enabled":true},{"patternId":"strings_UnnecessaryCaseChange","enabled":true},{"patternId":"migrating_IntegerInstantiation","enabled":true},{"patternId":"design_NonStaticInitializer","enabled":true},{"patternId":"design_MissingBreakInSwitch","enabled":true},{"patternId":"design_AvoidReassigningParameters","enabled":true},{"patternId":"basic_AvoidThreadGroup","enabled":true},{"patternId":"empty_EmptyCatchBlock","parameters":{"allowCommentedBlocks":"true"},"enabled":true},{"patternId":"codesize_ExcessiveParameterList","parameters":{"minimum":"8","violationSuppressRegex":"\"\"","violationSuppressXPath":"\"\""},"enabled":true},{"patternId":"naming_SuspiciousHashcodeMethodName","enabled":true},{"patternId":"migrating_JUnit4TestShouldUseBeforeAnnotation","enabled":true},{"patternId":"design_UncommentedEmptyMethodBody","enabled":true},{"patternId":"basic_BrokenNullCheck","enabled":true},{"patternId":"strings_ConsecutiveLiteralAppends","enabled":true},{"patternId":"strings_StringInstantiation","enabled":true},{"patternId":"design_EqualsNull","enabled":true},{"patternId":"basic_OverrideBothEqualsAndHashcode","enabled":true},{"patternId":"design_InstantiationToGetClass","enabled":true},{"patternId":"basic_BooleanInstantiation","enabled":true},{"patternId":"strings_AvoidStringBufferField","enabled":true},{"patternId":"basic_ReturnFromFinallyBlock","enabled":true},{"patternId":"empty_EmptyTryBlock","enabled":true},{"patternId":"naming_SuspiciousEqualsMethodName","enabled":true},{"patternId":"basic_ExtendsObject","enabled":true},{"patternId":"strings_UselessStringValueOf","enabled":true},{"patternId":"design_UnsynchronizedStaticDateFormatter","enabled":true},{"patternId":"design_UseCollectionIsEmpty","enabled":true},{"patternId":"controversial_AvoidFinalLocalVariable","enabled":true},{"patternId":"strictexception_AvoidThrowingNullPointerException","enabled":true},{"patternId":"design_AvoidProtectedMethodInFinalClassNotExtending","enabled":true},{"patternId":"optimizations_PrematureDeclaration","enabled":true},{"patternId":"empty_EmptySwitchStatements","enabled":true},{"patternId":"basic_MisplacedNullCheck","enabled":true},{"patternId":"optimizations_UseStringBufferForStringAppends","enabled":true},{"patternId":"strings_StringToString","enabled":true},{"patternId":"naming_MethodWithSameNameAsEnclosingClass","enabled":true},{"patternId":"migrating_ReplaceVectorWithList","enabled":true},{"patternId":"imports_UnusedImports","enabled":true},{"patternId":"unnecessary_UnnecessaryFinalModifier","enabled":true},{"patternId":"basic_AvoidMultipleUnaryOperators","enabled":true},{"patternId":"junit_SimplifyBooleanAssertion","enabled":true},{"patternId":"unnecessary_UselessParentheses","enabled":true},{"patternId":"design_IdempotentOperations","enabled":true},{"patternId":"braces_IfStmtsMustUseBraces","enabled":true},{"patternId":"strings_UseIndexOfChar","enabled":true},{"patternId":"naming_NoPackage","enabled":true},{"patternId":"finalizers_FinalizeDoesNotCallSuperFinalize","enabled":true},{"patternId":"design_UseVarargs","enabled":true},{"patternId":"unusedcode_UnusedFormalParameter","enabled":true},{"patternId":"design_ReturnEmptyArrayRatherThanNull","enabled":true},{"patternId":"junit_UseAssertNullInsteadOfAssertTrue","enabled":true},{"patternId":"design_UseUtilityClass","enabled":true},{"patternId":"design_AvoidDeeplyNestedIfStmts","enabled":true},{"patternId":"empty_EmptyStatementNotInLoop","enabled":true},{"patternId":"junit_UseAssertSameInsteadOfAssertTrue","enabled":true},{"patternId":"braces_ForLoopsMustUseBraces","enabled":true},{"patternId":"controversial_DoNotCallGarbageCollectionExplicitly","enabled":true},{"patternId":"naming_GenericsNaming","enabled":true},{"patternId":"strings_UseEqualsToCompareStrings","enabled":true},{"patternId":"optimizations_AvoidArrayLoops","enabled":true},{"patternId":"empty_EmptyStaticInitializer","enabled":true},{"patternId":"design_UncommentedEmptyConstructor","enabled":true},{"patternId":"empty_EmptyStatementBlock","enabled":true},{"patternId":"basic_CollapsibleIfStatements","enabled":true},{"patternId":"design_FinalFieldCouldBeStatic","enabled":true},{"patternId":"logging-java_MoreThanOneLogger","enabled":true},{"patternId":"codesize_ExcessiveClassLength","enabled":true},{"patternId":"design_ImmutableField","enabled":true},{"patternId":"controversial_OneDeclarationPerLine","enabled":true},{"patternId":"empty_EmptyWhileStmt","enabled":true},{"patternId":"unnecessary_UnnecessaryReturn","enabled":true},{"patternId":"strings_InefficientEmptyStringCheck","enabled":true},{"patternId":"design_UseNotifyAllInsteadOfNotify","enabled":true},{"patternId":"strictexception_DoNotThrowExceptionInFinally","enabled":true},{"patternId":"junit_UseAssertEqualsInsteadOfAssertTrue","enabled":true},{"patternId":"typeresolution_CloneMethodMustImplementCloneable","enabled":true},{"patternId":"codesize_NPathComplexity","enabled":true},{"patternId":"imports_DontImportJavaLang","enabled":true},{"patternId":"empty_EmptySynchronizedBlock","enabled":true},{"patternId":"migrating_JUnit4TestShouldUseAfterAnnotation","enabled":true},{"patternId":"design_AvoidConstantsInterface","enabled":true},{"patternId":"unnecessary_UselessOperationOnImmutable","enabled":true},{"patternId":"design_PositionLiteralsFirstInComparisons","enabled":true},{"patternId":"migrating_ByteInstantiation","enabled":true},{"patternId":"junit_JUnitSpelling","enabled":true},{"patternId":"junit_JUnitTestsShouldIncludeAssert","enabled":true},{"patternId":"finalizers_EmptyFinalizer","enabled":true},{"patternId":"design_NonCaseLabelInSwitchStatement","enabled":true},{"patternId":"android_DoNotHardCodeSDCard","enabled":true},{"patternId":"design_LogicInversion","enabled":true},{"patternId":"unusedcode_UnusedPrivateMethod","enabled":true},{"patternId":"naming_AvoidDollarSigns","enabled":true},{"patternId":"finalizers_FinalizeShouldBeProtected","enabled":true},{"patternId":"clone_ProperCloneImplementation","enabled":true},{"patternId":"basic_CheckResultSet","enabled":true},{"patternId":"controversial_AvoidPrefixingMethodParameters","enabled":true},{"patternId":"migrating_JUnit4SuitesShouldUseSuiteAnnotation","enabled":true},{"patternId":"empty_EmptyIfStmt","enabled":true},{"patternId":"basic_DontCallThreadRun","enabled":true},{"patternId":"junit_JUnitStaticSuite","enabled":true},{"patternId":"optimizations_UseArraysAsList","enabled":true},{"patternId":"design_MissingStaticMethodInNonInstantiatableClass","enabled":true},{"patternId":"unusedcode_UnusedModifier","enabled":true},{"patternId":"Style_MethodName","enabled":true},{"patternId":"Metrics_CyclomaticComplexity","enabled":true},{"patternId":"Lint_DuplicateMethods","enabled":true},{"patternId":"Style_Lambda","enabled":true},{"patternId":"Lint_UselessSetterCall","enabled":true},{"patternId":"Style_VariableName","enabled":true},{"patternId":"Lint_AmbiguousOperator","enabled":true},{"patternId":"Style_LeadingCommentSpace","enabled":true},{"patternId":"Style_CaseEquality","enabled":true},{"patternId":"Lint_StringConversionInInterpolation","enabled":true},{"patternId":"Performance_ReverseEach","enabled":true},{"patternId":"Lint_LiteralInCondition","enabled":true},{"patternId":"Performance_Sample","enabled":true},{"patternId":"Style_NonNilCheck","enabled":true},{"patternId":"Lint_RescueException","enabled":true},{"patternId":"Lint_UselessElseWithoutRescue","enabled":true},{"patternId":"Style_ConstantName","enabled":true},{"patternId":"Lint_LiteralInInterpolation","enabled":true},{"patternId":"Lint_NestedMethodDefinition","enabled":true},{"patternId":"Style_DoubleNegation","enabled":true},{"patternId":"Lint_SpaceBeforeFirstArg","enabled":true},{"patternId":"Lint_Debugger","enabled":true},{"patternId":"Style_ClassVars","enabled":true},{"patternId":"Lint_EmptyEnsure","enabled":true},{"patternId":"Style_MultilineBlockLayout","enabled":true},{"patternId":"Lint_UnusedBlockArgument","enabled":true},{"patternId":"Lint_UselessAccessModifier","enabled":true},{"patternId":"Performance_Size","enabled":true},{"patternId":"Lint_EachWithObjectArgument","enabled":true},{"patternId":"Style_Alias","enabled":true},{"patternId":"Lint_Loop","enabled":true},{"patternId":"Style_NegatedWhile","enabled":true},{"patternId":"Style_ColonMethodCall","enabled":true},{"patternId":"Lint_AmbiguousRegexpLiteral","enabled":true},{"patternId":"Lint_UnusedMethodArgument","enabled":true},{"patternId":"Style_MultilineIfThen","enabled":true},{"patternId":"Lint_EnsureReturn","enabled":true},{"patternId":"Style_NegatedIf","enabled":true},{"patternId":"Lint_Eval","enabled":true},{"patternId":"Style_NilComparison","enabled":true},{"patternId":"Style_ArrayJoin","enabled":true},{"patternId":"Lint_ConditionPosition","enabled":true},{"patternId":"Lint_UnreachableCode","enabled":true},{"patternId":"Performance_Count","enabled":true},{"patternId":"Lint_EmptyInterpolation","enabled":true},{"patternId":"Style_LambdaCall","enabled":true},{"patternId":"Lint_HandleExceptions","enabled":true},{"patternId":"Lint_ShadowingOuterLocalVariable","enabled":true},{"patternId":"Lint_EndAlignment","enabled":true},{"patternId":"Style_MultilineTernaryOperator","enabled":true},{"patternId":"Style_AutoResourceCleanup","enabled":true},{"patternId":"Lint_ElseLayout","enabled":true},{"patternId":"Style_NestedTernaryOperator","enabled":true},{"patternId":"Style_OneLineConditional","enabled":true},{"patternId":"Style_EmptyElse","enabled":true},{"patternId":"Lint_UselessComparison","enabled":true},{"patternId":"Metrics_PerceivedComplexity","enabled":true},{"patternId":"Style_InfiniteLoop","enabled":true},{"patternId":"Rails_Date","enabled":true},{"patternId":"Style_EvenOdd","enabled":true},{"patternId":"Style_IndentationConsistency","enabled":true},{"patternId":"Style_ModuleFunction","enabled":true},{"patternId":"Lint_UselessAssignment","enabled":true},{"patternId":"Style_EachWithObject","enabled":true},{"patternId":"Performance_Detect","enabled":true},{"patternId":"duplicate_key","enabled":true},{"patternId":"no_interpolation_in_single_quotes","enabled":true},{"patternId":"no_backticks","enabled":true},{"patternId":"no_unnecessary_fat_arrows","enabled":true},{"patternId":"indentation","enabled":true},{"patternId":"ensure_comprehensions","enabled":true},{"patternId":"no_stand_alone_at","enabled":true},{"patternId":"cyclomatic_complexity","enabled":true},{"patternId":"Deserialize","enabled":true},{"patternId":"SymbolDoS","enabled":true},{"patternId":"SkipBeforeFilter","enabled":true},{"patternId":"SanitizeMethods","enabled":true},{"patternId":"SelectTag","enabled":true},{"patternId":"XMLDoS","enabled":true},{"patternId":"SimpleFormat","enabled":true},{"patternId":"Evaluation","enabled":true},{"patternId":"BasicAuth","enabled":true},{"patternId":"JRubyXML","enabled":true},{"patternId":"RenderInline","enabled":true},{"patternId":"YAMLParsing","enabled":true},{"patternId":"Redirect","enabled":true},{"patternId":"UnsafeReflection","enabled":true},{"patternId":"SSLVerify","enabled":true},{"patternId":"HeaderDoS","enabled":true},{"patternId":"TranslateBug","enabled":true},{"patternId":"Execute","enabled":true},{"patternId":"JSONParsing","enabled":true},{"patternId":"LinkTo","enabled":true},{"patternId":"FileDisclosure","enabled":true},{"patternId":"SafeBufferManipulation","enabled":true},{"patternId":"ModelAttributes","enabled":true},{"patternId":"ResponseSplitting","enabled":true},{"patternId":"DigestDoS","enabled":true},{"patternId":"Send","enabled":true},{"patternId":"MailTo","enabled":true},{"patternId":"SymbolDoSCVE","enabled":true},{"patternId":"StripTags","enabled":true},{"patternId":"MassAssignment","enabled":true},{"patternId":"RegexDoS","enabled":true},{"patternId":"SelectVulnerability","enabled":true},{"patternId":"FileAccess","enabled":true},{"patternId":"ContentTag","enabled":true},{"patternId":"SessionSettings","enabled":true},{"patternId":"FilterSkipping","enabled":true},{"patternId":"CreateWith","enabled":true},{"patternId":"JSONEncoding","enabled":true},{"patternId":"SQLCVEs","enabled":true},{"patternId":"ForgerySetting","enabled":true},{"patternId":"QuoteTableName","enabled":true},{"patternId":"I18nXSS","enabled":true},{"patternId":"WithoutProtection","enabled":true},{"patternId":"CrossSiteScripting","enabled":true},{"patternId":"SingleQuotes","enabled":true},{"patternId":"NestedAttributes","enabled":true},{"patternId":"DetailedExceptions","enabled":true},{"patternId":"LinkToHref","enabled":true},{"patternId":"RenderDoS","enabled":true},{"patternId":"ModelSerialize","enabled":true},{"patternId":"SQL","enabled":true},{"patternId":"Render","enabled":true},{"patternId":"UnscopedFind","enabled":true},{"patternId":"ValidationRegex","enabled":true},{"patternId":"EscapeFunction","enabled":true},{"patternId":"Custom_Scala_FieldNamesChecker","enabled":true},{"patternId":"Custom_Scala_ObjDeserialization","enabled":true},{"patternId":"Custom_Scala_RSAPadding","enabled":true},{"patternId":"ESLint_no-extra-boolean-cast","enabled":true},{"patternId":"ESLint_no-iterator","enabled":true},{"patternId":"ESLint_no-invalid-regexp","enabled":true},{"patternId":"ESLint_no-obj-calls","enabled":true},{"patternId":"ESLint_no-sparse-arrays","enabled":true},{"patternId":"ESLint_no-unreachable","enabled":true},{"patternId":"ESLint_no-dupe-keys","enabled":true},{"patternId":"ESLint_no-multi-str","enabled":true},{"patternId":"ESLint_no-extend-native","enabled":true},{"patternId":"ESLint_guard-for-in","enabled":true},{"patternId":"ESLint_no-func-assign","enabled":true},{"patternId":"ESLint_no-extra-semi","enabled":true},{"patternId":"ESLint_camelcase","enabled":true},{"patternId":"ESLint_no-mixed-spaces-and-tabs","enabled":true},{"patternId":"ESLint_no-undef","enabled":true},{"patternId":"ESLint_semi","enabled":true},{"patternId":"ESLint_no-empty-character-class","enabled":true},{"patternId":"ESLint_complexity","enabled":true},{"patternId":"ESLint_no-dupe-class-members","enabled":true},{"patternId":"ESLint_no-debugger","enabled":true},{"patternId":"ESLint_block-scoped-var","enabled":true},{"patternId":"ESLint_no-loop-func","enabled":true},{"patternId":"ESLint_no-use-before-define","enabled":true},{"patternId":"ESLint_no-console","enabled":true},{"patternId":"ESLint_require-yield","enabled":true},{"patternId":"ESLint_no-redeclare","enabled":true},{"patternId":"ESLint_no-undefined","enabled":true},{"patternId":"ESLint_use-isnan","enabled":true},{"patternId":"ESLint_no-control-regex","enabled":true},{"patternId":"ESLint_no-const-assign","enabled":true},{"patternId":"ESLint_no-new","enabled":true},{"patternId":"ESLint_new-cap","enabled":true},{"patternId":"ESLint_no-irregular-whitespace","enabled":true},{"patternId":"ESLint_object-shorthand","enabled":true},{"patternId":"ESLint_no-ex-assign","enabled":true},{"patternId":"ESLint_wrap-iife","enabled":true},{"patternId":"ESLint_arrow-parens","enabled":true},{"patternId":"ESLint_no-constant-condition","enabled":true},{"patternId":"ESLint_no-octal","enabled":true},{"patternId":"ESLint_no-dupe-args","enabled":true},{"patternId":"ESLint_quotes","enabled":true},{"patternId":"ESLint_no-fallthrough","enabled":true},{"patternId":"ESLint_no-delete-var","enabled":true},{"patternId":"ESLint_no-caller","enabled":true},{"patternId":"ESLint_no-cond-assign","enabled":true},{"patternId":"ESLint_no-this-before-super","enabled":true},{"patternId":"ESLint_no-negated-in-lhs","enabled":true},{"patternId":"ESLint_no-inner-declarations","enabled":true},{"patternId":"ESLint_eqeqeq","enabled":true},{"patternId":"ESLint_curly","enabled":true},{"patternId":"ESLint_arrow-spacing","enabled":true},{"patternId":"ESLint_no-empty","enabled":true},{"patternId":"ESLint_no-unused-vars","enabled":true},{"patternId":"ESLint_generator-star-spacing","enabled":true},{"patternId":"ESLint_no-duplicate-case","enabled":true},{"patternId":"ESLint_valid-typeof","enabled":true},{"patternId":"ESLint_no-regex-spaces","enabled":true},{"patternId":"ESLint_no-class-assign","enabled":true},{"patternId":"PyLint_W0221","enabled":true},{"patternId":"PyLint_E0117","enabled":true},{"patternId":"PyLint_E0001","enabled":true},{"patternId":"PyLint_E0241","enabled":true},{"patternId":"PyLint_W0404","enabled":true},{"patternId":"PyLint_E0704","enabled":true},{"patternId":"PyLint_E0703","enabled":true},{"patternId":"PyLint_E0302","enabled":true},{"patternId":"PyLint_W1301","enabled":true},{"patternId":"PyLint_R0201","enabled":true},{"patternId":"PyLint_E0113","enabled":true},{"patternId":"PyLint_W0410","enabled":true},{"patternId":"PyLint_C0123","enabled":true},{"patternId":"PyLint_E0115","enabled":true},{"patternId":"PyLint_E0114","enabled":true},{"patternId":"PyLint_E1126","enabled":true},{"patternId":"PyLint_W0702","enabled":true},{"patternId":"PyLint_W1303","enabled":true},{"patternId":"PyLint_W0622","enabled":true},{"patternId":"PyLint_W0222","enabled":true},{"patternId":"PyLint_W0233","enabled":true},{"patternId":"PyLint_W1305","enabled":true},{"patternId":"PyLint_E1127","enabled":true},{"patternId":"PyLint_E0112","enabled":true},{"patternId":"PyLint_W0611","enabled":true},{"patternId":"PyLint_W0601","enabled":true},{"patternId":"PyLint_W1300","enabled":true},{"patternId":"PyLint_W0124","enabled":true},{"patternId":"PyLint_R0203","enabled":true},{"patternId":"PyLint_E0236","enabled":true},{"patternId":"PyLint_W0612","enabled":true},{"patternId":"PyLint_W0604","enabled":true},{"patternId":"PyLint_W0705","enabled":true},{"patternId":"PyLint_E0238","enabled":true},{"patternId":"PyLint_W0602","enabled":true},{"patternId":"PyLint_R0102","enabled":true},{"patternId":"PyLint_R0202","enabled":true},{"patternId":"PyLint_E0240","enabled":true},{"patternId":"PyLint_W0623","enabled":true},{"patternId":"PyLint_W0711","enabled":true},{"patternId":"PyLint_E0116","enabled":true},{"patternId":"PyLint_E0239","enabled":true},{"patternId":"PyLint_E1132","enabled":true},{"patternId":"PyLint_W1307","enabled":true},{"patternId":"PyLint_C0200","enabled":true},{"patternId":"PyLint_E0301","enabled":true},{"patternId":"PyLint_W1306","enabled":true},{"patternId":"PyLint_W1302","enabled":true},{"patternId":"PyLint_E0110","enabled":true},{"patternId":"PyLint_E1125","enabled":true}]} \ No newline at end of file From 65f4f8063273b65b258aaf2be73e0609afb9583a Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Tue, 16 Feb 2016 10:48:46 -0800 Subject: [PATCH 064/203] Add getter for key parent --- .../com/google/gcloud/datastore/BaseKey.java | 2 ++ .../gcloud/datastore/IncompleteKey.java | 19 +++++++++++++++++ .../google/gcloud/datastore/BaseKeyTest.java | 5 +++++ .../gcloud/datastore/IncompleteKeyTest.java | 21 ++++++++++++++++--- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseKey.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseKey.java index a8ad7d4e7734..4ab6f51b6767 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseKey.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseKey.java @@ -157,6 +157,8 @@ public String kind() { return leaf().kind(); } + abstract BaseKey parent(); + @Override public int hashCode() { return Objects.hash(projectId(), namespace(), path()); diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/IncompleteKey.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/IncompleteKey.java index 2ccd59e725a8..7c987693833e 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/IncompleteKey.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/IncompleteKey.java @@ -84,6 +84,25 @@ static IncompleteKey fromPb(DatastoreV1.Key keyPb) { return new IncompleteKey(projectId, namespace, path); } + /** + * Returns the key's parent. + */ + @Override + public Key parent() { + List ancestors = ancestors(); + if (!ancestors.isEmpty()) { + PathElement parent = ancestors.get(ancestors.size() - 1); + Key.Builder keyBuilder; + if (parent.hasName()) { + keyBuilder = Key.builder(projectId(), parent.kind(), parent.name()); + } else { + keyBuilder = Key.builder(projectId(), parent.kind(), parent.id()); + } + return keyBuilder.ancestors(ancestors.subList(0, ancestors.size() - 1)).build(); + } + return null; + } + public static Builder builder(String projectId, String kind) { return new Builder(projectId, kind); } diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseKeyTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseKeyTest.java index 8615ee025bd1..43db4695b191 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseKeyTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/BaseKeyTest.java @@ -50,6 +50,11 @@ protected BaseKey build() { protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException { return null; } + + @Override + protected BaseKey parent() { + return null; + } }; } } diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/IncompleteKeyTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/IncompleteKeyTest.java index 7edbf133d330..6cc425bbb90f 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/IncompleteKeyTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/IncompleteKeyTest.java @@ -17,21 +17,30 @@ package com.google.gcloud.datastore; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import org.junit.Before; import org.junit.Test; public class IncompleteKeyTest { +private static IncompleteKey pk1, pk2; + private static Key parent; + + @Before + public void setUp() { + pk1 = IncompleteKey.builder("ds", "kind1").build(); + parent = Key.builder("ds", "kind2", 10).build(); + pk2 = IncompleteKey.builder(parent, "kind3").build(); + } + @Test public void testBuilders() throws Exception { - IncompleteKey pk1 = IncompleteKey.builder("ds", "kind1").build(); assertEquals("ds", pk1.projectId()); assertEquals("kind1", pk1.kind()); assertTrue(pk1.ancestors().isEmpty()); - Key parent = Key.builder("ds", "kind2", 10).build(); - IncompleteKey pk2 = IncompleteKey.builder(parent, "kind3").build(); assertEquals("ds", pk2.projectId()); assertEquals("kind3", pk2.kind()); assertEquals(parent.path(), pk2.ancestors()); @@ -42,4 +51,10 @@ public void testBuilders() throws Exception { assertEquals("kind4", pk3.kind()); assertEquals(parent.path(), pk3.ancestors()); } + + @Test + public void testParent() { + assertNull(pk1.parent()); + assertEquals(parent, pk2.parent()); + } } From c2f8952befa41581dcad9a9bd8951837d9c7d39f Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Tue, 16 Feb 2016 14:26:49 -0800 Subject: [PATCH 065/203] Expose consistency parameter to users of LocalGcdHelper --- .../datastore/testing/LocalGcdHelper.java | 27 ++++++++++++++----- .../gcloud/datastore/DatastoreTest.java | 2 +- .../gcloud/datastore/LocalGcdHelperTest.java | 4 +-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java index 7c60da50b0b0..b5e0148fdf04 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java @@ -17,6 +17,7 @@ package com.google.gcloud.datastore.testing; import static com.google.common.base.MoreObjects.firstNonNull; +import static com.google.common.base.Preconditions.checkArgument; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.base.Strings; @@ -85,6 +86,7 @@ public class LocalGcdHelper { private static final String GCLOUD = "gcloud"; private static final Path INSTALLED_GCD_PATH; private static final String GCD_VERSION_PREFIX = "gcd-emulator "; + private static final double DEFAULT_CONSISTENCY = 0.9; static { INSTALLED_GCD_PATH = installedGcdPath(); @@ -398,9 +400,15 @@ public LocalGcdHelper(String projectId, int port) { * All content is written to a temporary directory that will be deleted when * {@link #stop()} is called or when the program terminates) to make sure that no left-over * data from prior runs is used. + * + * @param consistency the fraction of job application attempts that will succeed, with 0.0 + * resulting in no attempts succeeding, and 1.0 resulting in all attempts succeeding. Defaults + * to 0.9. Note that setting this to 1.0 may mask incorrect assumptions about the consistency + * of non-ancestor queries; non-ancestor queries are eventually consistent. */ - public void start() throws IOException, InterruptedException { + public void start(double consistency) throws IOException, InterruptedException { // send a quick request in case we have a hanging process from a previous run + checkArgument(consistency >= 0.0 && consistency <= 1.0, "Consistency must be between 0 and 1"); sendQuitRequest(port); // Each run is associated with its own folder that is deleted once test completes. gcdPath = Files.createTempDirectory("gcd"); @@ -415,7 +423,7 @@ public void start() throws IOException, InterruptedException { } else { gcdExecutablePath = INSTALLED_GCD_PATH; } - startGcd(gcdExecutablePath); + startGcd(gcdExecutablePath, consistency); } private void downloadGcd() throws IOException { @@ -453,7 +461,8 @@ private void downloadGcd() throws IOException { } } - private void startGcd(Path executablePath) throws IOException, InterruptedException { + private void startGcd(Path executablePath, double consistency) + throws IOException, InterruptedException { // cleanup any possible data for the same project File datasetFolder = new File(gcdPath.toFile(), projectId); deleteRecurse(datasetFolder.toPath()); @@ -486,7 +495,8 @@ private void startGcd(Path executablePath) throws IOException, InterruptedExcept startProcess = CommandWrapper.create() .command(gcdAbsolutePath.toString(), "start", "--testing", "--allow_remote_shutdown", - "--port=" + Integer.toString(port), projectId) + "--port=" + Integer.toString(port), "--consistency=" + Double.toString(consistency), + projectId) .directory(gcdPath) .start(); processReader = ProcessStreamReader.start(startProcess.getInputStream()); @@ -578,10 +588,10 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO }); } - public static LocalGcdHelper start(String projectId, int port) + public static LocalGcdHelper start(String projectId, int port, double consistency) throws IOException, InterruptedException { LocalGcdHelper helper = new LocalGcdHelper(projectId, port); - helper.start(); + helper.start(consistency); return helper; } @@ -590,10 +600,13 @@ public static void main(String... args) throws IOException, InterruptedException String action = parsedArgs.get("action"); int port = (parsedArgs.get("port") == null) ? DEFAULT_PORT : Integer.parseInt(parsedArgs.get("port")); + double consistency = + parsedArgs.get("consistency") == null + ? DEFAULT_CONSISTENCY : Double.parseDouble(parsedArgs.get("consistency")); switch (action) { case "START": if (!isActive(DEFAULT_PROJECT_ID, port)) { - LocalGcdHelper helper = start(DEFAULT_PROJECT_ID, port); + LocalGcdHelper helper = start(DEFAULT_PROJECT_ID, port, consistency); try (FileWriter writer = new FileWriter(".local_gcd_helper")) { writer.write(helper.gcdPath.toAbsolutePath().toString() + System.lineSeparator()); writer.write(Integer.toString(port)); diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java index e9eed027e8e0..92f232c18a56 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java @@ -118,7 +118,7 @@ public class DatastoreTest { @BeforeClass public static void beforeClass() throws IOException, InterruptedException { if (!LocalGcdHelper.isActive(PROJECT_ID, PORT)) { - gcdHelper = LocalGcdHelper.start(PROJECT_ID, PORT); + gcdHelper = LocalGcdHelper.start(PROJECT_ID, PORT, 1.0); } } diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/LocalGcdHelperTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/LocalGcdHelperTest.java index 40ea62c5a7e0..5d761a713506 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/LocalGcdHelperTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/LocalGcdHelperTest.java @@ -49,7 +49,7 @@ public void testFindAvailablePort() { @Test public void testSendQuitRequest() throws IOException, InterruptedException { - LocalGcdHelper gcdHelper = LocalGcdHelper.start(PROJECT_ID, PORT); + LocalGcdHelper gcdHelper = LocalGcdHelper.start(PROJECT_ID, PORT, 0.75); assertTrue(LocalGcdHelper.sendQuitRequest(PORT)); long timeoutMillis = 30000; long startTime = System.currentTimeMillis(); @@ -64,7 +64,7 @@ public void testSendQuitRequest() throws IOException, InterruptedException { @Test public void testStartStop() throws IOException, InterruptedException { - LocalGcdHelper gcdHelper = LocalGcdHelper.start(PROJECT_ID, PORT); + LocalGcdHelper gcdHelper = LocalGcdHelper.start(PROJECT_ID, PORT, 0.75); assertFalse(LocalGcdHelper.isActive("wrong-project-id", PORT)); assertTrue(LocalGcdHelper.isActive(PROJECT_ID, PORT)); gcdHelper.stop(); From 274b9ae5dfe0b8fc749dc5e55c38f574f09f8f0b Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Tue, 16 Feb 2016 16:12:08 -0800 Subject: [PATCH 066/203] Add set(...) javadoc, fix key namespace issue, fix ListValue.of(...), other minor fixes --- .../google/gcloud/datastore/BaseEntity.java | 141 +++++++++++++++++- .../gcloud/datastore/IncompleteKey.java | 24 +-- .../google/gcloud/datastore/ListValue.java | 17 ++- .../datastore/testing/LocalGcdHelper.java | 5 +- .../gcloud/datastore/IncompleteKeyTest.java | 17 ++- 5 files changed, 177 insertions(+), 27 deletions(-) diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java index af05cb42c315..389514c3bd83 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java @@ -129,16 +129,36 @@ public B remove(String name) { return self(); } + /** + * Sets a property. + * + * @param name name of the property + * @param value value associated with the property + */ public B set(String name, Value value) { properties.put(name, value); return self(); } + /** + * Sets a property of type {@link StringValue}. + * + * @param name name of the property + * @param value value associated with the property + */ public B set(String name, String value) { properties.put(name, of(value)); return self(); } + /** + * Sets a list property containing elements of type {@link StringValue}. + * + * @param name name of the property + * @param first the first string in the list + * @param second the second string in the list + * @param others other strings in the list + */ public B set(String name, String first, String second, String... others) { List values = new LinkedList<>(); values.add(of(first)); @@ -150,11 +170,25 @@ public B set(String name, String first, String second, String... others) { return self(); } + /** + * Sets a property of type {@link LongValue}. + * + * @param name name of the property + * @param value value associated with the property + */ public B set(String name, long value) { properties.put(name, of(value)); return self(); } + /** + * Sets a list property containing elements of type {@link LongValue}. + * + * @param name name of the property + * @param first the first long in the list + * @param second the second long in the list + * @param others other longs in the list + */ public B set(String name, long first, long second, long... others) { List values = new LinkedList<>(); values.add(of(first)); @@ -166,11 +200,25 @@ public B set(String name, long first, long second, long... others) { return self(); } + /** + * Sets a property of type {@link DoubleValue}. + * + * @param name name of the property + * @param value value associated with the property + */ public B set(String name, double value) { properties.put(name, of(value)); return self(); } + /** + * Sets a list property containing elements of type {@link DoubleValue}. + * + * @param name name of the property + * @param first the first double in the list + * @param second the second double in the list + * @param others other doubles in the list + */ public B set(String name, double first, double second, double... others) { List values = new LinkedList<>(); values.add(of(first)); @@ -182,11 +230,25 @@ public B set(String name, double first, double second, double... others) { return self(); } + /** + * Sets a property of type {@link BooleanValue}. + * + * @param name name of the property + * @param value value associated with the property + */ public B set(String name, boolean value) { properties.put(name, of(value)); return self(); } + /** + * Sets a list property containing elements of type {@link BooleanValue}. + * + * @param name name of the property + * @param first the first boolean in the list + * @param second the second boolean in the list + * @param others other booleans in the list + */ public B set(String name, boolean first, boolean second, boolean... others) { List values = new LinkedList<>(); values.add(of(first)); @@ -198,11 +260,25 @@ public B set(String name, boolean first, boolean second, boolean... others) { return self(); } + /** + * Sets a property of type {@link DateTimeValue}. + * + * @param name name of the property + * @param value value associated with the property + */ public B set(String name, DateTime value) { properties.put(name, of(value)); return self(); } + /** + * Sets a list property containing elements of type {@link DateTimeValue}. + * + * @param name name of the property + * @param first the first {@link DateTime} in the list + * @param second the second {@link DateTime} in the list + * @param others other {@link DateTime}s in the list + */ public B set(String name, DateTime first, DateTime second, DateTime... others) { List values = new LinkedList<>(); values.add(of(first)); @@ -214,11 +290,25 @@ public B set(String name, DateTime first, DateTime second, DateTime... others) { return self(); } + /** + * Sets a property of type {@link KeyValue}. + * + * @param name name of the property + * @param value value associated with the property + */ public B set(String name, Key value) { properties.put(name, of(value)); return self(); } + /** + * Sets a list property containing elements of type {@link KeyValue}. + * + * @param name name of the property + * @param first the first {@link Key} in the list + * @param second the second {@link Key} in the list + * @param others other {@link Key}s in the list + */ public B set(String name, Key first, Key second, Key... others) { List values = new LinkedList<>(); values.add(of(first)); @@ -230,11 +320,25 @@ public B set(String name, Key first, Key second, Key... others) { return self(); } + /** + * Sets a property of type {@link EntityValue}. + * + * @param name name of the property + * @param value value associated with the property + */ public B set(String name, FullEntity value) { properties.put(name, of(value)); return self(); } + /** + * Sets a list property containing elements of type {@link EntityValue}. + * + * @param name name of the property + * @param first the first {@link FullEntity} in the list + * @param second the second {@link FullEntity} in the list + * @param others other entities in the list + */ public B set(String name, FullEntity first, FullEntity second, FullEntity... others) { List values = new LinkedList<>(); values.add(of(first)); @@ -246,21 +350,49 @@ public B set(String name, FullEntity first, FullEntity second, FullEntity< return self(); } + /** + * Sets a property of type {@link ListValue}. + * + * @param name name of the property + * @param values list of values associated with the property + */ public B set(String name, List> values) { properties.put(name, of(values)); return self(); } - public B set(String name, Value first, Value second, Value... other) { - properties.put(name, of(first, second, other)); + /** + * Sets a property of type {@link ListValue}. + * + * @param name name of the property + * @param first the first value in the list + * @param second the second value in the list + * @param others other values in the list + */ + public B set(String name, Value first, Value second, Value... others) { + properties.put(name, of(first, second, others)); return self(); } + /** + * Sets a property of type {@link BlobValue}. + * + * @param name name of the property + * @param value value associated with the property + */ public B set(String name, Blob value) { properties.put(name, of(value)); return self(); } + /** + * Sets a list property containing elements of type {@link BlobValue}. + * + * @param name name of the property + * @param first the first {@link Blob} in the list + * @param second the second {@link Blob} in the list + * @param others other {@link Blob}s in the list + */ public B set(String name, Blob first, Blob second, Blob... others) { List values = new LinkedList<>(); values.add(of(first)); @@ -272,6 +404,11 @@ public B set(String name, Blob first, Blob second, Blob... others) { return self(); } + /** + * Sets a property of type {@code NullValue}. + * + * @param name name of the property + */ public B setNull(String name) { properties.put(name, of()); return self(); diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/IncompleteKey.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/IncompleteKey.java index 7c987693833e..2192384ef70b 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/IncompleteKey.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/IncompleteKey.java @@ -90,17 +90,21 @@ static IncompleteKey fromPb(DatastoreV1.Key keyPb) { @Override public Key parent() { List ancestors = ancestors(); - if (!ancestors.isEmpty()) { - PathElement parent = ancestors.get(ancestors.size() - 1); - Key.Builder keyBuilder; - if (parent.hasName()) { - keyBuilder = Key.builder(projectId(), parent.kind(), parent.name()); - } else { - keyBuilder = Key.builder(projectId(), parent.kind(), parent.id()); - } - return keyBuilder.ancestors(ancestors.subList(0, ancestors.size() - 1)).build(); + if (ancestors.isEmpty()) { + return null; + } + PathElement parent = ancestors.get(ancestors.size() - 1); + Key.Builder keyBuilder; + if (parent.hasName()) { + keyBuilder = Key.builder(projectId(), parent.kind(), parent.name()); + } else { + keyBuilder = Key.builder(projectId(), parent.kind(), parent.id()); + } + String namespace = namespace(); + if (namespace != null) { + keyBuilder.namespace(namespace); } - return null; + return keyBuilder.ancestors(ancestors.subList(0, ancestors.size() - 1)).build(); } public static Builder builder(String projectId, String kind) { diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java index 494d8daedfff..475fd35f8b35 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java @@ -77,9 +77,8 @@ public Builder addValue(Value value) { return this; } - public Builder addValue(Value first, Value second, Value... other) { + public Builder addValue(Value first, Value... other) { addValue(first); - addValue(second); for (Value value : other) { addValue(value); } @@ -122,8 +121,12 @@ public ListValue(List> values) { this(builder().set(values)); } - public ListValue(Value first, Value second, Value... other) { - this(new Builder().addValue(first, second, other)); + public ListValue(Value first, Value... other) { + this(new Builder().addValue(first, other)); + } + + ListValue(Value first, Value second, Value... other) { + this(new Builder().addValue(first).addValue(second, other)); } private ListValue(Builder builder) { @@ -139,7 +142,11 @@ public static ListValue of(List> values) { return new ListValue(values); } - public static ListValue of(Value first, Value second, Value... other) { + public static ListValue of(Value first, Value... other) { + return new ListValue(first, other); + } + + static ListValue of(Value first, Value second, Value... other) { return new ListValue(first, second, other); } diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java index b5e0148fdf04..9d4ea65af634 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java @@ -600,12 +600,11 @@ public static void main(String... args) throws IOException, InterruptedException String action = parsedArgs.get("action"); int port = (parsedArgs.get("port") == null) ? DEFAULT_PORT : Integer.parseInt(parsedArgs.get("port")); - double consistency = - parsedArgs.get("consistency") == null - ? DEFAULT_CONSISTENCY : Double.parseDouble(parsedArgs.get("consistency")); switch (action) { case "START": if (!isActive(DEFAULT_PROJECT_ID, port)) { + double consistency = parsedArgs.get("consistency") == null + ? DEFAULT_CONSISTENCY : Double.parseDouble(parsedArgs.get("consistency")); LocalGcdHelper helper = start(DEFAULT_PROJECT_ID, port, consistency); try (FileWriter writer = new FileWriter(".local_gcd_helper")) { writer.write(helper.gcdPath.toAbsolutePath().toString() + System.lineSeparator()); diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/IncompleteKeyTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/IncompleteKeyTest.java index 6cc425bbb90f..acd1dfd3c9e3 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/IncompleteKeyTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/IncompleteKeyTest.java @@ -25,14 +25,14 @@ public class IncompleteKeyTest { -private static IncompleteKey pk1, pk2; - private static Key parent; + private static IncompleteKey pk1, pk2; + private static Key parent1; @Before public void setUp() { pk1 = IncompleteKey.builder("ds", "kind1").build(); - parent = Key.builder("ds", "kind2", 10).build(); - pk2 = IncompleteKey.builder(parent, "kind3").build(); + parent1 = Key.builder("ds", "kind2", 10).namespace("ns").build(); + pk2 = IncompleteKey.builder(parent1, "kind3").build(); } @Test @@ -43,18 +43,21 @@ public void testBuilders() throws Exception { assertEquals("ds", pk2.projectId()); assertEquals("kind3", pk2.kind()); - assertEquals(parent.path(), pk2.ancestors()); + assertEquals(parent1.path(), pk2.ancestors()); assertEquals(pk2, IncompleteKey.builder(pk2).build()); IncompleteKey pk3 = IncompleteKey.builder(pk2).kind("kind4").build(); assertEquals("ds", pk3.projectId()); assertEquals("kind4", pk3.kind()); - assertEquals(parent.path(), pk3.ancestors()); + assertEquals(parent1.path(), pk3.ancestors()); } @Test public void testParent() { assertNull(pk1.parent()); - assertEquals(parent, pk2.parent()); + assertEquals(parent1, pk2.parent()); + Key parent2 = Key.builder("ds", "kind3", "name").namespace("ns").build(); + IncompleteKey pk3 = IncompleteKey.builder(parent2, "kind3").build(); + assertEquals(parent2, pk3.parent()); } } From 662f57f18845f8d6e5aadd52dddf2b118422c6e5 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Tue, 16 Feb 2016 17:05:49 -0800 Subject: [PATCH 067/203] remove unncessary changes to ListValue --- .../com/google/gcloud/datastore/BaseEntity.java | 2 +- .../com/google/gcloud/datastore/ListValue.java | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java index 389514c3bd83..20c0b13e5001 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java @@ -370,7 +370,7 @@ public B set(String name, List> values) { * @param others other values in the list */ public B set(String name, Value first, Value second, Value... others) { - properties.put(name, of(first, second, others)); + properties.put(name, ListValue.builder().addValue(first).addValue(second, others).build()); return self(); } diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java index 475fd35f8b35..06282a2c79d1 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java @@ -70,17 +70,16 @@ private Builder() { super(ValueType.LIST); } - public Builder addValue(Value value) { + private void addValueHelper(Value value) { // see datastore_v1.proto definition for list_value Preconditions.checkArgument(value.type() != ValueType.LIST, "Cannot contain another list"); listBuilder.add(value); - return this; } public Builder addValue(Value first, Value... other) { - addValue(first); + addValueHelper(first); for (Value value : other) { - addValue(value); + addValueHelper(value); } return this; } @@ -125,10 +124,6 @@ public ListValue(Value first, Value... other) { this(new Builder().addValue(first, other)); } - ListValue(Value first, Value second, Value... other) { - this(new Builder().addValue(first).addValue(second, other)); - } - private ListValue(Builder builder) { super(builder); } @@ -146,10 +141,6 @@ public static ListValue of(Value first, Value... other) { return new ListValue(first, other); } - static ListValue of(Value first, Value second, Value... other) { - return new ListValue(first, second, other); - } - public static Builder builder() { return new Builder(); } From 53290f5107f753cbf82bec432534d48eb556cfbd Mon Sep 17 00:00:00 2001 From: aozarov Date: Wed, 17 Feb 2016 15:32:56 -0800 Subject: [PATCH 068/203] fix lint issue --- .../test/java/com/google/gcloud/datastore/DatastoreTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java index d8337e7ae865..a289610fe841 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java @@ -473,7 +473,7 @@ public void testQueryPaginationWithLimit() throws DatastoreException { .andReturn(rpcMock); List responses = buildResponsesForQueryPaginationWithLimit(); List endCursors = Lists.newArrayListWithCapacity(responses.size()); - for (RunQueryResponse response: responses) { + for (RunQueryResponse response : responses) { EasyMock.expect(rpcMock.runQuery(EasyMock.anyObject(RunQueryRequest.class))) .andReturn(response); if (response.getBatch().getMoreResults() != QueryResultBatch.MoreResultsType.NOT_FINISHED) { From 1f6a7b3f07fbfb8f9cfdfb7cc83c13f32577c1f4 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Wed, 17 Feb 2016 17:28:13 -0800 Subject: [PATCH 069/203] support paging --- .../resourcemanager/ResourceManager.java | 5 +--- .../testing/LocalResourceManagerHelper.java | 27 ++++++++++++++----- .../LocalResourceManagerHelperTest.java | 26 +++++++++++++++--- .../ResourceManagerImplTest.java | 18 ++++++++++++- 4 files changed, 62 insertions(+), 14 deletions(-) diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java index af772dce6b60..b641fa74b584 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java @@ -147,8 +147,6 @@ public static ProjectListOption pageToken(String pageToken) { * *

The server can return fewer projects than requested. When there are more results than the * page size, the server will return a page token that can be used to fetch other results. - * Note: pagination is not yet supported; the server currently ignores this field and returns - * all results. */ public static ProjectListOption pageSize(int pageSize) { return new ProjectListOption(ResourceManagerRpc.Option.PAGE_SIZE, pageSize); @@ -228,8 +226,7 @@ public static ProjectListOption fields(ProjectField... fields) { * *

This method returns projects in an unspecified order. New projects do not necessarily appear * at the end of the list. Use {@link ProjectListOption} to filter this list, set page size, and - * set page tokens. Note that pagination is currently not implemented by the Cloud Resource - * Manager API. + * set page tokens. * * @see Cloud diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java index 25c763276b3b..f164766ade7a 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -34,7 +34,7 @@ import java.util.Map; import java.util.Random; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentSkipListMap; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.GZIPInputStream; @@ -71,7 +71,7 @@ public class LocalResourceManagerHelper { ImmutableSet.of('-', '\'', '"', ' ', '!'); private final HttpServer server; - private final ConcurrentHashMap projects = new ConcurrentHashMap<>(); + private final ConcurrentSkipListMap projects = new ConcurrentSkipListMap<>(); private final int port; private static class Response { @@ -245,10 +245,10 @@ private static Map parseListOptions(String query) { options.put("filter", argEntry[1].split(" ")); break; case "pageToken": - // support pageToken when Cloud Resource Manager supports this (#421) + options.put("pageToken", argEntry[1]); break; case "pageSize": - // support pageSize when Cloud Resource Manager supports this (#421) + options.put("pageSize", Integer.parseInt(argEntry[1])); break; } } @@ -353,16 +353,27 @@ Response get(String projectId, String[] fields) { } Response list(Map options) { - // Use pageSize and pageToken options when Cloud Resource Manager does so (#421) List projectsSerialized = new ArrayList<>(); String[] filters = (String[]) options.get("filter"); if (filters != null && !isValidFilter(filters)) { return Error.INVALID_ARGUMENT.response("Could not parse the filter."); } String[] fields = (String[]) options.get("fields"); + int count = 0; + String pageToken = (String) options.get("pageToken"); + Integer pageSize = (Integer) options.get("pageSize"); + String nextPageToken = null; for (Project p : projects.values()) { + if (pageToken != null && p.getProjectId().compareTo(pageToken) < 0) { + continue; + } + if (pageSize != null && count >= pageSize) { + nextPageToken = p.getProjectId(); + break; + } boolean includeProject = includeProject(p, filters); if (includeProject) { + count++; try { projectsSerialized.add(jsonFactory.toString(extractFields(p, fields))); } catch (IOException e) { @@ -374,7 +385,11 @@ Response list(Map options) { StringBuilder responseBody = new StringBuilder(); responseBody.append("{\"projects\": ["); Joiner.on(",").appendTo(responseBody, projectsSerialized); - responseBody.append("]}"); + responseBody.append("]"); + if (nextPageToken != null) { + responseBody.append(", \"nextPageToken\": \"" + nextPageToken + "\""); + } + responseBody.append("}"); return new Response(HTTP_OK, responseBody.toString()); } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java index 7eb0156d4e56..b5cf579cb860 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java @@ -19,6 +19,7 @@ import org.junit.Test; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; public class LocalResourceManagerHelperTest { @@ -278,7 +279,7 @@ public void testGetWithOptions() { public void testList() { Tuple> projects = rpc.list(EMPTY_RPC_OPTIONS); - assertNull(projects.x()); // change this when #421 is resolved + assertNull(projects.x()); assertFalse(projects.y().iterator().hasNext()); rpc.create(COMPLETE_PROJECT); RESOURCE_MANAGER_HELPER.changeLifecycleState( @@ -296,12 +297,31 @@ public void testList() { } } + @Test + public void testListPaging() { + Map rpcOptions = new HashMap<>(); + rpcOptions.put(ResourceManagerRpc.Option.PAGE_SIZE, 1); + rpc.create(PARTIAL_PROJECT); + rpc.create(COMPLETE_PROJECT); + Tuple> projects = + rpc.list(rpcOptions); + assertNotNull(projects.x()); + Iterator iterator = + projects.y().iterator(); + compareReadWriteFields(COMPLETE_PROJECT, iterator.next()); + assertFalse(iterator.hasNext()); + rpcOptions = new HashMap<>(); + rpcOptions.put(ResourceManagerRpc.Option.PAGE_TOKEN, projects.x()); + projects = rpc.list(rpcOptions); + iterator = projects.y().iterator(); + compareReadWriteFields(PARTIAL_PROJECT, iterator.next()); + assertFalse(iterator.hasNext()); + } + @Test public void testListFieldOptions() { Map rpcOptions = new HashMap<>(); rpcOptions.put(ResourceManagerRpc.Option.FIELDS, "projects(projectId,name,labels)"); - rpcOptions.put(ResourceManagerRpc.Option.PAGE_TOKEN, "somePageToken"); - rpcOptions.put(ResourceManagerRpc.Option.PAGE_SIZE, 1); rpc.create(PROJECT_WITH_PARENT); Tuple> projects = rpc.list(rpcOptions); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java index 37c54718fb4a..868d437a6f00 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java @@ -42,6 +42,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; +import java.util.Iterator; import java.util.Map; public class ResourceManagerImplTest { @@ -166,7 +167,7 @@ public void testGetWithOptions() { @Test public void testList() { Page projects = RESOURCE_MANAGER.list(); - assertFalse(projects.values().iterator().hasNext()); // TODO: change this when #421 is resolved + assertFalse(projects.values().iterator().hasNext()); RESOURCE_MANAGER.create(PARTIAL_PROJECT); RESOURCE_MANAGER.create(COMPLETE_PROJECT); for (Project p : RESOURCE_MANAGER.list().values()) { @@ -181,6 +182,21 @@ public void testList() { } } + @Test + public void tsetListPaging() { + RESOURCE_MANAGER.create(PARTIAL_PROJECT); + RESOURCE_MANAGER.create(COMPLETE_PROJECT); + Page page = RESOURCE_MANAGER.list(ProjectListOption.pageSize(1)); + assertNotNull(page.nextPageCursor()); + Iterator iterator = page.values().iterator(); + compareReadWriteFields(COMPLETE_PROJECT, iterator.next()); + assertFalse(iterator.hasNext()); + page = page.nextPage(); + iterator = page.values().iterator(); + compareReadWriteFields(PARTIAL_PROJECT, iterator.next()); + assertFalse(iterator.hasNext()); + } + @Test public void testListFieldOptions() { RESOURCE_MANAGER.create(COMPLETE_PROJECT); From 1dd2c04a45d1181de57e9efeeecef4e4f8c97c0f Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Wed, 17 Feb 2016 21:30:04 -0500 Subject: [PATCH 070/203] Fix broken hyperlink in comment --- .../main/java/com/google/gcloud/storage/StorageException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageException.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageException.java index 0c952c9a65d6..ee85b80d6e13 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageException.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageException.java @@ -33,7 +33,7 @@ */ public class StorageException extends BaseServiceException { - // see: https://cloud.google.com/storage/docs/concepts-techniques#practices + // see: https://cloud.google.com/storage/docs/resumable-uploads-xml#practices private static final Set RETRYABLE_ERRORS = ImmutableSet.of( new Error(504, null), new Error(503, null), From 6b322fa1a0cacb7c79b1709df78fe6163d48ce07 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 18 Feb 2016 08:30:30 -0800 Subject: [PATCH 071/203] minor fixes --- .../testing/LocalResourceManagerHelper.java | 21 ++++++++++++------- .../LocalResourceManagerHelperTest.java | 1 + .../ResourceManagerImplTest.java | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java index f164766ade7a..4a88a9527a34 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -248,7 +248,9 @@ private static Map parseListOptions(String query) { options.put("pageToken", argEntry[1]); break; case "pageSize": - options.put("pageSize", Integer.parseInt(argEntry[1])); + int pageSize = Integer.valueOf(argEntry[1]); + checkArgument(pageSize > 0, "Page size must be greater than 0."); + options.put("pageSize", pageSize); break; } } @@ -363,10 +365,11 @@ Response list(Map options) { String pageToken = (String) options.get("pageToken"); Integer pageSize = (Integer) options.get("pageSize"); String nextPageToken = null; - for (Project p : projects.values()) { - if (pageToken != null && p.getProjectId().compareTo(pageToken) < 0) { - continue; - } + Map projectsToScan = projects; + if (pageToken != null) { + projectsToScan = projects.tailMap(pageToken); + } + for (Project p : projectsToScan.values()) { if (pageSize != null && count >= pageSize) { nextPageToken = p.getProjectId(); break; @@ -385,11 +388,13 @@ Response list(Map options) { StringBuilder responseBody = new StringBuilder(); responseBody.append("{\"projects\": ["); Joiner.on(",").appendTo(responseBody, projectsSerialized); - responseBody.append("]"); + responseBody.append(']'); if (nextPageToken != null) { - responseBody.append(", \"nextPageToken\": \"" + nextPageToken + "\""); + responseBody.append(", \"nextPageToken\": \""); + responseBody.append(nextPageToken); + responseBody.append('"'); } - responseBody.append("}"); + responseBody.append('}'); return new Response(HTTP_OK, responseBody.toString()); } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java index b5cf579cb860..ebcb7dc48a65 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java @@ -316,6 +316,7 @@ public void testListPaging() { iterator = projects.y().iterator(); compareReadWriteFields(PARTIAL_PROJECT, iterator.next()); assertFalse(iterator.hasNext()); + assertNull(projects.x()); } @Test diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java index 868d437a6f00..8d64652a0696 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java @@ -183,7 +183,7 @@ public void testList() { } @Test - public void tsetListPaging() { + public void testListPaging() { RESOURCE_MANAGER.create(PARTIAL_PROJECT); RESOURCE_MANAGER.create(COMPLETE_PROJECT); Page page = RESOURCE_MANAGER.list(ProjectListOption.pageSize(1)); @@ -195,6 +195,7 @@ public void tsetListPaging() { iterator = page.values().iterator(); compareReadWriteFields(PARTIAL_PROJECT, iterator.next()); assertFalse(iterator.hasNext()); + assertNull(page.nextPageCursor()); } @Test From df32901b0d711c15728d4dcf184f64903fc14f8f Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 18 Feb 2016 09:51:13 -0800 Subject: [PATCH 072/203] Propagate page size error to user --- .../testing/LocalResourceManagerHelper.java | 6 ++++-- .../LocalResourceManagerHelperTest.java | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java index 4a88a9527a34..4c26a44cd4e6 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -228,7 +228,7 @@ private static String[] parseFields(String query) { return null; } - private static Map parseListOptions(String query) { + private static Map parseListOptions(String query) throws IOException { Map options = new HashMap<>(); if (query != null) { String[] args = query.split("&"); @@ -249,7 +249,9 @@ private static Map parseListOptions(String query) { break; case "pageSize": int pageSize = Integer.valueOf(argEntry[1]); - checkArgument(pageSize > 0, "Page size must be greater than 0."); + if (pageSize < 1) { + throw new IOException("Page size must be greater than 0."); + } options.put("pageSize", pageSize); break; } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java index ebcb7dc48a65..1c2e0ff9c667 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java @@ -297,6 +297,17 @@ public void testList() { } } + @Test + public void testInvalidListPaging() { + Map rpcOptions = new HashMap<>(); + rpcOptions.put(ResourceManagerRpc.Option.PAGE_SIZE, -1); + try { + rpc.list(rpcOptions); + } catch (Exception e) { + assertEquals("Page size must be greater than 0.", e.getMessage()); + } + } + @Test public void testListPaging() { Map rpcOptions = new HashMap<>(); From b9cd1a7aad8756330522baaa1db676938c9e261c Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 18 Feb 2016 13:40:58 -0800 Subject: [PATCH 073/203] catch ResourceManagerException instead of Exception --- .../gcloud/resourcemanager/LocalResourceManagerHelperTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java index 1c2e0ff9c667..6c20c4f1ae0e 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java @@ -303,7 +303,7 @@ public void testInvalidListPaging() { rpcOptions.put(ResourceManagerRpc.Option.PAGE_SIZE, -1); try { rpc.list(rpcOptions); - } catch (Exception e) { + } catch (ResourceManagerException e) { assertEquals("Page size must be greater than 0.", e.getMessage()); } } From ff2084764b6c75612d04a02084f76bd715064b24 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Wed, 17 Feb 2016 14:16:41 -0800 Subject: [PATCH 074/203] Add IAM Policy classes --- gcloud-java-core/pom.xml | 12 + .../java/com/google/gcloud/IamPolicy.java | 530 ++++++++++++++++++ .../java/com/google/gcloud/IamPolicyTest.java | 126 +++++ .../com/google/gcloud/SerializationTest.java | 49 ++ gcloud-java-resourcemanager/pom.xml | 12 - 5 files changed, 717 insertions(+), 12 deletions(-) create mode 100644 gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java create mode 100644 gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java create mode 100644 gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java diff --git a/gcloud-java-core/pom.xml b/gcloud-java-core/pom.xml index 3463f40b52bd..67d3af27d1a8 100644 --- a/gcloud-java-core/pom.xml +++ b/gcloud-java-core/pom.xml @@ -16,6 +16,18 @@ gcloud-java-core + + com.google.apis + google-api-services-cloudresourcemanager + v1beta1-rev10-1.21.0 + compile + + + com.google.guava + guava-jdk5 + + + com.google.auth google-auth-library-credentials diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java new file mode 100644 index 000000000000..31099729564a --- /dev/null +++ b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java @@ -0,0 +1,530 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; + +/** + * An Identity and Access Management (IAM) policy. It is used to specify access control policies for + * Cloud Platform resources. A Policy consists of a list of ACLs (also known as bindings in Cloud + * IAM documentation). An ACL binds a list of identities to a role, where the identities can be user + * accounts, Google groups, Google domains, and service accounts. A role is a named list of + * permissions defined by IAM. + * + * @see Policy + */ +public class IamPolicy implements Serializable { + + static final long serialVersionUID = 1114489978726897720L; + + private final List acls; + private final String etag; + private final int version; + + public static class Identity implements Serializable { + + private static final long serialVersionUID = 30811617560110848L; + + private final Type type; + private final String id; + + /** + * The types of IAM identities. + */ + public enum Type { + /** + * Represents anyone who is on the internet; with or without a Google account. + */ + ALL_USERS, + + /** + * Represents anyone who is authenticated with a Google account or a service account. + */ + ALL_AUTHENTICATED_USERS, + + /** + * Represents a specific Google account. + */ + USER, + + /** + * Represents a service account. + */ + SERVICE_ACCOUNT, + + /** + * Represents a Google group. + */ + GROUP, + + /** + * Represents all the users of a Google Apps domain name. + */ + DOMAIN + } + + Identity(Type type, String id) { + this.type = type; + this.id = id; + } + + public Type type() { + return type; + } + + /** + * Returns the string identifier for this identity. The id corresponds to: + *

    + *
  • email address (for identities of type {@code USER}, {@code SERVICE_ACCOUNT}, and + * {@code GROUP}) + *
  • domain (for identities of type {@code DOMAIN}) + *
  • null (for identities of type {@code ALL_USERS} and {@code ALL_AUTHENTICATED_USERS}) + *
+ */ + public String id() { + return id; + } + + /** + * Returns a new identity representing anyone who is on the internet; with or without a Google + * account. + */ + public static Identity allUsers() { + return new Identity(Type.ALL_USERS, null); + } + + /** + * Returns a new identity representing anyone who is authenticated with a Google account or a + * service account. + */ + public static Identity allAuthenticatedUsers() { + return new Identity(Type.ALL_AUTHENTICATED_USERS, null); + } + + /** + * Returns a new user identity. + * + * @param email An email address that represents a specific Google account. For example, + * alice@gmail.com or joe@example.com. + */ + public static Identity user(String email) { + return new Identity(Type.USER, checkNotNull(email)); + } + + /** + * Returns a new service account identity. + * + * @param email An email address that represents a service account. For example, + * my-other-app@appspot.gserviceaccount.com. + */ + public static Identity serviceAccount(String email) { + return new Identity(Type.SERVICE_ACCOUNT, checkNotNull(email)); + } + + /** + * Returns a new group identity. + * + * @param email An email address that represents a Google group. For example, + * admins@example.com. + */ + public static Identity group(String email) { + return new Identity(Type.GROUP, checkNotNull(email)); + } + + /** + * Returns a new domain identity. + * + * @param domain A Google Apps domain name that represents all the users of that domain. For + * example, google.com or example.com. + */ + public static Identity domain(String domain) { + return new Identity(Type.DOMAIN, checkNotNull(domain)); + } + + @Override + public int hashCode() { + return Objects.hash(id, type); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Identity)) { + return false; + } + Identity other = (Identity) obj; + return Objects.equals(toPb(), other.toPb()); + } + + String toPb() { + switch (type) { + case ALL_USERS: + return "allUsers"; + case ALL_AUTHENTICATED_USERS: + return "allAuthenticatedUsers"; + case USER: + return "user:" + id; + case SERVICE_ACCOUNT: + return "serviceAccount:" + id; + case GROUP: + return "group:" + id; + default: + return "domain:" + id; + } + } + + static Identity fromPb(String identityStr) { + String[] info = identityStr.split(":"); + switch (info[0]) { + case "allUsers": + return allUsers(); + case "allAuthenticatedUsers": + return allAuthenticatedUsers(); + case "user": + return user(info[1]); + case "serviceAccount": + return serviceAccount(info[1]); + case "group": + return group(info[1]); + case "domain": + return domain(info[1]); + default: + throw new IllegalArgumentException("Unexpected identity type: " + info[0]); + } + } + } + + /** + * An ACL binds a list of identities to a role, where the identities can be user accounts, Google + * groups, Google domains, and service accounts. A role is a named list of permissions defined by + * IAM. + * + * @see
Binding + */ + public static class Acl implements Serializable { + + private static final long serialVersionUID = 3954282899483745158L; + + private final List identities; + private final String role; + + /** + * An ACL builder. + */ + public static class Builder { + private final List members = new LinkedList<>(); + private String role; + + Builder(String role) { + this.role = role; + } + + /** + * Sets the role associated with this ACL. + */ + public Builder role(String role) { + this.role = role; + return this; + } + + /** + * Replaces the builder's list of identities with the given list. + */ + public Builder identities(List identities) { + this.members.clear(); + this.members.addAll(identities); + return this; + } + + /** + * Adds one or more identities to the list of identities associated with the ACL. + */ + public Builder addIdentity(Identity first, Identity... others) { + members.add(first); + members.addAll(Arrays.asList(others)); + return this; + } + + /** + * Removes the specified identity from the ACL. + */ + public Builder removeIdentity(Identity identity) { + members.remove(identity); + return this; + } + + public Acl build() { + return new Acl(this); + } + } + + Acl(Builder builder) { + identities = ImmutableList.copyOf(checkNotNull(builder.members)); + role = checkNotNull(builder.role); + } + + /** + * Returns the list of identities associated with this ACL. + */ + public List identities() { + return identities; + } + + /** + * Returns the role associated with this ACL. + */ + public String role() { + return role; + } + + /** + * Returns an ACL builder for the specific role type. + * + * @param role string representing the role, without the "roles/" prefix. An example of a valid + * legacy role is "viewer". An example of a valid service-specific role is + * "pubsub.publisher". + */ + public static Builder builder(String role) { + return new Builder(role); + } + + /** + * Returns an ACL for the role type and list of identities provided. + * + * @param role string representing the role, without the "roles/" prefix. An example of a valid + * legacy role is "viewer". An example of a valid service-specific role is + * "pubsub.publisher". + * @param members list of identities associated with the role. + */ + public static Acl of(String role, List members) { + return new Acl(new Builder(role).identities(members)); + } + + /** + * Returns an ACL for the role type and identities provided. + * + * @param role string representing the role, without the "roles/" prefix. An example of a valid + * legacy role is "viewer". An example of a valid service-specific role is + * "pubsub.publisher". + * @param first identity associated with the role. + * @param others any other identities associated with the role. + */ + public static Acl of(String role, Identity first, Identity... others) { + return new Acl(new Builder(role).addIdentity(first, others)); + } + + public Builder toBuilder() { + return new Builder(role).identities(identities); + } + + @Override + public int hashCode() { + return Objects.hash(identities, role); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Acl)) { + return false; + } + Acl other = (Acl) obj; + return Objects.equals(toPb(), other.toPb()); + } + + com.google.api.services.cloudresourcemanager.model.Binding toPb() { + com.google.api.services.cloudresourcemanager.model.Binding bindingPb = + new com.google.api.services.cloudresourcemanager.model.Binding(); + bindingPb.setMembers(Lists.transform(identities, new Function() { + @Override + public String apply(Identity identity) { + return identity.toPb(); + } + })); + bindingPb.setRole("roles/" + role); + return bindingPb; + } + + static Acl fromPb(com.google.api.services.cloudresourcemanager.model.Binding bindingPb) { + return of( + bindingPb.getRole().substring("roles/".length()), + Lists.transform(bindingPb.getMembers(), new Function() { + @Override + public Identity apply(String memberPb) { + return Identity.fromPb(memberPb); + } + })); + } + } + + /** + * Builder for an IAM Policy. + */ + public static class Builder { + + private final List acls = new LinkedList<>(); + private String etag; + private int version; + + /** + * Replaces the builder's list of ACLs with the given list of ACLs. + */ + public Builder acls(List acls) { + this.acls.clear(); + this.acls.addAll(acls); + return this; + } + + /** + * Adds one or more ACLs to the policy. + */ + public Builder addAcl(Acl first, Acl... others) { + acls.add(first); + acls.addAll(Arrays.asList(others)); + return this; + } + + /** + * Removes the specified ACL. + */ + public Builder removeAcl(Acl acl) { + acls.remove(acl); + return this; + } + + /** + * Sets the policy's etag. + * + *

Etags are used for optimistic concurrency control as a way to help prevent simultaneous + * updates of a policy from overwriting each other. It is strongly suggested that systems make + * use of the etag in the read-modify-write cycle to perform policy updates in order to avoid + * race conditions. An etag is returned in the response to getIamPolicy, and systems are + * expected to put that etag in the request to setIamPolicy to ensure that their change will be + * applied to the same version of the policy. If no etag is provided in the call to + * setIamPolicy, then the existing policy is overwritten blindly. + */ + public Builder etag(String etag) { + this.etag = etag; + return this; + } + + /** + * Sets the version of the policy. The default version is 0. + */ + public Builder version(int version) { + this.version = version; + return this; + } + + public IamPolicy build() { + return new IamPolicy(this); + } + } + + IamPolicy(Builder builder) { + acls = ImmutableList.copyOf(builder.acls); + etag = builder.etag; + version = builder.version; + } + + /** + * The list of ACLs specified in the policy. + */ + public List acls() { + return acls; + } + + /** + * The policy's etag. + * + *

Etags are used for optimistic concurrency control as a way to help prevent simultaneous + * updates of a policy from overwriting each other. It is strongly suggested that systems make + * use of the etag in the read-modify-write cycle to perform policy updates in order to avoid + * race conditions. An etag is returned in the response to getIamPolicy, and systems are + * expected to put that etag in the request to setIamPolicy to ensure that their change will be + * applied to the same version of the policy. If no etag is provided in the call to + * setIamPolicy, then the existing policy is overwritten blindly. + */ + public String etag() { + return etag; + } + + /** + * The version of the policy. The default version is 0. + */ + public int version() { + return version; + } + + @Override + public int hashCode() { + return Objects.hash(acls, etag, version); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof IamPolicy)) { + return false; + } + IamPolicy other = (IamPolicy) obj; + return Objects.equals(toPb(), other.toPb()); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().acls(acls).etag(etag).version(version); + } + + com.google.api.services.cloudresourcemanager.model.Policy toPb() { + com.google.api.services.cloudresourcemanager.model.Policy policyPb = + new com.google.api.services.cloudresourcemanager.model.Policy(); + policyPb.setBindings(Lists.transform( + acls, new Function() { + @Override + public com.google.api.services.cloudresourcemanager.model.Binding apply(Acl acl) { + return acl.toPb(); + } + })); + policyPb.setEtag(etag); + policyPb.setVersion(version); + return policyPb; + } + + static IamPolicy fromPb(com.google.api.services.cloudresourcemanager.model.Policy policyPb) { + Builder builder = new Builder(); + builder.acls(Lists.transform( + policyPb.getBindings(), + new Function() { + @Override + public Acl apply(com.google.api.services.cloudresourcemanager.model.Binding binding) { + return Acl.fromPb(binding); + } + })); + return builder.etag(policyPb.getEtag()).version(policyPb.getVersion()).build(); + } +} diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java new file mode 100644 index 000000000000..a87a0b5f287d --- /dev/null +++ b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java @@ -0,0 +1,126 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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.gcloud; + +import static org.junit.Assert.assertEquals; + +import com.google.common.collect.ImmutableList; +import com.google.gcloud.IamPolicy.Acl; +import com.google.gcloud.IamPolicy.Identity; + +import org.junit.Test; + +public class IamPolicyTest { + + private static final Identity ALL_USERS = Identity.allUsers(); + private static final Identity ALL_AUTHENTICATED_USERS = Identity.allAuthenticatedUsers(); + private static final Identity USER = Identity.user("abc@gmail.com"); + private static final Identity SERVICE_ACCOUNT = + Identity.serviceAccount("service-account@gmail.com"); + private static final Identity GROUP = Identity.group("group@gmail.com"); + private static final Identity DOMAIN = Identity.domain("google.com"); + private static final Acl ACL1 = Acl.of("viewer", USER, SERVICE_ACCOUNT, ALL_USERS); + private static final Acl ACL2 = Acl.of("editor", ALL_AUTHENTICATED_USERS, GROUP, DOMAIN); + private static final IamPolicy FULL_POLICY = + IamPolicy.builder().addAcl(ACL1, ACL2).etag("etag").version(1).build(); + private static final IamPolicy SIMPLE_POLICY = IamPolicy.builder().addAcl(ACL1, ACL2).build(); + + @Test + public void testIdentityOf() { + assertEquals(Identity.Type.ALL_USERS, ALL_USERS.type()); + assertEquals(null, ALL_USERS.id()); + assertEquals(Identity.Type.ALL_AUTHENTICATED_USERS, ALL_AUTHENTICATED_USERS.type()); + assertEquals(null, ALL_AUTHENTICATED_USERS.id()); + assertEquals(Identity.Type.USER, USER.type()); + assertEquals("abc@gmail.com", USER.id()); + assertEquals(Identity.Type.SERVICE_ACCOUNT, SERVICE_ACCOUNT.type()); + assertEquals("service-account@gmail.com", SERVICE_ACCOUNT.id()); + assertEquals(Identity.Type.GROUP, GROUP.type()); + assertEquals("group@gmail.com", GROUP.id()); + assertEquals(Identity.Type.DOMAIN, DOMAIN.type()); + assertEquals("google.com", DOMAIN.id()); + } + + @Test + public void testIdentityToAndFromPb() { + assertEquals(ALL_USERS, Identity.fromPb(ALL_USERS.toPb())); + assertEquals(ALL_AUTHENTICATED_USERS, Identity.fromPb(ALL_AUTHENTICATED_USERS.toPb())); + assertEquals(USER, Identity.fromPb(USER.toPb())); + assertEquals(SERVICE_ACCOUNT, Identity.fromPb(SERVICE_ACCOUNT.toPb())); + assertEquals(GROUP, Identity.fromPb(GROUP.toPb())); + assertEquals(DOMAIN, Identity.fromPb(DOMAIN.toPb())); + } + + @Test + public void testAclBuilder() { + Acl acl = Acl.builder("owner").addIdentity(USER, GROUP).build(); + assertEquals("owner", acl.role()); + assertEquals(ImmutableList.of(USER, GROUP), acl.identities()); + acl = acl.toBuilder().role("viewer").removeIdentity(GROUP).build(); + assertEquals("viewer", acl.role()); + assertEquals(ImmutableList.of(USER), acl.identities()); + acl = acl.toBuilder().identities(ImmutableList.of(SERVICE_ACCOUNT)).build(); + assertEquals("viewer", acl.role()); + assertEquals(ImmutableList.of(SERVICE_ACCOUNT), acl.identities()); + } + + @Test + public void testAclOf() { + assertEquals("viewer", ACL1.role()); + assertEquals(ImmutableList.of(USER, SERVICE_ACCOUNT, ALL_USERS), ACL1.identities()); + Acl aclFromIdentitiesList = Acl.of("editor", ImmutableList.of(USER, SERVICE_ACCOUNT)); + assertEquals("editor", aclFromIdentitiesList.role()); + assertEquals(ImmutableList.of(USER, SERVICE_ACCOUNT), aclFromIdentitiesList.identities()); + } + + @Test + public void testAclToBuilder() { + assertEquals(ACL1, ACL1.toBuilder().build()); + } + + @Test + public void testAclToAndFromPb() { + assertEquals(ACL1, Acl.fromPb(ACL1.toPb())); + } + + @Test + public void testIamPolicyBuilder() { + assertEquals(ImmutableList.of(ACL1, ACL2), FULL_POLICY.acls()); + assertEquals("etag", FULL_POLICY.etag()); + assertEquals(1, FULL_POLICY.version()); + IamPolicy policy = FULL_POLICY.toBuilder().acls(ImmutableList.of(ACL2)).build(); + assertEquals(ImmutableList.of(ACL2), policy.acls()); + assertEquals("etag", policy.etag()); + assertEquals(1, policy.version()); + policy = SIMPLE_POLICY.toBuilder().removeAcl(ACL2).build(); + assertEquals(ImmutableList.of(ACL1), policy.acls()); + assertEquals(null, policy.etag()); + assertEquals(0, policy.version()); + } + + @Test + public void testIamPolicyToBuilder() { + assertEquals(FULL_POLICY, FULL_POLICY.toBuilder().build()); + assertEquals(SIMPLE_POLICY, SIMPLE_POLICY.toBuilder().build()); + } + + @Test + public void testToAndFromPb() { + assertEquals(FULL_POLICY, IamPolicy.fromPb(FULL_POLICY.toPb())); + assertEquals(SIMPLE_POLICY, IamPolicy.fromPb(SIMPLE_POLICY.toPb())); + } +} diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java new file mode 100644 index 000000000000..b529b2c09ff5 --- /dev/null +++ b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java @@ -0,0 +1,49 @@ +package com.google.gcloud; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; + +import com.google.common.collect.ImmutableList; +import com.google.gcloud.IamPolicy.Acl; +import com.google.gcloud.IamPolicy.Identity; + +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +public class SerializationTest { + + private static final Identity IDENTITY = Identity.user("abc@gmail.com"); + private static final Acl ACL = Acl.of("viewer", ImmutableList.of(IDENTITY)); + private static final IamPolicy POLICY = + IamPolicy.builder().acls(ImmutableList.of(ACL)).etag("etag").version(1).build(); + + @Test + public void testModelAndRequests() throws Exception { + Serializable[] objects = {IDENTITY, ACL, POLICY}; + for (Serializable obj : objects) { + Object copy = serializeAndDeserialize(obj); + assertEquals(obj, obj); + assertEquals(obj, copy); + assertNotSame(obj, copy); + assertEquals(copy, copy); + } + } + + @SuppressWarnings("unchecked") + private T serializeAndDeserialize(T obj) throws IOException, ClassNotFoundException { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { + output.writeObject(obj); + } + try (ObjectInputStream input = + new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) { + return (T) input.readObject(); + } + } +} diff --git a/gcloud-java-resourcemanager/pom.xml b/gcloud-java-resourcemanager/pom.xml index 1311e4dc1bb5..5e77ab48f5b5 100644 --- a/gcloud-java-resourcemanager/pom.xml +++ b/gcloud-java-resourcemanager/pom.xml @@ -21,18 +21,6 @@ gcloud-java-core ${project.version} - - com.google.apis - google-api-services-cloudresourcemanager - v1beta1-rev10-1.21.0 - compile - - - com.google.guava - guava-jdk5 - - - junit junit From 3f07b2ce044df15af9235de39d37f5827a9a6d6c Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 18 Feb 2016 16:29:47 -0800 Subject: [PATCH 075/203] move to/fromPb functions to Resource Manager --- gcloud-java-core/pom.xml | 12 --- .../java/com/google/gcloud/IamPolicy.java | 98 +------------------ .../java/com/google/gcloud/IamPolicyTest.java | 27 +---- gcloud-java-resourcemanager/pom.xml | 12 +++ .../resourcemanager/ResourceManagerImpl.java | 94 ++++++++++++++++++ .../ResourceManagerImplTest.java | 44 +++++++++ 6 files changed, 157 insertions(+), 130 deletions(-) diff --git a/gcloud-java-core/pom.xml b/gcloud-java-core/pom.xml index 67d3af27d1a8..3463f40b52bd 100644 --- a/gcloud-java-core/pom.xml +++ b/gcloud-java-core/pom.xml @@ -16,18 +16,6 @@ gcloud-java-core - - com.google.apis - google-api-services-cloudresourcemanager - v1beta1-rev10-1.21.0 - compile - - - com.google.guava - guava-jdk5 - - - com.google.auth google-auth-library-credentials diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java index 31099729564a..a16ab790b363 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java @@ -18,9 +18,7 @@ import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.base.Function; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; import java.io.Serializable; import java.util.Arrays; @@ -176,44 +174,7 @@ public boolean equals(Object obj) { return false; } Identity other = (Identity) obj; - return Objects.equals(toPb(), other.toPb()); - } - - String toPb() { - switch (type) { - case ALL_USERS: - return "allUsers"; - case ALL_AUTHENTICATED_USERS: - return "allAuthenticatedUsers"; - case USER: - return "user:" + id; - case SERVICE_ACCOUNT: - return "serviceAccount:" + id; - case GROUP: - return "group:" + id; - default: - return "domain:" + id; - } - } - - static Identity fromPb(String identityStr) { - String[] info = identityStr.split(":"); - switch (info[0]) { - case "allUsers": - return allUsers(); - case "allAuthenticatedUsers": - return allAuthenticatedUsers(); - case "user": - return user(info[1]); - case "serviceAccount": - return serviceAccount(info[1]); - case "group": - return group(info[1]); - case "domain": - return domain(info[1]); - default: - throw new IllegalArgumentException("Unexpected identity type: " + info[0]); - } + return Objects.equals(id, other.id()) && Objects.equals(type, other.type()); } } @@ -351,31 +312,7 @@ public boolean equals(Object obj) { return false; } Acl other = (Acl) obj; - return Objects.equals(toPb(), other.toPb()); - } - - com.google.api.services.cloudresourcemanager.model.Binding toPb() { - com.google.api.services.cloudresourcemanager.model.Binding bindingPb = - new com.google.api.services.cloudresourcemanager.model.Binding(); - bindingPb.setMembers(Lists.transform(identities, new Function() { - @Override - public String apply(Identity identity) { - return identity.toPb(); - } - })); - bindingPb.setRole("roles/" + role); - return bindingPb; - } - - static Acl fromPb(com.google.api.services.cloudresourcemanager.model.Binding bindingPb) { - return of( - bindingPb.getRole().substring("roles/".length()), - Lists.transform(bindingPb.getMembers(), new Function() { - @Override - public Identity apply(String memberPb) { - return Identity.fromPb(memberPb); - } - })); + return Objects.equals(identities, other.identities()) && Objects.equals(role, other.role()); } } @@ -489,7 +426,8 @@ public boolean equals(Object obj) { return false; } IamPolicy other = (IamPolicy) obj; - return Objects.equals(toPb(), other.toPb()); + return Objects.equals(acls, other.acls()) && Objects.equals(etag, other.etag()) + && Objects.equals(version, other.version()); } public static Builder builder() { @@ -499,32 +437,4 @@ public static Builder builder() { public Builder toBuilder() { return new Builder().acls(acls).etag(etag).version(version); } - - com.google.api.services.cloudresourcemanager.model.Policy toPb() { - com.google.api.services.cloudresourcemanager.model.Policy policyPb = - new com.google.api.services.cloudresourcemanager.model.Policy(); - policyPb.setBindings(Lists.transform( - acls, new Function() { - @Override - public com.google.api.services.cloudresourcemanager.model.Binding apply(Acl acl) { - return acl.toPb(); - } - })); - policyPb.setEtag(etag); - policyPb.setVersion(version); - return policyPb; - } - - static IamPolicy fromPb(com.google.api.services.cloudresourcemanager.model.Policy policyPb) { - Builder builder = new Builder(); - builder.acls(Lists.transform( - policyPb.getBindings(), - new Function() { - @Override - public Acl apply(com.google.api.services.cloudresourcemanager.model.Binding binding) { - return Acl.fromPb(binding); - } - })); - return builder.etag(policyPb.getEtag()).version(policyPb.getVersion()).build(); - } } diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java index a87a0b5f287d..76a57b5fef50 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java @@ -55,16 +55,6 @@ public void testIdentityOf() { assertEquals("google.com", DOMAIN.id()); } - @Test - public void testIdentityToAndFromPb() { - assertEquals(ALL_USERS, Identity.fromPb(ALL_USERS.toPb())); - assertEquals(ALL_AUTHENTICATED_USERS, Identity.fromPb(ALL_AUTHENTICATED_USERS.toPb())); - assertEquals(USER, Identity.fromPb(USER.toPb())); - assertEquals(SERVICE_ACCOUNT, Identity.fromPb(SERVICE_ACCOUNT.toPb())); - assertEquals(GROUP, Identity.fromPb(GROUP.toPb())); - assertEquals(DOMAIN, Identity.fromPb(DOMAIN.toPb())); - } - @Test public void testAclBuilder() { Acl acl = Acl.builder("owner").addIdentity(USER, GROUP).build(); @@ -82,9 +72,9 @@ public void testAclBuilder() { public void testAclOf() { assertEquals("viewer", ACL1.role()); assertEquals(ImmutableList.of(USER, SERVICE_ACCOUNT, ALL_USERS), ACL1.identities()); - Acl aclFromIdentitiesList = Acl.of("editor", ImmutableList.of(USER, SERVICE_ACCOUNT)); - assertEquals("editor", aclFromIdentitiesList.role()); - assertEquals(ImmutableList.of(USER, SERVICE_ACCOUNT), aclFromIdentitiesList.identities()); + Acl aclFromList = Acl.of("editor", ImmutableList.of(USER, SERVICE_ACCOUNT)); + assertEquals("editor", aclFromList.role()); + assertEquals(ImmutableList.of(USER, SERVICE_ACCOUNT), aclFromList.identities()); } @Test @@ -92,11 +82,6 @@ public void testAclToBuilder() { assertEquals(ACL1, ACL1.toBuilder().build()); } - @Test - public void testAclToAndFromPb() { - assertEquals(ACL1, Acl.fromPb(ACL1.toPb())); - } - @Test public void testIamPolicyBuilder() { assertEquals(ImmutableList.of(ACL1, ACL2), FULL_POLICY.acls()); @@ -117,10 +102,4 @@ public void testIamPolicyToBuilder() { assertEquals(FULL_POLICY, FULL_POLICY.toBuilder().build()); assertEquals(SIMPLE_POLICY, SIMPLE_POLICY.toBuilder().build()); } - - @Test - public void testToAndFromPb() { - assertEquals(FULL_POLICY, IamPolicy.fromPb(FULL_POLICY.toPb())); - assertEquals(SIMPLE_POLICY, IamPolicy.fromPb(SIMPLE_POLICY.toPb())); - } } diff --git a/gcloud-java-resourcemanager/pom.xml b/gcloud-java-resourcemanager/pom.xml index 5e77ab48f5b5..1311e4dc1bb5 100644 --- a/gcloud-java-resourcemanager/pom.xml +++ b/gcloud-java-resourcemanager/pom.xml @@ -21,6 +21,18 @@ gcloud-java-core ${project.version} + + com.google.apis + google-api-services-cloudresourcemanager + v1beta1-rev10-1.21.0 + compile + + + com.google.guava + guava-jdk5 + + + junit junit diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java index 4176b4e610ba..e641f3c75a31 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java @@ -23,8 +23,12 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gcloud.BaseService; +import com.google.gcloud.IamPolicy; +import com.google.gcloud.IamPolicy.Acl; +import com.google.gcloud.IamPolicy.Identity; import com.google.gcloud.Page; import com.google.gcloud.PageImpl; import com.google.gcloud.PageImpl.NextPageFetcher; @@ -189,4 +193,94 @@ public Void call() { } return ImmutableMap.copyOf(temp); } + + static String identityToPb(Identity identity) { + switch (identity.type()) { + case ALL_USERS: + return "allUsers"; + case ALL_AUTHENTICATED_USERS: + return "allAuthenticatedUsers"; + case USER: + return "user:" + identity.id(); + case SERVICE_ACCOUNT: + return "serviceAccount:" + identity.id(); + case GROUP: + return "group:" + identity.id(); + default: + return "domain:" + identity.id(); + } + } + + static Identity identityFromPb(String identityStr) { + String[] info = identityStr.split(":"); + switch (info[0]) { + case "allUsers": + return Identity.allUsers(); + case "allAuthenticatedUsers": + return Identity.allAuthenticatedUsers(); + case "user": + return Identity.user(info[1]); + case "serviceAccount": + return Identity.serviceAccount(info[1]); + case "group": + return Identity.group(info[1]); + case "domain": + return Identity.domain(info[1]); + default: + throw new IllegalArgumentException("Unexpected identity type: " + info[0]); + } + } + + static com.google.api.services.cloudresourcemanager.model.Binding aclToPb(Acl acl) { + com.google.api.services.cloudresourcemanager.model.Binding bindingPb = + new com.google.api.services.cloudresourcemanager.model.Binding(); + bindingPb.setMembers(Lists.transform(acl.identities(), new Function() { + @Override + public String apply(Identity identity) { + return identityToPb(identity); + } + })); + bindingPb.setRole("roles/" + acl.role()); + return bindingPb; + } + + static Acl aclFromPb(com.google.api.services.cloudresourcemanager.model.Binding bindingPb) { + return Acl.of( + bindingPb.getRole().substring("roles/".length()), + Lists.transform(bindingPb.getMembers(), new Function() { + @Override + public Identity apply(String memberPb) { + return identityFromPb(memberPb); + } + })); + } + + static com.google.api.services.cloudresourcemanager.model.Policy policyToPb( + final IamPolicy policy) { + com.google.api.services.cloudresourcemanager.model.Policy policyPb = + new com.google.api.services.cloudresourcemanager.model.Policy(); + policyPb.setBindings(Lists.transform(policy.acls(), + new Function() { + @Override + public com.google.api.services.cloudresourcemanager.model.Binding apply(Acl acl) { + return aclToPb(acl); + } + })); + policyPb.setEtag(policy.etag()); + policyPb.setVersion(policy.version()); + return policyPb; + } + + static IamPolicy policyFromPb( + com.google.api.services.cloudresourcemanager.model.Policy policyPb) { + IamPolicy.Builder builder = new IamPolicy.Builder(); + builder.acls(Lists.transform(policyPb.getBindings(), + new Function() { + @Override + public Acl apply(com.google.api.services.cloudresourcemanager.model.Binding binding) { + return aclFromPb(binding); + } + })); + return builder.etag(policyPb.getEtag()).version(policyPb.getVersion()).build(); + } } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java index 37c54718fb4a..623bf68d085c 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java @@ -25,6 +25,9 @@ import static org.junit.Assert.fail; import com.google.common.collect.ImmutableMap; +import com.google.gcloud.IamPolicy; +import com.google.gcloud.IamPolicy.Acl; +import com.google.gcloud.IamPolicy.Identity; import com.google.gcloud.Page; import com.google.gcloud.resourcemanager.ProjectInfo.ResourceId; import com.google.gcloud.resourcemanager.ResourceManager.ProjectField; @@ -64,6 +67,18 @@ public class ResourceManagerImplTest { .parent(PARENT) .build(); private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); + private static final Identity ALL_USERS = Identity.allUsers(); + private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); + private static final Identity USER = Identity.user("abc@gmail.com"); + private static final Identity SERVICE_ACCOUNT = + Identity.serviceAccount("service-account@gmail.com"); + private static final Identity GROUP = Identity.group("group@gmail.com"); + private static final Identity DOMAIN = Identity.domain("google.com"); + private static final Acl ACL1 = Acl.of("viewer", USER, SERVICE_ACCOUNT, ALL_USERS); + private static final Acl ACL2 = Acl.of("editor", ALL_AUTH_USERS, GROUP, DOMAIN); + private static final IamPolicy FULL_POLICY = + IamPolicy.builder().addAcl(ACL1, ACL2).etag("etag").version(1).build(); + private static final IamPolicy SIMPLE_POLICY = IamPolicy.builder().addAcl(ACL1, ACL2).build(); @Rule public ExpectedException thrown = ExpectedException.none(); @@ -271,6 +286,35 @@ public void testUndelete() { } } + @Test + public void testIdentityToAndFromPb() { + assertEquals(ALL_USERS, + ResourceManagerImpl.identityFromPb(ResourceManagerImpl.identityToPb(ALL_USERS))); + assertEquals(ALL_AUTH_USERS, + ResourceManagerImpl.identityFromPb( + ResourceManagerImpl.identityToPb(ALL_AUTH_USERS))); + assertEquals(USER, ResourceManagerImpl.identityFromPb(ResourceManagerImpl.identityToPb(USER))); + assertEquals(SERVICE_ACCOUNT, + ResourceManagerImpl.identityFromPb(ResourceManagerImpl.identityToPb(SERVICE_ACCOUNT))); + assertEquals(GROUP, + ResourceManagerImpl.identityFromPb(ResourceManagerImpl.identityToPb(GROUP))); + assertEquals(DOMAIN, + ResourceManagerImpl.identityFromPb(ResourceManagerImpl.identityToPb(DOMAIN))); + } + + @Test + public void testAclToAndFromPb() { + assertEquals(ACL1, ResourceManagerImpl.aclFromPb(ResourceManagerImpl.aclToPb(ACL1))); + } + + @Test + public void testPolicyToAndFromPb() { + assertEquals(FULL_POLICY, + ResourceManagerImpl.policyFromPb(ResourceManagerImpl.policyToPb(FULL_POLICY))); + assertEquals(SIMPLE_POLICY, + ResourceManagerImpl.policyFromPb(ResourceManagerImpl.policyToPb(SIMPLE_POLICY))); + } + @Test public void testRetryableException() { ResourceManagerRpcFactory rpcFactoryMock = EasyMock.createMock(ResourceManagerRpcFactory.class); From c96469b6a135619708f08526c2f0d5cc50396c80 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 18 Feb 2016 17:33:13 -0800 Subject: [PATCH 076/203] variable rename to make codacy happy --- .../src/test/java/com/google/gcloud/IamPolicyTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java index 76a57b5fef50..0d4e9fbfa6c8 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java @@ -27,14 +27,14 @@ public class IamPolicyTest { private static final Identity ALL_USERS = Identity.allUsers(); - private static final Identity ALL_AUTHENTICATED_USERS = Identity.allAuthenticatedUsers(); + private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); private static final Identity USER = Identity.user("abc@gmail.com"); private static final Identity SERVICE_ACCOUNT = Identity.serviceAccount("service-account@gmail.com"); private static final Identity GROUP = Identity.group("group@gmail.com"); private static final Identity DOMAIN = Identity.domain("google.com"); private static final Acl ACL1 = Acl.of("viewer", USER, SERVICE_ACCOUNT, ALL_USERS); - private static final Acl ACL2 = Acl.of("editor", ALL_AUTHENTICATED_USERS, GROUP, DOMAIN); + private static final Acl ACL2 = Acl.of("editor", ALL_AUTH_USERS, GROUP, DOMAIN); private static final IamPolicy FULL_POLICY = IamPolicy.builder().addAcl(ACL1, ACL2).etag("etag").version(1).build(); private static final IamPolicy SIMPLE_POLICY = IamPolicy.builder().addAcl(ACL1, ACL2).build(); @@ -43,8 +43,8 @@ public class IamPolicyTest { public void testIdentityOf() { assertEquals(Identity.Type.ALL_USERS, ALL_USERS.type()); assertEquals(null, ALL_USERS.id()); - assertEquals(Identity.Type.ALL_AUTHENTICATED_USERS, ALL_AUTHENTICATED_USERS.type()); - assertEquals(null, ALL_AUTHENTICATED_USERS.id()); + assertEquals(Identity.Type.ALL_AUTHENTICATED_USERS, ALL_AUTH_USERS.type()); + assertEquals(null, ALL_AUTH_USERS.id()); assertEquals(Identity.Type.USER, USER.type()); assertEquals("abc@gmail.com", USER.id()); assertEquals(Identity.Type.SERVICE_ACCOUNT, SERVICE_ACCOUNT.type()); From 3695ddc93486ab9282f4b5b0996d48bcf75cec6d Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Fri, 19 Feb 2016 07:46:43 -0800 Subject: [PATCH 077/203] Update version for release --- gcloud-java-bigquery/pom.xml | 2 +- gcloud-java-contrib/pom.xml | 2 +- gcloud-java-core/pom.xml | 2 +- gcloud-java-datastore/pom.xml | 2 +- gcloud-java-examples/pom.xml | 2 +- gcloud-java-resourcemanager/pom.xml | 2 +- gcloud-java-storage/pom.xml | 2 +- gcloud-java/pom.xml | 2 +- pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcloud-java-bigquery/pom.xml b/gcloud-java-bigquery/pom.xml index b1e516a2268b..6758f66336d8 100644 --- a/gcloud-java-bigquery/pom.xml +++ b/gcloud-java-bigquery/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4-SNAPSHOT + 0.1.4 gcloud-java-bigquery diff --git a/gcloud-java-contrib/pom.xml b/gcloud-java-contrib/pom.xml index 35dfa606ae42..12f192d3fe31 100644 --- a/gcloud-java-contrib/pom.xml +++ b/gcloud-java-contrib/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4-SNAPSHOT + 0.1.4 gcloud-java-contrib diff --git a/gcloud-java-core/pom.xml b/gcloud-java-core/pom.xml index 3463f40b52bd..bc5e9c78ba87 100644 --- a/gcloud-java-core/pom.xml +++ b/gcloud-java-core/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4-SNAPSHOT + 0.1.4 gcloud-java-core diff --git a/gcloud-java-datastore/pom.xml b/gcloud-java-datastore/pom.xml index 6ffc8045ddb1..4ca38253984c 100644 --- a/gcloud-java-datastore/pom.xml +++ b/gcloud-java-datastore/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4-SNAPSHOT + 0.1.4 gcloud-java-datastore diff --git a/gcloud-java-examples/pom.xml b/gcloud-java-examples/pom.xml index e5a95f67a9eb..d39cc33808ef 100644 --- a/gcloud-java-examples/pom.xml +++ b/gcloud-java-examples/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4-SNAPSHOT + 0.1.4 gcloud-java-examples diff --git a/gcloud-java-resourcemanager/pom.xml b/gcloud-java-resourcemanager/pom.xml index 1311e4dc1bb5..dc4bb90fb695 100644 --- a/gcloud-java-resourcemanager/pom.xml +++ b/gcloud-java-resourcemanager/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4-SNAPSHOT + 0.1.4 gcloud-java-resourcemanager diff --git a/gcloud-java-storage/pom.xml b/gcloud-java-storage/pom.xml index 09487467a827..ff6588ca62be 100644 --- a/gcloud-java-storage/pom.xml +++ b/gcloud-java-storage/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4-SNAPSHOT + 0.1.4 gcloud-java-storage diff --git a/gcloud-java/pom.xml b/gcloud-java/pom.xml index 4d46ff7fd0f0..4afa7cb37a31 100644 --- a/gcloud-java/pom.xml +++ b/gcloud-java/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4-SNAPSHOT + 0.1.4 diff --git a/pom.xml b/pom.xml index c3c3554d976a..86cea55be722 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.gcloud gcloud-java-pom pom - 0.1.4-SNAPSHOT + 0.1.4 GCloud Java https://github.com/GoogleCloudPlatform/gcloud-java From cf792d87b838a529c4c288ee6c28694259630d5c Mon Sep 17 00:00:00 2001 From: travis-ci Date: Fri, 19 Feb 2016 16:22:46 +0000 Subject: [PATCH 078/203] Updating version in README files. [ci skip] --- README.md | 6 +++--- gcloud-java-bigquery/README.md | 6 +++--- gcloud-java-contrib/README.md | 6 +++--- gcloud-java-core/README.md | 6 +++--- gcloud-java-datastore/README.md | 6 +++--- gcloud-java-examples/README.md | 6 +++--- gcloud-java-resourcemanager/README.md | 6 +++--- gcloud-java-storage/README.md | 6 +++--- gcloud-java/README.md | 6 +++--- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index d465105dfd41..b6c2473f9794 100644 --- a/README.md +++ b/README.md @@ -29,16 +29,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java - 0.1.3 + 0.1.4 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java:0.1.3' +compile 'com.google.gcloud:gcloud-java:0.1.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.3" +libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.4" ``` Example Applications diff --git a/gcloud-java-bigquery/README.md b/gcloud-java-bigquery/README.md index ba6caa87783a..b406fb5496d2 100644 --- a/gcloud-java-bigquery/README.md +++ b/gcloud-java-bigquery/README.md @@ -22,16 +22,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-bigquery - 0.1.3 + 0.1.4 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-bigquery:0.1.3' +compile 'com.google.gcloud:gcloud-java-bigquery:0.1.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.3" +libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.4" ``` Example Application diff --git a/gcloud-java-contrib/README.md b/gcloud-java-contrib/README.md index 01f455e3a43c..7a935192891d 100644 --- a/gcloud-java-contrib/README.md +++ b/gcloud-java-contrib/README.md @@ -16,16 +16,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-contrib - 0.1.3 + 0.1.4 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-contrib:0.1.3' +compile 'com.google.gcloud:gcloud-java-contrib:0.1.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-contrib" % "0.1.3" +libraryDependencies += "com.google.gcloud" % "gcloud-java-contrib" % "0.1.4" ``` Java Versions diff --git a/gcloud-java-core/README.md b/gcloud-java-core/README.md index b7e5e05b6ad3..bc9463b9cc2b 100644 --- a/gcloud-java-core/README.md +++ b/gcloud-java-core/README.md @@ -19,16 +19,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-core - 0.1.3 + 0.1.4 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-core:0.1.3' +compile 'com.google.gcloud:gcloud-java-core:0.1.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-core" % "0.1.3" +libraryDependencies += "com.google.gcloud" % "gcloud-java-core" % "0.1.4" ``` Troubleshooting diff --git a/gcloud-java-datastore/README.md b/gcloud-java-datastore/README.md index 7d985e882a44..a1d024fcc96d 100644 --- a/gcloud-java-datastore/README.md +++ b/gcloud-java-datastore/README.md @@ -22,16 +22,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-datastore - 0.1.3 + 0.1.4 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-datastore:0.1.3' +compile 'com.google.gcloud:gcloud-java-datastore:0.1.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-datastore" % "0.1.3" +libraryDependencies += "com.google.gcloud" % "gcloud-java-datastore" % "0.1.4" ``` Example Application diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md index 0ab9b3ca6924..59fbca11e219 100644 --- a/gcloud-java-examples/README.md +++ b/gcloud-java-examples/README.md @@ -19,16 +19,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-examples - 0.1.3 + 0.1.4 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-examples:0.1.3' +compile 'com.google.gcloud:gcloud-java-examples:0.1.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-examples" % "0.1.3" +libraryDependencies += "com.google.gcloud" % "gcloud-java-examples" % "0.1.4" ``` To run examples from your command line: diff --git a/gcloud-java-resourcemanager/README.md b/gcloud-java-resourcemanager/README.md index fc80190ebd05..9637b37d3bb8 100644 --- a/gcloud-java-resourcemanager/README.md +++ b/gcloud-java-resourcemanager/README.md @@ -22,16 +22,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-resourcemanager - 0.1.3 + 0.1.4 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-resourcemanager:0.1.3' +compile 'com.google.gcloud:gcloud-java-resourcemanager:0.1.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-resourcemanager" % "0.1.3" +libraryDependencies += "com.google.gcloud" % "gcloud-java-resourcemanager" % "0.1.4" ``` Example Application diff --git a/gcloud-java-storage/README.md b/gcloud-java-storage/README.md index 80b2ffd0cd67..3b013eb03724 100644 --- a/gcloud-java-storage/README.md +++ b/gcloud-java-storage/README.md @@ -22,16 +22,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-storage - 0.1.3 + 0.1.4 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-storage:0.1.3' +compile 'com.google.gcloud:gcloud-java-storage:0.1.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-storage" % "0.1.3" +libraryDependencies += "com.google.gcloud" % "gcloud-java-storage" % "0.1.4" ``` Example Application diff --git a/gcloud-java/README.md b/gcloud-java/README.md index 7443bf5e3392..c51b4e8fe7bc 100644 --- a/gcloud-java/README.md +++ b/gcloud-java/README.md @@ -27,16 +27,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java - 0.1.3 + 0.1.4 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java:0.1.3' +compile 'com.google.gcloud:gcloud-java:0.1.4' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.3" +libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.4" ``` Troubleshooting From 60998b7d6ab6fb1ac7a8f88f28b7b77f9cb28e25 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Fri, 19 Feb 2016 08:38:20 -0800 Subject: [PATCH 079/203] Update version to 0.1.5-SNAPSHOT --- gcloud-java-bigquery/pom.xml | 2 +- gcloud-java-contrib/pom.xml | 2 +- gcloud-java-core/pom.xml | 2 +- gcloud-java-datastore/pom.xml | 2 +- gcloud-java-examples/pom.xml | 2 +- gcloud-java-resourcemanager/pom.xml | 2 +- gcloud-java-storage/pom.xml | 2 +- gcloud-java/pom.xml | 2 +- pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcloud-java-bigquery/pom.xml b/gcloud-java-bigquery/pom.xml index 6758f66336d8..0f41d8bc1eec 100644 --- a/gcloud-java-bigquery/pom.xml +++ b/gcloud-java-bigquery/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4 + 0.1.5-SNAPSHOT gcloud-java-bigquery diff --git a/gcloud-java-contrib/pom.xml b/gcloud-java-contrib/pom.xml index 12f192d3fe31..dd976991e2af 100644 --- a/gcloud-java-contrib/pom.xml +++ b/gcloud-java-contrib/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4 + 0.1.5-SNAPSHOT gcloud-java-contrib diff --git a/gcloud-java-core/pom.xml b/gcloud-java-core/pom.xml index bc5e9c78ba87..d07a567b7e5a 100644 --- a/gcloud-java-core/pom.xml +++ b/gcloud-java-core/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4 + 0.1.5-SNAPSHOT gcloud-java-core diff --git a/gcloud-java-datastore/pom.xml b/gcloud-java-datastore/pom.xml index 4ca38253984c..452986ba5ea3 100644 --- a/gcloud-java-datastore/pom.xml +++ b/gcloud-java-datastore/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4 + 0.1.5-SNAPSHOT gcloud-java-datastore diff --git a/gcloud-java-examples/pom.xml b/gcloud-java-examples/pom.xml index d39cc33808ef..862d48c89eaa 100644 --- a/gcloud-java-examples/pom.xml +++ b/gcloud-java-examples/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4 + 0.1.5-SNAPSHOT gcloud-java-examples diff --git a/gcloud-java-resourcemanager/pom.xml b/gcloud-java-resourcemanager/pom.xml index dc4bb90fb695..40a865f4db68 100644 --- a/gcloud-java-resourcemanager/pom.xml +++ b/gcloud-java-resourcemanager/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4 + 0.1.5-SNAPSHOT gcloud-java-resourcemanager diff --git a/gcloud-java-storage/pom.xml b/gcloud-java-storage/pom.xml index ff6588ca62be..5e53c36c6221 100644 --- a/gcloud-java-storage/pom.xml +++ b/gcloud-java-storage/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4 + 0.1.5-SNAPSHOT gcloud-java-storage diff --git a/gcloud-java/pom.xml b/gcloud-java/pom.xml index 4afa7cb37a31..adfa716fe27b 100644 --- a/gcloud-java/pom.xml +++ b/gcloud-java/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4 + 0.1.5-SNAPSHOT diff --git a/pom.xml b/pom.xml index 86cea55be722..4bc8f37c35de 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.gcloud gcloud-java-pom pom - 0.1.4 + 0.1.5-SNAPSHOT GCloud Java https://github.com/GoogleCloudPlatform/gcloud-java From a1ec7f46c9e4e53ad185039011f49113de48c53a Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 19 Feb 2016 10:32:17 -0800 Subject: [PATCH 080/203] Added local implementation of the service and tests. --- .../google/gcloud/testing/LocalDnsHelper.java | 1426 +++++++++++++++++ .../testing/OptionParsersAndExtractors.java | 279 ++++ .../gcloud/testing/LocalDnsHelperTest.java | 955 +++++++++++ 3 files changed, 2660 insertions(+) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/testing/LocalDnsHelper.java create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/testing/LocalDnsHelperTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/testing/LocalDnsHelper.java b/gcloud-java-dns/src/main/java/com/google/gcloud/testing/LocalDnsHelper.java new file mode 100644 index 000000000000..2d30cf9e5d90 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/testing/LocalDnsHelper.java @@ -0,0 +1,1426 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.testing; + +import static com.google.common.base.Preconditions.checkNotNull; +import static java.net.HttpURLConnection.HTTP_NO_CONTENT; +import static java.net.HttpURLConnection.HTTP_OK; + +import com.google.api.client.json.JsonFactory; +import com.google.api.client.repackaged.com.google.common.base.Joiner; +import com.google.api.services.dns.model.Change; +import com.google.api.services.dns.model.ManagedZone; +import com.google.api.services.dns.model.Project; +import com.google.api.services.dns.model.Quota; +import com.google.api.services.dns.model.ResourceRecordSet; +import com.google.common.base.Function; +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import com.google.common.io.ByteStreams; +import com.google.gcloud.dns.DnsOptions; + +import com.sun.net.httpserver.Headers; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; + +import org.joda.time.format.ISODateTimeFormat; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.math.BigInteger; +import java.net.InetSocketAddress; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.NavigableSet; +import java.util.Objects; +import java.util.Random; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ConcurrentSkipListMap; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.zip.GZIPInputStream; + +import javax.annotation.Nullable; + +/** + * A utility to create local Google Cloud DNS mock. + * + *

The mock runs in a separate thread, listening for HTTP requests on the local machine at an + * ephemeral port. + * + *

While the mock attempts to simulate the service, there are some differences in the behaviour. + * The mock will accept any project ID and never returns a notFound or another error because of + * project ID. It assumes that all project IDs exists and that the user has all the necessary + * privileges to manipulate any project. Similarly, the local simulation does not work with any + * verification of domain name ownership. Any request for creating a managed zone will be approved. + * The mock does not track quota and will allow the user to exceed it. The mock provides only basic + * validation of the DNS data for records of type A and AAAA. It does not validate any other record + * types. + */ +public class LocalDnsHelper { + + private final ConcurrentSkipListMap projects + = new ConcurrentSkipListMap<>(); + private static final URI BASE_CONTEXT; + private static final Logger log = Logger.getLogger(LocalDnsHelper.class.getName()); + private static final JsonFactory jsonFactory = + new com.google.api.client.json.jackson.JacksonFactory(); + private static final Random ID_GENERATOR = new Random(); + private static final String VERSION = "v1"; + private static final String CONTEXT = "/" + VERSION + "/projects"; + private static final Set SUPPORTED_COMPRESSION_ENCODINGS = + ImmutableSet.of("gzip", "x-gzip"); + private static final List TYPES = ImmutableList.of("A", "AAAA", "CNAME", "MX", "NAPTR", + "NS", "PTR", "SOA", "SPF", "SRV", "TXT"); + + static { + try { + BASE_CONTEXT = new URI(CONTEXT); + } catch (URISyntaxException e) { + throw new RuntimeException( + "Could not initialize LocalDnsHelper due to URISyntaxException.", e); + } + } + + private long delayChange; + private final HttpServer server; + private final int port; + + /** + * For matching URLs to operations. + */ + private enum CallRegex { + CHANGE_CREATE("POST", "/[^/]+/managedZones/[^/]+/changes"), + CHANGE_GET("GET", "/[^/]+/managedZones/[^/]+/changes/[^/]+"), + CHANGE_LIST("GET", "/[^/]+/managedZones/[^/]+/changes"), + ZONE_CREATE("POST", "/[^/]+/managedZones"), + ZONE_DELETE("DELETE", "/[^/]+/managedZones/[^/]+"), + ZONE_GET("GET", "/[^/]+/managedZones/[^/]+"), + ZONE_LIST("GET", "/[^/]+/managedZones"), + PROJECT_GET("GET", "/[^/]+"), + RECORD_LIST("GET", "/[^/]+/managedZones/[^/]+/rrsets"); + + private String method; + private String pathRegex; + + CallRegex(String method, String pathRegex) { + this.pathRegex = pathRegex; + this.method = method; + } + } + + /** + * Wraps DNS data by adding a timestamp and id which is used for paging and listing. + */ + static class RrsetWrapper { + static final Function WRAP_FUNCTION = + new Function() { + @Nullable + @Override + public RrsetWrapper apply(@Nullable ResourceRecordSet input) { + return new RrsetWrapper(input); + } + }; + private final ResourceRecordSet rrset; + private final Long timestamp = System.currentTimeMillis(); + private String id; + + RrsetWrapper(ResourceRecordSet rrset) { + // The constructor creates a copy in order to prevent side effects. + this.rrset = new ResourceRecordSet(); + this.rrset.setName(rrset.getName()); + this.rrset.setTtl(rrset.getTtl()); + this.rrset.setRrdatas(ImmutableList.copyOf(rrset.getRrdatas())); + this.rrset.setType(rrset.getType()); + } + + void setId(String id) { + this.id = id; + } + + String id() { + return id; + } + + /** + * Equals does not care about the listing id and timestamp metadata, just the rrset. + */ + @Override + public boolean equals(Object other) { + return (other instanceof RrsetWrapper) && Objects.equals(rrset, ((RrsetWrapper) other).rrset); + } + + @Override + public int hashCode() { + return Objects.hash(rrset); + } + + ResourceRecordSet rrset() { + return rrset; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("rrset", rrset) + .add("timestamp", timestamp) + .add("id", id) + .toString(); + } + } + + /** + * Associates a project with a collection of ManagedZones. Thread safe. + */ + static class ProjectContainer { + private final Project project; + private final ConcurrentSkipListMap zones = + new ConcurrentSkipListMap<>(); + + ProjectContainer(Project project) { + this.project = project; + } + + Project project() { + return project; + } + + ConcurrentSkipListMap zones() { + return zones; + } + } + + /** + * Associates a zone with a collection of changes and dns record. Thread safe. + */ + static class ZoneContainer { + private final ManagedZone zone; + /** + * DNS records are held in a map to allow for atomic replacement of record sets when applying + * changes. The key for the map is always the zone name. The collection of records is immutable + * and must always exist, i.e., dnsRecords.get(zone.getName()) is never null. + */ + private final ConcurrentSkipListMap> + dnsRecords = new ConcurrentSkipListMap<>(); + private final ConcurrentLinkedQueue changes = new ConcurrentLinkedQueue<>(); + + ZoneContainer(ManagedZone zone) { + this.zone = zone; + this.dnsRecords.put(zone.getName(), ImmutableList.of()); + } + + ManagedZone zone() { + return zone; + } + + ConcurrentSkipListMap> dnsRecords() { + return dnsRecords; + } + + ConcurrentLinkedQueue changes() { + return changes; + } + + Change findChange(String changeId) { + for (Change current : changes) { + if (changeId.equals(current.getId())) { + return current; + } + } + return null; + } + } + + static class Response { + private final int code; + private final String body; + + Response(int code, String body) { + this.code = code; + this.body = body; + } + + int code() { + return code; + } + + String body() { + return body; + } + } + + private enum Error { + REQUIRED(400, "global", "required", "REQUIRED"), + INTERNAL_ERROR(500, "global", "internalError", "INTERNAL_ERROR"), + BAD_REQUEST(400, "global", "badRequest", "BAD_REQUEST"), + INVALID(400, "global", "invalid", "INVALID"), + NOT_AVAILABLE(400, "global", "managedZoneDnsNameNotAvailable", "NOT_AVAILABLE"), + NOT_FOUND(404, "global", "notFound", "NOT_FOUND"), + ALREADY_EXISTS(409, "global", "alreadyExists", "ALREADY_EXISTS"), + CONDITION_NOT_MET(412, "global", "conditionNotMet", "CONDITION_NOT_MET"), + INVALID_ZONE_APEX(400, "global", "invalidZoneApex", "INVALID_ZONE_APEX"); + + private final int code; + private final String domain; + private final String reason; + private final String status; + + Error(int code, String domain, String reason, String status) { + this.code = code; + this.domain = domain; + this.reason = reason; + this.status = status; + } + + Response response(String message) { + try { + return new Response(code, toJson(message)); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response("Error when generating JSON error response."); + } + } + + private String toJson(String message) throws IOException { + Map errors = new HashMap<>(); + errors.put("domain", domain); + errors.put("message", message); + errors.put("reason", reason); + Map args = new HashMap<>(); + args.put("errors", ImmutableList.of(errors)); + args.put("code", code); + args.put("message", message); + args.put("status", status); + return jsonFactory.toString(ImmutableMap.of("error", args)); + } + } + + private class RequestHandler implements HttpHandler { + + /** + * Chooses the proper handler for a request. + */ + private Response pickHandler(HttpExchange exchange, CallRegex regex) { + switch (regex) { + case CHANGE_GET: + return handleChangeGet(exchange); + case CHANGE_LIST: + return handleChangeList(exchange); + case ZONE_GET: + return handleZoneGet(exchange); + case ZONE_DELETE: + return handleZoneDelete(exchange); + case ZONE_LIST: + return handleZoneList(exchange); + case PROJECT_GET: + return handleProjectGet(exchange); + case RECORD_LIST: + return handleDnsRecordList(exchange); + case ZONE_CREATE: + try { + return handleZoneCreate(exchange); + } catch (IOException ex) { + return Error.BAD_REQUEST.response(ex.getMessage()); + } + case CHANGE_CREATE: + try { + return handleChangeCreate(exchange); + } catch (IOException ex) { + return Error.BAD_REQUEST.response(ex.getMessage()); + } + default: + return Error.INTERNAL_ERROR.response("Operation without a handler."); + } + } + + @Override + public void handle(HttpExchange exchange) throws IOException { + String requestMethod = exchange.getRequestMethod(); + String rawPath = exchange.getRequestURI().getRawPath(); + for (CallRegex regex : CallRegex.values()) { + if (requestMethod.equals(regex.method) && rawPath.matches(regex.pathRegex)) { + // there is a match, pass the handling accordingly + Response response = pickHandler(exchange, regex); + writeResponse(exchange, response); + return; // only one match is possible + } + } + // could not be matched, the service returns 404 page not found here + writeResponse(exchange, Error.NOT_FOUND.response("The url does not match any API call.")); + } + + // todo(mderka) Test handlers using gcloud-java-dns. Issue #665. + private Response handleZoneDelete(HttpExchange exchange) { + String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); + String[] tokens = path.split("/"); + String projectId = tokens[1]; + String zoneName = tokens[3]; + return deleteZone(projectId, zoneName); + } + + private Response handleZoneGet(HttpExchange exchange) { + String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); + String[] tokens = path.split("/"); + String projectId = tokens[1]; + String zoneName = tokens[3]; + String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); + String[] fields = OptionParsersAndExtractors.parseGetOptions(query); + return getZone(projectId, zoneName, fields); + } + + private Response handleZoneList(HttpExchange exchange) { + String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); + String[] tokens = path.split("/"); + String projectId = tokens[1]; + String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); + Map options = OptionParsersAndExtractors.parseListZonesOptions(query); + return listZones(projectId, options); + } + + private Response handleProjectGet(HttpExchange exchange) { + String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); + String[] tokens = path.split("/"); + String projectId = tokens[1]; + String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); + String[] fields = OptionParsersAndExtractors.parseGetOptions(query); + return getProject(projectId, fields); + } + + /** + * @throws IOException if the request cannot be parsed. + */ + private Response handleChangeCreate(HttpExchange exchange) throws IOException { + String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); + String[] tokens = path.split("/"); + String projectId = tokens[1]; + String zoneName = tokens[3]; + String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); + String[] fields = OptionParsersAndExtractors.parseGetOptions(query); + String requestBody = decodeContent(exchange.getRequestHeaders(), exchange.getRequestBody()); + Change change = jsonFactory.fromString(requestBody, Change.class); + return createChange(projectId, zoneName, change, fields); + } + + private Response handleChangeGet(HttpExchange exchange) { + String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); + String[] tokens = path.split("/"); + String projectId = tokens[1]; + String zoneName = tokens[3]; + String changeId = tokens[5]; + String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); + String[] fields = OptionParsersAndExtractors.parseGetOptions(query); + return getChange(projectId, zoneName, changeId, fields); + } + + private Response handleChangeList(HttpExchange exchange) { + String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); + String[] tokens = path.split("/"); + String projectId = tokens[1]; + String zoneName = tokens[3]; + String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); + Map options = OptionParsersAndExtractors.parseListChangesOptions(query); + return listChanges(projectId, zoneName, options); + } + + private Response handleDnsRecordList(HttpExchange exchange) { + String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); + String[] tokens = path.split("/"); + String projectId = tokens[1]; + String zoneName = tokens[3]; + String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); + Map options = OptionParsersAndExtractors.parseListDnsRecordsOptions(query); + return listDnsRecords(projectId, zoneName, options); + } + + /** + * @throws IOException if the request cannot be parsed. + */ + private Response handleZoneCreate(HttpExchange exchange) throws IOException { + String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); + String[] tokens = path.split("/"); + String projectId = tokens[1]; + String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); + String[] options = OptionParsersAndExtractors.parseGetOptions(query); + String requestBody = decodeContent(exchange.getRequestHeaders(), exchange.getRequestBody()); + ManagedZone zone; + try { + // IllegalArgumentException if the request body is an empty string + zone = jsonFactory.fromString(requestBody, ManagedZone.class); + } catch (IllegalArgumentException ex) { + return Error.REQUIRED.response( + "The 'entity.managedZone' parameter is required but was missing."); + } + return createZone(projectId, zone, options); + } + } + + private LocalDnsHelper(long delay) { + this.delayChange = delay; // 0 makes this synchronous + try { + server = HttpServer.create(new InetSocketAddress(0), 0); + port = server.getAddress().getPort(); + server.createContext(CONTEXT, new RequestHandler()); + } catch (IOException e) { + throw new RuntimeException("Could not bind the mock DNS server.", e); + } + } + + /** + * Accessor for testing purposes. + */ + ConcurrentSkipListMap projects() { + return projects; + } + + /** + * Creates new {@link LocalDnsHelper} instance that listens to requests on the local machine. This + * instance processes changes separate threads. The parameter determines how long a thread should + * wait before processing a change. If it is set to 0, the threading is turned off and the mock + * will behave synchronously. + * + * @param delay delay for processing changes in ms or 0 for synchronous processing + */ + public static LocalDnsHelper create(Long delay) { + return new LocalDnsHelper(delay); + } + + /** + * Returns a DnsOptions instance that sets the host to use the mock server. + */ + public DnsOptions options() { + return DnsOptions.builder().host("http://localhost:" + port).build(); + } + + /** + * Starts the thread that runs the local DNS server. + */ + public void start() { + server.start(); + } + + /** + * Stops the thread that runs the mock DNS server. + */ + public void stop() { + server.stop(1); + } + + private static void writeResponse(HttpExchange exchange, Response response) { + exchange.getResponseHeaders().set("Content-type", "application/json; charset=UTF-8"); + OutputStream outputStream = exchange.getResponseBody(); + try { + exchange.getResponseHeaders().add("Connection", "close"); + exchange.sendResponseHeaders(response.code(), response.body().length()); + outputStream.write(response.body().getBytes(StandardCharsets.UTF_8)); + outputStream.close(); + } catch (IOException e) { + log.log(Level.WARNING, "IOException encountered when sending response.", e); + } + } + + /** + * Decodes content of the HttpRequest. + */ + private static String decodeContent(Headers headers, InputStream inputStream) throws IOException { + List contentEncoding = headers.get("Content-encoding"); + InputStream input = inputStream; + try { + if (contentEncoding != null && !contentEncoding.isEmpty()) { + String encoding = contentEncoding.get(0); + if (SUPPORTED_COMPRESSION_ENCODINGS.contains(encoding)) { + input = new GZIPInputStream(inputStream); + } else if (!encoding.equals("identity")) { + throw new IOException( + "The request has the following unsupported HTTP content encoding: " + encoding); + } + } + return new String(ByteStreams.toByteArray(input), StandardCharsets.UTF_8); + } catch (IOException e) { + throw new IOException("Exception encountered when decoding request content.", e); + } + } + + /** + * Generates a JSON response. Tested. + */ + static Response toListResponse(List serializedObjects, String pageToken, + boolean includePageToken) { + // start building response + StringBuilder responseBody = new StringBuilder(); + responseBody.append("{\"projects\": ["); + Joiner.on(",").appendTo(responseBody, serializedObjects); + responseBody.append("]"); + // add page token only if exists and is asked for + if (pageToken != null && includePageToken) { + responseBody.append(",\"pageToken\": \"").append(pageToken).append("\""); + } + responseBody.append("}"); + return new Response(HTTP_OK, responseBody.toString()); + } + + /** + * Prepares DNS records that are created by default for each zone. + */ + private static ImmutableList defaultRecords(ManagedZone zone) { + ResourceRecordSet soa = new ResourceRecordSet(); + soa.setTtl(21600); + soa.setName(zone.getDnsName()); + soa.setRrdatas(ImmutableList.of( + // taken from the service + "ns-cloud-c1.googledomains.com. cloud-dns-hostmaster.google.com. 0 21600 3600 1209600 312" + )); + soa.setType("SOA"); + ResourceRecordSet ns = new ResourceRecordSet(); + ns.setTtl(21600); + ns.setName(zone.getDnsName()); + ns.setRrdatas(zone.getNameServers()); + ns.setType("NS"); + RrsetWrapper nsWrapper = new RrsetWrapper(ns); + RrsetWrapper soaWrapper = new RrsetWrapper(soa); + ImmutableList results = ImmutableList.of(nsWrapper, soaWrapper); + nsWrapper.setId(getUniqueId(results)); + soaWrapper.setId(getUniqueId(results)); + return results; + } + + /** + * Returns a list of four nameservers randomly chosen from the predefined set. + */ + static List randomNameservers() { + ArrayList nameservers = Lists.newArrayList( + "dns1.googlecloud.com", "dns2.googlecloud.com", "dns3.googlecloud.com", + "dns4.googlecloud.com", "dns5.googlecloud.com", "dns6.googlecloud.com" + ); + while (nameservers.size() != 4) { + int index = ID_GENERATOR.nextInt(nameservers.size()); + nameservers.remove(index); + } + return nameservers; + } + + /** + * Returns a hex string id (used for a dns record) unique withing the set of wrappers. + */ + static String getUniqueId(List wrappers) { + TreeSet ids = Sets.newTreeSet(Lists.transform(wrappers, + new Function() { + @Nullable + @Override + public String apply(@Nullable RrsetWrapper input) { + return input.id() == null ? "null" : input.id(); + } + })); + String id; + do { + id = Long.toHexString(System.currentTimeMillis()) + + Long.toHexString(Math.abs(ID_GENERATOR.nextLong())); + if (!ids.contains(id)) { + return id; + } + } while (ids.contains(id)); + return id; + } + + /** + * Tests if a DNS record matches name and type (if provided). Used for filtering. + */ + static boolean matchesCriteria(ResourceRecordSet record, String name, String type) { + if (type != null && !record.getType().equals(type)) { + return false; + } + if (name != null && !record.getName().equals(name)) { + return false; + } + return true; + } + + /** + * Returns a project container. Never returns null because we assume that all projects exists. + */ + ProjectContainer findProject(String projectId) { + ProjectContainer defaultProject = createProject(projectId); + projects.putIfAbsent(projectId, defaultProject); + return projects.get(projectId); + } + + /** + * Returns a zone container. Returns null if zone does not exist within project. + */ + ZoneContainer findZone(String projectId, String zoneName) { + ProjectContainer projectContainer = findProject(projectId); // never null + return projectContainer.zones().get(zoneName); + } + + /** + * Returns a change found by its id. Returns null if such a change does not exist. + */ + Change findChange(String projectId, String zoneName, String changeId) { + ZoneContainer wrapper = findZone(projectId, zoneName); + return wrapper == null ? null : wrapper.findChange(changeId); + } + + /** + * Returns a response to get change call. + */ + Response getChange(String projectId, String zoneName, String changeId, String[] fields) { + Change change = findChange(projectId, zoneName, changeId); + if (change == null) { + ZoneContainer zone = findZone(projectId, zoneName); + if (zone == null) { + // zone does not exist + return Error.NOT_FOUND.response(String.format( + "The 'parameters.managedZone' resource named '%s' does not exist.", zoneName)); + } + // zone exists but change does not + return Error.NOT_FOUND.response(String.format( + "The 'parameters.changeId' resource named '%s' does not exist.", changeId)); + } + Change result = OptionParsersAndExtractors.extractFields(change, fields); + try { + return new Response(HTTP_OK, jsonFactory.toString(result)); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response(String.format( + "Error when serializing change %s in managed zone %s in project %s.", + changeId, zoneName, projectId)); + } + // todo(mderka) Test field options within #665. + } + + /** + * Returns a response to get zone call. + */ + Response getZone(String projectId, String zoneName, String[] fields) { + ZoneContainer container = findZone(projectId, zoneName); + if (container == null) { + return Error.NOT_FOUND.response(String.format( + "The 'parameters.managedZone' resource named '%s' does not exist.", zoneName)); + } + ManagedZone result = OptionParsersAndExtractors.extractFields(container.zone(), fields); + try { + return new Response(HTTP_OK, jsonFactory.toString(result)); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response(String.format( + "Error when serializing managed zone %s in project %s.", zoneName, projectId)); + } + // todo(mderka) Test field options within #665. + } + + /** + * We assume that every project exists. If we do not have it in the collection yet, we just create + * a new default project instance with default quota. + */ + Response getProject(String projectId, String[] fields) { + ProjectContainer defaultProject = createProject(projectId); + projects.putIfAbsent(projectId, defaultProject); + Project project = projects.get(projectId).project(); // project is now guaranteed to exist + Project result = OptionParsersAndExtractors.extractFields(project, fields); + try { + return new Response(HTTP_OK, jsonFactory.toString(result)); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response( + String.format("Error when serializing project %s.", projectId)); + } + // todo(mderka) Test field options within #665. + } + + /** + * Creates a project. It generates a project number randomly (we do not have project numbers + * available). + */ + private ProjectContainer createProject(String projectId) { + Quota quota = new Quota(); + quota.setManagedZones(10000); + quota.setRrsetsPerManagedZone(10000); + quota.setRrsetAdditionsPerChange(100); + quota.setRrsetDeletionsPerChange(100); + quota.setTotalRrdataSizePerChange(10000); + quota.setResourceRecordsPerRrset(100); + Project project = new Project(); + project.setId(projectId); + project.setNumber(new BigInteger(String.valueOf( + Math.abs(ID_GENERATOR.nextLong() % Long.MAX_VALUE)))); + project.setQuota(quota); + return new ProjectContainer(project); + } + + /** + * Deletes a zone. + */ + Response deleteZone(String projectId, String zoneName) { + ProjectContainer projectContainer = projects.get(projectId); + ZoneContainer previous = projectContainer.zones.remove(zoneName); + return previous == null + // map was not in the collection + ? Error.NOT_FOUND.response(String.format( + "The 'parameters.managedZone' resource named '%s' does not exist.", zoneName)) + : new Response(HTTP_NO_CONTENT, "{}"); + } + + /** + * Creates new managed zone and stores it in the collection. Assumes that project exists. + */ + Response createZone(String projectId, ManagedZone zone, String[] fields) { + checkNotNull(zone, "Zone to create cannot be null"); + // check if the provided data is valid + Response errorResponse = checkZone(zone); + if (errorResponse != null) { + return errorResponse; + } + // create a copy of the managed zone in order to avoid side effects + ManagedZone completeZone = new ManagedZone(); + completeZone.setName(zone.getName()); + completeZone.setDnsName(zone.getDnsName()); + completeZone.setNameServerSet(zone.getNameServerSet()); + completeZone.setCreationTime(ISODateTimeFormat.dateTime().withZoneUTC() + .print(System.currentTimeMillis())); + completeZone.setId( + new BigInteger(String.valueOf(Math.abs(ID_GENERATOR.nextLong() % Long.MAX_VALUE)))); + completeZone.setNameServers(randomNameservers()); + ZoneContainer zoneContainer = new ZoneContainer(completeZone); + // create the default NS and SOA records + zoneContainer.dnsRecords().put(zone.getName(), defaultRecords(completeZone)); + // place the zone in the data collection + ProjectContainer projectContainer = findProject(projectId); + ZoneContainer oldValue = projectContainer.zones().putIfAbsent( + completeZone.getName(), zoneContainer); + if (oldValue != null) { + return Error.ALREADY_EXISTS.response(String.format( + "The resource 'entity.managedZone' named '%s' already exists", completeZone.getName())); + } + // now return the desired attributes + ManagedZone result = OptionParsersAndExtractors.extractFields(completeZone, fields); + try { + return new Response(HTTP_OK, jsonFactory.toString(result)); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response( + String.format("Error when serializing managed zone %s.", result.getName())); + } + // todo(mderka) Test field options within #665. + } + + /** + * Creates a new change, stores it, and invokes processing in a new thread. + */ + Response createChange(String projectId, String zoneName, Change change, String[] fields) { + ZoneContainer zoneContainer = findZone(projectId, zoneName); + if (zoneContainer == null) { + return Error.NOT_FOUND.response(String.format( + "The 'parameters.managedZone' resource named %s does not exist.", zoneName)); + } + // check that the change to be applied is valid + Response response = checkChange(change, zoneContainer); + if (response != null) { + return response; + } + // start applying + Change completeChange = new Change(); // copy to avoid side effects + if (change.getAdditions() != null) { + completeChange.setAdditions(ImmutableList.copyOf(change.getAdditions())); + } + if (change.getDeletions() != null) { + completeChange.setDeletions(ImmutableList.copyOf(change.getDeletions())); + } + /* we need to get the proper ID in concurrent environment + the element fell on an index between 0 and maxId + we will reset all IDs in this range (all of them are valid) */ + ConcurrentLinkedQueue changeSequence = zoneContainer.changes(); + changeSequence.add(completeChange); + int maxId = changeSequence.size(); + int index = 0; + for (Change c : changeSequence) { + if (index == maxId) { + break; + } + c.setId(String.valueOf(++index)); // indexing from 1 + } + completeChange.setStatus("pending"); // not finished yet + completeChange.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC() + .print(System.currentTimeMillis())); // accepted + invokeChange(projectId, zoneName, completeChange.getId()); + Change result = OptionParsersAndExtractors.extractFields(completeChange, fields); + try { + return new Response(HTTP_OK, jsonFactory.toString(result)); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response( + String.format("Error when serializing change %s in managed zone %s in project %s.", + result.getId(), zoneName, projectId)); + } + // todo(mderka) Test field options within #665. + } + + /** + * Applies change. Uses a new thread which applies the change only if DELAY_CHANGE is > 0. + */ + private Thread invokeChange(final String projectId, final String zoneName, + final String changeId) { + if (delayChange > 0) { + Thread thread = new Thread() { + @Override + public void run() { + try { + Thread.sleep(delayChange); // simulate delayed execution + } catch (InterruptedException ex) { + log.log(Level.WARNING, "Thread was interrupted while sleeping.", ex); + } + // start applying the changes + applyExistingChange(projectId, zoneName, changeId); + } + }; + thread.start(); + return thread; + } else { + applyExistingChange(projectId, zoneName, changeId); + return null; + } + } + + /** + * Applies changes to a zone. Repeatedly tries until succeeds. Thread safe and deadlock safe. + */ + private void applyExistingChange(String projectId, String zoneName, String changeId) { + Change change = findChange(projectId, zoneName, changeId); + if (change == null) { + return; // no such change exists, nothing to do + } + ZoneContainer wrapper = findZone(projectId, zoneName); + ConcurrentSkipListMap> dnsRecords = wrapper.dnsRecords(); + while (true) { + // managed zone must have a set of records which is not null + ImmutableList original = dnsRecords.get(zoneName); + assert original != null; + List copy = Lists.newLinkedList(original); + // apply deletions first + List deletions = change.getDeletions(); + if (deletions != null) { + List transformedDeletions = Lists.transform(deletions, + RrsetWrapper.WRAP_FUNCTION); + copy.removeAll(transformedDeletions); + } + // apply additions + List additions = change.getAdditions(); + if (additions != null) { + for (ResourceRecordSet addition : additions) { + String id = getUniqueId(copy); + RrsetWrapper rrsetWrapper = new RrsetWrapper(addition); + rrsetWrapper.setId(id); + copy.add(rrsetWrapper); + } + } + // make it immutable and replace + boolean success = dnsRecords.replace(zoneName, original, ImmutableList.copyOf(copy)); + if (success) { + break; // success if no other thread modified the value in the meantime + } + } + // set status to done + change.setStatus("done"); + } + + /** + * Lists zones. Next page token is the last listed zone name and is returned only of there is more + * to list. + */ + Response listZones(String projectId, Map options) { + Response response = checkListOptions(options); + if (response != null) { + return response; + } + ConcurrentSkipListMap containers = findProject(projectId).zones(); + String[] fields = (String[]) options.get("fields"); + String dnsName = (String) options.get("dnsName"); + String pageToken = (String) options.get("pageToken"); + Integer maxResults = options.get("maxResults") == null + ? null : Integer.valueOf((String) options.get("maxResults")); + // matches will be included in the result if true + boolean listing = (pageToken == null || !containers.containsKey(pageToken)); + boolean sizeReached = false; // maximum result size was reached, we should not return more + boolean hasMorePages = false; // should next page token be included in the response? + LinkedList serializedZones = new LinkedList<>(); + String lastZoneName = null; + for (ZoneContainer zoneContainer : containers.values()) { + ManagedZone zone = zoneContainer.zone(); + if (listing) { + if (dnsName == null || zone.getDnsName().equals(dnsName)) { + lastZoneName = zone.getName(); + if (sizeReached) { + // we do not add this, just note that there would be more and there should be a token + hasMorePages = true; + break; + } else { + try { + serializedZones.addLast(jsonFactory.toString( + OptionParsersAndExtractors.extractFields(zone, fields))); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response(String.format( + "Error when serializing managed zone %s in project %s", zone.getName(), + projectId)); + } + } + } + } + // either we are listing already, or we check if we should start in the next iteration + listing = zone.getName().equals(pageToken) || listing; + sizeReached = (maxResults != null) && maxResults.equals(serializedZones.size()); + } + boolean includePageToken = + hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("pageToken")); + return toListResponse(serializedZones, lastZoneName, includePageToken); + // todo(mderka) Test field and listing options within #665. + } + + /** + * Lists DNS records for a zone. Next page token is ID of the last record listed. + */ + Response listDnsRecords(String projectId, String zoneName, Map options) { + Response response = checkListOptions(options); + if (response != null) { + return response; + } + ZoneContainer zoneContainer = findZone(projectId, zoneName); + if (zoneContainer == null) { + return Error.NOT_FOUND.response(String.format( + "The 'parameters.managedZone' resource named '%s' does not exist.", zoneName)); + } + List dnsRecords = zoneContainer.dnsRecords().get(zoneName); + String[] fields = (String[]) options.get("fields"); + String name = (String) options.get("name"); + String type = (String) options.get("type"); + String pageToken = (String) options.get("pageToken"); + Integer maxResults = options.get("maxResults") == null + ? null : Integer.valueOf((String) options.get("maxResults")); + boolean listing = (pageToken == null); // matches will be included in the result if true + boolean sizeReached = false; // maximum result size was reached, we should not return more + boolean hasMorePages = false; // should next page token be included in the response? + LinkedList serializedRrsets = new LinkedList<>(); + String lastRecordId = null; + for (RrsetWrapper recordWrapper : dnsRecords) { + ResourceRecordSet record = recordWrapper.rrset(); + if (listing) { + if (matchesCriteria(record, name, type)) { + lastRecordId = recordWrapper.id(); + if (sizeReached) { + // we do not add this, just note that there would be more and there should be a token + hasMorePages = true; + break; + } else { + try { + serializedRrsets.addLast(jsonFactory.toString( + OptionParsersAndExtractors.extractFields(record, fields))); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response(String.format( + "Error when serializing resource record set in managed zone %s in project %s", + zoneName, projectId)); + } + } + } + } + // either we are listing already, or we check if we should start in the next iteration + listing = recordWrapper.id().equals(pageToken) || listing; + sizeReached = (maxResults != null) && maxResults.equals(serializedRrsets.size()); + } + boolean includePageToken = + hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("pageToken")); + return toListResponse(serializedRrsets, lastRecordId, includePageToken); + // todo(mderka) Test field and listing options within #665. + } + + /** + * Lists changes. Next page token is ID of the last change listed. + */ + Response listChanges(String projectId, String zoneName, Map options) { + Response response = checkListOptions(options); + if (response != null) { + return response; + } + ZoneContainer zoneContainer = findZone(projectId, zoneName); + // take a sorted snapshot of the current change list + TreeMap changes = new TreeMap<>(); + for (Change c : zoneContainer.changes()) { + if (c.getId() != null) { + changes.put(Integer.valueOf(c.getId()), c); + } + } + String[] fields = (String[]) options.get("fields"); + String sortOrder = (String) options.get("sortOrder"); + String pageToken = (String) options.get("pageToken"); + Integer maxResults = options.get("maxResults") == null + ? null : Integer.valueOf((String) options.get("maxResults")); + // we are not reading sort by as it the only key is the change sequence + NavigableSet keys; + if ("descending".equals(sortOrder)) { + keys = changes.descendingKeySet(); + } else { + keys = changes.navigableKeySet(); + } + boolean listing = (pageToken == null); // matches will be included in the result if true + boolean sizeReached = false; // maximum result size was reached, we should not return more + boolean hasMorePages = false; // should next page token be included in the response? + LinkedList serializedResults = new LinkedList<>(); + String lastChangeId = null; + for (Integer key : keys) { + Change change = changes.get(key); + if (listing) { + lastChangeId = change.getId(); + if (sizeReached) { + // we do not add this, just note that there would be more and there should be a token + hasMorePages = true; + break; + } else { + try { + serializedResults.addLast(jsonFactory.toString( + OptionParsersAndExtractors.extractFields(change, fields))); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response(String.format( + "Error when serializing change %s in managed zone %s in project %s", + change.getId(), zoneName, projectId)); + } + } + } + + // either we are listing already, or we check if we should start in the next iteration + listing = change.getId().equals(pageToken) || listing; + sizeReached = (maxResults != null) && maxResults.equals(serializedResults.size()); + } + boolean includePageToken = + hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("pageToken")); + return toListResponse(serializedResults, lastChangeId, includePageToken); + // todo(mderka) Test field and listing options within #665. + } + + /** + * Validates a zone to be created. + */ + static Response checkZone(ManagedZone zone) { + if (zone.getName() == null) { + return Error.REQUIRED.response( + "The 'entity.managedZone.name' parameter is required but was missing."); + } + if (zone.getDnsName() == null) { + return Error.REQUIRED.response( + "The 'entity.managedZone.dnsName' parameter is required but was missing."); + } + if (zone.getDescription() == null) { + return Error.REQUIRED.response( + "The 'entity.managedZone.description' parameter is required but was missing."); + } + try { + int number = Integer.valueOf(zone.getName()); + return Error.INVALID.response( + String.format("Invalid value for 'entity.managedZone.name': '%s'", number)); + } catch (NumberFormatException ex) { + // expected + } + if (zone.getName().isEmpty()) { + return Error.INVALID.response( + String.format("Invalid value for 'entity.managedZone.name': '%s'", zone.getName())); + } + if (zone.getDnsName().isEmpty() || !zone.getDnsName().endsWith(".")) { + return Error.INVALID.response( + String.format("Invalid value for 'entity.managedZone.dnsName': '%s'", zone.getDnsName())); + } + TreeSet forbidden = Sets.newTreeSet( + ImmutableList.of("google.com.", "com.", "example.com.", "net.", "org.")); + if (forbidden.contains(zone.getDnsName())) { + return Error.NOT_AVAILABLE.response(String.format( + "The '%s' managed zone is not available to be created.", zone.getDnsName())); + } + return null; + } + + /** + * Validates a change to be created. + */ + static Response checkChange(Change change, ZoneContainer zone) { + checkNotNull(zone); + if ((change.getDeletions() != null && change.getDeletions().size() > 0) + || (change.getAdditions() != null && change.getAdditions().size() > 0)) { + // ok, this is what we want + } else { + return Error.REQUIRED.response("The 'entity.change' parameter is required but was missing."); + } + if (change.getAdditions() != null) { + int counter = 0; + for (ResourceRecordSet addition : change.getAdditions()) { + Response response = checkRrset(addition, zone, counter, "additions"); + if (response != null) { + return response; + } + counter++; + } + } + if (change.getDeletions() != null) { + int counter = 0; + for (ResourceRecordSet deletion : change.getDeletions()) { + Response response = checkRrset(deletion, zone, counter, "deletions"); + if (response != null) { + return response; + } + counter++; + } + } + return additionsMeetDeletions(change.getAdditions(), change.getDeletions(), zone); + // null if everything is ok + } + + /** + * Checks a rrset within a change. + * + * @param type [additions|deletions] + * @param index the index or addition or deletion in the list + * @param zone the zone that this change is applied to + */ + static Response checkRrset(ResourceRecordSet rrset, ZoneContainer zone, int index, String type) { + if (rrset.getName() == null || !rrset.getName().endsWith(zone.zone().getDnsName())) { + return Error.INVALID.response(String.format( + "Invalid value for 'entity.change.%s[%s].name': '%s'", type, index, rrset.getName())); + } + if (rrset.getType() == null || !TYPES.contains(rrset.getType())) { + return Error.INVALID.response(String.format( + "Invalid value for 'entity.change.%s[%s].type': '%s'", type, index, rrset.getType())); + } + if (rrset.getTtl() != null && rrset.getTtl() != 0 && rrset.getTtl() < 0) { + return Error.INVALID.response(String.format( + "Invalid value for 'entity.change.%s[%s].ttl': '%s'", type, index, rrset.getTtl())); + } + if (rrset.getRrdatas() == null || rrset.isEmpty()) { + return Error.INVALID.response(String.format( + "Invalid value for 'entity.change.%s[%s].rrdata': '%s'", type, index, "")); + } + int counter = 0; + for (String record : rrset.getRrdatas()) { + if (!checkRrData(record, rrset.getType())) { + return Error.INVALID.response(String.format( + "Invalid value for 'entity.change.%s[%s].rrdata[%s]': '%s'", + type, index, counter, record)); + } + counter++; + } + if ("deletions".equals(type)) { + // check that deletion has a match by name and type + boolean found = false; + for (RrsetWrapper rrsetWrapper : zone.dnsRecords().get(zone.zone().getName())) { + ResourceRecordSet wrappedRrset = rrsetWrapper.rrset(); + if (rrset.getName().equals(wrappedRrset.getName()) + && rrset.getType().equals(wrappedRrset.getType())) { + found = true; + break; + } + } + if (!found) { + return Error.NOT_FOUND.response(String.format( + "The 'entity.change.deletions[%s]' resource named '%s (%s)' does not exist.", + index, rrset.getName(), rrset.getType())); + } + // if found, we still need an exact match + if ("deletions".equals(type) + && !zone.dnsRecords().get(zone.zone().getName()).contains(new RrsetWrapper(rrset))) { + // such a record does not exist + return Error.CONDITION_NOT_MET.response(String.format( + "Precondition not met for 'entity.change.deletions[%s]", index)); + } + } + return null; + } + + /** + * Checks that for each record that already exists, we have a matching deletion. Furthermore, + * check that mandatory SOA and NS records stay. + */ + static Response additionsMeetDeletions(List additions, + List deletions, ZoneContainer zone) { + if (additions != null) { + int index = 0; + for (ResourceRecordSet rrset : additions) { + for (RrsetWrapper wrapper : zone.dnsRecords().get(zone.zone().getName())) { + ResourceRecordSet wrappedRrset = wrapper.rrset(); + if (rrset.getName().equals(wrappedRrset.getName()) + && rrset.getType().equals(wrappedRrset.getType())) { + // such a record exist and we must have a deletion + if (deletions == null || !deletions.contains(wrappedRrset)) { + return Error.ALREADY_EXISTS.response(String.format( + "The 'entity.change.additions[%s]' resource named '%s (%s)' already exists.", + index, rrset.getName(), rrset.getType())); + } + } + } + if (rrset.getType().equals("SOA") && findByNameAndType(deletions, null, "SOA") == null) { + return Error.INVALID_ZONE_APEX.response(String.format("The resource record set 'entity" + + ".change.additions[%s]' is invalid because a zone must contain exactly one resource" + + " record set of type 'SOA' at the apex.", index)); + } + if (rrset.getType().equals("NS") && findByNameAndType(deletions, null, "NS") == null) { + return Error.INVALID_ZONE_APEX.response(String.format("The resource record set 'entity" + + ".change.additions[%s]' is invalid because a zone must contain exactly one resource" + + " record set of type 'NS' at the apex.", index)); + } + index++; + } + } + if (deletions != null) { + int index = 0; + for (ResourceRecordSet rrset : deletions) { + if (rrset.getType().equals("SOA") && findByNameAndType(additions, null, "SOA") == null) { + return Error.INVALID_ZONE_APEX.response(String.format("The resource record set 'entity" + + ".change.deletions[%s]' is invalid because a zone must contain exactly one resource" + + " record set of type 'SOA' at the apex.", index)); + } + if (rrset.getType().equals("NS") && findByNameAndType(additions, null, "NS") == null) { + return Error.INVALID_ZONE_APEX.response(String.format("The resource record set 'entity" + + ".change.deletions[%s]' is invalid because a zone must contain exactly one resource" + + " record set of type 'NS' at the apex.", index)); + } + index++; + } + } + return null; + } + + /** + * Helper for searching rrsets in a collection. + */ + private static ResourceRecordSet findByNameAndType(Iterable records, + String name, String type) { + if (records != null) { + for (ResourceRecordSet rrset : records) { + if ((name == null || name.equals(rrset.getName())) + && (type == null || type.equals(rrset.getType()))) { + return rrset; + } + } + } + return null; + } + + /** + * We only provide the most basic validation for A and AAAA records. + */ + static boolean checkRrData(String data, String type) { + // todo add validation for other records + String[] tokens; + switch (type) { + case "A": + tokens = data.split("\\."); + if (tokens.length != 4) { + return false; + } + for (String token : tokens) { + try { + Integer number = Integer.valueOf(token); + if (number < 0 || number > 255) { + return false; + } + } catch (NumberFormatException ex) { + return false; + } + } + return true; + case "AAAA": + tokens = data.split(":", -1); + if (tokens.length != 8) { + return false; + } + for (String token : tokens) { + try { + if (!token.isEmpty()) { + // empty is ok + Long number = Long.parseLong(token, 16); + if (number < 0 || number > 0xFFFF) { + return false; + } + } + } catch (NumberFormatException ex) { + return false; + } + } + return true; + default: + return true; + } + } + + /** + * Check supplied listing options. + */ + static Response checkListOptions(Map options) { + // for general listing + String maxResultsString = (String) options.get("maxResults"); + if (maxResultsString != null) { + Integer maxResults = null; + try { + maxResults = Integer.valueOf(maxResultsString); + } catch (NumberFormatException ex) { + return Error.INVALID.response(String.format( + "Invalid integer value': '%s'.", maxResultsString)); + } + if (maxResults <= 0) { + return Error.INVALID.response(String.format( + "Invalid value for 'parameters.maxResults': '%s'", maxResults)); + } + } + String dnsName = (String) options.get("dnsName"); + if (dnsName != null) { + if (!dnsName.endsWith(".")) { + return Error.INVALID.response(String.format( + "Invalid value for 'parameters.dnsName': '%s'", dnsName)); + } + } + // for listing dns records, name must be fully qualified + String name = (String) options.get("name"); + if (name != null) { + if (!name.endsWith(".")) { + return Error.INVALID.response(String.format( + "Invalid value for 'parameters.name': '%s'", name)); + } + } + String type = (String) options.get("type"); // must be provided with name + if (type != null) { + if (name == null) { + return Error.INVALID.response("Invalid value for 'parameters.name': ''"); + } + if (!TYPES.contains(type)) { + return Error.INVALID.response(String.format( + "Invalid value for 'parameters.type': '%s'", type)); + } + } + // for listing changes + String order = (String) options.get("sortOrder"); + if (order != null && !"ascending".equals(order) && !"descending".equals(order)) { + return Error.INVALID.response(String.format( + "Invalid value for 'parameters.sortOrder': '%s'", order)); + } + String sortBy = (String) options.get("sortBy"); // case insensitive + if (sortBy != null && !"changesequence".equals(sortBy.toLowerCase())) { + return Error.INVALID.response(String.format( + "Invalid string value: '%s'. Allowed values: [changesequence]", sortBy)); + } + return null; + } +} diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java b/gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java new file mode 100644 index 000000000000..f94cb15779ca --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java @@ -0,0 +1,279 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.testing; + +import com.google.api.services.dns.model.Change; +import com.google.api.services.dns.model.ManagedZone; +import com.google.api.services.dns.model.Project; +import com.google.api.services.dns.model.ResourceRecordSet; + +import java.util.HashMap; +import java.util.Map; + +/** + * Utility helpers for LocalDnsHelper. + */ +class OptionParsersAndExtractors { + + /** + * Makes a map of list options. Expects query to be only query part of the url (i.e., what follows + * the '?'). + */ + static Map parseListZonesOptions(String query) { + Map options = new HashMap<>(); + if (query != null) { + String[] args = query.split("&"); + for (String arg : args) { + String[] argEntry = arg.split("="); + switch (argEntry[0]) { + case "fields": + // List fields are in the form "managedZones(field1, field2, ...)" + options.put( + "fields", + argEntry[1].substring("managedZones(".length(), argEntry[1].length() - 1) + .split(",")); + break; + case "dnsName": + options.put("dnsName", argEntry[1]); + break; + case "pageToken": + options.put("pageToken", argEntry[1]); + break; + case "maxResults": + // parsing to int is done while handling + options.put("maxResults", argEntry[1]); + break; + default: + break; + } + } + } + return options; + } + + /** + * Makes a map of list options. Expects query to be only query part of the url (i.e., what follows + * the '?'). This format is common for all of zone, change and project. + */ + static String[] parseGetOptions(String query) { + if (query != null) { + String[] args = query.split("&"); + for (String arg : args) { + String[] argEntry = arg.split("="); + if (argEntry[0].equals("fields")) { + // List fields are in the form "fields=field1, field2,..." + return argEntry[1].split(","); + } + } + } + return null; + } + + /** + * Extracts only request fields. + */ + static ManagedZone extractFields(ManagedZone fullZone, String[] fields) { + if (fields == null) { + return fullZone; + } + ManagedZone managedZone = new ManagedZone(); + for (String field : fields) { + switch (field) { + case "creationTime": + managedZone.setCreationTime(fullZone.getCreationTime()); + break; + case "description": + managedZone.setDescription(fullZone.getDescription()); + break; + case "dnsName": + managedZone.setDnsName(fullZone.getDnsName()); + break; + case "id": + managedZone.setId(fullZone.getId()); + break; + case "name": + managedZone.setName(fullZone.getName()); + break; + case "nameServerSet": + managedZone.setNameServerSet(fullZone.getNameServerSet()); + break; + case "nameServers": + managedZone.setNameServers(fullZone.getNameServers()); + break; + default: + break; + } + } + return managedZone; + } + + /** + * Extracts only request fields. + */ + static Change extractFields(Change fullChange, String[] fields) { + if (fields == null) { + return fullChange; + } + Change change = new Change(); + for (String field : fields) { + switch (field) { + case "additions": + // todo the fragmentation is ignored here as our api does not support it + change.setAdditions(fullChange.getAdditions()); + break; + case "deletions": + // todo the fragmentation is ignored here as our api does not support it + change.setDeletions(fullChange.getDeletions()); + break; + case "id": + change.setId(fullChange.getId()); + break; + case "startTime": + change.setStartTime(fullChange.getStartTime()); + break; + case "status": + change.setStatus(fullChange.getStatus()); + break; + default: + break; + } + } + return change; + } + + /** + * Extracts only request fields. + */ + static Project extractFields(Project fullProject, String[] fields) { + if (fields == null) { + return fullProject; + } + Project project = new Project(); + for (String field : fields) { + switch (field) { + case "id": + project.setId(fullProject.getId()); + break; + case "number": + project.setNumber(fullProject.getNumber()); + break; + case "quota": + project.setQuota(fullProject.getQuota()); + break; + default: + break; + } + } + return project; + } + + /** + * Extracts only request fields. + */ + static ResourceRecordSet extractFields(ResourceRecordSet fullRecord, String[] fields) { + if (fields == null) { + return fullRecord; + } + ResourceRecordSet record = new ResourceRecordSet(); + for (String field : fields) { + switch (field) { + case "name": + record.setName(fullRecord.getName()); + break; + case "rrdatas": + record.setRrdatas(fullRecord.getRrdatas()); + break; + case "type": + record.setType(fullRecord.getType()); + break; + case "ttl": + record.setTtl(fullRecord.getTtl()); + break; + default: + break; + } + } + return record; + } + + static Map parseListChangesOptions(String query) { + Map options = new HashMap<>(); + if (query != null) { + String[] args = query.split("&"); + for (String arg : args) { + String[] argEntry = arg.split("="); + switch (argEntry[0]) { + case "fields": + // todo we do not support fragmentation in deletions and additions + options.put( + "fields", + argEntry[1].substring("changes(".length(), argEntry[1].length() - 1).split(",")); + break; + case "name": + options.put("name", argEntry[1]); + break; + case "pageToken": + options.put("pageToken", argEntry[1]); + break; + case "sortBy": + options.put("sortBy", argEntry[1]); + break; + case "sortOrder": + options.put("sortOrder", argEntry[1]); + break; + case "maxResults": + // parsing to int is done while handling + options.put("maxResults", argEntry[1]); + break; + default: + break; + } + } + } + return options; + } + + static Map parseListDnsRecordsOptions(String query) { + Map options = new HashMap<>(); + if (query != null) { + String[] args = query.split("&"); + for (String arg : args) { + String[] argEntry = arg.split("="); + switch (argEntry[0]) { + case "fields": + options.put( + "fields", + argEntry[1].substring("rrsets(".length(), argEntry[1].length() - 1).split(",")); + break; + case "name": + options.put("name", argEntry[1]); + break; + case "pageToken": + options.put("pageToken", argEntry[1]); + break; + case "maxResults": + // parsing to int is done while handling + options.put("maxResults", argEntry[1]); + break; + default: + break; + } + } + } + return options; + } +} diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/testing/LocalDnsHelperTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/testing/LocalDnsHelperTest.java new file mode 100644 index 000000000000..1f851045659c --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/testing/LocalDnsHelperTest.java @@ -0,0 +1,955 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.testing; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.api.services.dns.model.Change; +import com.google.api.services.dns.model.ManagedZone; +import com.google.api.services.dns.model.ResourceRecordSet; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +public class LocalDnsHelperTest { + + private static final String RRSET_TYPE = "A"; + private static final ResourceRecordSet RRSET1 = new ResourceRecordSet(); + private static final ResourceRecordSet RRSET2 = new ResourceRecordSet(); + private static final ResourceRecordSet RRSET_KEEP = new ResourceRecordSet(); + private static final String PROJECT_ID1 = "2135436541254"; + private static final String PROJECT_ID2 = "882248761325"; + private static final String ZONE_NAME1 = "my little zone"; + private static final String ZONE_NAME2 = "another zone name"; + private static final ManagedZone ZONE1 = new ManagedZone(); + private static final ManagedZone ZONE2 = new ManagedZone(); + private static final String DNS_NAME = "www.example.com."; + private static final Change CHANGE1 = new Change(); + private static final Change CHANGE2 = new Change(); + private static final Change CHANGE_KEEP = new Change(); + private Map optionsMap; + private LocalDnsHelper localDns; + private ManagedZone minimalZone = new ManagedZone(); // to be adjusted as needed + + @BeforeClass + public static void before() { + RRSET1.setName(DNS_NAME); + RRSET1.setType(RRSET_TYPE); + RRSET1.setRrdatas(ImmutableList.of("1.1.1.1")); + ZONE1.setName(ZONE_NAME1); + ZONE1.setDescription(""); + ZONE1.setDnsName(DNS_NAME); + ZONE2.setName(ZONE_NAME2); + ZONE2.setDescription(""); + ZONE2.setDnsName(DNS_NAME); + RRSET2.setName(DNS_NAME); + RRSET2.setType(RRSET_TYPE); + RRSET_KEEP.setName(DNS_NAME); + RRSET_KEEP.setType("MX"); + RRSET_KEEP.setRrdatas(ImmutableList.of("255.255.255.254")); + RRSET2.setRrdatas(ImmutableList.of("123.132.153.156")); + CHANGE1.setAdditions(ImmutableList.of(RRSET1, RRSET2)); + CHANGE2.setDeletions(ImmutableList.of(RRSET2)); + CHANGE_KEEP.setAdditions(ImmutableList.of(RRSET_KEEP)); + } + + @Before + public void setUp() { + localDns = LocalDnsHelper.create(0L); // synchronous + optionsMap = new HashMap<>(); + minimalZone = copyZone(ZONE1); + } + + @After + public void after() { + localDns = null; + } + + @Test + public void testMatchesCriteria() { + assertTrue(LocalDnsHelper.matchesCriteria(RRSET1, RRSET1.getName(), RRSET1.getType())); + assertFalse(LocalDnsHelper.matchesCriteria(RRSET1, RRSET1.getName(), "anothertype")); + assertTrue(LocalDnsHelper.matchesCriteria(RRSET1, null, RRSET1.getType())); + assertTrue(LocalDnsHelper.matchesCriteria(RRSET1, RRSET1.getName(), null)); + assertFalse(LocalDnsHelper.matchesCriteria(RRSET1, "anothername", RRSET1.getType())); + } + + @Test + public void testGetUniqueId() { + assertNotNull(LocalDnsHelper.getUniqueId(Lists.newLinkedList())); + } + + @Test + public void testFindProject() { + assertEquals(0, localDns.projects().size()); + LocalDnsHelper.ProjectContainer project = localDns.findProject(PROJECT_ID1); + assertNotNull(project); + assertTrue(localDns.projects().containsKey(PROJECT_ID1)); + assertNotNull(localDns.findProject(PROJECT_ID2)); + assertTrue(localDns.projects().containsKey(PROJECT_ID2)); + assertTrue(localDns.projects().containsKey(PROJECT_ID1)); + assertNotNull(project.zones()); + assertEquals(0, project.zones().size()); + assertNotNull(project.project()); + assertNotNull(project.project().getQuota()); + } + + @Test + public void testCreateAndFindZone() { + LocalDnsHelper.ZoneContainer zone1 = localDns.findZone(PROJECT_ID1, ZONE_NAME1); + assertTrue(localDns.projects().containsKey(PROJECT_ID1)); + assertNull(zone1); + localDns.createZone(PROJECT_ID1, ZONE1, null); // we do not care about options + zone1 = localDns.findZone(PROJECT_ID1, ZONE1.getName()); + assertNotNull(zone1); + // cannot call equals because id and timestamp got assigned + assertEquals(ZONE_NAME1, zone1.zone().getName()); + assertNotNull(zone1.changes()); + assertTrue(zone1.changes().isEmpty()); + assertNotNull(zone1.dnsRecords()); + assertEquals(2, zone1.dnsRecords().get(ZONE_NAME1).size()); // default SOA and NS + localDns.createZone(PROJECT_ID2, ZONE1, null); // project does not exits yet + assertEquals(ZONE1.getName(), localDns.findZone(PROJECT_ID2, ZONE_NAME1).zone().getName()); + } + + @Test + public void testDeleteZone() { + localDns.createZone(PROJECT_ID1, ZONE1, null); + LocalDnsHelper.Response response = localDns.deleteZone(PROJECT_ID1, ZONE1.getName()); + assertEquals(204, response.code()); + // deleting non-existent zone + response = localDns.deleteZone(PROJECT_ID1, ZONE1.getName()); + assertEquals(404, response.code()); + assertNull(localDns.findZone(PROJECT_ID1, ZONE1.getName())); + localDns.createZone(PROJECT_ID1, ZONE1, null); + localDns.createZone(PROJECT_ID1, ZONE2, null); + assertNotNull(localDns.findZone(PROJECT_ID1, ZONE1.getName())); + assertNotNull(localDns.findZone(PROJECT_ID1, ZONE2.getName())); + // delete in reverse order + response = localDns.deleteZone(PROJECT_ID1, ZONE1.getName()); + assertEquals(204, response.code()); + assertNull(localDns.findZone(PROJECT_ID1, ZONE1.getName())); + assertNotNull(localDns.findZone(PROJECT_ID1, ZONE2.getName())); + localDns.deleteZone(PROJECT_ID1, ZONE2.getName()); + assertEquals(204, response.code()); + assertNull(localDns.findZone(PROJECT_ID1, ZONE1.getName())); + assertNull(localDns.findZone(PROJECT_ID1, ZONE2.getName())); + } + + @Test + public void testCreateAndApplyChange() { + localDns = LocalDnsHelper.create(5 * 1000L); // we will be using threads here + localDns.createZone(PROJECT_ID1, ZONE1, null); + assertNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); + LocalDnsHelper.Response response + = localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add + assertEquals(200, response.code()); + assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); + assertNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); + localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add + assertEquals(200, response.code()); + assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); + assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); + localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); // delete + assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); + assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); + assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("3")); + localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE_KEEP, null); // id is "4" + // check execution + Change change = localDns.findChange(PROJECT_ID1, ZONE_NAME1, "4"); + for (int i = 0; i < 10 && !change.getStatus().equals("done"); i++) { + // change has not been finished yet; wait at most 20 seconds + // it takes 5 seconds for the thread to kick in in the first place + try { + Thread.sleep(2 * 1000); + } catch (InterruptedException e) { + fail("Test was interrupted"); + } + } + assertEquals("done", change.getStatus()); + List list = + localDns.findZone(PROJECT_ID1, ZONE_NAME1).dnsRecords().get(ZONE_NAME1); + assertTrue(list.contains(new LocalDnsHelper.RrsetWrapper(RRSET_KEEP))); + } + + @Test + public void testFindChange() { + localDns.createZone(PROJECT_ID1, ZONE1, null); + Change change = localDns.findChange(PROJECT_ID1, ZONE1.getName(), "somerandomchange"); + assertNull(change); + localDns.createChange(PROJECT_ID1, ZONE1.getName(), CHANGE1, null); + // changes are sequential so we should find ID 1 + assertNotNull(localDns.findChange(PROJECT_ID1, ZONE1.getName(), "1")); + // add another + localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); + assertNotNull(localDns.findChange(PROJECT_ID1, ZONE1.getName(), "1")); + assertNotNull(localDns.findChange(PROJECT_ID1, ZONE1.getName(), "2")); + // try to find non-existent change + assertNull(localDns.findChange(PROJECT_ID1, ZONE1.getName(), "3")); + // try to find a change in yet non-existent project + assertNull(localDns.findChange(PROJECT_ID2, ZONE1.getName(), "3")); + } + + @Test + public void testRandomNameServers() { + assertEquals(4, LocalDnsHelper.randomNameservers().size()); + assertEquals(4, LocalDnsHelper.randomNameservers().size()); + assertEquals(4, LocalDnsHelper.randomNameservers().size()); + assertEquals(4, LocalDnsHelper.randomNameservers().size()); + } + + @Test + public void testGetProject() { + // only interested in no exceptions and non-null response here + assertNotNull(localDns.getProject(PROJECT_ID1, null)); + assertNotNull(localDns.getProject(PROJECT_ID2, null)); + } + + @Test + public void testGetZone() { + // non-existent + LocalDnsHelper.Response response = localDns.getZone(PROJECT_ID1, ZONE_NAME1, null); + assertEquals(404, response.code()); + assertTrue(response.body().contains("does not exist")); + // existent + localDns.createZone(PROJECT_ID1, ZONE1, null); + response = localDns.getZone(PROJECT_ID1, ZONE1.getName(), null); + assertEquals(200, response.code()); + } + + @Test + public void testCreateZone() { + // only interested in no exceptions and non-null response here + LocalDnsHelper.Response response = localDns.createZone(PROJECT_ID1, ZONE1, null); + assertEquals(200, response.code()); + assertEquals(1, localDns.projects().get(PROJECT_ID1).zones().size()); + try { + localDns.createZone(PROJECT_ID1, null, null); + fail("Zone cannot be null"); + } catch (NullPointerException ex) { + // expected + } + // create zone twice + response = localDns.createZone(PROJECT_ID1, ZONE1, null); + assertEquals(409, response.code()); + assertTrue(response.body().contains("already exists")); + } + + @Test + public void testCreateChange() { + // non-existent zone + LocalDnsHelper.Response response = + localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); + assertEquals(404, response.code()); + + // existent zone + assertNotNull(localDns.createZone(PROJECT_ID1, ZONE1, null)); + assertNull(localDns.findChange(PROJECT_ID1, ZONE_NAME1, "1")); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); + assertEquals(200, response.code()); + assertNotNull(localDns.findChange(PROJECT_ID1, ZONE_NAME1, "1")); + } + + @Test + public void testGetChange() { + // existent + assertEquals(200, localDns.createZone(PROJECT_ID1, ZONE1, null).code()); + assertEquals(200, localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null).code()); + assertEquals(200, localDns.getChange(PROJECT_ID1, ZONE_NAME1, "1", null).code()); + // non-existent + LocalDnsHelper.Response response = localDns.getChange(PROJECT_ID1, ZONE_NAME1, "2", null); + assertEquals(404, response.code()); + assertTrue(response.body().contains("parameters.changeId")); + // non-existent zone + response = localDns.getChange(PROJECT_ID1, ZONE_NAME2, "1", null); + assertEquals(404, response.code()); + assertTrue(response.body().contains("parameters.managedZone")); + } + + @Test + public void testListZones() { + // only interested in no exceptions and non-null response here + optionsMap.put("dnsName", null); + optionsMap.put("fields", null); + optionsMap.put("pageToken", null); + optionsMap.put("maxResults", null); + LocalDnsHelper.Response response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(200, response.code()); + // some zones exists + localDns.createZone(PROJECT_ID1, ZONE1, null); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(200, response.code()); + localDns.createZone(PROJECT_ID1, ZONE2, null); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(200, response.code()); + // error in options + optionsMap.put("maxResults", "aaa"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("maxResults", "0"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("maxResults", "-1"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("maxResults", "15"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(200, response.code()); + optionsMap.put("dnsName", "aaa"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("dnsName", "aaa."); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(200, response.code()); + } + + @Test + public void testListDnsRecords() { + // only interested in no exceptions and non-null response here + optionsMap.put("name", null); + optionsMap.put("fields", null); + optionsMap.put("type", null); + optionsMap.put("pageToken", null); + optionsMap.put("maxResults", null); + // no zone exists + LocalDnsHelper.Response response = localDns.listDnsRecords(PROJECT_ID1, ZONE_NAME1, + optionsMap); + assertEquals(404, response.code()); + // zone exists but has no records + localDns.createZone(PROJECT_ID1, ZONE1, null); + localDns.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); + // zone has records + localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); + response = localDns.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(200, response.code()); + // error in options + optionsMap.put("maxResults", "aaa"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("maxResults", "0"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("maxResults", "-1"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("maxResults", "15"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(200, response.code()); + optionsMap.put("name", "aaa"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("name", "aaa."); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(200, response.code()); + optionsMap.put("name", null); + optionsMap.put("type", "A"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("name", "aaa."); + optionsMap.put("type", "a"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("name", "aaaa."); + optionsMap.put("type", "A"); + response = localDns.listZones(PROJECT_ID1, optionsMap); + assertEquals(200, response.code()); + } + + @Test + public void testListChanges() { + optionsMap.put("sortBy", null); + optionsMap.put("sortOrder", null); + optionsMap.put("fields", null); + optionsMap.put("pageToken", null); + optionsMap.put("maxResults", null); + // no such zone exists + LocalDnsHelper.Response response = localDns.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(404, response.code()); + assertTrue(response.body().contains("managedZone")); + // zone exists but has no changes + localDns.createZone(PROJECT_ID1, ZONE1, null); + assertNotNull(localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); + // zone has changes + localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); + assertNotNull(localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); + localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); + localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); + localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); + assertNotNull(localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); + // error in options + optionsMap.put("maxResults", "aaa"); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("maxResults", "0"); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("maxResults", "-1"); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("maxResults", "15"); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(200, response.code()); + optionsMap.put("dnsName", "aaa"); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(400, response.code()); + optionsMap.put("dnsName", "aaa."); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(200, response.code()); + optionsMap.put("sortBy", "changeSequence"); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(200, response.code()); + optionsMap.put("sortBy", "something else"); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("Allowed values: [changesequence]")); + optionsMap.put("sortBy", "ChAnGeSeQuEnCe"); // is not case sensitive + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(200, response.code()); + optionsMap.put("sortOrder", "ascending"); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(200, response.code()); + optionsMap.put("sortBy", null); + optionsMap.put("sortOrder", "descending"); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(200, response.code()); + optionsMap.put("sortOrder", "somethingelse"); + response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("parameters.sortOrder")); + } + + @Test + public void testToListResponse() { + LocalDnsHelper.Response response = LocalDnsHelper.toListResponse( + Lists.newArrayList("some", "multiple", "words"), "IncludeThisPageToken", true); + assertTrue(response.body().contains("IncludeThisPageToken")); + response = LocalDnsHelper.toListResponse( + Lists.newArrayList("some", "multiple", "words"), "IncludeThisPageToken", false); + assertFalse(response.body().contains("IncludeThisPageToken")); + response = LocalDnsHelper.toListResponse( + Lists.newArrayList("some", "multiple", "words"), null, true); + assertFalse(response.body().contains("pageToken")); + } + + @Test + public void testCheckZone() { + // no name + ManagedZone copy = copyZone(minimalZone); + copy.setName(null); + LocalDnsHelper.Response response = LocalDnsHelper.checkZone(copy); + assertEquals(400, response.code()); + assertTrue(response.body().contains("entity.managedZone.name")); + // no description + copy = copyZone(minimalZone); + copy.setDescription(null); + response = LocalDnsHelper.checkZone(copy); + assertEquals(400, response.code()); + assertTrue(response.body().contains("entity.managedZone.description")); + // no description + copy = copyZone(minimalZone); + copy.setDnsName(null); + response = LocalDnsHelper.checkZone(copy); + assertEquals(400, response.code()); + assertTrue(response.body().contains("entity.managedZone.dnsName")); + // zone name is a number + copy = copyZone(minimalZone); + copy.setName("123456"); + response = LocalDnsHelper.checkZone(copy); + assertEquals(400, response.code()); + assertTrue(response.body().contains("entity.managedZone.name")); + assertTrue(response.body().contains("Invalid")); + // dns name does not end with period + copy = copyZone(minimalZone); + copy.setDnsName("aaaaaa.com"); + response = LocalDnsHelper.checkZone(copy); + assertEquals(400, response.code()); + assertTrue(response.body().contains("entity.managedZone.dnsName")); + assertTrue(response.body().contains("Invalid")); + // dns name is reserved + copy = copyZone(minimalZone); + copy.setDnsName("com."); + response = LocalDnsHelper.checkZone(copy); + assertEquals(400, response.code()); + assertTrue(response.body().contains("not available to be created.")); + // empty description should pass + copy = copyZone(minimalZone); + copy.setDescription(""); + assertNull(LocalDnsHelper.checkZone(copy)); + } + + @Test + public void testCreateZoneValidatesZone() { + // no name + ManagedZone copy = copyZone(minimalZone); + copy.setName(null); + LocalDnsHelper.Response response = localDns.createZone(PROJECT_ID1, copy, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("entity.managedZone.name")); + // no description + copy = copyZone(minimalZone); + copy.setDescription(null); + response = localDns.createZone(PROJECT_ID1, copy, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("entity.managedZone.description")); + // no dns name + copy = copyZone(minimalZone); + copy.setDnsName(null); + response = localDns.createZone(PROJECT_ID1, copy, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("entity.managedZone.dnsName")); + // zone name is a number + copy = copyZone(minimalZone); + copy.setName("123456"); + response = localDns.createZone(PROJECT_ID1, copy, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("entity.managedZone.name")); + assertTrue(response.body().contains("Invalid")); + // dns name does not end with period + copy = copyZone(minimalZone); + copy.setDnsName("aaaaaa.com"); + response = localDns.createZone(PROJECT_ID1, copy, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("entity.managedZone.dnsName")); + assertTrue(response.body().contains("Invalid")); + // dns name is reserved + copy = copyZone(minimalZone); + copy.setDnsName("com."); + response = localDns.createZone(PROJECT_ID1, copy, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("not available to be created.")); + // empty description should pass + copy = copyZone(minimalZone); + copy.setDescription(""); + response = localDns.createZone(PROJECT_ID1, copy, null); + assertEquals(200, response.code()); + } + + @Test + public void testCheckListOptions() { + // listing zones + optionsMap.put("maxResults", "-1"); + LocalDnsHelper.Response response = LocalDnsHelper.checkListOptions(optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("parameters.maxResults")); + optionsMap.put("maxResults", "0"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("parameters.maxResults")); + optionsMap.put("maxResults", "aaaa"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("integer")); + optionsMap.put("maxResults", "15"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertNull(response); + optionsMap.put("dnsName", "aaa"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("parameters.dnsName")); + optionsMap.put("dnsName", "aaa."); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertNull(response); + // listing dns records + optionsMap.put("name", "aaa"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("parameters.name")); + optionsMap.put("name", "aaa."); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertNull(response); + optionsMap.put("name", null); + optionsMap.put("type", "A"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("parameters.name")); + optionsMap.put("name", "aaa."); + optionsMap.put("type", "a"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("parameters.type")); + optionsMap.put("name", "aaaa."); + optionsMap.put("type", "A"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertNull(response); + // listing changes + optionsMap.put("sortBy", "changeSequence"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertNull(response); + optionsMap.put("sortBy", "something else"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("Allowed values: [changesequence]")); + optionsMap.put("sortBy", "ChAnGeSeQuEnCe"); // is not case sensitive + response = LocalDnsHelper.checkListOptions(optionsMap); + assertNull(response); + optionsMap.put("sortOrder", "ascending"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertNull(response); + optionsMap.put("sortOrder", "descending"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertNull(response); + optionsMap.put("sortOrder", "somethingelse"); + response = LocalDnsHelper.checkListOptions(optionsMap); + assertEquals(400, response.code()); + assertTrue(response.body().contains("parameters.sortOrder")); + } + + @Test + public void testCheckRrset() { + ResourceRecordSet valid = new ResourceRecordSet(); + valid.setName(ZONE1.getDnsName()); + valid.setType("A"); + valid.setRrdatas(ImmutableList.of("0.255.1.5")); + valid.setTtl(500); + Change validChange = new Change(); + validChange.setAdditions(ImmutableList.of(valid)); + localDns.createZone(PROJECT_ID1, ZONE1, null); + localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + // delete with field mismatch + LocalDnsHelper.ZoneContainer zone = localDns.findZone(PROJECT_ID1, ZONE_NAME1); + valid.setTtl(valid.getTtl() + 20); + LocalDnsHelper.Response response = LocalDnsHelper.checkRrset(valid, zone, 0, "deletions"); + assertEquals(412, response.code()); + assertTrue(response.body().contains("entity.change.deletions[0]")); + } + + @Test + public void testCheckRrdata() { + // A + assertTrue(LocalDnsHelper.checkRrData("255.255.255.255", "A")); + assertTrue(LocalDnsHelper.checkRrData("13.15.145.165", "A")); + assertTrue(LocalDnsHelper.checkRrData("0.0.0.0", "A")); + assertFalse(LocalDnsHelper.checkRrData("255.255.255.256", "A")); + assertFalse(LocalDnsHelper.checkRrData("-1.255.255.255", "A")); + assertFalse(LocalDnsHelper.checkRrData(".255.255.254", "A")); + assertFalse(LocalDnsHelper.checkRrData("111.255.255.", "A")); + assertFalse(LocalDnsHelper.checkRrData("111.255..22", "A")); + assertFalse(LocalDnsHelper.checkRrData("111.255.aa.22", "A")); + assertFalse(LocalDnsHelper.checkRrData("", "A")); + assertFalse(LocalDnsHelper.checkRrData("...", "A")); + assertFalse(LocalDnsHelper.checkRrData("111.255.12", "A")); + assertFalse(LocalDnsHelper.checkRrData("111.255.12.11.11", "A")); + // AAAA + assertTrue(LocalDnsHelper.checkRrData(":::::::", "AAAA")); + assertTrue(LocalDnsHelper.checkRrData("1F:fa:09fd::343:aaaa:AAAA:", "AAAA")); + assertTrue(LocalDnsHelper.checkRrData("0000:FFFF:09fd::343:aaaa:AAAA:", "AAAA")); + assertFalse(LocalDnsHelper.checkRrData("-2:::::::", "AAAA")); + assertTrue(LocalDnsHelper.checkRrData("0:::::::", "AAAA")); + assertFalse(LocalDnsHelper.checkRrData("::1FFFF:::::", "AAAA")); + assertFalse(LocalDnsHelper.checkRrData("::aqaa:::::", "AAAA")); + assertFalse(LocalDnsHelper.checkRrData("::::::::", "AAAA")); // too long + assertFalse(LocalDnsHelper.checkRrData("::::::", "AAAA")); // too short + } + + @Test + public void testCheckChange() { + ResourceRecordSet validA = new ResourceRecordSet(); + validA.setName(ZONE1.getDnsName()); + validA.setType("A"); + validA.setRrdatas(ImmutableList.of("0.255.1.5")); + ResourceRecordSet invalidA = new ResourceRecordSet(); + invalidA.setName(ZONE1.getDnsName()); + invalidA.setType("A"); + invalidA.setRrdatas(ImmutableList.of("0.-255.1.5")); + Change validChange = new Change(); + validChange.setAdditions(ImmutableList.of(validA)); + Change invalidChange = new Change(); + invalidChange.setAdditions(ImmutableList.of(invalidA)); + LocalDnsHelper.ZoneContainer zoneContainer = new LocalDnsHelper.ZoneContainer(ZONE1); + LocalDnsHelper.Response response = LocalDnsHelper.checkChange(validChange, zoneContainer); + assertNull(response); + response = LocalDnsHelper.checkChange(invalidChange, zoneContainer); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].rrdata[0]")); + // only empty additions/deletions + Change empty = new Change(); + empty.setAdditions(ImmutableList.of()); + empty.setDeletions(ImmutableList.of()); + response = LocalDnsHelper.checkChange(empty, zoneContainer); + assertEquals(400, response.code()); + assertTrue(response.body().contains( + "The 'entity.change' parameter is required but was missing.")); + // null additions/deletions + empty = new Change(); + response = LocalDnsHelper.checkChange(empty, zoneContainer); + assertEquals(400, response.code()); + assertTrue(response.body().contains( + "The 'entity.change' parameter is required but was missing.")); + // non-matching name + validA.setName(ZONE1.getDnsName() + ".aaa."); + response = LocalDnsHelper.checkChange(validChange, zoneContainer); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].name")); + // wrong type + validA.setName(ZONE1.getDnsName()); // revert + validA.setType("ABCD"); + response = LocalDnsHelper.checkChange(validChange, zoneContainer); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].type")); + // wrong ttl + validA.setType("A"); // revert + validA.setTtl(-1); + response = LocalDnsHelper.checkChange(validChange, zoneContainer); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].ttl")); + validA.setTtl(null); + // null name + validA.setName(null); + response = LocalDnsHelper.checkChange(validChange, zoneContainer); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].name")); + validA.setName(ZONE1.getDnsName()); + // null type + validA.setType(null); + response = LocalDnsHelper.checkChange(validChange, zoneContainer); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].type")); + validA.setType("A"); + // null rrdata + List temp = validA.getRrdatas(); // preserve + validA.setRrdatas(null); + response = LocalDnsHelper.checkChange(validChange, zoneContainer); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].rrdata")); + validA.setRrdatas(temp); + // delete non-existent + ResourceRecordSet nonExistent = new ResourceRecordSet(); + nonExistent.setName(ZONE1.getDnsName()); + nonExistent.setType("AAAA"); + nonExistent.setRrdatas(ImmutableList.of(":::::::")); + Change delete = new Change(); + delete.setDeletions(ImmutableList.of(nonExistent)); + response = LocalDnsHelper.checkChange(delete, zoneContainer); + assertEquals(404, response.code()); + assertTrue(response.body().contains("deletions[0]")); + + } + + @Test + public void testAdditionsMeetDeletions() { + ResourceRecordSet validA = new ResourceRecordSet(); + validA.setName(ZONE1.getDnsName()); + validA.setType("A"); + validA.setRrdatas(ImmutableList.of("0.255.1.5")); + Change validChange = new Change(); + validChange.setAdditions(ImmutableList.of(validA)); + localDns.createZone(PROJECT_ID1, ZONE1, null); + localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LocalDnsHelper.ZoneContainer container = localDns.findZone(PROJECT_ID1, ZONE_NAME1); + LocalDnsHelper.Response response = + LocalDnsHelper.additionsMeetDeletions(ImmutableList.of(validA), null, container); + assertEquals(409, response.code()); + assertTrue(response.body().contains("already exists")); + + } + + @Test + public void testCreateChangeValidatesChangeContent() { + ResourceRecordSet validA = new ResourceRecordSet(); + validA.setName(ZONE1.getDnsName()); + validA.setType("A"); + validA.setRrdatas(ImmutableList.of("0.255.1.5")); + Change validChange = new Change(); + validChange.setAdditions(ImmutableList.of(validA)); + localDns.createZone(PROJECT_ID1, ZONE1, null); + localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LocalDnsHelper.Response response = + localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + assertEquals(409, response.code()); + assertTrue(response.body().contains("already exists")); + // delete with field mismatch + Change delete = new Change(); + validA.setTtl(20); // mismatch + delete.setDeletions(ImmutableList.of(validA)); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + assertEquals(412, response.code()); + assertTrue(response.body().contains("entity.change.deletions[0]")); + // delete and add SOA + Change addition = new Change(); + ImmutableList rrsetWrappers + = localDns.findZone(PROJECT_ID1, ZONE_NAME1).dnsRecords().get(ZONE_NAME1); + LinkedList deletions = new LinkedList<>(); + LinkedList additions = new LinkedList<>(); + for (LocalDnsHelper.RrsetWrapper wrapper : rrsetWrappers) { + ResourceRecordSet rrset = wrapper.rrset(); + if (rrset.getType().equals("SOA")) { + deletions.add(rrset); + ResourceRecordSet copy = copyRrset(rrset); + copy.setName("x." + copy.getName()); + additions.add(copy); + break; + } + } + delete.setDeletions(deletions); + addition.setAdditions(additions); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains( + "zone must contain exactly one resource record set of type 'SOA' at the apex")); + assertTrue(response.body().contains("deletions[0]")); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains( + "zone must contain exactly one resource record set of type 'SOA' at the apex")); + assertTrue(response.body().contains("additions[0]")); + // delete NS + deletions = new LinkedList<>(); + additions = new LinkedList<>(); + for (LocalDnsHelper.RrsetWrapper wrapper : rrsetWrappers) { + ResourceRecordSet rrset = wrapper.rrset(); + if (rrset.getType().equals("NS")) { + deletions.add(rrset); + ResourceRecordSet copy = copyRrset(rrset); + copy.setName("x." + copy.getName()); + additions.add(copy); + break; + } + } + delete.setDeletions(deletions); + addition.setAdditions(additions); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains( + "zone must contain exactly one resource record set of type 'NS' at the apex")); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains( + "zone must contain exactly one resource record set of type 'NS' at the apex")); + assertTrue(response.body().contains("additions[0]")); + // change (delete + add) + addition.setDeletions(deletions); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); + assertEquals(200, response.code()); + } + + @Test + public void testCreateChangeValidatesChange() { + localDns.createZone(PROJECT_ID1, ZONE1, null); + ResourceRecordSet validA = new ResourceRecordSet(); + validA.setName(ZONE1.getDnsName()); + validA.setType("A"); + validA.setRrdatas(ImmutableList.of("0.255.1.5")); + ResourceRecordSet invalidA = new ResourceRecordSet(); + invalidA.setName(ZONE1.getDnsName()); + invalidA.setType("A"); + invalidA.setRrdatas(ImmutableList.of("0.-255.1.5")); + Change validChange = new Change(); + validChange.setAdditions(ImmutableList.of(validA)); + Change invalidChange = new Change(); + invalidChange.setAdditions(ImmutableList.of(invalidA)); + LocalDnsHelper.Response response = + localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + assertEquals(200, response.code()); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, invalidChange, null); + assertEquals(400, response.code()); + // only empty additions/deletions + Change empty = new Change(); + empty.setAdditions(ImmutableList.of()); + empty.setDeletions(ImmutableList.of()); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, empty, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains( + "The 'entity.change' parameter is required but was missing.")); + // non-matching name + validA.setName(ZONE1.getDnsName() + ".aaa."); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].name")); + // wrong type + validA.setName(ZONE1.getDnsName()); // revert + validA.setType("ABCD"); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].type")); + // wrong ttl + validA.setType("A"); // revert + validA.setTtl(-1); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].ttl")); + validA.setTtl(null); // revert + // null name + validA.setName(null); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].name")); + validA.setName(ZONE1.getDnsName()); + // null type + validA.setType(null); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].type")); + validA.setType("A"); + // null rrdata + List temp = validA.getRrdatas(); // preserve + validA.setRrdatas(null); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + assertEquals(400, response.code()); + assertTrue(response.body().contains("additions[0].rrdata")); + validA.setRrdatas(temp); + // delete non-existent + ResourceRecordSet nonExistent = new ResourceRecordSet(); + nonExistent.setName(ZONE1.getDnsName()); + nonExistent.setType("AAAA"); + nonExistent.setRrdatas(ImmutableList.of(":::::::")); + Change delete = new Change(); + delete.setDeletions(ImmutableList.of(nonExistent)); + response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + assertEquals(404, response.code()); + assertTrue(response.body().contains("deletions[0]")); + } + + private static ManagedZone copyZone(ManagedZone original) { + ManagedZone copy = new ManagedZone(); + copy.setDescription(original.getDescription()); + copy.setName(original.getName()); + copy.setCreationTime(original.getCreationTime()); + copy.setId(original.getId()); + copy.setNameServerSet(original.getNameServerSet()); + copy.setDnsName(original.getDnsName()); + if (original.getNameServers() != null) { + copy.setNameServers(ImmutableList.copyOf(original.getNameServers())); + } + return copy; + } + + private static ResourceRecordSet copyRrset(ResourceRecordSet set) { + ResourceRecordSet copy = new ResourceRecordSet(); + if (set.getRrdatas() != null) { + copy.setRrdatas(ImmutableList.copyOf(set.getRrdatas())); + } + copy.setTtl(set.getTtl()); + copy.setName(set.getName()); + copy.setType(set.getType()); + return copy; + } +} From d72a8c66d5e57143c175971b44e78e8b40715f3c Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 19 Feb 2016 16:25:40 -0800 Subject: [PATCH 081/203] Added "do not use production projects for tests" Added statement about not using production projects for running integration tests. --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bf87d471e34a..3d93f2d032c7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,8 @@ When changes are made to authentication and project ID-related code, authenticat Known issue: If you have installed the Google Cloud SDK, be sure to log in (using `gcloud auth login`) before running tests. Though the Datastore tests use a local Datastore emulator that doesn't require authentication, they will not run if you have the Google Cloud SDK installed but aren't authenticated. +**Please, do not use your production projects for executing integration tests.** While we do our best to make our tests independent of your project's state and content, they do perform create, modify and deletes, and you do not want to have your production data accidentally modified. + Adding Features --------------- In order to add a feature to gcloud-java: From e44e12a2b996d1649704a9ce124f670c23bd6c7e Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Fri, 19 Feb 2016 20:08:22 -0800 Subject: [PATCH 082/203] Make BaseIamPolicy in core and a subclass in Resource Manager --- .../{IamPolicy.java => BaseIamPolicy.java} | 245 ++++-------------- .../com/google/gcloud/BaseIamPolicyTest.java | 50 ++++ .../java/com/google/gcloud/IamPolicyTest.java | 105 -------- .../com/google/gcloud/SerializationTest.java | 49 ---- .../gcloud/resourcemanager/IamPolicy.java | 162 ++++++++++++ .../resourcemanager/ResourceManagerImpl.java | 94 ------- .../gcloud/resourcemanager/IamPolicyTest.java | 91 +++++++ .../ResourceManagerImplTest.java | 44 ---- .../resourcemanager/SerializationTest.java | 7 +- 9 files changed, 360 insertions(+), 487 deletions(-) rename gcloud-java-core/src/main/java/com/google/gcloud/{IamPolicy.java => BaseIamPolicy.java} (50%) create mode 100644 gcloud-java-core/src/test/java/com/google/gcloud/BaseIamPolicyTest.java delete mode 100644 gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java delete mode 100644 gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java create mode 100644 gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/IamPolicy.java create mode 100644 gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/IamPolicyTest.java diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java b/gcloud-java-core/src/main/java/com/google/gcloud/BaseIamPolicy.java similarity index 50% rename from gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java rename to gcloud-java-core/src/main/java/com/google/gcloud/BaseIamPolicy.java index a16ab790b363..bc0aed43b95d 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/BaseIamPolicy.java @@ -21,29 +21,28 @@ import com.google.common.collect.ImmutableList; import java.io.Serializable; -import java.util.Arrays; -import java.util.LinkedList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; /** - * An Identity and Access Management (IAM) policy. It is used to specify access control policies for - * Cloud Platform resources. A Policy consists of a list of ACLs (also known as bindings in Cloud - * IAM documentation). An ACL binds a list of identities to a role, where the identities can be user - * accounts, Google groups, Google domains, and service accounts. A role is a named list of - * permissions defined by IAM. + * Base class for Identity and Access Management (IAM) policies. IAM policies are used to specify + * access settings for Cloud Platform resources. A Policy consists of a list of bindings. An binding + * assigns a list of identities to a role, where the identities can be user accounts, Google groups, + * Google domains, and service accounts. A role is a named list of permissions defined by IAM. * * @see Policy */ -public class IamPolicy implements Serializable { +public abstract class BaseIamPolicy implements Serializable { - static final long serialVersionUID = 1114489978726897720L; + private static final long serialVersionUID = 1114489978726897720L; - private final List acls; + private final Map> bindings; private final String etag; private final int version; - public static class Identity implements Serializable { + public static final class Identity implements Serializable { private static final long serialVersionUID = 30811617560110848L; @@ -85,7 +84,7 @@ public enum Type { DOMAIN } - Identity(Type type, String id) { + private Identity(Type type, String id) { this.type = type; this.id = id; } @@ -178,177 +177,38 @@ public boolean equals(Object obj) { } } - /** - * An ACL binds a list of identities to a role, where the identities can be user accounts, Google - * groups, Google domains, and service accounts. A role is a named list of permissions defined by - * IAM. - * - * @see Binding - */ - public static class Acl implements Serializable { - - private static final long serialVersionUID = 3954282899483745158L; - - private final List identities; - private final String role; - - /** - * An ACL builder. - */ - public static class Builder { - private final List members = new LinkedList<>(); - private String role; - - Builder(String role) { - this.role = role; - } - - /** - * Sets the role associated with this ACL. - */ - public Builder role(String role) { - this.role = role; - return this; - } - - /** - * Replaces the builder's list of identities with the given list. - */ - public Builder identities(List identities) { - this.members.clear(); - this.members.addAll(identities); - return this; - } - - /** - * Adds one or more identities to the list of identities associated with the ACL. - */ - public Builder addIdentity(Identity first, Identity... others) { - members.add(first); - members.addAll(Arrays.asList(others)); - return this; - } - - /** - * Removes the specified identity from the ACL. - */ - public Builder removeIdentity(Identity identity) { - members.remove(identity); - return this; - } - - public Acl build() { - return new Acl(this); - } - } - - Acl(Builder builder) { - identities = ImmutableList.copyOf(checkNotNull(builder.members)); - role = checkNotNull(builder.role); - } - - /** - * Returns the list of identities associated with this ACL. - */ - public List identities() { - return identities; - } - - /** - * Returns the role associated with this ACL. - */ - public String role() { - return role; - } - - /** - * Returns an ACL builder for the specific role type. - * - * @param role string representing the role, without the "roles/" prefix. An example of a valid - * legacy role is "viewer". An example of a valid service-specific role is - * "pubsub.publisher". - */ - public static Builder builder(String role) { - return new Builder(role); - } - - /** - * Returns an ACL for the role type and list of identities provided. - * - * @param role string representing the role, without the "roles/" prefix. An example of a valid - * legacy role is "viewer". An example of a valid service-specific role is - * "pubsub.publisher". - * @param members list of identities associated with the role. - */ - public static Acl of(String role, List members) { - return new Acl(new Builder(role).identities(members)); - } - - /** - * Returns an ACL for the role type and identities provided. - * - * @param role string representing the role, without the "roles/" prefix. An example of a valid - * legacy role is "viewer". An example of a valid service-specific role is - * "pubsub.publisher". - * @param first identity associated with the role. - * @param others any other identities associated with the role. - */ - public static Acl of(String role, Identity first, Identity... others) { - return new Acl(new Builder(role).addIdentity(first, others)); - } - - public Builder toBuilder() { - return new Builder(role).identities(identities); - } - - @Override - public int hashCode() { - return Objects.hash(identities, role); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Acl)) { - return false; - } - Acl other = (Acl) obj; - return Objects.equals(identities, other.identities()) && Objects.equals(role, other.role()); - } - } - /** * Builder for an IAM Policy. */ - public static class Builder { + protected abstract static class BaseBuilder> { - private final List acls = new LinkedList<>(); + private final Map> bindings = new HashMap<>(); private String etag; private int version; /** - * Replaces the builder's list of ACLs with the given list of ACLs. + * Replaces the builder's list of bindings with the given list of bindings. */ - public Builder acls(List acls) { - this.acls.clear(); - this.acls.addAll(acls); - return this; + public B bindings(Map> bindings) { + this.bindings.clear(); + this.bindings.putAll(bindings); + return self(); } /** - * Adds one or more ACLs to the policy. + * Adds one or more bindings to the policy. */ - public Builder addAcl(Acl first, Acl... others) { - acls.add(first); - acls.addAll(Arrays.asList(others)); - return this; + public B addBinding(R role, List identities) { + bindings.put(role, ImmutableList.copyOf(identities)); + return self(); } /** * Removes the specified ACL. */ - public Builder removeAcl(Acl acl) { - acls.remove(acl); - return this; + public B removeBinding(R role) { + bindings.remove(role); + return self(); } /** @@ -362,35 +222,40 @@ public Builder removeAcl(Acl acl) { * applied to the same version of the policy. If no etag is provided in the call to * setIamPolicy, then the existing policy is overwritten blindly. */ - public Builder etag(String etag) { + protected B etag(String etag) { this.etag = etag; - return this; + return self(); } /** - * Sets the version of the policy. The default version is 0. + * Sets the version of the policy. The default version is 0, meaning roles that are in alpha + * (non-legacy) roles are not permitted. If the version is 1, you may use roles other than + * "owner", "editor", and "viewer". */ - public Builder version(int version) { + protected B version(int version) { this.version = version; - return this; + return self(); } - public IamPolicy build() { - return new IamPolicy(this); + @SuppressWarnings("unchecked") + private B self() { + return (B) this; } + + public abstract BaseIamPolicy build(); } - IamPolicy(Builder builder) { - acls = ImmutableList.copyOf(builder.acls); - etag = builder.etag; - version = builder.version; + protected BaseIamPolicy(BaseBuilder> builder) { + this.bindings = builder.bindings; + this.etag = builder.etag; + this.version = builder.version; } /** * The list of ACLs specified in the policy. */ - public List acls() { - return acls; + public Map> bindings() { + return bindings; } /** @@ -415,26 +280,18 @@ public int version() { return version; } - @Override - public int hashCode() { - return Objects.hash(acls, etag, version); + public int baseHashCode() { + return Objects.hash(bindings, etag, version); } - @Override - public boolean equals(Object obj) { - if (!(obj instanceof IamPolicy)) { + public boolean baseEquals(Object obj) { + if (!(obj instanceof BaseIamPolicy)) { return false; } - IamPolicy other = (IamPolicy) obj; - return Objects.equals(acls, other.acls()) && Objects.equals(etag, other.etag()) + @SuppressWarnings("rawtypes") + BaseIamPolicy other = (BaseIamPolicy) obj; + return Objects.equals(bindings, other.bindings()) + && Objects.equals(etag, other.etag()) && Objects.equals(version, other.version()); } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().acls(acls).etag(etag).version(version); - } } diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/BaseIamPolicyTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/BaseIamPolicyTest.java new file mode 100644 index 000000000000..0c26bc806812 --- /dev/null +++ b/gcloud-java-core/src/test/java/com/google/gcloud/BaseIamPolicyTest.java @@ -0,0 +1,50 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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.gcloud; + +import static org.junit.Assert.assertEquals; + +import com.google.gcloud.BaseIamPolicy.Identity; + +import org.junit.Test; + +public class BaseIamPolicyTest { + + private static final Identity ALL_USERS = Identity.allUsers(); + private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); + private static final Identity USER = Identity.user("abc@gmail.com"); + private static final Identity SERVICE_ACCOUNT = + Identity.serviceAccount("service-account@gmail.com"); + private static final Identity GROUP = Identity.group("group@gmail.com"); + private static final Identity DOMAIN = Identity.domain("google.com"); + + @Test + public void testIdentityOf() { + assertEquals(Identity.Type.ALL_USERS, ALL_USERS.type()); + assertEquals(null, ALL_USERS.id()); + assertEquals(Identity.Type.ALL_AUTHENTICATED_USERS, ALL_AUTH_USERS.type()); + assertEquals(null, ALL_AUTH_USERS.id()); + assertEquals(Identity.Type.USER, USER.type()); + assertEquals("abc@gmail.com", USER.id()); + assertEquals(Identity.Type.SERVICE_ACCOUNT, SERVICE_ACCOUNT.type()); + assertEquals("service-account@gmail.com", SERVICE_ACCOUNT.id()); + assertEquals(Identity.Type.GROUP, GROUP.type()); + assertEquals("group@gmail.com", GROUP.id()); + assertEquals(Identity.Type.DOMAIN, DOMAIN.type()); + assertEquals("google.com", DOMAIN.id()); + } +} diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java deleted file mode 100644 index 0d4e9fbfa6c8..000000000000 --- a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * 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.gcloud; - -import static org.junit.Assert.assertEquals; - -import com.google.common.collect.ImmutableList; -import com.google.gcloud.IamPolicy.Acl; -import com.google.gcloud.IamPolicy.Identity; - -import org.junit.Test; - -public class IamPolicyTest { - - private static final Identity ALL_USERS = Identity.allUsers(); - private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); - private static final Identity USER = Identity.user("abc@gmail.com"); - private static final Identity SERVICE_ACCOUNT = - Identity.serviceAccount("service-account@gmail.com"); - private static final Identity GROUP = Identity.group("group@gmail.com"); - private static final Identity DOMAIN = Identity.domain("google.com"); - private static final Acl ACL1 = Acl.of("viewer", USER, SERVICE_ACCOUNT, ALL_USERS); - private static final Acl ACL2 = Acl.of("editor", ALL_AUTH_USERS, GROUP, DOMAIN); - private static final IamPolicy FULL_POLICY = - IamPolicy.builder().addAcl(ACL1, ACL2).etag("etag").version(1).build(); - private static final IamPolicy SIMPLE_POLICY = IamPolicy.builder().addAcl(ACL1, ACL2).build(); - - @Test - public void testIdentityOf() { - assertEquals(Identity.Type.ALL_USERS, ALL_USERS.type()); - assertEquals(null, ALL_USERS.id()); - assertEquals(Identity.Type.ALL_AUTHENTICATED_USERS, ALL_AUTH_USERS.type()); - assertEquals(null, ALL_AUTH_USERS.id()); - assertEquals(Identity.Type.USER, USER.type()); - assertEquals("abc@gmail.com", USER.id()); - assertEquals(Identity.Type.SERVICE_ACCOUNT, SERVICE_ACCOUNT.type()); - assertEquals("service-account@gmail.com", SERVICE_ACCOUNT.id()); - assertEquals(Identity.Type.GROUP, GROUP.type()); - assertEquals("group@gmail.com", GROUP.id()); - assertEquals(Identity.Type.DOMAIN, DOMAIN.type()); - assertEquals("google.com", DOMAIN.id()); - } - - @Test - public void testAclBuilder() { - Acl acl = Acl.builder("owner").addIdentity(USER, GROUP).build(); - assertEquals("owner", acl.role()); - assertEquals(ImmutableList.of(USER, GROUP), acl.identities()); - acl = acl.toBuilder().role("viewer").removeIdentity(GROUP).build(); - assertEquals("viewer", acl.role()); - assertEquals(ImmutableList.of(USER), acl.identities()); - acl = acl.toBuilder().identities(ImmutableList.of(SERVICE_ACCOUNT)).build(); - assertEquals("viewer", acl.role()); - assertEquals(ImmutableList.of(SERVICE_ACCOUNT), acl.identities()); - } - - @Test - public void testAclOf() { - assertEquals("viewer", ACL1.role()); - assertEquals(ImmutableList.of(USER, SERVICE_ACCOUNT, ALL_USERS), ACL1.identities()); - Acl aclFromList = Acl.of("editor", ImmutableList.of(USER, SERVICE_ACCOUNT)); - assertEquals("editor", aclFromList.role()); - assertEquals(ImmutableList.of(USER, SERVICE_ACCOUNT), aclFromList.identities()); - } - - @Test - public void testAclToBuilder() { - assertEquals(ACL1, ACL1.toBuilder().build()); - } - - @Test - public void testIamPolicyBuilder() { - assertEquals(ImmutableList.of(ACL1, ACL2), FULL_POLICY.acls()); - assertEquals("etag", FULL_POLICY.etag()); - assertEquals(1, FULL_POLICY.version()); - IamPolicy policy = FULL_POLICY.toBuilder().acls(ImmutableList.of(ACL2)).build(); - assertEquals(ImmutableList.of(ACL2), policy.acls()); - assertEquals("etag", policy.etag()); - assertEquals(1, policy.version()); - policy = SIMPLE_POLICY.toBuilder().removeAcl(ACL2).build(); - assertEquals(ImmutableList.of(ACL1), policy.acls()); - assertEquals(null, policy.etag()); - assertEquals(0, policy.version()); - } - - @Test - public void testIamPolicyToBuilder() { - assertEquals(FULL_POLICY, FULL_POLICY.toBuilder().build()); - assertEquals(SIMPLE_POLICY, SIMPLE_POLICY.toBuilder().build()); - } -} diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java deleted file mode 100644 index b529b2c09ff5..000000000000 --- a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.google.gcloud; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; - -import com.google.common.collect.ImmutableList; -import com.google.gcloud.IamPolicy.Acl; -import com.google.gcloud.IamPolicy.Identity; - -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -public class SerializationTest { - - private static final Identity IDENTITY = Identity.user("abc@gmail.com"); - private static final Acl ACL = Acl.of("viewer", ImmutableList.of(IDENTITY)); - private static final IamPolicy POLICY = - IamPolicy.builder().acls(ImmutableList.of(ACL)).etag("etag").version(1).build(); - - @Test - public void testModelAndRequests() throws Exception { - Serializable[] objects = {IDENTITY, ACL, POLICY}; - for (Serializable obj : objects) { - Object copy = serializeAndDeserialize(obj); - assertEquals(obj, obj); - assertEquals(obj, copy); - assertNotSame(obj, copy); - assertEquals(copy, copy); - } - } - - @SuppressWarnings("unchecked") - private T serializeAndDeserialize(T obj) throws IOException, ClassNotFoundException { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { - output.writeObject(obj); - } - try (ObjectInputStream input = - new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) { - return (T) input.readObject(); - } - } -} diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/IamPolicy.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/IamPolicy.java new file mode 100644 index 000000000000..ccb436fd8a2f --- /dev/null +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/IamPolicy.java @@ -0,0 +1,162 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.resourcemanager; + +import com.google.common.base.Function; +import com.google.common.collect.Lists; +import com.google.gcloud.BaseIamPolicy; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * Base class for Identity and Access Management (IAM) policies. IAM policies are used to specify + * access settings for Cloud Platform resources. A Policy consists of a list of bindings. An binding + * assigns a list of identities to a role, where the identities can be user accounts, Google groups, + * Google domains, and service accounts. A role is a named list of permissions defined by IAM. + * + * @see Policy + */ +public class IamPolicy extends BaseIamPolicy implements Serializable { + + private static final long serialVersionUID = -5573557282693961850L; + + /** + * Builder for an IAM Policy. + */ + protected static class Builder extends BaseBuilder { + + Builder() {} + + Builder(Map> bindings, String etag, int version) { + bindings(bindings).etag(etag).version(version); + } + + @Override + public IamPolicy build() { + return new IamPolicy(this); + } + } + + private IamPolicy(Builder builder) { + super(builder); + } + + @Override + public int hashCode() { + return baseHashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof IamPolicy)) { + return false; + } + IamPolicy other = (IamPolicy) obj; + return Objects.equals(bindings(), other.bindings()) + && Objects.equals(etag(), other.etag()) + && Objects.equals(version(), other.version()); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(bindings(), etag(), version()); + } + + static String identityToPb(Identity identity) { + switch (identity.type()) { + case ALL_USERS: + return "allUsers"; + case ALL_AUTHENTICATED_USERS: + return "allAuthenticatedUsers"; + case USER: + return "user:" + identity.id(); + case SERVICE_ACCOUNT: + return "serviceAccount:" + identity.id(); + case GROUP: + return "group:" + identity.id(); + default: + return "domain:" + identity.id(); + } + } + + static Identity identityFromPb(String identityStr) { + String[] info = identityStr.split(":"); + switch (info[0]) { + case "allUsers": + return Identity.allUsers(); + case "allAuthenticatedUsers": + return Identity.allAuthenticatedUsers(); + case "user": + return Identity.user(info[1]); + case "serviceAccount": + return Identity.serviceAccount(info[1]); + case "group": + return Identity.group(info[1]); + case "domain": + return Identity.domain(info[1]); + default: + throw new IllegalArgumentException("Unexpected identity type: " + info[0]); + } + } + + com.google.api.services.cloudresourcemanager.model.Policy toPb() { + com.google.api.services.cloudresourcemanager.model.Policy policyPb = + new com.google.api.services.cloudresourcemanager.model.Policy(); + List bindingPbList = + new LinkedList<>(); + for (Map.Entry> binding : bindings().entrySet()) { + com.google.api.services.cloudresourcemanager.model.Binding bindingPb = + new com.google.api.services.cloudresourcemanager.model.Binding(); + bindingPb.setRole("roles/" + binding.getKey()); + bindingPb.setMembers(Lists.transform(binding.getValue(), new Function() { + @Override + public String apply(Identity identity) { + return identityToPb(identity); + } + })); + bindingPbList.add(bindingPb); + } + policyPb.setBindings(bindingPbList); + policyPb.setEtag(etag()); + policyPb.setVersion(version()); + return policyPb; + } + + static IamPolicy fromPb( + com.google.api.services.cloudresourcemanager.model.Policy policyPb) { + Map> bindings = new HashMap<>(); + for (com.google.api.services.cloudresourcemanager.model.Binding bindingPb : + policyPb.getBindings()) { + bindings.put(bindingPb.getRole().substring("roles/".length()), + Lists.transform(bindingPb.getMembers(), new Function() { + @Override + public Identity apply(String identityPb) { + return identityFromPb(identityPb); + } + })); + } + return new IamPolicy.Builder(bindings, policyPb.getEtag(), policyPb.getVersion()).build(); + } +} diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java index e641f3c75a31..4176b4e610ba 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java @@ -23,12 +23,8 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gcloud.BaseService; -import com.google.gcloud.IamPolicy; -import com.google.gcloud.IamPolicy.Acl; -import com.google.gcloud.IamPolicy.Identity; import com.google.gcloud.Page; import com.google.gcloud.PageImpl; import com.google.gcloud.PageImpl.NextPageFetcher; @@ -193,94 +189,4 @@ public Void call() { } return ImmutableMap.copyOf(temp); } - - static String identityToPb(Identity identity) { - switch (identity.type()) { - case ALL_USERS: - return "allUsers"; - case ALL_AUTHENTICATED_USERS: - return "allAuthenticatedUsers"; - case USER: - return "user:" + identity.id(); - case SERVICE_ACCOUNT: - return "serviceAccount:" + identity.id(); - case GROUP: - return "group:" + identity.id(); - default: - return "domain:" + identity.id(); - } - } - - static Identity identityFromPb(String identityStr) { - String[] info = identityStr.split(":"); - switch (info[0]) { - case "allUsers": - return Identity.allUsers(); - case "allAuthenticatedUsers": - return Identity.allAuthenticatedUsers(); - case "user": - return Identity.user(info[1]); - case "serviceAccount": - return Identity.serviceAccount(info[1]); - case "group": - return Identity.group(info[1]); - case "domain": - return Identity.domain(info[1]); - default: - throw new IllegalArgumentException("Unexpected identity type: " + info[0]); - } - } - - static com.google.api.services.cloudresourcemanager.model.Binding aclToPb(Acl acl) { - com.google.api.services.cloudresourcemanager.model.Binding bindingPb = - new com.google.api.services.cloudresourcemanager.model.Binding(); - bindingPb.setMembers(Lists.transform(acl.identities(), new Function() { - @Override - public String apply(Identity identity) { - return identityToPb(identity); - } - })); - bindingPb.setRole("roles/" + acl.role()); - return bindingPb; - } - - static Acl aclFromPb(com.google.api.services.cloudresourcemanager.model.Binding bindingPb) { - return Acl.of( - bindingPb.getRole().substring("roles/".length()), - Lists.transform(bindingPb.getMembers(), new Function() { - @Override - public Identity apply(String memberPb) { - return identityFromPb(memberPb); - } - })); - } - - static com.google.api.services.cloudresourcemanager.model.Policy policyToPb( - final IamPolicy policy) { - com.google.api.services.cloudresourcemanager.model.Policy policyPb = - new com.google.api.services.cloudresourcemanager.model.Policy(); - policyPb.setBindings(Lists.transform(policy.acls(), - new Function() { - @Override - public com.google.api.services.cloudresourcemanager.model.Binding apply(Acl acl) { - return aclToPb(acl); - } - })); - policyPb.setEtag(policy.etag()); - policyPb.setVersion(policy.version()); - return policyPb; - } - - static IamPolicy policyFromPb( - com.google.api.services.cloudresourcemanager.model.Policy policyPb) { - IamPolicy.Builder builder = new IamPolicy.Builder(); - builder.acls(Lists.transform(policyPb.getBindings(), - new Function() { - @Override - public Acl apply(com.google.api.services.cloudresourcemanager.model.Binding binding) { - return aclFromPb(binding); - } - })); - return builder.etag(policyPb.getEtag()).version(policyPb.getVersion()).build(); - } } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/IamPolicyTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/IamPolicyTest.java new file mode 100644 index 000000000000..e2f05ac8493b --- /dev/null +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/IamPolicyTest.java @@ -0,0 +1,91 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.resourcemanager; + +import static org.junit.Assert.assertEquals; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.gcloud.BaseIamPolicy.Identity; + +import org.junit.Test; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class IamPolicyTest { + + private static final Identity ALL_USERS = Identity.allUsers(); + private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); + private static final Identity USER = Identity.user("abc@gmail.com"); + private static final Identity SERVICE_ACCOUNT = + Identity.serviceAccount("service-account@gmail.com"); + private static final Identity GROUP = Identity.group("group@gmail.com"); + private static final Identity DOMAIN = Identity.domain("google.com"); + private static final Map> BINDINGS = ImmutableMap.of( + "viewer", + ImmutableList.of(USER, SERVICE_ACCOUNT, ALL_USERS), + "editor", + ImmutableList.of(ALL_AUTH_USERS, GROUP, DOMAIN)); + private static final IamPolicy SIMPLE_POLICY = IamPolicy.builder() + .addBinding("viewer", ImmutableList.of(USER, SERVICE_ACCOUNT, ALL_USERS)) + .addBinding("editor", ImmutableList.of(ALL_AUTH_USERS, GROUP, DOMAIN)) + .build(); + private static final IamPolicy FULL_POLICY = + new IamPolicy.Builder(SIMPLE_POLICY.bindings(), "etag", 1).build(); + + @Test + public void testIamPolicyBuilder() { + assertEquals(BINDINGS, FULL_POLICY.bindings()); + assertEquals("etag", FULL_POLICY.etag()); + assertEquals(1, FULL_POLICY.version()); + Map> editorBinding = new HashMap<>(); + editorBinding.put("editor", BINDINGS.get("editor")); + IamPolicy policy = FULL_POLICY.toBuilder().bindings(editorBinding).build(); + assertEquals(ImmutableMap.of("editor", BINDINGS.get("editor")), policy.bindings()); + assertEquals("etag", policy.etag()); + assertEquals(1, policy.version()); + policy = SIMPLE_POLICY.toBuilder().removeBinding("editor").build(); + assertEquals(ImmutableMap.of("viewer", BINDINGS.get("viewer")), policy.bindings()); + assertEquals(null, policy.etag()); + assertEquals(0, policy.version()); + } + + @Test + public void testIamPolicyToBuilder() { + assertEquals(FULL_POLICY, FULL_POLICY.toBuilder().build()); + assertEquals(SIMPLE_POLICY, SIMPLE_POLICY.toBuilder().build()); + } + + @Test + public void testIdentityToAndFromPb() { + assertEquals(ALL_USERS, IamPolicy.identityFromPb(IamPolicy.identityToPb(ALL_USERS))); + assertEquals(ALL_AUTH_USERS, IamPolicy.identityFromPb(IamPolicy.identityToPb(ALL_AUTH_USERS))); + assertEquals(USER, IamPolicy.identityFromPb(IamPolicy.identityToPb(USER))); + assertEquals( + SERVICE_ACCOUNT, IamPolicy.identityFromPb(IamPolicy.identityToPb(SERVICE_ACCOUNT))); + assertEquals(GROUP, IamPolicy.identityFromPb(IamPolicy.identityToPb(GROUP))); + assertEquals(DOMAIN, IamPolicy.identityFromPb(IamPolicy.identityToPb(DOMAIN))); + } + + @Test + public void testPolicyToAndFromPb() { + assertEquals(FULL_POLICY, IamPolicy.fromPb(FULL_POLICY.toPb())); + assertEquals(SIMPLE_POLICY, IamPolicy.fromPb(SIMPLE_POLICY.toPb())); + } +} diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java index 623bf68d085c..37c54718fb4a 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java @@ -25,9 +25,6 @@ import static org.junit.Assert.fail; import com.google.common.collect.ImmutableMap; -import com.google.gcloud.IamPolicy; -import com.google.gcloud.IamPolicy.Acl; -import com.google.gcloud.IamPolicy.Identity; import com.google.gcloud.Page; import com.google.gcloud.resourcemanager.ProjectInfo.ResourceId; import com.google.gcloud.resourcemanager.ResourceManager.ProjectField; @@ -67,18 +64,6 @@ public class ResourceManagerImplTest { .parent(PARENT) .build(); private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); - private static final Identity ALL_USERS = Identity.allUsers(); - private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); - private static final Identity USER = Identity.user("abc@gmail.com"); - private static final Identity SERVICE_ACCOUNT = - Identity.serviceAccount("service-account@gmail.com"); - private static final Identity GROUP = Identity.group("group@gmail.com"); - private static final Identity DOMAIN = Identity.domain("google.com"); - private static final Acl ACL1 = Acl.of("viewer", USER, SERVICE_ACCOUNT, ALL_USERS); - private static final Acl ACL2 = Acl.of("editor", ALL_AUTH_USERS, GROUP, DOMAIN); - private static final IamPolicy FULL_POLICY = - IamPolicy.builder().addAcl(ACL1, ACL2).etag("etag").version(1).build(); - private static final IamPolicy SIMPLE_POLICY = IamPolicy.builder().addAcl(ACL1, ACL2).build(); @Rule public ExpectedException thrown = ExpectedException.none(); @@ -286,35 +271,6 @@ public void testUndelete() { } } - @Test - public void testIdentityToAndFromPb() { - assertEquals(ALL_USERS, - ResourceManagerImpl.identityFromPb(ResourceManagerImpl.identityToPb(ALL_USERS))); - assertEquals(ALL_AUTH_USERS, - ResourceManagerImpl.identityFromPb( - ResourceManagerImpl.identityToPb(ALL_AUTH_USERS))); - assertEquals(USER, ResourceManagerImpl.identityFromPb(ResourceManagerImpl.identityToPb(USER))); - assertEquals(SERVICE_ACCOUNT, - ResourceManagerImpl.identityFromPb(ResourceManagerImpl.identityToPb(SERVICE_ACCOUNT))); - assertEquals(GROUP, - ResourceManagerImpl.identityFromPb(ResourceManagerImpl.identityToPb(GROUP))); - assertEquals(DOMAIN, - ResourceManagerImpl.identityFromPb(ResourceManagerImpl.identityToPb(DOMAIN))); - } - - @Test - public void testAclToAndFromPb() { - assertEquals(ACL1, ResourceManagerImpl.aclFromPb(ResourceManagerImpl.aclToPb(ACL1))); - } - - @Test - public void testPolicyToAndFromPb() { - assertEquals(FULL_POLICY, - ResourceManagerImpl.policyFromPb(ResourceManagerImpl.policyToPb(FULL_POLICY))); - assertEquals(SIMPLE_POLICY, - ResourceManagerImpl.policyFromPb(ResourceManagerImpl.policyToPb(SIMPLE_POLICY))); - } - @Test public void testRetryableException() { ResourceManagerRpcFactory rpcFactoryMock = EasyMock.createMock(ResourceManagerRpcFactory.class); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index 497de880254a..1049f40f5f17 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -19,7 +19,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.gcloud.BaseIamPolicy.Identity; import com.google.gcloud.PageImpl; import com.google.gcloud.RetryParams; @@ -53,6 +55,9 @@ public class SerializationTest { ResourceManager.ProjectGetOption.fields(ResourceManager.ProjectField.NAME); private static final ResourceManager.ProjectListOption PROJECT_LIST_OPTION = ResourceManager.ProjectListOption.filter("name:*"); + private static final Identity IDENTITY = Identity.user("abc@gmail.com"); + private static final IamPolicy POLICY = + IamPolicy.builder().addBinding("viewer", ImmutableList.of(IDENTITY)).build(); @Test public void testServiceOptions() throws Exception { @@ -70,7 +75,7 @@ public void testServiceOptions() throws Exception { @Test public void testModelAndRequests() throws Exception { Serializable[] objects = {PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PROJECT, PAGE_RESULT, - PROJECT_GET_OPTION, PROJECT_LIST_OPTION}; + PROJECT_GET_OPTION, PROJECT_LIST_OPTION, IDENTITY, POLICY}; for (Serializable obj : objects) { Object copy = serializeAndDeserialize(obj); assertEquals(obj, obj); From 04f354a16a8759af38d3e883b9bb9dcc467744f3 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 23 Feb 2016 11:38:51 -0800 Subject: [PATCH 083/203] Added RPC layer of tests for local helpers. Closes #665. Debugged parsing for options. Fixed context for the server URLs and regular expression parsing. Fixed paging. Improved error detection for missing zones vs. non-existent changes. --- .../com/google/gcloud/spi/DefaultDnsRpc.java | 4 +- .../google/gcloud/testing/LocalDnsHelper.java | 126 +- .../testing/OptionParsersAndExtractors.java | 31 +- .../gcloud/testing/LocalDnsHelperTest.java | 1176 ++++++++++++++--- 4 files changed, 1097 insertions(+), 240 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java index 6ed9c7e0f216..b72a21445a80 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java @@ -162,7 +162,9 @@ public Change getChangeRequest(String zoneName, String changeRequestId, MapWhile the mock attempts to simulate the service, there are some differences in the behaviour. * The mock will accept any project ID and never returns a notFound or another error because of - * project ID. It assumes that all project IDs exists and that the user has all the necessary + * project ID. It assumes that all project IDs exist and that the user has all the necessary * privileges to manipulate any project. Similarly, the local simulation does not work with any * verification of domain name ownership. Any request for creating a managed zone will be approved. * The mock does not track quota and will allow the user to exceed it. The mock provides only basic @@ -92,11 +93,10 @@ public class LocalDnsHelper { = new ConcurrentSkipListMap<>(); private static final URI BASE_CONTEXT; private static final Logger log = Logger.getLogger(LocalDnsHelper.class.getName()); - private static final JsonFactory jsonFactory = - new com.google.api.client.json.jackson.JacksonFactory(); + private static final JsonFactory jsonFactory = new JacksonFactory(); private static final Random ID_GENERATOR = new Random(); private static final String VERSION = "v1"; - private static final String CONTEXT = "/" + VERSION + "/projects"; + private static final String CONTEXT = "/dns/" + VERSION + "/projects"; private static final Set SUPPORTED_COMPRESSION_ENCODINGS = ImmutableSet.of("gzip", "x-gzip"); private static final List TYPES = ImmutableList.of("A", "AAAA", "CNAME", "MX", "NAPTR", @@ -119,15 +119,15 @@ public class LocalDnsHelper { * For matching URLs to operations. */ private enum CallRegex { - CHANGE_CREATE("POST", "/[^/]+/managedZones/[^/]+/changes"), - CHANGE_GET("GET", "/[^/]+/managedZones/[^/]+/changes/[^/]+"), - CHANGE_LIST("GET", "/[^/]+/managedZones/[^/]+/changes"), - ZONE_CREATE("POST", "/[^/]+/managedZones"), - ZONE_DELETE("DELETE", "/[^/]+/managedZones/[^/]+"), - ZONE_GET("GET", "/[^/]+/managedZones/[^/]+"), - ZONE_LIST("GET", "/[^/]+/managedZones"), - PROJECT_GET("GET", "/[^/]+"), - RECORD_LIST("GET", "/[^/]+/managedZones/[^/]+/rrsets"); + CHANGE_CREATE("POST", CONTEXT + "/[^/]+/managedZones/[^/]+/changes"), + CHANGE_GET("GET", CONTEXT + "/[^/]+/managedZones/[^/]+/changes/[^/]+"), + CHANGE_LIST("GET", CONTEXT + "/[^/]+/managedZones/[^/]+/changes"), + ZONE_CREATE("POST", CONTEXT + "/[^/]+/managedZones"), + ZONE_DELETE("DELETE", CONTEXT + "/[^/]+/managedZones/[^/]+"), + ZONE_GET("GET", CONTEXT + "/[^/]+/managedZones/[^/]+"), + ZONE_LIST("GET", CONTEXT + "/[^/]+/managedZones"), + PROJECT_GET("GET", CONTEXT + "/[^/]+"), + RECORD_LIST("GET", CONTEXT + "/[^/]+/managedZones/[^/]+/rrsets"); private String method; private String pathRegex; @@ -220,14 +220,14 @@ ConcurrentSkipListMap zones() { } /** - * Associates a zone with a collection of changes and dns record. Thread safe. + * Associates a zone with a collection of changes and dns records. Thread safe. */ static class ZoneContainer { private final ManagedZone zone; /** * DNS records are held in a map to allow for atomic replacement of record sets when applying * changes. The key for the map is always the zone name. The collection of records is immutable - * and must always exist, i.e., dnsRecords.get(zone.getName()) is never null. + * and must always exist, i.e., dnsRecords.get(zone.getName()) is never {@code null}. */ private final ConcurrentSkipListMap> dnsRecords = new ConcurrentSkipListMap<>(); @@ -377,20 +377,19 @@ public void handle(HttpExchange exchange) throws IOException { writeResponse(exchange, Error.NOT_FOUND.response("The url does not match any API call.")); } - // todo(mderka) Test handlers using gcloud-java-dns. Issue #665. private Response handleZoneDelete(HttpExchange exchange) { String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); String[] tokens = path.split("/"); - String projectId = tokens[1]; - String zoneName = tokens[3]; + String projectId = tokens[0]; + String zoneName = tokens[2]; return deleteZone(projectId, zoneName); } private Response handleZoneGet(HttpExchange exchange) { String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); String[] tokens = path.split("/"); - String projectId = tokens[1]; - String zoneName = tokens[3]; + String projectId = tokens[0]; + String zoneName = tokens[2]; String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); String[] fields = OptionParsersAndExtractors.parseGetOptions(query); return getZone(projectId, zoneName, fields); @@ -399,7 +398,7 @@ private Response handleZoneGet(HttpExchange exchange) { private Response handleZoneList(HttpExchange exchange) { String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); String[] tokens = path.split("/"); - String projectId = tokens[1]; + String projectId = tokens[0]; String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); Map options = OptionParsersAndExtractors.parseListZonesOptions(query); return listZones(projectId, options); @@ -408,7 +407,7 @@ private Response handleZoneList(HttpExchange exchange) { private Response handleProjectGet(HttpExchange exchange) { String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); String[] tokens = path.split("/"); - String projectId = tokens[1]; + String projectId = tokens[0]; String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); String[] fields = OptionParsersAndExtractors.parseGetOptions(query); return getProject(projectId, fields); @@ -420,8 +419,8 @@ private Response handleProjectGet(HttpExchange exchange) { private Response handleChangeCreate(HttpExchange exchange) throws IOException { String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); String[] tokens = path.split("/"); - String projectId = tokens[1]; - String zoneName = tokens[3]; + String projectId = tokens[0]; + String zoneName = tokens[2]; String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); String[] fields = OptionParsersAndExtractors.parseGetOptions(query); String requestBody = decodeContent(exchange.getRequestHeaders(), exchange.getRequestBody()); @@ -432,9 +431,9 @@ private Response handleChangeCreate(HttpExchange exchange) throws IOException { private Response handleChangeGet(HttpExchange exchange) { String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); String[] tokens = path.split("/"); - String projectId = tokens[1]; - String zoneName = tokens[3]; - String changeId = tokens[5]; + String projectId = tokens[0]; + String zoneName = tokens[2]; + String changeId = tokens[4]; String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); String[] fields = OptionParsersAndExtractors.parseGetOptions(query); return getChange(projectId, zoneName, changeId, fields); @@ -443,8 +442,8 @@ private Response handleChangeGet(HttpExchange exchange) { private Response handleChangeList(HttpExchange exchange) { String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); String[] tokens = path.split("/"); - String projectId = tokens[1]; - String zoneName = tokens[3]; + String projectId = tokens[0]; + String zoneName = tokens[2]; String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); Map options = OptionParsersAndExtractors.parseListChangesOptions(query); return listChanges(projectId, zoneName, options); @@ -453,8 +452,8 @@ private Response handleChangeList(HttpExchange exchange) { private Response handleDnsRecordList(HttpExchange exchange) { String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); String[] tokens = path.split("/"); - String projectId = tokens[1]; - String zoneName = tokens[3]; + String projectId = tokens[0]; + String zoneName = tokens[2]; String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); Map options = OptionParsersAndExtractors.parseListDnsRecordsOptions(query); return listDnsRecords(projectId, zoneName, options); @@ -466,7 +465,7 @@ private Response handleDnsRecordList(HttpExchange exchange) { private Response handleZoneCreate(HttpExchange exchange) throws IOException { String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); String[] tokens = path.split("/"); - String projectId = tokens[1]; + String projectId = tokens[0]; String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); String[] options = OptionParsersAndExtractors.parseGetOptions(query); String requestBody = decodeContent(exchange.getRequestHeaders(), exchange.getRequestBody()); @@ -539,7 +538,9 @@ private static void writeResponse(HttpExchange exchange, Response response) { try { exchange.getResponseHeaders().add("Connection", "close"); exchange.sendResponseHeaders(response.code(), response.body().length()); - outputStream.write(response.body().getBytes(StandardCharsets.UTF_8)); + if (response.code() != 204) { + outputStream.write(response.body().getBytes(StandardCharsets.UTF_8)); + } outputStream.close(); } catch (IOException e) { log.log(Level.WARNING, "IOException encountered when sending response.", e); @@ -569,18 +570,20 @@ private static String decodeContent(Headers headers, InputStream inputStream) th } /** - * Generates a JSON response. Tested. + * Generates a JSON response. + * + * @param context managedZones | projects | rrsets | changes */ - static Response toListResponse(List serializedObjects, String pageToken, + static Response toListResponse(List serializedObjects, String context, String pageToken, boolean includePageToken) { // start building response StringBuilder responseBody = new StringBuilder(); - responseBody.append("{\"projects\": ["); + responseBody.append("{\"").append(context).append("\": ["); Joiner.on(",").appendTo(responseBody, serializedObjects); responseBody.append("]"); // add page token only if exists and is asked for if (pageToken != null && includePageToken) { - responseBody.append(",\"pageToken\": \"").append(pageToken).append("\""); + responseBody.append(",\"nextPageToken\": \"").append(pageToken).append("\""); } responseBody.append("}"); return new Response(HTTP_OK, responseBody.toString()); @@ -627,14 +630,13 @@ static List randomNameservers() { } /** - * Returns a hex string id (used for a dns record) unique withing the set of wrappers. + * Returns a hex string id (used for a dns record) unique within the set of wrappers. */ static String getUniqueId(List wrappers) { TreeSet ids = Sets.newTreeSet(Lists.transform(wrappers, new Function() { - @Nullable @Override - public String apply(@Nullable RrsetWrapper input) { + public String apply(RrsetWrapper input) { return input.id() == null ? "null" : input.id(); } })); @@ -663,7 +665,8 @@ static boolean matchesCriteria(ResourceRecordSet record, String name, String typ } /** - * Returns a project container. Never returns null because we assume that all projects exists. + * Returns a project container. Never returns {@code null} because we assume that all projects + * exists. */ ProjectContainer findProject(String projectId) { ProjectContainer defaultProject = createProject(projectId); @@ -672,7 +675,7 @@ ProjectContainer findProject(String projectId) { } /** - * Returns a zone container. Returns null if zone does not exist within project. + * Returns a zone container. Returns {@code null} if zone does not exist within project. */ ZoneContainer findZone(String projectId, String zoneName) { ProjectContainer projectContainer = findProject(projectId); // never null @@ -680,7 +683,7 @@ ZoneContainer findZone(String projectId, String zoneName) { } /** - * Returns a change found by its id. Returns null if such a change does not exist. + * Returns a change found by its id. Returns {@code null} if such a change does not exist. */ Change findChange(String projectId, String zoneName, String changeId) { ZoneContainer wrapper = findZone(projectId, zoneName); @@ -688,7 +691,7 @@ Change findChange(String projectId, String zoneName, String changeId) { } /** - * Returns a response to get change call. + * Returns a response to getChange service call. */ Response getChange(String projectId, String zoneName, String changeId, String[] fields) { Change change = findChange(projectId, zoneName, changeId); @@ -711,11 +714,10 @@ Response getChange(String projectId, String zoneName, String changeId, String[] "Error when serializing change %s in managed zone %s in project %s.", changeId, zoneName, projectId)); } - // todo(mderka) Test field options within #665. } /** - * Returns a response to get zone call. + * Returns a response to getZone service call. */ Response getZone(String projectId, String zoneName, String[] fields) { ZoneContainer container = findZone(projectId, zoneName); @@ -730,7 +732,6 @@ Response getZone(String projectId, String zoneName, String[] fields) { return Error.INTERNAL_ERROR.response(String.format( "Error when serializing managed zone %s in project %s.", zoneName, projectId)); } - // todo(mderka) Test field options within #665. } /** @@ -748,7 +749,6 @@ Response getProject(String projectId, String[] fields) { return Error.INTERNAL_ERROR.response( String.format("Error when serializing project %s.", projectId)); } - // todo(mderka) Test field options within #665. } /** @@ -798,6 +798,7 @@ Response createZone(String projectId, ManagedZone zone, String[] fields) { ManagedZone completeZone = new ManagedZone(); completeZone.setName(zone.getName()); completeZone.setDnsName(zone.getDnsName()); + completeZone.setDescription(zone.getDescription()); completeZone.setNameServerSet(zone.getNameServerSet()); completeZone.setCreationTime(ISODateTimeFormat.dateTime().withZoneUTC() .print(System.currentTimeMillis())); @@ -823,7 +824,6 @@ Response createZone(String projectId, ManagedZone zone, String[] fields) { return Error.INTERNAL_ERROR.response( String.format("Error when serializing managed zone %s.", result.getName())); } - // todo(mderka) Test field options within #665. } /** @@ -873,7 +873,6 @@ we will reset all IDs in this range (all of them are valid) */ String.format("Error when serializing change %s in managed zone %s in project %s.", result.getId(), zoneName, projectId)); } - // todo(mderka) Test field options within #665. } /** @@ -969,13 +968,13 @@ Response listZones(String projectId, Map options) { ManagedZone zone = zoneContainer.zone(); if (listing) { if (dnsName == null || zone.getDnsName().equals(dnsName)) { - lastZoneName = zone.getName(); if (sizeReached) { // we do not add this, just note that there would be more and there should be a token hasMorePages = true; break; } else { try { + lastZoneName = zone.getName(); serializedZones.addLast(jsonFactory.toString( OptionParsersAndExtractors.extractFields(zone, fields))); } catch (IOException e) { @@ -991,9 +990,8 @@ Response listZones(String projectId, Map options) { sizeReached = (maxResults != null) && maxResults.equals(serializedZones.size()); } boolean includePageToken = - hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("pageToken")); - return toListResponse(serializedZones, lastZoneName, includePageToken); - // todo(mderka) Test field and listing options within #665. + hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("nextPageToken")); + return toListResponse(serializedZones, "managedZones", lastZoneName, includePageToken); } /** @@ -1025,12 +1023,12 @@ Response listDnsRecords(String projectId, String zoneName, Map o ResourceRecordSet record = recordWrapper.rrset(); if (listing) { if (matchesCriteria(record, name, type)) { - lastRecordId = recordWrapper.id(); if (sizeReached) { // we do not add this, just note that there would be more and there should be a token hasMorePages = true; break; } else { + lastRecordId = recordWrapper.id(); try { serializedRrsets.addLast(jsonFactory.toString( OptionParsersAndExtractors.extractFields(record, fields))); @@ -1047,9 +1045,8 @@ Response listDnsRecords(String projectId, String zoneName, Map o sizeReached = (maxResults != null) && maxResults.equals(serializedRrsets.size()); } boolean includePageToken = - hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("pageToken")); - return toListResponse(serializedRrsets, lastRecordId, includePageToken); - // todo(mderka) Test field and listing options within #665. + hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("nextPageToken")); + return toListResponse(serializedRrsets, "rrsets", lastRecordId, includePageToken); } /** @@ -1061,6 +1058,10 @@ Response listChanges(String projectId, String zoneName, Map opti return response; } ZoneContainer zoneContainer = findZone(projectId, zoneName); + if (zoneContainer == null) { + return Error.NOT_FOUND.response(String.format( + "The 'parameters.managedZone' resource named '%s' does not exist", zoneName)); + } // take a sorted snapshot of the current change list TreeMap changes = new TreeMap<>(); for (Change c : zoneContainer.changes()) { @@ -1088,12 +1089,12 @@ Response listChanges(String projectId, String zoneName, Map opti for (Integer key : keys) { Change change = changes.get(key); if (listing) { - lastChangeId = change.getId(); if (sizeReached) { // we do not add this, just note that there would be more and there should be a token hasMorePages = true; break; } else { + lastChangeId = change.getId(); try { serializedResults.addLast(jsonFactory.toString( OptionParsersAndExtractors.extractFields(change, fields))); @@ -1110,9 +1111,8 @@ Response listChanges(String projectId, String zoneName, Map opti sizeReached = (maxResults != null) && maxResults.equals(serializedResults.size()); } boolean includePageToken = - hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("pageToken")); - return toListResponse(serializedResults, lastChangeId, includePageToken); - // todo(mderka) Test field and listing options within #665. + hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("nextPageToken")); + return toListResponse(serializedResults, "changes", lastChangeId, includePageToken); } /** diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java b/gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java index f94cb15779ca..26759f7e3ccc 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java @@ -42,14 +42,19 @@ static Map parseListZonesOptions(String query) { switch (argEntry[0]) { case "fields": // List fields are in the form "managedZones(field1, field2, ...)" + String replaced = argEntry[1].replace("managedZones(", ","); + replaced = replaced.replace(")", ","); + // we will get empty strings, but it does not matter, they will be ignored options.put( "fields", - argEntry[1].substring("managedZones(".length(), argEntry[1].length() - 1) - .split(",")); + replaced.split(",")); break; case "dnsName": options.put("dnsName", argEntry[1]); break; + case "nextPageToken": + options.put("nextPageToken", argEntry[1]); + break; case "pageToken": options.put("pageToken", argEntry[1]); break; @@ -218,14 +223,16 @@ static Map parseListChangesOptions(String query) { String[] argEntry = arg.split("="); switch (argEntry[0]) { case "fields": - // todo we do not support fragmentation in deletions and additions - options.put( - "fields", - argEntry[1].substring("changes(".length(), argEntry[1].length() - 1).split(",")); + // todo we do not support fragmentation in deletions and additions in the library + String replaced = argEntry[1].replace("changes(", ",").replace(")", ","); + options.put("fields", replaced.split(",")); // empty strings will be ignored break; case "name": options.put("name", argEntry[1]); break; + case "nextPageToken": + options.put("nextPageToken", argEntry[1]); + break; case "pageToken": options.put("pageToken", argEntry[1]); break; @@ -255,16 +262,22 @@ static Map parseListDnsRecordsOptions(String query) { String[] argEntry = arg.split("="); switch (argEntry[0]) { case "fields": - options.put( - "fields", - argEntry[1].substring("rrsets(".length(), argEntry[1].length() - 1).split(",")); + String replace = argEntry[1].replace("rrsets(", ","); + replace = replace.replace(")", ","); + options.put("fields", replace.split(",")); // empty strings do not matter break; case "name": options.put("name", argEntry[1]); break; + case "type": + options.put("type", argEntry[1]); + break; case "pageToken": options.put("pageToken", argEntry[1]); break; + case "nextPageToken": + options.put("nextPageToken", argEntry[1]); + break; case "maxResults": // parsing to int is done while handling options.put("maxResults", argEntry[1]); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/testing/LocalDnsHelperTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/testing/LocalDnsHelperTest.java index 1f851045659c..7a97b69846ef 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/testing/LocalDnsHelperTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/testing/LocalDnsHelperTest.java @@ -18,6 +18,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -25,11 +26,16 @@ import com.google.api.services.dns.model.Change; import com.google.api.services.dns.model.ManagedZone; +import com.google.api.services.dns.model.Project; import com.google.api.services.dns.model.ResourceRecordSet; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import com.google.gcloud.dns.DnsException; +import com.google.gcloud.spi.DefaultDnsRpc; +import com.google.gcloud.spi.DnsRpc; -import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -55,8 +61,14 @@ public class LocalDnsHelperTest { private static final Change CHANGE1 = new Change(); private static final Change CHANGE2 = new Change(); private static final Change CHANGE_KEEP = new Change(); + private static final Change CHANGE_COMPLEX = new Change(); + private static final LocalDnsHelper LOCAL_DNS_HELPER = LocalDnsHelper.create(0L); // synchronous + private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); + private static final DnsRpc RPC = + new DefaultDnsRpc(LOCAL_DNS_HELPER.options()); + private static final String REAL_PROJECT_ID = LOCAL_DNS_HELPER.options().projectId(); private Map optionsMap; - private LocalDnsHelper localDns; + private ManagedZone minimalZone = new ManagedZone(); // to be adjusted as needed @BeforeClass @@ -67,9 +79,11 @@ public static void before() { ZONE1.setName(ZONE_NAME1); ZONE1.setDescription(""); ZONE1.setDnsName(DNS_NAME); + ZONE1.setNameServerSet("somenameserveset"); ZONE2.setName(ZONE_NAME2); ZONE2.setDescription(""); ZONE2.setDnsName(DNS_NAME); + ZONE2.setNameServerSet("somenameserveset"); RRSET2.setName(DNS_NAME); RRSET2.setType(RRSET_TYPE); RRSET_KEEP.setName(DNS_NAME); @@ -79,18 +93,27 @@ public static void before() { CHANGE1.setAdditions(ImmutableList.of(RRSET1, RRSET2)); CHANGE2.setDeletions(ImmutableList.of(RRSET2)); CHANGE_KEEP.setAdditions(ImmutableList.of(RRSET_KEEP)); + CHANGE_COMPLEX.setAdditions(ImmutableList.of(RRSET_KEEP)); + CHANGE_COMPLEX.setDeletions(ImmutableList.of(RRSET_KEEP)); + LOCAL_DNS_HELPER.start(); } @Before public void setUp() { - localDns = LocalDnsHelper.create(0L); // synchronous + resetProjects(); optionsMap = new HashMap<>(); minimalZone = copyZone(ZONE1); } - @After - public void after() { - localDns = null; + private static void resetProjects() { + for (String project : LOCAL_DNS_HELPER.projects().keySet()) { + LOCAL_DNS_HELPER.projects().remove(project); + } + } + + @AfterClass + public static void after() { + LOCAL_DNS_HELPER.stop(); } @Test @@ -109,13 +132,13 @@ public void testGetUniqueId() { @Test public void testFindProject() { - assertEquals(0, localDns.projects().size()); - LocalDnsHelper.ProjectContainer project = localDns.findProject(PROJECT_ID1); + assertEquals(0, LOCAL_DNS_HELPER.projects().size()); + LocalDnsHelper.ProjectContainer project = LOCAL_DNS_HELPER.findProject(PROJECT_ID1); assertNotNull(project); - assertTrue(localDns.projects().containsKey(PROJECT_ID1)); - assertNotNull(localDns.findProject(PROJECT_ID2)); - assertTrue(localDns.projects().containsKey(PROJECT_ID2)); - assertTrue(localDns.projects().containsKey(PROJECT_ID1)); + assertTrue(LOCAL_DNS_HELPER.projects().containsKey(PROJECT_ID1)); + assertNotNull(LOCAL_DNS_HELPER.findProject(PROJECT_ID2)); + assertTrue(LOCAL_DNS_HELPER.projects().containsKey(PROJECT_ID2)); + assertTrue(LOCAL_DNS_HELPER.projects().containsKey(PROJECT_ID1)); assertNotNull(project.zones()); assertEquals(0, project.zones().size()); assertNotNull(project.project()); @@ -124,11 +147,11 @@ public void testFindProject() { @Test public void testCreateAndFindZone() { - LocalDnsHelper.ZoneContainer zone1 = localDns.findZone(PROJECT_ID1, ZONE_NAME1); - assertTrue(localDns.projects().containsKey(PROJECT_ID1)); + LocalDnsHelper.ZoneContainer zone1 = LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE_NAME1); + assertTrue(LOCAL_DNS_HELPER.projects().containsKey(PROJECT_ID1)); assertNull(zone1); - localDns.createZone(PROJECT_ID1, ZONE1, null); // we do not care about options - zone1 = localDns.findZone(PROJECT_ID1, ZONE1.getName()); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); // we do not care about options + zone1 = LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE1.getName()); assertNotNull(zone1); // cannot call equals because id and timestamp got assigned assertEquals(ZONE_NAME1, zone1.zone().getName()); @@ -136,56 +159,99 @@ public void testCreateAndFindZone() { assertTrue(zone1.changes().isEmpty()); assertNotNull(zone1.dnsRecords()); assertEquals(2, zone1.dnsRecords().get(ZONE_NAME1).size()); // default SOA and NS - localDns.createZone(PROJECT_ID2, ZONE1, null); // project does not exits yet - assertEquals(ZONE1.getName(), localDns.findZone(PROJECT_ID2, ZONE_NAME1).zone().getName()); + LOCAL_DNS_HELPER.createZone(PROJECT_ID2, ZONE1, null); // project does not exits yet + assertEquals(ZONE1.getName(), + LOCAL_DNS_HELPER.findZone(PROJECT_ID2, ZONE_NAME1).zone().getName()); + } + + @Test + public void testCreateAndFindZoneUsingRpc() { + // zone does not exist yet + ManagedZone zone1 = RPC.getZone(ZONE_NAME1, EMPTY_RPC_OPTIONS); + assertTrue(LOCAL_DNS_HELPER.projects().containsKey(REAL_PROJECT_ID)); // check internal state + assertNull(zone1); + // create zone + ManagedZone createdZone = RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + assertEquals(ZONE1.getName(), createdZone.getName()); + assertEquals(ZONE1.getDescription(), createdZone.getDescription()); + assertEquals(ZONE1.getDnsName(), createdZone.getDnsName()); + assertEquals(4, createdZone.getNameServers().size()); + // get the same zone zone + ManagedZone zone = RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS); + assertEquals(createdZone, zone); + // check that default records were created + DnsRpc.ListResult resourceRecordSetListResult + = RPC.listDnsRecords(ZONE1.getName(), EMPTY_RPC_OPTIONS); + assertEquals(2, Lists.newLinkedList(resourceRecordSetListResult.results()).size()); } @Test public void testDeleteZone() { - localDns.createZone(PROJECT_ID1, ZONE1, null); - LocalDnsHelper.Response response = localDns.deleteZone(PROJECT_ID1, ZONE1.getName()); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); + LocalDnsHelper.Response response = LOCAL_DNS_HELPER.deleteZone(PROJECT_ID1, ZONE1.getName()); assertEquals(204, response.code()); // deleting non-existent zone - response = localDns.deleteZone(PROJECT_ID1, ZONE1.getName()); + response = LOCAL_DNS_HELPER.deleteZone(PROJECT_ID1, ZONE1.getName()); assertEquals(404, response.code()); - assertNull(localDns.findZone(PROJECT_ID1, ZONE1.getName())); - localDns.createZone(PROJECT_ID1, ZONE1, null); - localDns.createZone(PROJECT_ID1, ZONE2, null); - assertNotNull(localDns.findZone(PROJECT_ID1, ZONE1.getName())); - assertNotNull(localDns.findZone(PROJECT_ID1, ZONE2.getName())); + assertNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE1.getName())); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE2, null); + assertNotNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE1.getName())); + assertNotNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE2.getName())); // delete in reverse order - response = localDns.deleteZone(PROJECT_ID1, ZONE1.getName()); + response = LOCAL_DNS_HELPER.deleteZone(PROJECT_ID1, ZONE1.getName()); assertEquals(204, response.code()); - assertNull(localDns.findZone(PROJECT_ID1, ZONE1.getName())); - assertNotNull(localDns.findZone(PROJECT_ID1, ZONE2.getName())); - localDns.deleteZone(PROJECT_ID1, ZONE2.getName()); + assertNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE1.getName())); + assertNotNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE2.getName())); + LOCAL_DNS_HELPER.deleteZone(PROJECT_ID1, ZONE2.getName()); assertEquals(204, response.code()); - assertNull(localDns.findZone(PROJECT_ID1, ZONE1.getName())); - assertNull(localDns.findZone(PROJECT_ID1, ZONE2.getName())); + assertNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE1.getName())); + assertNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE2.getName())); + } + + @Test + public void testDeleteZoneUsingRpc() { + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + assertTrue(RPC.deleteZone(ZONE1.getName())); + assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); + // deleting non-existent zone + assertFalse(RPC.deleteZone(ZONE1.getName())); + assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + RPC.create(ZONE2, EMPTY_RPC_OPTIONS); + assertNotNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); + assertNotNull(RPC.getZone(ZONE2.getName(), EMPTY_RPC_OPTIONS)); + // delete in reverse order + assertTrue(RPC.deleteZone(ZONE1.getName())); + assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); + assertNotNull(RPC.getZone(ZONE2.getName(), EMPTY_RPC_OPTIONS)); + assertTrue(RPC.deleteZone(ZONE2.getName())); + assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); + assertNull(RPC.getZone(ZONE2.getName(), EMPTY_RPC_OPTIONS)); } @Test public void testCreateAndApplyChange() { - localDns = LocalDnsHelper.create(5 * 1000L); // we will be using threads here - localDns.createZone(PROJECT_ID1, ZONE1, null); - assertNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); + LocalDnsHelper localDnsThreaded = LocalDnsHelper.create(5 * 1000L); // using threads here + localDnsThreaded.createZone(PROJECT_ID1, ZONE1, null); + assertNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); LocalDnsHelper.Response response - = localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add + = localDnsThreaded.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add assertEquals(200, response.code()); - assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); - assertNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); - localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add + assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); + assertNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); + localDnsThreaded.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add + response = localDnsThreaded.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add assertEquals(200, response.code()); - assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); - assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); - localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); // delete - assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); - assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); - assertNotNull(localDns.findZone(PROJECT_ID1, ZONE_NAME1).findChange("3")); - localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE_KEEP, null); // id is "4" + assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); + assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); + localDnsThreaded.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); // delete + assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); + assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); + assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("3")); + localDnsThreaded.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE_KEEP, null); // id is "4" // check execution - Change change = localDns.findChange(PROJECT_ID1, ZONE_NAME1, "4"); + Change change = localDnsThreaded.findChange(PROJECT_ID1, ZONE_NAME1, "4"); for (int i = 0; i < 10 && !change.getStatus().equals("done"); i++) { // change has not been finished yet; wait at most 20 seconds // it takes 5 seconds for the thread to kick in in the first place @@ -197,26 +263,70 @@ public void testCreateAndApplyChange() { } assertEquals("done", change.getStatus()); List list = - localDns.findZone(PROJECT_ID1, ZONE_NAME1).dnsRecords().get(ZONE_NAME1); + localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).dnsRecords().get(ZONE_NAME1); assertTrue(list.contains(new LocalDnsHelper.RrsetWrapper(RRSET_KEEP))); + localDnsThreaded.stop(); + } + + @Test + public void testCreateAndApplyChangeUsingRpc() { + // not using threads + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + assertNull(RPC.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS)); + //add + Change createdChange = RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); + assertEquals(createdChange.getAdditions(), CHANGE1.getAdditions()); + assertEquals(createdChange.getDeletions(), CHANGE1.getDeletions()); + assertNotNull(createdChange.getStartTime()); + assertEquals("1", createdChange.getId()); + Change retrievedChange = RPC.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS); + assertEquals(createdChange, retrievedChange); + assertNull(RPC.getChangeRequest(ZONE1.getName(), "2", EMPTY_RPC_OPTIONS)); + try { + Change anotherChange = RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); + } catch (DnsException ex) { + assertEquals(409, ex.code()); + } + assertNotNull(RPC.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS)); + assertNull(RPC.getChangeRequest(ZONE1.getName(), "2", EMPTY_RPC_OPTIONS)); + // delete + RPC.applyChangeRequest(ZONE1.getName(), CHANGE2, EMPTY_RPC_OPTIONS); + assertNotNull(RPC.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS)); + assertNotNull(RPC.getChangeRequest(ZONE1.getName(), "2", EMPTY_RPC_OPTIONS)); + Change last = RPC.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); + assertEquals("done", last.getStatus()); + // todo(mderka) replace with real call + List list = + LOCAL_DNS_HELPER.findZone(REAL_PROJECT_ID, ZONE_NAME1).dnsRecords().get(ZONE_NAME1); + assertTrue(list.contains(new LocalDnsHelper.RrsetWrapper(RRSET_KEEP))); + Iterable results = + RPC.listDnsRecords(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); + boolean ok = false; + for (ResourceRecordSet dnsRecord : results) { + if (dnsRecord.getName().equals(RRSET_KEEP.getName()) + && dnsRecord.getType().equals(RRSET_KEEP.getType())) { + ok = true; + } + } + assertTrue(ok); } @Test public void testFindChange() { - localDns.createZone(PROJECT_ID1, ZONE1, null); - Change change = localDns.findChange(PROJECT_ID1, ZONE1.getName(), "somerandomchange"); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); + Change change = LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE1.getName(), "somerandomchange"); assertNull(change); - localDns.createChange(PROJECT_ID1, ZONE1.getName(), CHANGE1, null); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE1.getName(), CHANGE1, null); // changes are sequential so we should find ID 1 - assertNotNull(localDns.findChange(PROJECT_ID1, ZONE1.getName(), "1")); + assertNotNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE1.getName(), "1")); // add another - localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); - assertNotNull(localDns.findChange(PROJECT_ID1, ZONE1.getName(), "1")); - assertNotNull(localDns.findChange(PROJECT_ID1, ZONE1.getName(), "2")); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); + assertNotNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE1.getName(), "1")); + assertNotNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE1.getName(), "2")); // try to find non-existent change - assertNull(localDns.findChange(PROJECT_ID1, ZONE1.getName(), "3")); + assertNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE1.getName(), "3")); // try to find a change in yet non-existent project - assertNull(localDns.findChange(PROJECT_ID2, ZONE1.getName(), "3")); + assertNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID2, ZONE1.getName(), "3")); } @Test @@ -230,71 +340,375 @@ public void testRandomNameServers() { @Test public void testGetProject() { // only interested in no exceptions and non-null response here - assertNotNull(localDns.getProject(PROJECT_ID1, null)); - assertNotNull(localDns.getProject(PROJECT_ID2, null)); + assertNotNull(LOCAL_DNS_HELPER.getProject(PROJECT_ID1, null)); + assertNotNull(LOCAL_DNS_HELPER.getProject(PROJECT_ID2, null)); + Project project = RPC.getProject(EMPTY_RPC_OPTIONS); + assertNotNull(project.getQuota()); + assertEquals(REAL_PROJECT_ID, project.getId()); + // fields options + Map options = new HashMap<>(); + options.put(DnsRpc.Option.FIELDS, "number"); + project = RPC.getProject(options); + assertNull(project.getId()); + assertNotNull(project.getNumber()); + assertNull(project.getQuota()); + options.put(DnsRpc.Option.FIELDS, "id"); + project = RPC.getProject(options); + assertNotNull(project.getId()); + assertNull(project.getNumber()); + assertNull(project.getQuota()); + options.put(DnsRpc.Option.FIELDS, "quota"); + project = RPC.getProject(options); + assertNull(project.getId()); + assertNull(project.getNumber()); + assertNotNull(project.getQuota()); } @Test public void testGetZone() { // non-existent - LocalDnsHelper.Response response = localDns.getZone(PROJECT_ID1, ZONE_NAME1, null); + LocalDnsHelper.Response response = LOCAL_DNS_HELPER.getZone(PROJECT_ID1, ZONE_NAME1, null); assertEquals(404, response.code()); assertTrue(response.body().contains("does not exist")); // existent - localDns.createZone(PROJECT_ID1, ZONE1, null); - response = localDns.getZone(PROJECT_ID1, ZONE1.getName(), null); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); + response = LOCAL_DNS_HELPER.getZone(PROJECT_ID1, ZONE1.getName(), null); assertEquals(200, response.code()); } + @Test + public void testGetZoneUsingRpc() { + // non-existent + assertNull(RPC.getZone(ZONE_NAME1, EMPTY_RPC_OPTIONS)); + // existent + ManagedZone created = RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + ManagedZone zone = RPC.getZone(ZONE_NAME1, EMPTY_RPC_OPTIONS); + assertEquals(created, zone); + assertEquals(ZONE1.getName(), zone.getName()); + // field options + Map options = new HashMap<>(); + options.put(DnsRpc.Option.FIELDS, "id"); + zone = RPC.getZone(ZONE1.getName(), options); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNotNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "creationTime"); + zone = RPC.getZone(ZONE1.getName(), options); + assertNotNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "dnsName"); + zone = RPC.getZone(ZONE1.getName(), options); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNotNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "description"); + zone = RPC.getZone(ZONE1.getName(), options); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNotNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "nameServers"); + zone = RPC.getZone(ZONE1.getName(), options); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNotNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "nameServerSet"); + zone = RPC.getZone(ZONE1.getName(), options); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNotNull(zone.getNameServerSet()); + assertNull(zone.getId()); + // several combined + options.put(DnsRpc.Option.FIELDS, "nameServerSet,description,id,name"); + zone = RPC.getZone(ZONE1.getName(), options); + assertNull(zone.getCreationTime()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNotNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNotNull(zone.getNameServerSet()); + assertNotNull(zone.getId()); + } + @Test public void testCreateZone() { // only interested in no exceptions and non-null response here - LocalDnsHelper.Response response = localDns.createZone(PROJECT_ID1, ZONE1, null); + LocalDnsHelper.Response response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); assertEquals(200, response.code()); - assertEquals(1, localDns.projects().get(PROJECT_ID1).zones().size()); + assertEquals(1, LOCAL_DNS_HELPER.projects().get(PROJECT_ID1).zones().size()); try { - localDns.createZone(PROJECT_ID1, null, null); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, null, null); fail("Zone cannot be null"); } catch (NullPointerException ex) { // expected } // create zone twice - response = localDns.createZone(PROJECT_ID1, ZONE1, null); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); assertEquals(409, response.code()); assertTrue(response.body().contains("already exists")); } + @Test + public void testCreateZoneUsingRpc() { + ManagedZone created = RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + assertEquals(created, LOCAL_DNS_HELPER.findZone(REAL_PROJECT_ID, ZONE1.getName()).zone()); + ManagedZone zone = RPC.getZone(ZONE_NAME1, EMPTY_RPC_OPTIONS); + assertEquals(created, zone); + try { + RPC.create(null, EMPTY_RPC_OPTIONS); + fail("Zone cannot be null"); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("entity.managedZone")); + } + // create zone twice + try { + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + } catch (DnsException ex) { + // expected + assertEquals(409, ex.code()); + assertTrue(ex.getMessage().contains("already exists")); + } + // field options + resetProjects(); + Map options = new HashMap<>(); + options.put(DnsRpc.Option.FIELDS, "id"); + zone = RPC.create(ZONE1, options); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNotNull(zone.getId()); + resetProjects(); + options.put(DnsRpc.Option.FIELDS, "creationTime"); + zone = RPC.create(ZONE1, options); + assertNotNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "dnsName"); + resetProjects(); + zone = RPC.create(ZONE1, options); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNotNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "description"); + resetProjects(); + zone = RPC.create(ZONE1, options); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNotNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "nameServers"); + resetProjects(); + zone = RPC.create(ZONE1, options); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNotNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "nameServerSet"); + resetProjects(); + zone = RPC.create(ZONE1, options); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNotNull(zone.getNameServerSet()); + assertNull(zone.getId()); + // several combined + options.put(DnsRpc.Option.FIELDS, "nameServerSet,description,id,name"); + resetProjects(); + zone = RPC.create(ZONE1, options); + assertNull(zone.getCreationTime()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNotNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNotNull(zone.getNameServerSet()); + assertNotNull(zone.getId()); + } + @Test public void testCreateChange() { // non-existent zone LocalDnsHelper.Response response = - localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); assertEquals(404, response.code()); - // existent zone - assertNotNull(localDns.createZone(PROJECT_ID1, ZONE1, null)); - assertNull(localDns.findChange(PROJECT_ID1, ZONE_NAME1, "1")); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); + assertNotNull(LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null)); + assertNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE_NAME1, "1")); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); assertEquals(200, response.code()); - assertNotNull(localDns.findChange(PROJECT_ID1, ZONE_NAME1, "1")); + assertNotNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE_NAME1, "1")); + } + + @Test + public void testCreateChangeUsingRpc() { + // non-existent zone + try { + RPC.applyChangeRequest(ZONE_NAME1, CHANGE1, EMPTY_RPC_OPTIONS); + } catch (DnsException ex) { + assertEquals(404, ex.code()); + } + // existent zone + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + assertNull(RPC.getChangeRequest(ZONE_NAME1, "1", EMPTY_RPC_OPTIONS)); + Change created = RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); + assertEquals(created, RPC.getChangeRequest(ZONE_NAME1, "1", EMPTY_RPC_OPTIONS)); + // field options + RPC.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); + Map options = new HashMap<>(); + options.put(DnsRpc.Option.FIELDS, "additions"); + Change complex = RPC.applyChangeRequest(ZONE1.getName(), CHANGE_COMPLEX, options); + assertNotNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNull(complex.getStatus()); + options.put(DnsRpc.Option.FIELDS, "deletions"); + complex = RPC.applyChangeRequest(ZONE1.getName(), CHANGE_COMPLEX, options); + assertNull(complex.getAdditions()); + assertNotNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNull(complex.getStatus()); + options.put(DnsRpc.Option.FIELDS, "id"); + complex = RPC.applyChangeRequest(ZONE1.getName(), CHANGE_COMPLEX, options); + assertNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNotNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNull(complex.getStatus()); + options.put(DnsRpc.Option.FIELDS, "startTime"); + complex = RPC.applyChangeRequest(ZONE1.getName(), CHANGE_COMPLEX, options); + assertNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNotNull(complex.getStartTime()); + assertNull(complex.getStatus()); + options.put(DnsRpc.Option.FIELDS, "status"); + complex = RPC.applyChangeRequest(ZONE1.getName(), CHANGE_COMPLEX, options); + assertNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNotNull(complex.getStatus()); } @Test public void testGetChange() { // existent - assertEquals(200, localDns.createZone(PROJECT_ID1, ZONE1, null).code()); - assertEquals(200, localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null).code()); - assertEquals(200, localDns.getChange(PROJECT_ID1, ZONE_NAME1, "1", null).code()); + assertEquals(200, LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null).code()); + assertEquals(200, LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null).code()); + assertEquals(200, LOCAL_DNS_HELPER.getChange(PROJECT_ID1, ZONE_NAME1, "1", null).code()); // non-existent - LocalDnsHelper.Response response = localDns.getChange(PROJECT_ID1, ZONE_NAME1, "2", null); + LocalDnsHelper.Response response = + LOCAL_DNS_HELPER.getChange(PROJECT_ID1, ZONE_NAME1, "2", null); assertEquals(404, response.code()); assertTrue(response.body().contains("parameters.changeId")); // non-existent zone - response = localDns.getChange(PROJECT_ID1, ZONE_NAME2, "1", null); + response = LOCAL_DNS_HELPER.getChange(PROJECT_ID1, ZONE_NAME2, "1", null); assertEquals(404, response.code()); assertTrue(response.body().contains("parameters.managedZone")); } + @Test + public void testGetChangeUsingRpc() { + // existent + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + Change created = RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); + Change retrieved = RPC.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS); + assertEquals(created, retrieved); + // non-existent + assertNull(RPC.getChangeRequest(ZONE1.getName(), "2", EMPTY_RPC_OPTIONS)); + // non-existent zone + try { + RPC.getChangeRequest(ZONE_NAME2, "1", EMPTY_RPC_OPTIONS); + } catch (DnsException ex) { + // expected + assertEquals(404, ex.code()); + } + // field options + RPC.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); + Change change = RPC.applyChangeRequest(ZONE1.getName(), CHANGE_COMPLEX, EMPTY_RPC_OPTIONS); + Map options = new HashMap<>(); + options.put(DnsRpc.Option.FIELDS, "additions"); + Change complex = RPC.getChangeRequest(ZONE1.getName(), change.getId(), options); + assertNotNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNull(complex.getStatus()); + options.put(DnsRpc.Option.FIELDS, "deletions"); + complex = RPC.getChangeRequest(ZONE1.getName(), change.getId(), options); + assertNull(complex.getAdditions()); + assertNotNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNull(complex.getStatus()); + options.put(DnsRpc.Option.FIELDS, "id"); + complex = RPC.getChangeRequest(ZONE1.getName(), change.getId(), options); + assertNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNotNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNull(complex.getStatus()); + options.put(DnsRpc.Option.FIELDS, "startTime"); + complex = RPC.getChangeRequest(ZONE1.getName(), change.getId(), options); + assertNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNotNull(complex.getStartTime()); + assertNull(complex.getStatus()); + options.put(DnsRpc.Option.FIELDS, "status"); + complex = RPC.getChangeRequest(ZONE1.getName(), change.getId(), options); + assertNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNotNull(complex.getStatus()); + } + @Test public void testListZones() { // only interested in no exceptions and non-null response here @@ -302,36 +716,175 @@ public void testListZones() { optionsMap.put("fields", null); optionsMap.put("pageToken", null); optionsMap.put("maxResults", null); - LocalDnsHelper.Response response = localDns.listZones(PROJECT_ID1, optionsMap); + LocalDnsHelper.Response response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(200, response.code()); // some zones exists - localDns.createZone(PROJECT_ID1, ZONE1, null); - response = localDns.listZones(PROJECT_ID1, optionsMap); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(200, response.code()); - localDns.createZone(PROJECT_ID1, ZONE2, null); - response = localDns.listZones(PROJECT_ID1, optionsMap); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE2, null); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(200, response.code()); // error in options optionsMap.put("maxResults", "aaa"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(400, response.code()); optionsMap.put("maxResults", "0"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(400, response.code()); optionsMap.put("maxResults", "-1"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(400, response.code()); optionsMap.put("maxResults", "15"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(200, response.code()); optionsMap.put("dnsName", "aaa"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(400, response.code()); optionsMap.put("dnsName", "aaa."); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(200, response.code()); } + @Test + public void testListZonesUsingRpc() { + Iterable results = RPC.listZones(EMPTY_RPC_OPTIONS).results(); + ImmutableList zones = ImmutableList.copyOf(results); + assertEquals(0, zones.size()); + // some zones exists + ManagedZone created = RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + results = RPC.listZones(EMPTY_RPC_OPTIONS).results(); + zones = ImmutableList.copyOf(results); + assertEquals(created, zones.get(0)); + assertEquals(1, zones.size()); + created = RPC.create(ZONE2, EMPTY_RPC_OPTIONS); + results = RPC.listZones(EMPTY_RPC_OPTIONS).results(); + zones = ImmutableList.copyOf(results); + assertEquals(2, zones.size()); + assertTrue(zones.contains(created)); + // error in options + Map options = new HashMap<>(); + options.put(DnsRpc.Option.PAGE_SIZE, 0); + try { + RPC.listZones(options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + options = new HashMap<>(); + options.put(DnsRpc.Option.PAGE_SIZE, -1); + try { + RPC.listZones(options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + // ok size + options = new HashMap<>(); + options.put(DnsRpc.Option.PAGE_SIZE, 1); + results = RPC.listZones(options).results(); + zones = ImmutableList.copyOf(results); + assertEquals(1, zones.size()); + // dns name problems + options = new HashMap<>(); + options.put(DnsRpc.Option.DNS_NAME, "aaa"); + try { + RPC.listZones(options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + // ok name + options = new HashMap<>(); + options.put(DnsRpc.Option.DNS_NAME, "aaaa."); + results = RPC.listZones(options).results(); + zones = ImmutableList.copyOf(results); + assertEquals(0, zones.size()); + // field options + options = new HashMap<>(); + options.put(DnsRpc.Option.FIELDS, "managedZones(id)"); + ManagedZone zone = RPC.listZones(options).results().iterator().next(); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNotNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "managedZones(creationTime)"); + zone = RPC.listZones(options).results().iterator().next(); + assertNotNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "managedZones(dnsName)"); + zone = RPC.listZones(options).results().iterator().next(); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNotNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "managedZones(description)"); + zone = RPC.listZones(options).results().iterator().next(); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNotNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "managedZones(nameServers)"); + zone = RPC.listZones(options).results().iterator().next(); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNotNull(zone.getNameServers()); + assertNull(zone.getNameServerSet()); + assertNull(zone.getId()); + options.put(DnsRpc.Option.FIELDS, "managedZones(nameServerSet)"); + DnsRpc.ListResult managedZoneListResult = RPC.listZones(options); + zone = managedZoneListResult.results().iterator().next(); + assertNull(managedZoneListResult.pageToken()); + assertNull(zone.getCreationTime()); + assertNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNotNull(zone.getNameServerSet()); + assertNull(zone.getId()); + // several combined + options.put(DnsRpc.Option.FIELDS, + "managedZones(nameServerSet,description,id,name),nextPageToken"); + options.put(DnsRpc.Option.PAGE_SIZE, 1); + managedZoneListResult = RPC.listZones(options); + zone = managedZoneListResult.results().iterator().next(); + assertNull(zone.getCreationTime()); + assertNotNull(zone.getName()); + assertNull(zone.getDnsName()); + assertNotNull(zone.getDescription()); + assertNull(zone.getNameServers()); + assertNotNull(zone.getNameServerSet()); + assertNotNull(zone.getId()); + assertEquals(zone.getName(), managedZoneListResult.pageToken()); + // paging + options = new HashMap<>(); + options.put(DnsRpc.Option.PAGE_SIZE, 1); + managedZoneListResult = RPC.listZones(options); + ImmutableList page1 = ImmutableList.copyOf(managedZoneListResult.results()); + assertEquals(1, page1.size()); + options.put(DnsRpc.Option.PAGE_TOKEN, managedZoneListResult.pageToken()); + managedZoneListResult = RPC.listZones(options); + ImmutableList page2 = ImmutableList.copyOf(managedZoneListResult.results()); + assertEquals(1, page2.size()); + assertNotEquals(page1.get(0), page2.get(0)); + } + @Test public void testListDnsRecords() { // only interested in no exceptions and non-null response here @@ -341,49 +894,196 @@ public void testListDnsRecords() { optionsMap.put("pageToken", null); optionsMap.put("maxResults", null); // no zone exists - LocalDnsHelper.Response response = localDns.listDnsRecords(PROJECT_ID1, ZONE_NAME1, + LocalDnsHelper.Response response = LOCAL_DNS_HELPER.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(404, response.code()); // zone exists but has no records - localDns.createZone(PROJECT_ID1, ZONE1, null); - localDns.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); + LOCAL_DNS_HELPER.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); // zone has records - localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); - response = localDns.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); + response = LOCAL_DNS_HELPER.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(200, response.code()); // error in options optionsMap.put("maxResults", "aaa"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(400, response.code()); optionsMap.put("maxResults", "0"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(400, response.code()); optionsMap.put("maxResults", "-1"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(400, response.code()); optionsMap.put("maxResults", "15"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(200, response.code()); optionsMap.put("name", "aaa"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(400, response.code()); optionsMap.put("name", "aaa."); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(200, response.code()); optionsMap.put("name", null); optionsMap.put("type", "A"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(400, response.code()); optionsMap.put("name", "aaa."); optionsMap.put("type", "a"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(400, response.code()); optionsMap.put("name", "aaaa."); optionsMap.put("type", "A"); - response = localDns.listZones(PROJECT_ID1, optionsMap); + response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); assertEquals(200, response.code()); } + @Test + public void testListDnsRecordsUsingRpc() { + // no zone exists + try { + RPC.listDnsRecords(ZONE_NAME1, EMPTY_RPC_OPTIONS); + } catch (DnsException ex) { + // expected + assertEquals(404, ex.code()); + } + // zone exists but has no records + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + Iterable results = + RPC.listDnsRecords(ZONE_NAME1, EMPTY_RPC_OPTIONS).results(); + ImmutableList records = ImmutableList.copyOf(results); + assertEquals(2, records.size()); // contains default NS and SOA + // zone has records + RPC.applyChangeRequest(ZONE_NAME1, CHANGE_KEEP, EMPTY_RPC_OPTIONS); + results = RPC.listDnsRecords(ZONE_NAME1, EMPTY_RPC_OPTIONS).results(); + records = ImmutableList.copyOf(results); + assertEquals(3, records.size()); + // error in options + Map options = new HashMap<>(); + options.put(DnsRpc.Option.PAGE_SIZE, 0); + try { + RPC.listDnsRecords(ZONE1.getName(), options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + options.put(DnsRpc.Option.PAGE_SIZE, -1); + try { + RPC.listDnsRecords(ZONE1.getName(), options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + options.put(DnsRpc.Option.PAGE_SIZE, 1); + results = RPC.listDnsRecords(ZONE1.getName(), options).results(); + records = ImmutableList.copyOf(results); + assertEquals(1, records.size()); + options.put(DnsRpc.Option.PAGE_SIZE, 15); + results = RPC.listDnsRecords(ZONE1.getName(), options).results(); + records = ImmutableList.copyOf(results); + assertEquals(3, records.size()); + + // dnsName filter + options = new HashMap<>(); + options.put(DnsRpc.Option.NAME, "aaa"); + try { + RPC.listDnsRecords(ZONE1.getName(), options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + options.put(DnsRpc.Option.NAME, "aaa."); + results = RPC.listDnsRecords(ZONE1.getName(), options).results(); + records = ImmutableList.copyOf(results); + assertEquals(0, records.size()); + options.put(DnsRpc.Option.NAME, null); + options.put(DnsRpc.Option.DNS_TYPE, "A"); + try { + RPC.listDnsRecords(ZONE1.getName(), options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + options.put(DnsRpc.Option.NAME, "aaa."); + options.put(DnsRpc.Option.DNS_TYPE, "a"); + try { + RPC.listDnsRecords(ZONE1.getName(), options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + options.put(DnsRpc.Option.NAME, DNS_NAME); + options.put(DnsRpc.Option.DNS_TYPE, "SOA"); + results = RPC.listDnsRecords(ZONE1.getName(), options).results(); + records = ImmutableList.copyOf(results); + assertEquals(1, records.size()); + // field options + options = new HashMap<>(); + options.put(DnsRpc.Option.FIELDS, "rrsets(name)"); + DnsRpc.ListResult resourceRecordSetListResult = + RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + ResourceRecordSet record = records.get(0); + assertNotNull(record.getName()); + assertNull(record.getRrdatas()); + assertNull(record.getType()); + assertNull(record.getTtl()); + assertNull(resourceRecordSetListResult.pageToken()); + options.put(DnsRpc.Option.FIELDS, "rrsets(rrdatas)"); + resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + record = records.get(0); + assertNull(record.getName()); + assertNotNull(record.getRrdatas()); + assertNull(record.getType()); + assertNull(record.getTtl()); + assertNull(resourceRecordSetListResult.pageToken()); + options.put(DnsRpc.Option.FIELDS, "rrsets(ttl)"); + resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + record = records.get(0); + assertNull(record.getName()); + assertNull(record.getRrdatas()); + assertNull(record.getType()); + assertNotNull(record.getTtl()); + assertNull(resourceRecordSetListResult.pageToken()); + options.put(DnsRpc.Option.FIELDS, "rrsets(type)"); + resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + record = records.get(0); + assertNull(record.getName()); + assertNull(record.getRrdatas()); + assertNotNull(record.getType()); + assertNull(record.getTtl()); + assertNull(resourceRecordSetListResult.pageToken()); + options.put(DnsRpc.Option.FIELDS, "nextPageToken"); + resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + record = records.get(0); + assertNull(record.getName()); + assertNull(record.getRrdatas()); + assertNull(record.getType()); + assertNull(record.getTtl()); + assertNull(resourceRecordSetListResult.pageToken()); + options.put(DnsRpc.Option.FIELDS, "nextPageToken,rrsets(name,rrdatas)"); + options.put(DnsRpc.Option.PAGE_SIZE, 1); + resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + assertEquals(1, records.size()); + record = records.get(0); + assertNotNull(record.getName()); + assertNotNull(record.getRrdatas()); + assertNull(record.getType()); + assertNull(record.getTtl()); + assertNotNull(resourceRecordSetListResult.pageToken()); + // paging + options.put(DnsRpc.Option.PAGE_TOKEN, resourceRecordSetListResult.pageToken()); + resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + assertEquals(1, records.size()); + ResourceRecordSet nextRecord = records.get(0); + assertNotEquals(record, nextRecord); + } + @Test public void testListChanges() { optionsMap.put("sortBy", null); @@ -392,72 +1092,214 @@ public void testListChanges() { optionsMap.put("pageToken", null); optionsMap.put("maxResults", null); // no such zone exists - LocalDnsHelper.Response response = localDns.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); + LocalDnsHelper.Response response = + LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(404, response.code()); assertTrue(response.body().contains("managedZone")); // zone exists but has no changes - localDns.createZone(PROJECT_ID1, ZONE1, null); - assertNotNull(localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); + assertNotNull(LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); // zone has changes - localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); - assertNotNull(localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); - localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); - localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); - localDns.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); - assertNotNull(localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); + assertNotNull(LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); + assertNotNull(LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); // error in options optionsMap.put("maxResults", "aaa"); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(400, response.code()); optionsMap.put("maxResults", "0"); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(400, response.code()); optionsMap.put("maxResults", "-1"); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(400, response.code()); optionsMap.put("maxResults", "15"); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(200, response.code()); - optionsMap.put("dnsName", "aaa"); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("dnsName", "aaa."); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(200, response.code()); optionsMap.put("sortBy", "changeSequence"); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(200, response.code()); optionsMap.put("sortBy", "something else"); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(400, response.code()); assertTrue(response.body().contains("Allowed values: [changesequence]")); optionsMap.put("sortBy", "ChAnGeSeQuEnCe"); // is not case sensitive - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(200, response.code()); optionsMap.put("sortOrder", "ascending"); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(200, response.code()); optionsMap.put("sortBy", null); optionsMap.put("sortOrder", "descending"); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(200, response.code()); optionsMap.put("sortOrder", "somethingelse"); - response = localDns.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); + response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); assertEquals(400, response.code()); assertTrue(response.body().contains("parameters.sortOrder")); } + @Test + public void testListChangesUsingRpc() { + // no such zone exists + try { + RPC.listChangeRequests(ZONE_NAME1, EMPTY_RPC_OPTIONS); + } catch (DnsException ex) { + // expected + assertEquals(404, ex.code()); + } + // zone exists but has no changes + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + Iterable results = RPC.listChangeRequests(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); + ImmutableList changes = ImmutableList.copyOf(results); + assertEquals(0, changes.size()); + // zone has changes + RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); + RPC.applyChangeRequest(ZONE1.getName(), CHANGE2, EMPTY_RPC_OPTIONS); + RPC.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); + results = RPC.listChangeRequests(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); + changes = ImmutableList.copyOf(results); + assertEquals(3, changes.size()); + // error in options + Map options = new HashMap<>(); + options.put(DnsRpc.Option.PAGE_SIZE, 0); + try { + RPC.listChangeRequests(ZONE1.getName(), options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + options.put(DnsRpc.Option.PAGE_SIZE, -1); + try { + RPC.listChangeRequests(ZONE1.getName(), options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + options.put(DnsRpc.Option.PAGE_SIZE, 15); + try { + RPC.listChangeRequests(ZONE1.getName(), options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + options = new HashMap<>(); + options.put(DnsRpc.Option.SORTING_ORDER, "descending"); + results = RPC.listChangeRequests(ZONE1.getName(), options).results(); + ImmutableList descending = ImmutableList.copyOf(results); + results = RPC.listChangeRequests(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); + ImmutableList ascending = ImmutableList.copyOf(results); + int size = 3; + assertEquals(size, descending.size()); + for (int i = 0; i < size; i++) { + assertEquals(descending.get(i), ascending.get(size - i - 1)); + } + options.put(DnsRpc.Option.SORTING_ORDER, "something else"); + try { + RPC.listChangeRequests(ZONE1.getName(), options); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + } + // field options + RPC.applyChangeRequest(ZONE1.getName(), CHANGE_COMPLEX, EMPTY_RPC_OPTIONS); + options = new HashMap<>(); + options.put(DnsRpc.Option.SORTING_ORDER, "descending"); + options.put(DnsRpc.Option.FIELDS, "changes(additions)"); + DnsRpc.ListResult changeListResult = + RPC.listChangeRequests(ZONE1.getName(), options); + changes = ImmutableList.copyOf(changeListResult.results()); + Change complex = changes.get(0); + assertNotNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNull(complex.getStatus()); + assertNull(changeListResult.pageToken()); + options.put(DnsRpc.Option.FIELDS, "changes(deletions)"); + changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); + changes = ImmutableList.copyOf(changeListResult.results()); + complex = changes.get(0); + assertNull(complex.getAdditions()); + assertNotNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNull(complex.getStatus()); + assertNull(changeListResult.pageToken()); + options.put(DnsRpc.Option.FIELDS, "changes(id)"); + changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); + changes = ImmutableList.copyOf(changeListResult.results()); + complex = changes.get(0); + assertNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNotNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNull(complex.getStatus()); + assertNull(changeListResult.pageToken()); + options.put(DnsRpc.Option.FIELDS, "changes(startTime)"); + changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); + changes = ImmutableList.copyOf(changeListResult.results()); + complex = changes.get(0); + assertNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNotNull(complex.getStartTime()); + assertNull(complex.getStatus()); + assertNull(changeListResult.pageToken()); + options.put(DnsRpc.Option.FIELDS, "changes(status)"); + changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); + changes = ImmutableList.copyOf(changeListResult.results()); + complex = changes.get(0); + assertNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNotNull(complex.getStatus()); + assertNull(changeListResult.pageToken()); + options.put(DnsRpc.Option.FIELDS, "nextPageToken"); + options.put(DnsRpc.Option.PAGE_SIZE, 1); + changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); + changes = ImmutableList.copyOf(changeListResult.results()); + complex = changes.get(0); + assertNull(complex.getAdditions()); + assertNull(complex.getDeletions()); + assertNull(complex.getId()); + assertNull(complex.getStartTime()); + assertNull(complex.getStatus()); + assertNotNull(changeListResult.pageToken()); + // paging + options.put(DnsRpc.Option.FIELDS, "nextPageToken,changes(id)"); + options.put(DnsRpc.Option.PAGE_SIZE, 1); + changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); + changes = ImmutableList.copyOf(changeListResult.results()); + assertEquals(1, changes.size()); + final Change first = changes.get(0); + assertNotNull(changeListResult.pageToken()); + options.put(DnsRpc.Option.PAGE_TOKEN, changeListResult.pageToken()); + changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); + changes = ImmutableList.copyOf(changeListResult.results()); + assertEquals(1, changes.size()); + Change second = changes.get(0); + assertNotEquals(first, second); + } + @Test public void testToListResponse() { LocalDnsHelper.Response response = LocalDnsHelper.toListResponse( - Lists.newArrayList("some", "multiple", "words"), "IncludeThisPageToken", true); + Lists.newArrayList("some", "multiple", "words"), "contextA", "IncludeThisPageToken", true); assertTrue(response.body().contains("IncludeThisPageToken")); + assertTrue(response.body().contains("contextA")); response = LocalDnsHelper.toListResponse( - Lists.newArrayList("some", "multiple", "words"), "IncludeThisPageToken", false); + Lists.newArrayList("some", "multiple", "words"), "contextB", "IncludeThisPageToken", false); assertFalse(response.body().contains("IncludeThisPageToken")); + assertTrue(response.body().contains("contextB")); response = LocalDnsHelper.toListResponse( - Lists.newArrayList("some", "multiple", "words"), null, true); + Lists.newArrayList("some", "multiple", "words"), "contextC", null, true); assertFalse(response.body().contains("pageToken")); + assertTrue(response.body().contains("contextC")); } @Test @@ -511,45 +1353,45 @@ public void testCreateZoneValidatesZone() { // no name ManagedZone copy = copyZone(minimalZone); copy.setName(null); - LocalDnsHelper.Response response = localDns.createZone(PROJECT_ID1, copy, null); + LocalDnsHelper.Response response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.name")); // no description copy = copyZone(minimalZone); copy.setDescription(null); - response = localDns.createZone(PROJECT_ID1, copy, null); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.description")); // no dns name copy = copyZone(minimalZone); copy.setDnsName(null); - response = localDns.createZone(PROJECT_ID1, copy, null); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.dnsName")); // zone name is a number copy = copyZone(minimalZone); copy.setName("123456"); - response = localDns.createZone(PROJECT_ID1, copy, null); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.name")); assertTrue(response.body().contains("Invalid")); // dns name does not end with period copy = copyZone(minimalZone); copy.setDnsName("aaaaaa.com"); - response = localDns.createZone(PROJECT_ID1, copy, null); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.dnsName")); assertTrue(response.body().contains("Invalid")); // dns name is reserved copy = copyZone(minimalZone); copy.setDnsName("com."); - response = localDns.createZone(PROJECT_ID1, copy, null); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); assertEquals(400, response.code()); assertTrue(response.body().contains("not available to be created.")); // empty description should pass copy = copyZone(minimalZone); copy.setDescription(""); - response = localDns.createZone(PROJECT_ID1, copy, null); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); assertEquals(200, response.code()); } @@ -632,10 +1474,10 @@ public void testCheckRrset() { valid.setTtl(500); Change validChange = new Change(); validChange.setAdditions(ImmutableList.of(valid)); - localDns.createZone(PROJECT_ID1, ZONE1, null); - localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); // delete with field mismatch - LocalDnsHelper.ZoneContainer zone = localDns.findZone(PROJECT_ID1, ZONE_NAME1); + LocalDnsHelper.ZoneContainer zone = LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE_NAME1); valid.setTtl(valid.getTtl() + 20); LocalDnsHelper.Response response = LocalDnsHelper.checkRrset(valid, zone, 0, "deletions"); assertEquals(412, response.code()); @@ -735,7 +1577,7 @@ public void testCheckChange() { assertTrue(response.body().contains("additions[0].type")); validA.setType("A"); // null rrdata - List temp = validA.getRrdatas(); // preserve + final List temp = validA.getRrdatas(); // preserve validA.setRrdatas(null); response = LocalDnsHelper.checkChange(validChange, zoneContainer); assertEquals(400, response.code()); @@ -762,9 +1604,9 @@ public void testAdditionsMeetDeletions() { validA.setRrdatas(ImmutableList.of("0.255.1.5")); Change validChange = new Change(); validChange.setAdditions(ImmutableList.of(validA)); - localDns.createZone(PROJECT_ID1, ZONE1, null); - localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); - LocalDnsHelper.ZoneContainer container = localDns.findZone(PROJECT_ID1, ZONE_NAME1); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LocalDnsHelper.ZoneContainer container = LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE_NAME1); LocalDnsHelper.Response response = LocalDnsHelper.additionsMeetDeletions(ImmutableList.of(validA), null, container); assertEquals(409, response.code()); @@ -780,23 +1622,23 @@ public void testCreateChangeValidatesChangeContent() { validA.setRrdatas(ImmutableList.of("0.255.1.5")); Change validChange = new Change(); validChange.setAdditions(ImmutableList.of(validA)); - localDns.createZone(PROJECT_ID1, ZONE1, null); - localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); LocalDnsHelper.Response response = - localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); assertEquals(409, response.code()); assertTrue(response.body().contains("already exists")); // delete with field mismatch Change delete = new Change(); validA.setTtl(20); // mismatch delete.setDeletions(ImmutableList.of(validA)); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); assertEquals(412, response.code()); assertTrue(response.body().contains("entity.change.deletions[0]")); // delete and add SOA Change addition = new Change(); ImmutableList rrsetWrappers - = localDns.findZone(PROJECT_ID1, ZONE_NAME1).dnsRecords().get(ZONE_NAME1); + = LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE_NAME1).dnsRecords().get(ZONE_NAME1); LinkedList deletions = new LinkedList<>(); LinkedList additions = new LinkedList<>(); for (LocalDnsHelper.RrsetWrapper wrapper : rrsetWrappers) { @@ -811,12 +1653,12 @@ public void testCreateChangeValidatesChangeContent() { } delete.setDeletions(deletions); addition.setAdditions(additions); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); assertEquals(400, response.code()); assertTrue(response.body().contains( "zone must contain exactly one resource record set of type 'SOA' at the apex")); assertTrue(response.body().contains("deletions[0]")); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); assertEquals(400, response.code()); assertTrue(response.body().contains( "zone must contain exactly one resource record set of type 'SOA' at the apex")); @@ -836,24 +1678,24 @@ public void testCreateChangeValidatesChangeContent() { } delete.setDeletions(deletions); addition.setAdditions(additions); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); assertEquals(400, response.code()); assertTrue(response.body().contains( "zone must contain exactly one resource record set of type 'NS' at the apex")); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); assertEquals(400, response.code()); assertTrue(response.body().contains( "zone must contain exactly one resource record set of type 'NS' at the apex")); assertTrue(response.body().contains("additions[0]")); // change (delete + add) addition.setDeletions(deletions); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); assertEquals(200, response.code()); } @Test public void testCreateChangeValidatesChange() { - localDns.createZone(PROJECT_ID1, ZONE1, null); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); ResourceRecordSet validA = new ResourceRecordSet(); validA.setName(ZONE1.getDnsName()); validA.setType("A"); @@ -867,52 +1709,52 @@ public void testCreateChangeValidatesChange() { Change invalidChange = new Change(); invalidChange.setAdditions(ImmutableList.of(invalidA)); LocalDnsHelper.Response response = - localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); assertEquals(200, response.code()); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, invalidChange, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, invalidChange, null); assertEquals(400, response.code()); // only empty additions/deletions Change empty = new Change(); empty.setAdditions(ImmutableList.of()); empty.setDeletions(ImmutableList.of()); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, empty, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, empty, null); assertEquals(400, response.code()); assertTrue(response.body().contains( "The 'entity.change' parameter is required but was missing.")); // non-matching name validA.setName(ZONE1.getDnsName() + ".aaa."); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); assertEquals(400, response.code()); assertTrue(response.body().contains("additions[0].name")); // wrong type validA.setName(ZONE1.getDnsName()); // revert validA.setType("ABCD"); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); assertEquals(400, response.code()); assertTrue(response.body().contains("additions[0].type")); // wrong ttl validA.setType("A"); // revert validA.setTtl(-1); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); assertEquals(400, response.code()); assertTrue(response.body().contains("additions[0].ttl")); validA.setTtl(null); // revert // null name validA.setName(null); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); assertEquals(400, response.code()); assertTrue(response.body().contains("additions[0].name")); validA.setName(ZONE1.getDnsName()); // null type validA.setType(null); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); assertEquals(400, response.code()); assertTrue(response.body().contains("additions[0].type")); validA.setType("A"); // null rrdata - List temp = validA.getRrdatas(); // preserve + final List temp = validA.getRrdatas(); // preserve validA.setRrdatas(null); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); assertEquals(400, response.code()); assertTrue(response.body().contains("additions[0].rrdata")); validA.setRrdatas(temp); @@ -923,7 +1765,7 @@ public void testCreateChangeValidatesChange() { nonExistent.setRrdatas(ImmutableList.of(":::::::")); Change delete = new Change(); delete.setDeletions(ImmutableList.of(nonExistent)); - response = localDns.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); assertEquals(404, response.code()); assertTrue(response.body().contains("deletions[0]")); } From b2c2d40a9eff216ad86b168dafc39391ff326224 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Wed, 24 Feb 2016 17:18:49 +0100 Subject: [PATCH 084/203] Udpate dependencies: source plugin, bigquery, storage and fluido skin --- gcloud-java-bigquery/pom.xml | 2 +- gcloud-java-storage/pom.xml | 2 +- pom.xml | 2 +- src/site/site.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcloud-java-bigquery/pom.xml b/gcloud-java-bigquery/pom.xml index 0f41d8bc1eec..f7304e276d75 100644 --- a/gcloud-java-bigquery/pom.xml +++ b/gcloud-java-bigquery/pom.xml @@ -30,7 +30,7 @@ com.google.apis google-api-services-bigquery - v2-rev261-1.21.0 + v2-rev270-1.21.0 compile diff --git a/gcloud-java-storage/pom.xml b/gcloud-java-storage/pom.xml index 5e53c36c6221..d98fcd2647e2 100644 --- a/gcloud-java-storage/pom.xml +++ b/gcloud-java-storage/pom.xml @@ -24,7 +24,7 @@ com.google.apis google-api-services-storage - v1-rev60-1.21.0 + v1-rev62-1.21.0 compile diff --git a/pom.xml b/pom.xml index 4bc8f37c35de..28bcba708f7f 100644 --- a/pom.xml +++ b/pom.xml @@ -229,7 +229,7 @@ org.apache.maven.plugins maven-source-plugin - 2.4 + 3.0.0 attach-sources diff --git a/src/site/site.xml b/src/site/site.xml index 55047ce85c54..6279179eb389 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -20,7 +20,7 @@ org.apache.maven.skins maven-fluido-skin - 1.3.1 + 1.4 From ee78b22a2656517681ab157aecd1667fdb384a4e Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 22 Feb 2016 09:51:53 -0800 Subject: [PATCH 085/203] Fix equals, javadoc, bindings representation, and address other comments. --- .../java/com/google/gcloud/BaseIamPolicy.java | 297 ------------------ .../java/com/google/gcloud/IamPolicy.java | 213 +++++++++++++ .../main/java/com/google/gcloud/Identity.java | 208 ++++++++++++ .../java/com/google/gcloud/IamPolicyTest.java | 173 ++++++++++ .../java/com/google/gcloud/IdentityTest.java | 110 +++++++ .../gcloud/resourcemanager/IamPolicy.java | 162 ---------- .../google/gcloud/resourcemanager/Policy.java | 122 +++++++ .../gcloud/resourcemanager/IamPolicyTest.java | 91 ------ .../gcloud/resourcemanager/PolicyTest.java | 37 ++- .../resourcemanager/SerializationTest.java | 12 +- 10 files changed, 852 insertions(+), 573 deletions(-) delete mode 100644 gcloud-java-core/src/main/java/com/google/gcloud/BaseIamPolicy.java create mode 100644 gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java create mode 100644 gcloud-java-core/src/main/java/com/google/gcloud/Identity.java create mode 100644 gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java create mode 100644 gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java delete mode 100644 gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/IamPolicy.java create mode 100644 gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java delete mode 100644 gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/IamPolicyTest.java rename gcloud-java-core/src/test/java/com/google/gcloud/BaseIamPolicyTest.java => gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java (55%) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/BaseIamPolicy.java b/gcloud-java-core/src/main/java/com/google/gcloud/BaseIamPolicy.java deleted file mode 100644 index bc0aed43b95d..000000000000 --- a/gcloud-java-core/src/main/java/com/google/gcloud/BaseIamPolicy.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * 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.gcloud; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.collect.ImmutableList; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * Base class for Identity and Access Management (IAM) policies. IAM policies are used to specify - * access settings for Cloud Platform resources. A Policy consists of a list of bindings. An binding - * assigns a list of identities to a role, where the identities can be user accounts, Google groups, - * Google domains, and service accounts. A role is a named list of permissions defined by IAM. - * - * @see Policy - */ -public abstract class BaseIamPolicy implements Serializable { - - private static final long serialVersionUID = 1114489978726897720L; - - private final Map> bindings; - private final String etag; - private final int version; - - public static final class Identity implements Serializable { - - private static final long serialVersionUID = 30811617560110848L; - - private final Type type; - private final String id; - - /** - * The types of IAM identities. - */ - public enum Type { - /** - * Represents anyone who is on the internet; with or without a Google account. - */ - ALL_USERS, - - /** - * Represents anyone who is authenticated with a Google account or a service account. - */ - ALL_AUTHENTICATED_USERS, - - /** - * Represents a specific Google account. - */ - USER, - - /** - * Represents a service account. - */ - SERVICE_ACCOUNT, - - /** - * Represents a Google group. - */ - GROUP, - - /** - * Represents all the users of a Google Apps domain name. - */ - DOMAIN - } - - private Identity(Type type, String id) { - this.type = type; - this.id = id; - } - - public Type type() { - return type; - } - - /** - * Returns the string identifier for this identity. The id corresponds to: - *

    - *
  • email address (for identities of type {@code USER}, {@code SERVICE_ACCOUNT}, and - * {@code GROUP}) - *
  • domain (for identities of type {@code DOMAIN}) - *
  • null (for identities of type {@code ALL_USERS} and {@code ALL_AUTHENTICATED_USERS}) - *
- */ - public String id() { - return id; - } - - /** - * Returns a new identity representing anyone who is on the internet; with or without a Google - * account. - */ - public static Identity allUsers() { - return new Identity(Type.ALL_USERS, null); - } - - /** - * Returns a new identity representing anyone who is authenticated with a Google account or a - * service account. - */ - public static Identity allAuthenticatedUsers() { - return new Identity(Type.ALL_AUTHENTICATED_USERS, null); - } - - /** - * Returns a new user identity. - * - * @param email An email address that represents a specific Google account. For example, - * alice@gmail.com or joe@example.com. - */ - public static Identity user(String email) { - return new Identity(Type.USER, checkNotNull(email)); - } - - /** - * Returns a new service account identity. - * - * @param email An email address that represents a service account. For example, - * my-other-app@appspot.gserviceaccount.com. - */ - public static Identity serviceAccount(String email) { - return new Identity(Type.SERVICE_ACCOUNT, checkNotNull(email)); - } - - /** - * Returns a new group identity. - * - * @param email An email address that represents a Google group. For example, - * admins@example.com. - */ - public static Identity group(String email) { - return new Identity(Type.GROUP, checkNotNull(email)); - } - - /** - * Returns a new domain identity. - * - * @param domain A Google Apps domain name that represents all the users of that domain. For - * example, google.com or example.com. - */ - public static Identity domain(String domain) { - return new Identity(Type.DOMAIN, checkNotNull(domain)); - } - - @Override - public int hashCode() { - return Objects.hash(id, type); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Identity)) { - return false; - } - Identity other = (Identity) obj; - return Objects.equals(id, other.id()) && Objects.equals(type, other.type()); - } - } - - /** - * Builder for an IAM Policy. - */ - protected abstract static class BaseBuilder> { - - private final Map> bindings = new HashMap<>(); - private String etag; - private int version; - - /** - * Replaces the builder's list of bindings with the given list of bindings. - */ - public B bindings(Map> bindings) { - this.bindings.clear(); - this.bindings.putAll(bindings); - return self(); - } - - /** - * Adds one or more bindings to the policy. - */ - public B addBinding(R role, List identities) { - bindings.put(role, ImmutableList.copyOf(identities)); - return self(); - } - - /** - * Removes the specified ACL. - */ - public B removeBinding(R role) { - bindings.remove(role); - return self(); - } - - /** - * Sets the policy's etag. - * - *

Etags are used for optimistic concurrency control as a way to help prevent simultaneous - * updates of a policy from overwriting each other. It is strongly suggested that systems make - * use of the etag in the read-modify-write cycle to perform policy updates in order to avoid - * race conditions. An etag is returned in the response to getIamPolicy, and systems are - * expected to put that etag in the request to setIamPolicy to ensure that their change will be - * applied to the same version of the policy. If no etag is provided in the call to - * setIamPolicy, then the existing policy is overwritten blindly. - */ - protected B etag(String etag) { - this.etag = etag; - return self(); - } - - /** - * Sets the version of the policy. The default version is 0, meaning roles that are in alpha - * (non-legacy) roles are not permitted. If the version is 1, you may use roles other than - * "owner", "editor", and "viewer". - */ - protected B version(int version) { - this.version = version; - return self(); - } - - @SuppressWarnings("unchecked") - private B self() { - return (B) this; - } - - public abstract BaseIamPolicy build(); - } - - protected BaseIamPolicy(BaseBuilder> builder) { - this.bindings = builder.bindings; - this.etag = builder.etag; - this.version = builder.version; - } - - /** - * The list of ACLs specified in the policy. - */ - public Map> bindings() { - return bindings; - } - - /** - * The policy's etag. - * - *

Etags are used for optimistic concurrency control as a way to help prevent simultaneous - * updates of a policy from overwriting each other. It is strongly suggested that systems make - * use of the etag in the read-modify-write cycle to perform policy updates in order to avoid - * race conditions. An etag is returned in the response to getIamPolicy, and systems are - * expected to put that etag in the request to setIamPolicy to ensure that their change will be - * applied to the same version of the policy. If no etag is provided in the call to - * setIamPolicy, then the existing policy is overwritten blindly. - */ - public String etag() { - return etag; - } - - /** - * The version of the policy. The default version is 0. - */ - public int version() { - return version; - } - - public int baseHashCode() { - return Objects.hash(bindings, etag, version); - } - - public boolean baseEquals(Object obj) { - if (!(obj instanceof BaseIamPolicy)) { - return false; - } - @SuppressWarnings("rawtypes") - BaseIamPolicy other = (BaseIamPolicy) obj; - return Objects.equals(bindings, other.bindings()) - && Objects.equals(etag, other.etag()) - && Objects.equals(version, other.version()); - } -} diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java new file mode 100644 index 000000000000..ed9dcf9503c7 --- /dev/null +++ b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java @@ -0,0 +1,213 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** + * Base class for Identity and Access Management (IAM) policies. IAM policies are used to specify + * access settings for Cloud Platform resources. A policy is a map of bindings. A binding assigns + * a set of identities to a role, where the identities can be user accounts, Google groups, Google + * domains, and service accounts. A role is a named list of permissions defined by IAM. + * + * @param the data type of roles (should be serializable) + * @see Policy + */ +public abstract class IamPolicy implements Serializable { + + private static final long serialVersionUID = 1114489978726897720L; + + private final Map> bindings; + private final String etag; + private final Integer version; + + /** + * Builder for an IAM Policy. + * + * @param the data type of roles + * @param the subclass extending this abstract builder + */ + public abstract static class Builder> { + + private final Map> bindings = new HashMap<>(); + private String etag; + private Integer version; + + protected Builder() {} + + /** + * Replaces the builder's map of bindings with the given map of bindings. + */ + public final B bindings(Map> bindings) { + this.bindings.clear(); + for (Map.Entry> binding : bindings.entrySet()) { + this.bindings.put(binding.getKey(), new HashSet(binding.getValue())); + } + return self(); + } + + /** + * Adds a binding to the policy. + */ + public final B addBinding(R role, Set identities) { + checkArgument(!bindings.containsKey(role), + "The policy already contains a binding with the role " + role.toString()); + bindings.put(role, new HashSet(identities)); + return self(); + } + + /** + * Adds a binding to the policy. + */ + public final B addBinding(R role, Identity first, Identity... others) { + checkArgument(!bindings.containsKey(role), + "The policy already contains a binding with the role " + role.toString()); + HashSet identities = new HashSet<>(); + identities.add(first); + identities.addAll(Arrays.asList(others)); + bindings.put(role, identities); + return self(); + } + + /** + * Removes the binding associated with the specified role. + */ + public final B removeBinding(R role) { + bindings.remove(role); + return self(); + } + + /** + * Adds one or more identities to an existing binding. + */ + public final B addIdentity(R role, Identity first, Identity... others) { + Set identities = bindings.get(role); + identities.add(first); + identities.addAll(Arrays.asList(others)); + return self(); + } + + /** + * Removes one or more identities from an existing binding. + */ + public final B removeIdentity(R role, Identity first, Identity... others) { + bindings.get(role).remove(first); + bindings.get(role).removeAll(Arrays.asList(others)); + return self(); + } + + /** + * Sets the policy's etag. + * + *

Etags are used for optimistic concurrency control as a way to help prevent simultaneous + * updates of a policy from overwriting each other. It is strongly suggested that systems make + * use of the etag in the read-modify-write cycle to perform policy updates in order to avoid + * race conditions. An etag is returned in the response to getIamPolicy, and systems are + * expected to put that etag in the request to setIamPolicy to ensure that their change will be + * applied to the same version of the policy. If no etag is provided in the call to + * setIamPolicy, then the existing policy is overwritten blindly. + */ + protected final B etag(String etag) { + this.etag = etag; + return self(); + } + + /** + * Sets the version of the policy. The default version is 0, meaning only the "owner", "editor", + * and "viewer" roles are permitted. If the version is 1, you may also use other roles. + */ + protected final B version(Integer version) { + this.version = version; + return self(); + } + + @SuppressWarnings("unchecked") + private B self() { + return (B) this; + } + + public abstract IamPolicy build(); + } + + protected IamPolicy(Builder> builder) { + ImmutableMap.Builder> bindingsBuilder = ImmutableMap.builder(); + for (Map.Entry> binding : builder.bindings.entrySet()) { + bindingsBuilder.put(binding.getKey(), ImmutableSet.copyOf(binding.getValue())); + } + this.bindings = bindingsBuilder.build(); + this.etag = builder.etag; + this.version = builder.version; + } + + /** + * The map of bindings that comprises the policy. + */ + public Map> bindings() { + return bindings; + } + + /** + * The policy's etag. + * + *

Etags are used for optimistic concurrency control as a way to help prevent simultaneous + * updates of a policy from overwriting each other. It is strongly suggested that systems make + * use of the etag in the read-modify-write cycle to perform policy updates in order to avoid + * race conditions. An etag is returned in the response to getIamPolicy, and systems are + * expected to put that etag in the request to setIamPolicy to ensure that their change will be + * applied to the same version of the policy. If no etag is provided in the call to + * setIamPolicy, then the existing policy is overwritten blindly. + */ + public String etag() { + return etag; + } + + /** + * Sets the version of the policy. The default version is 0, meaning only the "owner", "editor", + * and "viewer" roles are permitted. If the version is 1, you may also use other roles. + */ + public Integer version() { + return version; + } + + @Override + public final int hashCode() { + return Objects.hash(getClass(), bindings, etag, version); + } + + @Override + public final boolean equals(Object obj) { + if (obj == null || !getClass().equals(obj.getClass())) { + return false; + } + @SuppressWarnings("rawtypes") + IamPolicy other = (IamPolicy) obj; + return Objects.equals(bindings, other.bindings()) + && Objects.equals(etag, other.etag()) + && Objects.equals(version, other.version()); + } +} diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java b/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java new file mode 100644 index 000000000000..0513916cc8b4 --- /dev/null +++ b/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java @@ -0,0 +1,208 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.Serializable; +import java.util.Objects; + +/** + * An identity in an {@link IamPolicy}. + */ +public final class Identity implements Serializable { + + private static final long serialVersionUID = -8181841964597657446L; + + private final Type type; + private final String id; + + /** + * The types of IAM identities. + */ + public enum Type { + + /** + * Represents anyone who is on the internet; with or without a Google account. + */ + ALL_USERS, + + /** + * Represents anyone who is authenticated with a Google account or a service account. + */ + ALL_AUTHENTICATED_USERS, + + /** + * Represents a specific Google account. + */ + USER, + + /** + * Represents a service account. + */ + SERVICE_ACCOUNT, + + /** + * Represents a Google group. + */ + GROUP, + + /** + * Represents all the users of a Google Apps domain name. + */ + DOMAIN + } + + private Identity(Type type, String id) { + this.type = type; + this.id = id; + } + + public Type type() { + return type; + } + + /** + * Returns the string identifier for this identity. The id corresponds to: + *

    + *
  • email address (for identities of type {@code USER}, {@code SERVICE_ACCOUNT}, and + * {@code GROUP}) + *
  • domain (for identities of type {@code DOMAIN}) + *
  • null (for identities of type {@code ALL_USERS} and {@code ALL_AUTHENTICATED_USERS}) + *
+ */ + public String id() { + return id; + } + + /** + * Returns a new identity representing anyone who is on the internet; with or without a Google + * account. + */ + public static Identity allUsers() { + return new Identity(Type.ALL_USERS, null); + } + + /** + * Returns a new identity representing anyone who is authenticated with a Google account or a + * service account. + */ + public static Identity allAuthenticatedUsers() { + return new Identity(Type.ALL_AUTHENTICATED_USERS, null); + } + + /** + * Returns a new user identity. + * + * @param email An email address that represents a specific Google account. For example, + * alice@gmail.com or joe@example.com. + */ + public static Identity user(String email) { + return new Identity(Type.USER, checkNotNull(email)); + } + + /** + * Returns a new service account identity. + * + * @param email An email address that represents a service account. For example, + * my-other-app@appspot.gserviceaccount.com. + */ + public static Identity serviceAccount(String email) { + return new Identity(Type.SERVICE_ACCOUNT, checkNotNull(email)); + } + + /** + * Returns a new group identity. + * + * @param email An email address that represents a Google group. For example, + * admins@example.com. + */ + public static Identity group(String email) { + return new Identity(Type.GROUP, checkNotNull(email)); + } + + /** + * Returns a new domain identity. + * + * @param domain A Google Apps domain name that represents all the users of that domain. For + * example, google.com or example.com. + */ + public static Identity domain(String domain) { + return new Identity(Type.DOMAIN, checkNotNull(domain)); + } + + @Override + public int hashCode() { + return Objects.hash(id, type); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Identity)) { + return false; + } + Identity other = (Identity) obj; + return Objects.equals(id, other.id()) && Objects.equals(type, other.type()); + } + + /** + * Returns the string value associated with the identity. Used primarily for converting from + * {@code Identity} objects to strings for protobuf-generated policies. + */ + public String strValue() { + switch (type) { + case ALL_USERS: + return "allUsers"; + case ALL_AUTHENTICATED_USERS: + return "allAuthenticatedUsers"; + case USER: + return "user:" + id; + case SERVICE_ACCOUNT: + return "serviceAccount:" + id; + case GROUP: + return "group:" + id; + case DOMAIN: + return "domain:" + id; + default: + throw new IllegalArgumentException("Unexpected identity type: " + type); + } + } + + /** + * Converts a string to an {@code Identity}. Used primarily for converting protobuf-generated + * policy identities to {@code Identity} objects. + */ + public static Identity valueOf(String identityStr) { + String[] info = identityStr.split(":"); + switch (info[0]) { + case "allUsers": + return Identity.allUsers(); + case "allAuthenticatedUsers": + return Identity.allAuthenticatedUsers(); + case "user": + return Identity.user(info[1]); + case "serviceAccount": + return Identity.serviceAccount(info[1]); + case "group": + return Identity.group(info[1]); + case "domain": + return Identity.domain(info[1]); + default: + throw new IllegalArgumentException("Unexpected identity type: " + info[0]); + } + } +} diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java new file mode 100644 index 000000000000..b77b5e2df7fa --- /dev/null +++ b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java @@ -0,0 +1,173 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +import org.junit.Test; + +import java.util.Map; +import java.util.Set; + +public class IamPolicyTest { + + private static final Identity ALL_USERS = Identity.allUsers(); + private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); + private static final Identity USER = Identity.user("abc@gmail.com"); + private static final Identity SERVICE_ACCOUNT = + Identity.serviceAccount("service-account@gmail.com"); + private static final Identity GROUP = Identity.group("group@gmail.com"); + private static final Identity DOMAIN = Identity.domain("google.com"); + private static final Map> BINDINGS = ImmutableMap.of( + "viewer", + ImmutableSet.of(USER, SERVICE_ACCOUNT, ALL_USERS), + "editor", + ImmutableSet.of(ALL_AUTH_USERS, GROUP, DOMAIN)); + private static final PolicyImpl SIMPLE_POLICY = PolicyImpl.builder() + .addBinding("viewer", ImmutableSet.of(USER, SERVICE_ACCOUNT, ALL_USERS)) + .addBinding("editor", ImmutableSet.of(ALL_AUTH_USERS, GROUP, DOMAIN)) + .build(); + private static final PolicyImpl FULL_POLICY = + new PolicyImpl.Builder(SIMPLE_POLICY.bindings(), "etag", 1).build(); + + static class PolicyImpl extends IamPolicy { + + static class Builder extends IamPolicy.Builder { + + private Builder() {} + + private Builder(Map> bindings, String etag, Integer version) { + bindings(bindings).etag(etag).version(version); + } + + @Override + public PolicyImpl build() { + return new PolicyImpl(this); + } + } + + PolicyImpl(Builder builder) { + super(builder); + } + + Builder toBuilder() { + return new Builder(bindings(), etag(), version()); + } + + static Builder builder() { + return new Builder(); + } + } + + @Test + public void testBuilder() { + assertEquals(BINDINGS, FULL_POLICY.bindings()); + assertEquals("etag", FULL_POLICY.etag()); + assertEquals(1, FULL_POLICY.version().intValue()); + Map> editorBinding = + ImmutableMap.>builder().put("editor", BINDINGS.get("editor")).build(); + PolicyImpl policy = FULL_POLICY.toBuilder().bindings(editorBinding).build(); + assertEquals(editorBinding, policy.bindings()); + assertEquals("etag", policy.etag()); + assertEquals(1, policy.version().intValue()); + policy = SIMPLE_POLICY.toBuilder().removeBinding("editor").build(); + assertEquals(ImmutableMap.of("viewer", BINDINGS.get("viewer")), policy.bindings()); + assertEquals(null, policy.etag()); + assertEquals(null, policy.version()); + policy = policy.toBuilder() + .removeIdentity("viewer", USER, ALL_USERS) + .addIdentity("viewer", DOMAIN, GROUP) + .build(); + assertEquals(ImmutableMap.of("viewer", ImmutableSet.of(SERVICE_ACCOUNT, DOMAIN, GROUP)), + policy.bindings()); + assertEquals(null, policy.etag()); + assertEquals(null, policy.version()); + policy = PolicyImpl.builder().addBinding("owner", USER, SERVICE_ACCOUNT).build(); + assertEquals( + ImmutableMap.of("owner", ImmutableSet.of(USER, SERVICE_ACCOUNT)), policy.bindings()); + assertEquals(null, policy.etag()); + assertEquals(null, policy.version()); + try { + SIMPLE_POLICY.toBuilder().addBinding("viewer", USER); + fail("Should have failed due to duplicate role."); + } catch (IllegalArgumentException e) { + assertEquals("The policy already contains a binding with the role viewer", e.getMessage()); + } + try { + SIMPLE_POLICY.toBuilder().addBinding("editor", ImmutableSet.of(USER)); + fail("Should have failed due to duplicate role."); + } catch (IllegalArgumentException e) { + assertEquals("The policy already contains a binding with the role editor", e.getMessage()); + } + } + + @Test + public void testEqualsHashCode() { + assertNotEquals(FULL_POLICY, null); + PolicyImpl emptyPolicy = PolicyImpl.builder().build(); + AnotherPolicyImpl anotherPolicy = new AnotherPolicyImpl.Builder().build(); + assertNotEquals(emptyPolicy, anotherPolicy); + assertNotEquals(emptyPolicy.hashCode(), anotherPolicy.hashCode()); + assertNotEquals(FULL_POLICY, SIMPLE_POLICY); + assertNotEquals(FULL_POLICY.hashCode(), SIMPLE_POLICY.hashCode()); + PolicyImpl copy = SIMPLE_POLICY.toBuilder().build(); + assertEquals(SIMPLE_POLICY, copy); + assertEquals(SIMPLE_POLICY.hashCode(), copy.hashCode()); + } + + @Test + public void testBindings() { + assertTrue(PolicyImpl.builder().build().bindings().isEmpty()); + assertEquals(BINDINGS, SIMPLE_POLICY.bindings()); + } + + @Test + public void testEtag() { + assertNull(SIMPLE_POLICY.etag()); + assertEquals("etag", FULL_POLICY.etag()); + } + + @Test + public void testVersion() { + assertNull(SIMPLE_POLICY.version()); + assertEquals(null, SIMPLE_POLICY.version()); + } + + static class AnotherPolicyImpl extends IamPolicy { + + static class Builder extends IamPolicy.Builder { + + private Builder() {} + + @Override + public AnotherPolicyImpl build() { + return new AnotherPolicyImpl(this); + } + } + + AnotherPolicyImpl(Builder builder) { + super(builder); + } + } +} diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java new file mode 100644 index 000000000000..7abbc98521a0 --- /dev/null +++ b/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java @@ -0,0 +1,110 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import org.junit.Test; + +public class IdentityTest { + + private static final Identity ALL_USERS = Identity.allUsers(); + private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); + private static final Identity USER = Identity.user("abc@gmail.com"); + private static final Identity SERVICE_ACCOUNT = + Identity.serviceAccount("service-account@gmail.com"); + private static final Identity GROUP = Identity.group("group@gmail.com"); + private static final Identity DOMAIN = Identity.domain("google.com"); + + @Test + public void testAllUsers() { + assertEquals(Identity.Type.ALL_USERS, ALL_USERS.type()); + assertNull(ALL_USERS.id()); + } + + @Test + public void testAllAuthenticatedUsers() { + assertEquals(Identity.Type.ALL_AUTHENTICATED_USERS, ALL_AUTH_USERS.type()); + assertNull(ALL_AUTH_USERS.id()); + } + + @Test + public void testUser() { + assertEquals(Identity.Type.USER, USER.type()); + assertEquals("abc@gmail.com", USER.id()); + try { + Identity.user(null); + fail("Should have thrown exception due to null email address."); + } catch (NullPointerException e) { + // expected + } + } + + @Test + public void testServiceAccount() { + assertEquals(Identity.Type.SERVICE_ACCOUNT, SERVICE_ACCOUNT.type()); + assertEquals("service-account@gmail.com", SERVICE_ACCOUNT.id()); + try { + Identity.serviceAccount(null); + fail("Should have thrown exception due to null email address."); + } catch (NullPointerException e) { + // expected + } + } + + @Test + public void testGroup() { + assertEquals(Identity.Type.GROUP, GROUP.type()); + assertEquals("group@gmail.com", GROUP.id()); + try { + Identity.group(null); + fail("Should have thrown exception due to null email address."); + } catch (NullPointerException e) { + // expected + } + } + + @Test + public void testDomain() { + assertEquals(Identity.Type.DOMAIN, DOMAIN.type()); + assertEquals("google.com", DOMAIN.id()); + try { + Identity.domain(null); + fail("Should have thrown exception due to null domain."); + } catch (NullPointerException e) { + // expected + } + } + + @Test + public void testIdentityToAndFromPb() { + compareIdentities(ALL_USERS, Identity.valueOf(ALL_USERS.strValue())); + compareIdentities(ALL_AUTH_USERS, Identity.valueOf(ALL_AUTH_USERS.strValue())); + compareIdentities(USER, Identity.valueOf(USER.strValue())); + compareIdentities(SERVICE_ACCOUNT, Identity.valueOf(SERVICE_ACCOUNT.strValue())); + compareIdentities(GROUP, Identity.valueOf(GROUP.strValue())); + compareIdentities(DOMAIN, Identity.valueOf(DOMAIN.strValue())); + } + + private void compareIdentities(Identity expected, Identity actual) { + assertEquals(expected, actual); + assertEquals(expected.type(), actual.type()); + assertEquals(expected.id(), actual.id()); + } +} diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/IamPolicy.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/IamPolicy.java deleted file mode 100644 index ccb436fd8a2f..000000000000 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/IamPolicy.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * 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.gcloud.resourcemanager; - -import com.google.common.base.Function; -import com.google.common.collect.Lists; -import com.google.gcloud.BaseIamPolicy; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * Base class for Identity and Access Management (IAM) policies. IAM policies are used to specify - * access settings for Cloud Platform resources. A Policy consists of a list of bindings. An binding - * assigns a list of identities to a role, where the identities can be user accounts, Google groups, - * Google domains, and service accounts. A role is a named list of permissions defined by IAM. - * - * @see Policy - */ -public class IamPolicy extends BaseIamPolicy implements Serializable { - - private static final long serialVersionUID = -5573557282693961850L; - - /** - * Builder for an IAM Policy. - */ - protected static class Builder extends BaseBuilder { - - Builder() {} - - Builder(Map> bindings, String etag, int version) { - bindings(bindings).etag(etag).version(version); - } - - @Override - public IamPolicy build() { - return new IamPolicy(this); - } - } - - private IamPolicy(Builder builder) { - super(builder); - } - - @Override - public int hashCode() { - return baseHashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof IamPolicy)) { - return false; - } - IamPolicy other = (IamPolicy) obj; - return Objects.equals(bindings(), other.bindings()) - && Objects.equals(etag(), other.etag()) - && Objects.equals(version(), other.version()); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(bindings(), etag(), version()); - } - - static String identityToPb(Identity identity) { - switch (identity.type()) { - case ALL_USERS: - return "allUsers"; - case ALL_AUTHENTICATED_USERS: - return "allAuthenticatedUsers"; - case USER: - return "user:" + identity.id(); - case SERVICE_ACCOUNT: - return "serviceAccount:" + identity.id(); - case GROUP: - return "group:" + identity.id(); - default: - return "domain:" + identity.id(); - } - } - - static Identity identityFromPb(String identityStr) { - String[] info = identityStr.split(":"); - switch (info[0]) { - case "allUsers": - return Identity.allUsers(); - case "allAuthenticatedUsers": - return Identity.allAuthenticatedUsers(); - case "user": - return Identity.user(info[1]); - case "serviceAccount": - return Identity.serviceAccount(info[1]); - case "group": - return Identity.group(info[1]); - case "domain": - return Identity.domain(info[1]); - default: - throw new IllegalArgumentException("Unexpected identity type: " + info[0]); - } - } - - com.google.api.services.cloudresourcemanager.model.Policy toPb() { - com.google.api.services.cloudresourcemanager.model.Policy policyPb = - new com.google.api.services.cloudresourcemanager.model.Policy(); - List bindingPbList = - new LinkedList<>(); - for (Map.Entry> binding : bindings().entrySet()) { - com.google.api.services.cloudresourcemanager.model.Binding bindingPb = - new com.google.api.services.cloudresourcemanager.model.Binding(); - bindingPb.setRole("roles/" + binding.getKey()); - bindingPb.setMembers(Lists.transform(binding.getValue(), new Function() { - @Override - public String apply(Identity identity) { - return identityToPb(identity); - } - })); - bindingPbList.add(bindingPb); - } - policyPb.setBindings(bindingPbList); - policyPb.setEtag(etag()); - policyPb.setVersion(version()); - return policyPb; - } - - static IamPolicy fromPb( - com.google.api.services.cloudresourcemanager.model.Policy policyPb) { - Map> bindings = new HashMap<>(); - for (com.google.api.services.cloudresourcemanager.model.Binding bindingPb : - policyPb.getBindings()) { - bindings.put(bindingPb.getRole().substring("roles/".length()), - Lists.transform(bindingPb.getMembers(), new Function() { - @Override - public Identity apply(String identityPb) { - return identityFromPb(identityPb); - } - })); - } - return new IamPolicy.Builder(bindings, policyPb.getEtag(), policyPb.getVersion()).build(); - } -} diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java new file mode 100644 index 000000000000..09cbfa1db554 --- /dev/null +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java @@ -0,0 +1,122 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.resourcemanager; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.gcloud.IamPolicy; +import com.google.gcloud.Identity; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * An Identity and Access Management (IAM) policy for a project. IAM policies are used to specify + * access settings for Cloud Platform resources. A policy is a map of bindings. A binding assigns + * a set of identities to a role, where the identities can be user accounts, Google groups, Google + * domains, and service accounts. A role is a named list of permissions defined by IAM. Policies set + * at the project level control access both to the project and to resources associated with the + * project. + * + * @see Policy + */ +public class Policy extends IamPolicy { + + private static final long serialVersionUID = -5573557282693961850L; + + /** + * Builder for an IAM Policy. + */ + public static class Builder extends IamPolicy.Builder { + + private Builder() {} + + @VisibleForTesting + Builder(Map> bindings, String etag, Integer version) { + bindings(bindings).etag(etag).version(version); + } + + @Override + public Policy build() { + return new Policy(this); + } + } + + private Policy(Builder builder) { + super(builder); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(bindings(), etag(), version()); + } + + com.google.api.services.cloudresourcemanager.model.Policy toPb() { + com.google.api.services.cloudresourcemanager.model.Policy policyPb = + new com.google.api.services.cloudresourcemanager.model.Policy(); + List bindingPbList = + new LinkedList<>(); + for (Map.Entry> binding : bindings().entrySet()) { + com.google.api.services.cloudresourcemanager.model.Binding bindingPb = + new com.google.api.services.cloudresourcemanager.model.Binding(); + bindingPb.setRole("roles/" + binding.getKey()); + bindingPb.setMembers( + Lists.transform( + new ArrayList<>(binding.getValue()), + new Function() { + @Override + public String apply(Identity identity) { + return identity.strValue(); + } + })); + bindingPbList.add(bindingPb); + } + policyPb.setBindings(bindingPbList); + policyPb.setEtag(etag()); + policyPb.setVersion(version()); + return policyPb; + } + + static Policy fromPb( + com.google.api.services.cloudresourcemanager.model.Policy policyPb) { + Map> bindings = new HashMap<>(); + for (com.google.api.services.cloudresourcemanager.model.Binding bindingPb : + policyPb.getBindings()) { + bindings.put( + bindingPb.getRole().substring("roles/".length()), + ImmutableSet.copyOf( + Lists.transform( + bindingPb.getMembers(), + new Function() { + @Override + public Identity apply(String identityPb) { + return Identity.valueOf(identityPb); + } + }))); + } + return new Policy.Builder(bindings, policyPb.getEtag(), policyPb.getVersion()).build(); + } +} diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/IamPolicyTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/IamPolicyTest.java deleted file mode 100644 index e2f05ac8493b..000000000000 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/IamPolicyTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2016 Google Inc. All Rights Reserved. - * - * 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.gcloud.resourcemanager; - -import static org.junit.Assert.assertEquals; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.gcloud.BaseIamPolicy.Identity; - -import org.junit.Test; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class IamPolicyTest { - - private static final Identity ALL_USERS = Identity.allUsers(); - private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); - private static final Identity USER = Identity.user("abc@gmail.com"); - private static final Identity SERVICE_ACCOUNT = - Identity.serviceAccount("service-account@gmail.com"); - private static final Identity GROUP = Identity.group("group@gmail.com"); - private static final Identity DOMAIN = Identity.domain("google.com"); - private static final Map> BINDINGS = ImmutableMap.of( - "viewer", - ImmutableList.of(USER, SERVICE_ACCOUNT, ALL_USERS), - "editor", - ImmutableList.of(ALL_AUTH_USERS, GROUP, DOMAIN)); - private static final IamPolicy SIMPLE_POLICY = IamPolicy.builder() - .addBinding("viewer", ImmutableList.of(USER, SERVICE_ACCOUNT, ALL_USERS)) - .addBinding("editor", ImmutableList.of(ALL_AUTH_USERS, GROUP, DOMAIN)) - .build(); - private static final IamPolicy FULL_POLICY = - new IamPolicy.Builder(SIMPLE_POLICY.bindings(), "etag", 1).build(); - - @Test - public void testIamPolicyBuilder() { - assertEquals(BINDINGS, FULL_POLICY.bindings()); - assertEquals("etag", FULL_POLICY.etag()); - assertEquals(1, FULL_POLICY.version()); - Map> editorBinding = new HashMap<>(); - editorBinding.put("editor", BINDINGS.get("editor")); - IamPolicy policy = FULL_POLICY.toBuilder().bindings(editorBinding).build(); - assertEquals(ImmutableMap.of("editor", BINDINGS.get("editor")), policy.bindings()); - assertEquals("etag", policy.etag()); - assertEquals(1, policy.version()); - policy = SIMPLE_POLICY.toBuilder().removeBinding("editor").build(); - assertEquals(ImmutableMap.of("viewer", BINDINGS.get("viewer")), policy.bindings()); - assertEquals(null, policy.etag()); - assertEquals(0, policy.version()); - } - - @Test - public void testIamPolicyToBuilder() { - assertEquals(FULL_POLICY, FULL_POLICY.toBuilder().build()); - assertEquals(SIMPLE_POLICY, SIMPLE_POLICY.toBuilder().build()); - } - - @Test - public void testIdentityToAndFromPb() { - assertEquals(ALL_USERS, IamPolicy.identityFromPb(IamPolicy.identityToPb(ALL_USERS))); - assertEquals(ALL_AUTH_USERS, IamPolicy.identityFromPb(IamPolicy.identityToPb(ALL_AUTH_USERS))); - assertEquals(USER, IamPolicy.identityFromPb(IamPolicy.identityToPb(USER))); - assertEquals( - SERVICE_ACCOUNT, IamPolicy.identityFromPb(IamPolicy.identityToPb(SERVICE_ACCOUNT))); - assertEquals(GROUP, IamPolicy.identityFromPb(IamPolicy.identityToPb(GROUP))); - assertEquals(DOMAIN, IamPolicy.identityFromPb(IamPolicy.identityToPb(DOMAIN))); - } - - @Test - public void testPolicyToAndFromPb() { - assertEquals(FULL_POLICY, IamPolicy.fromPb(FULL_POLICY.toPb())); - assertEquals(SIMPLE_POLICY, IamPolicy.fromPb(SIMPLE_POLICY.toPb())); - } -} diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/BaseIamPolicyTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java similarity index 55% rename from gcloud-java-core/src/test/java/com/google/gcloud/BaseIamPolicyTest.java rename to gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java index 0c26bc806812..3383eebf470c 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/BaseIamPolicyTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Google Inc. All Rights Reserved. + * Copyright 2016 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,16 @@ * limitations under the License. */ -package com.google.gcloud; +package com.google.gcloud.resourcemanager; import static org.junit.Assert.assertEquals; -import com.google.gcloud.BaseIamPolicy.Identity; +import com.google.common.collect.ImmutableSet; +import com.google.gcloud.Identity; import org.junit.Test; -public class BaseIamPolicyTest { +public class PolicyTest { private static final Identity ALL_USERS = Identity.allUsers(); private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); @@ -31,20 +32,22 @@ public class BaseIamPolicyTest { Identity.serviceAccount("service-account@gmail.com"); private static final Identity GROUP = Identity.group("group@gmail.com"); private static final Identity DOMAIN = Identity.domain("google.com"); + private static final Policy SIMPLE_POLICY = Policy.builder() + .addBinding("viewer", ImmutableSet.of(USER, SERVICE_ACCOUNT, ALL_USERS)) + .addBinding("editor", ImmutableSet.of(ALL_AUTH_USERS, GROUP, DOMAIN)) + .build(); + private static final Policy FULL_POLICY = + new Policy.Builder(SIMPLE_POLICY.bindings(), "etag", 1).build(); @Test - public void testIdentityOf() { - assertEquals(Identity.Type.ALL_USERS, ALL_USERS.type()); - assertEquals(null, ALL_USERS.id()); - assertEquals(Identity.Type.ALL_AUTHENTICATED_USERS, ALL_AUTH_USERS.type()); - assertEquals(null, ALL_AUTH_USERS.id()); - assertEquals(Identity.Type.USER, USER.type()); - assertEquals("abc@gmail.com", USER.id()); - assertEquals(Identity.Type.SERVICE_ACCOUNT, SERVICE_ACCOUNT.type()); - assertEquals("service-account@gmail.com", SERVICE_ACCOUNT.id()); - assertEquals(Identity.Type.GROUP, GROUP.type()); - assertEquals("group@gmail.com", GROUP.id()); - assertEquals(Identity.Type.DOMAIN, DOMAIN.type()); - assertEquals("google.com", DOMAIN.id()); + public void testIamPolicyToBuilder() { + assertEquals(FULL_POLICY, FULL_POLICY.toBuilder().build()); + assertEquals(SIMPLE_POLICY, SIMPLE_POLICY.toBuilder().build()); + } + + @Test + public void testPolicyToAndFromPb() { + assertEquals(FULL_POLICY, Policy.fromPb(FULL_POLICY.toPb())); + assertEquals(SIMPLE_POLICY, Policy.fromPb(SIMPLE_POLICY.toPb())); } } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index 1049f40f5f17..99c0fd7572c0 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -19,9 +19,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.gcloud.BaseIamPolicy.Identity; +import com.google.common.collect.ImmutableSet; +import com.google.gcloud.Identity; import com.google.gcloud.PageImpl; import com.google.gcloud.RetryParams; @@ -55,9 +55,9 @@ public class SerializationTest { ResourceManager.ProjectGetOption.fields(ResourceManager.ProjectField.NAME); private static final ResourceManager.ProjectListOption PROJECT_LIST_OPTION = ResourceManager.ProjectListOption.filter("name:*"); - private static final Identity IDENTITY = Identity.user("abc@gmail.com"); - private static final IamPolicy POLICY = - IamPolicy.builder().addBinding("viewer", ImmutableList.of(IDENTITY)).build(); + private static final Policy POLICY = Policy.builder() + .addBinding("viewer", ImmutableSet.of(Identity.user("abc@gmail.com"))) + .build(); @Test public void testServiceOptions() throws Exception { @@ -75,7 +75,7 @@ public void testServiceOptions() throws Exception { @Test public void testModelAndRequests() throws Exception { Serializable[] objects = {PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PROJECT, PAGE_RESULT, - PROJECT_GET_OPTION, PROJECT_LIST_OPTION, IDENTITY, POLICY}; + PROJECT_GET_OPTION, PROJECT_LIST_OPTION, POLICY}; for (Serializable obj : objects) { Object copy = serializeAndDeserialize(obj); assertEquals(obj, obj); From 1583e2c8b8763a003b5d0d16d27cf53a97410603 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 25 Feb 2016 16:20:54 +0100 Subject: [PATCH 086/203] Add pageToken to list fields option for GCS and resourcemanager --- .../resourcemanager/ResourceManager.java | 2 +- .../testing/LocalResourceManagerHelper.java | 24 +++++--- .../LocalResourceManagerHelperTest.java | 61 ++++++++++++++++++- .../ResourceManagerImplTest.java | 32 ++++++++++ .../com/google/gcloud/storage/Storage.java | 4 +- .../gcloud/storage/StorageImplTest.java | 12 ++-- 6 files changed, 120 insertions(+), 15 deletions(-) diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java index b641fa74b584..3d27f2a33ac8 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java @@ -162,7 +162,7 @@ public static ProjectListOption pageSize(int pageSize) { */ public static ProjectListOption fields(ProjectField... fields) { StringBuilder builder = new StringBuilder(); - builder.append("projects(").append(ProjectField.selector(fields)).append(")"); + builder.append("projects(").append(ProjectField.selector(fields)).append("),nextPageToken"); return new ProjectListOption(ResourceManagerRpc.Option.FIELDS, builder.toString()); } } diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java index 4c26a44cd4e6..2e3b8c25db41 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -236,10 +236,18 @@ private static Map parseListOptions(String query) throws IOExcep String[] argEntry = arg.split("="); switch (argEntry[0]) { case "fields": - // List fields are in the form "projects(field1, field2, ...)" - options.put( - "fields", - argEntry[1].substring("projects(".length(), argEntry[1].length() - 1).split(",")); + // List fields are in the form "projects(field1, field2, ...),nextPageToken" + String option = argEntry[1]; + int projectStart = option.indexOf("projects("); + int projectEnd = option.indexOf(')'); + if (projectStart != -1 && projectEnd != -1 + && projectEnd > projectStart + "projects(".length()) { + String projectFields = + option.substring(projectStart + "projects(".length(), projectEnd); + options.put("projectFields", projectFields.split(",")); + option = option.replace(option.substring(projectStart, projectEnd), ""); + } + options.put("listFields", option.split(",")); break; case "filter": options.put("filter", argEntry[1].split(" ")); @@ -362,7 +370,7 @@ Response list(Map options) { if (filters != null && !isValidFilter(filters)) { return Error.INVALID_ARGUMENT.response("Could not parse the filter."); } - String[] fields = (String[]) options.get("fields"); + String[] projectFields = (String[]) options.get("projectFields"); int count = 0; String pageToken = (String) options.get("pageToken"); Integer pageSize = (Integer) options.get("pageSize"); @@ -380,7 +388,7 @@ Response list(Map options) { if (includeProject) { count++; try { - projectsSerialized.add(jsonFactory.toString(extractFields(p, fields))); + projectsSerialized.add(jsonFactory.toString(extractFields(p, projectFields))); } catch (IOException e) { return Error.INTERNAL_ERROR.response( "Error when serializing project " + p.getProjectId()); @@ -391,7 +399,9 @@ Response list(Map options) { responseBody.append("{\"projects\": ["); Joiner.on(",").appendTo(responseBody, projectsSerialized); responseBody.append(']'); - if (nextPageToken != null) { + String[] listFields = (String[]) options.get("listFields"); + if (nextPageToken != null && (listFields == null + || ImmutableSet.copyOf(listFields).contains("nextPageToken"))) { responseBody.append(", \"nextPageToken\": \""); responseBody.append(nextPageToken); responseBody.append('"'); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java index 6c20c4f1ae0e..978e9c2f0416 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java @@ -333,7 +333,8 @@ public void testListPaging() { @Test public void testListFieldOptions() { Map rpcOptions = new HashMap<>(); - rpcOptions.put(ResourceManagerRpc.Option.FIELDS, "projects(projectId,name,labels)"); + rpcOptions.put(ResourceManagerRpc.Option.FIELDS, + "projects(projectId,name,labels),nextPageToken"); rpc.create(PROJECT_WITH_PARENT); Tuple> projects = rpc.list(rpcOptions); @@ -349,6 +350,64 @@ public void testListFieldOptions() { assertNull(returnedProject.getCreateTime()); } + @Test + public void testListPageTokenFieldOptions() { + Map rpcOptions = new HashMap<>(); + rpcOptions.put(ResourceManagerRpc.Option.PAGE_SIZE, 1); + rpcOptions.put(ResourceManagerRpc.Option.FIELDS, "nextPageToken,projects(projectId,name)"); + rpc.create(PARTIAL_PROJECT); + rpc.create(COMPLETE_PROJECT); + Tuple> projects = + rpc.list(rpcOptions); + assertNotNull(projects.x()); + Iterator iterator = + projects.y().iterator(); + com.google.api.services.cloudresourcemanager.model.Project returnedProject = iterator.next(); + assertEquals(COMPLETE_PROJECT.getProjectId(), returnedProject.getProjectId()); + assertEquals(COMPLETE_PROJECT.getName(), returnedProject.getName()); + assertNull(returnedProject.getLabels()); + assertNull(returnedProject.getParent()); + assertNull(returnedProject.getProjectNumber()); + assertNull(returnedProject.getLifecycleState()); + assertNull(returnedProject.getCreateTime()); + assertFalse(iterator.hasNext()); + rpcOptions.put(ResourceManagerRpc.Option.PAGE_TOKEN, projects.x()); + projects = rpc.list(rpcOptions); + iterator = projects.y().iterator(); + returnedProject = iterator.next(); + assertEquals(PARTIAL_PROJECT.getProjectId(), returnedProject.getProjectId()); + assertEquals(PARTIAL_PROJECT.getName(), returnedProject.getName()); + assertNull(returnedProject.getLabels()); + assertNull(returnedProject.getParent()); + assertNull(returnedProject.getProjectNumber()); + assertNull(returnedProject.getLifecycleState()); + assertNull(returnedProject.getCreateTime()); + assertNull(projects.x()); + } + + @Test + public void testListNoPageTokenFieldOptions() { + Map rpcOptions = new HashMap<>(); + rpcOptions.put(ResourceManagerRpc.Option.PAGE_SIZE, 1); + rpcOptions.put(ResourceManagerRpc.Option.FIELDS, "projects(projectId,name)"); + rpc.create(PARTIAL_PROJECT); + rpc.create(COMPLETE_PROJECT); + Tuple> projects = + rpc.list(rpcOptions); + assertNull(projects.x()); + Iterator iterator = + projects.y().iterator(); + com.google.api.services.cloudresourcemanager.model.Project returnedProject = iterator.next(); + assertEquals(COMPLETE_PROJECT.getProjectId(), returnedProject.getProjectId()); + assertEquals(COMPLETE_PROJECT.getName(), returnedProject.getName()); + assertNull(returnedProject.getLabels()); + assertNull(returnedProject.getParent()); + assertNull(returnedProject.getProjectNumber()); + assertNull(returnedProject.getLifecycleState()); + assertNull(returnedProject.getCreateTime()); + assertFalse(iterator.hasNext()); + } + @Test public void testListFilterOptions() { Map rpcFilterOptions = new HashMap<>(); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java index 8d64652a0696..1bc233311a4d 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java @@ -213,6 +213,38 @@ public void testListFieldOptions() { assertSame(RESOURCE_MANAGER, returnedProject.resourceManager()); } + @Test + public void testListPagingWithFieldOptions() { + RESOURCE_MANAGER.create(PARTIAL_PROJECT); + RESOURCE_MANAGER.create(COMPLETE_PROJECT); + Page projects = RESOURCE_MANAGER.list(LIST_FIELDS, ProjectListOption.pageSize(1)); + assertNotNull(projects.nextPageCursor()); + Iterator iterator = projects.values().iterator(); + Project returnedProject = iterator.next(); + assertEquals(COMPLETE_PROJECT.projectId(), returnedProject.projectId()); + assertEquals(COMPLETE_PROJECT.name(), returnedProject.name()); + assertEquals(COMPLETE_PROJECT.labels(), returnedProject.labels()); + assertNull(returnedProject.parent()); + assertNull(returnedProject.projectNumber()); + assertNull(returnedProject.state()); + assertNull(returnedProject.createTimeMillis()); + assertSame(RESOURCE_MANAGER, returnedProject.resourceManager()); + assertFalse(iterator.hasNext()); + projects = projects.nextPage(); + iterator = projects.values().iterator(); + returnedProject = iterator.next(); + assertEquals(PARTIAL_PROJECT.projectId(), returnedProject.projectId()); + assertEquals(PARTIAL_PROJECT.name(), returnedProject.name()); + assertEquals(PARTIAL_PROJECT.labels(), returnedProject.labels()); + assertNull(returnedProject.parent()); + assertNull(returnedProject.projectNumber()); + assertNull(returnedProject.state()); + assertNull(returnedProject.createTimeMillis()); + assertSame(RESOURCE_MANAGER, returnedProject.resourceManager()); + assertFalse(iterator.hasNext()); + assertNull(projects.nextPageCursor()); + } + @Test public void testListFilterOptions() { ProjectInfo matchingProject = ProjectInfo.builder("matching-project") diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 0ebe013202b0..4acc1dbcad07 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -655,7 +655,7 @@ public static BucketListOption prefix(String prefix) { */ public static BucketListOption fields(BucketField... fields) { StringBuilder builder = new StringBuilder(); - builder.append("items(").append(BucketField.selector(fields)).append(")"); + builder.append("items(").append(BucketField.selector(fields)).append("),nextPageToken"); return new BucketListOption(StorageRpc.Option.FIELDS, builder.toString()); } } @@ -708,7 +708,7 @@ public static BlobListOption recursive(boolean recursive) { */ public static BlobListOption fields(BlobField... fields) { StringBuilder builder = new StringBuilder(); - builder.append("items(").append(BlobField.selector(fields)).append(")"); + builder.append("items(").append(BlobField.selector(fields)).append("),nextPageToken"); return new BlobListOption(StorageRpc.Option.FIELDS, builder.toString()); } } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java index f49938c5e9c1..b14dcd057438 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java @@ -586,7 +586,8 @@ public void testListBucketsWithSelectedFields() { assertTrue(selector.contains("name")); assertTrue(selector.contains("acl")); assertTrue(selector.contains("location")); - assertEquals(24, selector.length()); + assertTrue(selector.contains("nextPageToken")); + assertEquals(38, selector.length()); assertEquals(cursor, page.nextPageCursor()); assertArrayEquals(bucketList.toArray(), Iterables.toArray(page.values(), Bucket.class)); } @@ -606,7 +607,8 @@ public void testListBucketsWithEmptyFields() { String selector = (String) capturedOptions.getValue().get(BLOB_LIST_FIELDS.rpcOption()); assertTrue(selector.contains("items")); assertTrue(selector.contains("name")); - assertEquals(11, selector.length()); + assertTrue(selector.contains("nextPageToken")); + assertEquals(25, selector.length()); assertEquals(cursor, page.nextPageCursor()); assertArrayEquals(bucketList.toArray(), Iterables.toArray(page.values(), Bucket.class)); } @@ -678,7 +680,8 @@ public void testListBlobsWithSelectedFields() { assertTrue(selector.contains("name")); assertTrue(selector.contains("contentType")); assertTrue(selector.contains("md5Hash")); - assertEquals(38, selector.length()); + assertTrue(selector.contains("nextPageToken")); + assertEquals(52, selector.length()); assertEquals(cursor, page.nextPageCursor()); assertArrayEquals(blobList.toArray(), Iterables.toArray(page.values(), Blob.class)); } @@ -706,7 +709,8 @@ public void testListBlobsWithEmptyFields() { assertTrue(selector.contains("items")); assertTrue(selector.contains("bucket")); assertTrue(selector.contains("name")); - assertEquals(18, selector.length()); + assertTrue(selector.contains("nextPageToken")); + assertEquals(32, selector.length()); assertEquals(cursor, page.nextPageCursor()); assertArrayEquals(blobList.toArray(), Iterables.toArray(page.values(), Blob.class)); } From 28f4a18ae41148f82ffe11bbb311f92f50da180f Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 25 Feb 2016 17:05:55 +0100 Subject: [PATCH 087/203] validateOpen throws ClosedChannelException in BaseWriteChannel and BlobReadChannel --- .../src/main/java/com/google/gcloud/BaseWriteChannel.java | 5 +++-- .../test/java/com/google/gcloud/BaseWriteChannelTest.java | 4 ++-- .../java/com/google/gcloud/storage/BlobReadChannel.java | 7 ++++--- .../com/google/gcloud/storage/BlobReadChannelTest.java | 7 ++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/BaseWriteChannel.java b/gcloud-java-core/src/main/java/com/google/gcloud/BaseWriteChannel.java index e05383a65826..1d18a5a27e81 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/BaseWriteChannel.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/BaseWriteChannel.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; import java.util.Arrays; import java.util.Objects; @@ -114,9 +115,9 @@ private void flush() { } } - private void validateOpen() throws IOException { + private void validateOpen() throws ClosedChannelException { if (!isOpen) { - throw new IOException("stream is closed"); + throw new ClosedChannelException(); } } diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/BaseWriteChannelTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/BaseWriteChannelTest.java index e49a17b019e0..6d5306a3bc7f 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/BaseWriteChannelTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/BaseWriteChannelTest.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; import java.util.Arrays; import java.util.Random; @@ -102,8 +103,7 @@ public void testClose() throws IOException { @Test public void testValidateOpen() throws IOException { channel.close(); - thrown.expect(IOException.class); - thrown.expectMessage("stream is closed"); + thrown.expect(ClosedChannelException.class); channel.write(ByteBuffer.allocate(42)); } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java index 121f2eb63589..2b9643434ecc 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.Serializable; import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; import java.util.Map; import java.util.Objects; import java.util.concurrent.Callable; @@ -55,7 +56,7 @@ class BlobReadChannel implements ReadChannel { private byte[] buffer; BlobReadChannel(StorageOptions serviceOptions, BlobId blob, - Map requestOptions) { + Map requestOptions) { this.serviceOptions = serviceOptions; this.blob = blob; this.requestOptions = requestOptions; @@ -91,9 +92,9 @@ public void close() { } } - private void validateOpen() throws IOException { + private void validateOpen() throws ClosedChannelException { if (!isOpen) { - throw new IOException("stream is closed"); + throw new ClosedChannelException(); } } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobReadChannelTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobReadChannelTest.java index ffb37e8c5032..5dc947df51f8 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobReadChannelTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobReadChannelTest.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; import java.util.Arrays; import java.util.Map; import java.util.Random; @@ -156,15 +157,15 @@ public void testClose() { } @Test - public void testReadClosed() { + public void testReadClosed() throws IOException { replay(storageRpcMock); reader = new BlobReadChannel(options, BLOB_ID, EMPTY_RPC_OPTIONS); reader.close(); try { ByteBuffer readBuffer = ByteBuffer.allocate(DEFAULT_CHUNK_SIZE); reader.read(readBuffer); - fail("Expected BlobReadChannel read to throw IOException"); - } catch (IOException ex) { + fail("Expected BlobReadChannel read to throw ClosedChannelException"); + } catch (ClosedChannelException ex) { // expected } } From 08295eeca633772ebab9dafab62aa2cc1e8ad627 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Thu, 25 Feb 2016 09:13:01 -0800 Subject: [PATCH 088/203] Document exceptions and satisfy codacy's demands. --- .../java/com/google/gcloud/IamPolicy.java | 15 +++++++ .../java/com/google/gcloud/IdentityTest.java | 45 +++++++++---------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java index ed9dcf9503c7..73c3e3fec6ac 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java @@ -58,6 +58,9 @@ public abstract static class Builder> { private String etag; private Integer version; + /** + * Constructor for IAM Policy builder. + */ protected Builder() {} /** @@ -73,6 +76,8 @@ public final B bindings(Map> bindings) { /** * Adds a binding to the policy. + * + * @throws IllegalArgumentException if the policy already contains a binding with the same role */ public final B addBinding(R role, Set identities) { checkArgument(!bindings.containsKey(role), @@ -83,6 +88,8 @@ public final B addBinding(R role, Set identities) { /** * Adds a binding to the policy. + * + * @throws IllegalArgumentException if the policy already contains a binding with the same role */ public final B addBinding(R role, Identity first, Identity... others) { checkArgument(!bindings.containsKey(role), @@ -104,8 +111,12 @@ public final B removeBinding(R role) { /** * Adds one or more identities to an existing binding. + * + * @throws IllegalArgumentException if the policy doesn't contain a binding with the specified + * role */ public final B addIdentity(R role, Identity first, Identity... others) { + checkArgument(bindings.containsKey(role), "The policy doesn't contain the specified role."); Set identities = bindings.get(role); identities.add(first); identities.addAll(Arrays.asList(others)); @@ -114,8 +125,12 @@ public final B addIdentity(R role, Identity first, Identity... others) { /** * Removes one or more identities from an existing binding. + * + * @throws IllegalArgumentException if the policy doesn't contain a binding with the specified + * role */ public final B removeIdentity(R role, Identity first, Identity... others) { + checkArgument(bindings.containsKey(role), "The policy doesn't contain the specified role."); bindings.get(role).remove(first); bindings.get(role).removeAll(Arrays.asList(others)); return self(); diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java index 7abbc98521a0..828f1c839431 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; import org.junit.Test; @@ -48,48 +47,44 @@ public void testAllAuthenticatedUsers() { public void testUser() { assertEquals(Identity.Type.USER, USER.type()); assertEquals("abc@gmail.com", USER.id()); - try { - Identity.user(null); - fail("Should have thrown exception due to null email address."); - } catch (NullPointerException e) { - // expected - } + } + + @Test(expected = NullPointerException.class) + public void testUserNullEmail() { + Identity.user(null); } @Test public void testServiceAccount() { assertEquals(Identity.Type.SERVICE_ACCOUNT, SERVICE_ACCOUNT.type()); assertEquals("service-account@gmail.com", SERVICE_ACCOUNT.id()); - try { - Identity.serviceAccount(null); - fail("Should have thrown exception due to null email address."); - } catch (NullPointerException e) { - // expected - } + } + + @Test(expected = NullPointerException.class) + public void testServiceAccountNullEmail() { + Identity.serviceAccount(null); } @Test public void testGroup() { assertEquals(Identity.Type.GROUP, GROUP.type()); assertEquals("group@gmail.com", GROUP.id()); - try { - Identity.group(null); - fail("Should have thrown exception due to null email address."); - } catch (NullPointerException e) { - // expected - } + } + + @Test(expected = NullPointerException.class) + public void testGroupNullEmail() { + Identity.group(null); } @Test public void testDomain() { assertEquals(Identity.Type.DOMAIN, DOMAIN.type()); assertEquals("google.com", DOMAIN.id()); - try { - Identity.domain(null); - fail("Should have thrown exception due to null domain."); - } catch (NullPointerException e) { - // expected - } + } + + @Test(expected = NullPointerException.class) + public void testDomainNullId() { + Identity.domain(null); } @Test From 5fea7ce3b1796f8dea70286a6fbfd2ed7ed0eed9 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 25 Feb 2016 19:12:00 +0100 Subject: [PATCH 089/203] Use Pattern to match list fields selector --- .../testing/LocalResourceManagerHelper.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java index 2e3b8c25db41..7caf7ef0e84d 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -37,6 +37,8 @@ import java.util.concurrent.ConcurrentSkipListMap; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; /** @@ -56,6 +58,8 @@ public class LocalResourceManagerHelper { private static final URI BASE_CONTEXT; private static final Set SUPPORTED_COMPRESSION_ENCODINGS = ImmutableSet.of("gzip", "x-gzip"); + private static final Pattern LIST_FIELDS_PATTERN = + Pattern.compile("(.*?)projects\\((.*?)\\)(.*?)"); static { try { @@ -237,17 +241,11 @@ private static Map parseListOptions(String query) throws IOExcep switch (argEntry[0]) { case "fields": // List fields are in the form "projects(field1, field2, ...),nextPageToken" - String option = argEntry[1]; - int projectStart = option.indexOf("projects("); - int projectEnd = option.indexOf(')'); - if (projectStart != -1 && projectEnd != -1 - && projectEnd > projectStart + "projects(".length()) { - String projectFields = - option.substring(projectStart + "projects(".length(), projectEnd); - options.put("projectFields", projectFields.split(",")); - option = option.replace(option.substring(projectStart, projectEnd), ""); + Matcher matcher = LIST_FIELDS_PATTERN.matcher(argEntry[1]); + if (matcher.matches()) { + options.put("projectFields", matcher.group(2).split(",")); + options.put("listFields", (matcher.group(1) + matcher.group(3)).split(",")); } - options.put("listFields", option.split(",")); break; case "filter": options.put("filter", argEntry[1].split(" ")); From a62c69dec52fcb1248c173fa3f2e104af9473048 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 25 Feb 2016 21:23:25 +0100 Subject: [PATCH 090/203] Handle no project fields are selected on list --- .../testing/LocalResourceManagerHelper.java | 23 +++++++++++++++---- .../LocalResourceManagerHelperTest.java | 17 ++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java index 7caf7ef0e84d..438439c44dd0 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -60,6 +60,7 @@ public class LocalResourceManagerHelper { ImmutableSet.of("gzip", "x-gzip"); private static final Pattern LIST_FIELDS_PATTERN = Pattern.compile("(.*?)projects\\((.*?)\\)(.*?)"); + private static final String[] NO_FIELDS = {}; static { try { @@ -245,6 +246,9 @@ private static Map parseListOptions(String query) throws IOExcep if (matcher.matches()) { options.put("projectFields", matcher.group(2).split(",")); options.put("listFields", (matcher.group(1) + matcher.group(3)).split(",")); + } else { + options.put("projectFields", NO_FIELDS); + options.put("listFields", argEntry[1].split(",")); } break; case "filter": @@ -393,14 +397,23 @@ Response list(Map options) { } } } - StringBuilder responseBody = new StringBuilder(); - responseBody.append("{\"projects\": ["); - Joiner.on(",").appendTo(responseBody, projectsSerialized); - responseBody.append(']'); String[] listFields = (String[]) options.get("listFields"); + StringBuilder responseBody = new StringBuilder(); + responseBody.append('{'); + boolean commaNeeded = false; + // If fields parameter is set but no project field is selected we must return no projects. + if (!(projectFields != null && projectFields.length == 0)) { + responseBody.append("\"projects\": ["); + Joiner.on(",").appendTo(responseBody, projectsSerialized); + responseBody.append(']'); + commaNeeded = true; + } if (nextPageToken != null && (listFields == null || ImmutableSet.copyOf(listFields).contains("nextPageToken"))) { - responseBody.append(", \"nextPageToken\": \""); + if (commaNeeded) { + responseBody.append(','); + } + responseBody.append("\"nextPageToken\": \""); responseBody.append(nextPageToken); responseBody.append('"'); } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java index 978e9c2f0416..a3418fff98ab 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java @@ -408,6 +408,23 @@ public void testListNoPageTokenFieldOptions() { assertFalse(iterator.hasNext()); } + @Test + public void testListPageTokenNoFieldsOptions() { + Map rpcOptions = new HashMap<>(); + rpcOptions.put(ResourceManagerRpc.Option.PAGE_SIZE, 1); + rpcOptions.put(ResourceManagerRpc.Option.FIELDS, "nextPageToken"); + rpc.create(PARTIAL_PROJECT); + rpc.create(COMPLETE_PROJECT); + Tuple> projects = + rpc.list(rpcOptions); + assertNotNull(projects.x()); + assertNull(projects.y()); + rpcOptions.put(ResourceManagerRpc.Option.PAGE_TOKEN, projects.x()); + projects = rpc.list(rpcOptions); + assertNull(projects.x()); + assertNull(projects.y()); + } + @Test public void testListFilterOptions() { Map rpcFilterOptions = new HashMap<>(); From cbf737da9a05d69355199bf979e8e2b950aa56e1 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 24 Feb 2016 08:45:58 -0800 Subject: [PATCH 091/203] Added integration tests. --- .../main/java/com/google/gcloud/dns/Dns.java | 17 +- .../com/google/gcloud/spi/DefaultDnsRpc.java | 4 +- .../com/google/gcloud/dns/DnsImplTest.java | 2 +- .../java/com/google/gcloud/dns/DnsTest.java | 2 +- .../java/com/google/gcloud/dns/ITDnsTest.java | 1268 +++++++++++++++++ 5 files changed, 1283 insertions(+), 10 deletions(-) create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/ITDnsTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 3ad2094ec2e3..b2cb9fbad371 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -68,7 +68,8 @@ static String selector(ProjectField... fields) { * The fields of a zone. * *

These values can be used to specify the fields to include in a partial response when calling - * {@link Dns#getZone(String, ZoneOption...)}. The name is always returned, even if not specified. + * {@link Dns#getZone(String, ZoneOption...)}. The name is always returned, even if not + * specified. */ enum ZoneField { CREATION_TIME("creationTime"), @@ -103,8 +104,8 @@ static String selector(ZoneField... fields) { * The fields of a DNS record. * *

These values can be used to specify the fields to include in a partial response when calling - * {@link Dns#listDnsRecords(String, DnsRecordListOption...)}. The name is always returned even if - * not selected. + * {@link Dns#listDnsRecords(String, DnsRecordListOption...)}. The name and type are always + * returned even if not selected. */ enum DnsRecordField { DNS_RECORDS("rrdatas"), @@ -125,6 +126,7 @@ String selector() { static String selector(DnsRecordField... fields) { Set fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1); fieldStrings.add(NAME.selector()); + fieldStrings.add(TYPE.selector()); for (DnsRecordField field : fields) { fieldStrings.add(field.selector()); } @@ -198,7 +200,7 @@ class DnsRecordListOption extends AbstractOption implements Serializable { */ public static DnsRecordListOption fields(DnsRecordField... fields) { StringBuilder builder = new StringBuilder(); - builder.append("rrsets(").append(DnsRecordField.selector(fields)).append(')'); + builder.append("nextPageToken,rrsets(").append(DnsRecordField.selector(fields)).append(')'); return new DnsRecordListOption(DnsRpc.Option.FIELDS, builder.toString()); } @@ -234,7 +236,7 @@ public static DnsRecordListOption dnsName(String dnsName) { * Dns.DnsRecordListOption#dnsName(String)} must also be present. */ public static DnsRecordListOption type(DnsRecord.Type type) { - return new DnsRecordListOption(DnsRpc.Option.DNS_TYPE, type); + return new DnsRecordListOption(DnsRpc.Option.DNS_TYPE, type.name()); } } @@ -281,7 +283,7 @@ class ZoneListOption extends AbstractOption implements Serializable { */ public static ZoneListOption fields(ZoneField... fields) { StringBuilder builder = new StringBuilder(); - builder.append("managedZones(").append(ZoneField.selector(fields)).append(')'); + builder.append("nextPageToken,managedZones(").append(ZoneField.selector(fields)).append(')'); return new ZoneListOption(DnsRpc.Option.FIELDS, builder.toString()); } @@ -388,7 +390,8 @@ class ChangeRequestListOption extends AbstractOption implements Serializable { */ public static ChangeRequestListOption fields(ChangeRequestField... fields) { StringBuilder builder = new StringBuilder(); - builder.append("changes(").append(ChangeRequestField.selector(fields)).append(')'); + builder.append("nextPageToken,changes(").append(ChangeRequestField.selector(fields)) + .append(')'); return new ChangeRequestListOption(DnsRpc.Option.FIELDS, builder.toString()); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java index 6ed9c7e0f216..1df0a8a2f831 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java @@ -162,7 +162,9 @@ public Change getChangeRequest(String zoneName, String changeRequestId, Map zones = DNS.listZones(); + Iterator zoneIterator = zones.iterateAll(); + while (zoneIterator.hasNext()) { + Zone zone = zoneIterator.next(); + List toDelete = new LinkedList<>(); + if (zone.name().startsWith(PREFIX)) { + Iterator dnsRecordIterator = zone.listDnsRecords().iterateAll(); + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + if (!ImmutableList.of(DnsRecord.Type.NS, DnsRecord.Type.SOA).contains(record.type())) { + toDelete.add(record); + } + } + if (!toDelete.isEmpty()) { + zone.applyChangeRequest(ChangeRequest.builder().deletions(toDelete).build()); + } + zone.delete(); + } + } + } + + private static List filter(Iterator iterator) { + List result = new LinkedList<>(); + while (iterator.hasNext()) { + Zone zone = iterator.next(); + if (zone.name().startsWith(PREFIX)) { + result.add(zone); + } + } + return result; + } + + @BeforeClass + public static void before() { + purge(); + } + + @AfterClass + public static void after() { + purge(); + } + + @Test + public void testCreateValidZone() { + Zone created = DNS.create(ZONE1); + assertEquals(ZONE1.description(), created.description()); + assertEquals(ZONE1.dnsName(), created.dnsName()); + assertEquals(ZONE1.name(), created.name()); + assertNotNull(created.creationTimeMillis()); + assertNotNull(created.nameServers()); + assertNull(created.nameServerSet()); + assertNotNull(created.id()); + Zone retrieved = DNS.getZone(ZONE1.name()); + assertEquals(created, retrieved); + created = DNS.create(ZONE_EMPTY_DESCRIPTION); + assertEquals(ZONE_EMPTY_DESCRIPTION.description(), created.description()); + assertEquals(ZONE_EMPTY_DESCRIPTION.dnsName(), created.dnsName()); + assertEquals(ZONE_EMPTY_DESCRIPTION.name(), created.name()); + assertNotNull(created.creationTimeMillis()); + assertNotNull(created.nameServers()); + assertNull(created.nameServerSet()); + assertNotNull(created.id()); + retrieved = DNS.getZone(ZONE_EMPTY_DESCRIPTION.name()); + assertEquals(created, retrieved); + } + + @After + public void tearDown() { + purge(); + } + + @Test + public void testCreateZoneWithErrors() { + try { + DNS.create(ZONE_MISSING_DNS_NAME); + fail("Zone is missing DNS name. The service returns an error."); + } catch (DnsException ex) { + // expected + // todo(mderka) test non-retryable when implemented within #593 + } + try { + DNS.create(ZONE_MISSING_DESCRIPTION); + fail("Zone is missing description name. The service returns an error."); + } catch (DnsException ex) { + // expected + // todo(mderka) test non-retryable when implemented within #593 + } + try { + DNS.create(ZONE_NAME_ERROR); + fail("Zone name is missing a period. The service returns an error."); + } catch (DnsException ex) { + // expected + // todo(mderka) test non-retryable when implemented within #593 + } + try { + DNS.create(ZONE_DNS_NO_PERIOD); + fail("Zone name is missing a period. The service returns an error."); + } catch (DnsException ex) { + // expected + // todo(mderka) test non-retryable when implemented within #593 + } + } + + @Test + public void testCreateZoneWithOptions() { + Zone created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNotNull(created.creationTimeMillis()); + assertNull(created.description()); + assertNull(created.dnsName()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.DESCRIPTION)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertEquals(ZONE1.description(), created.description()); + assertNull(created.dnsName()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.DNS_NAME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertEquals(ZONE1.dnsName(), created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVER_SET)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); // we did not set it + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVERS)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertFalse(created.nameServers().isEmpty()); + assertNull(created.nameServerSet()); + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertNotNull(created.nameServers()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNotNull(created.id()); + created.delete(); + // combination of multiple things + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID, + Dns.ZoneField.NAME_SERVERS, Dns.ZoneField.NAME_SERVER_SET, Dns.ZoneField.DESCRIPTION)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertEquals(ZONE1.description(), created.description()); + assertFalse(created.nameServers().isEmpty()); + assertNull(created.nameServerSet()); // we did not set it + assertNotNull(created.id()); + } + + @Test + public void testZoneReload() { + Zone created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNotNull(created.creationTimeMillis()); + assertNull(created.description()); + assertNull(created.dnsName()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.DESCRIPTION)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertEquals(ZONE1.description(), created.description()); + assertNull(created.dnsName()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.DNS_NAME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertEquals(ZONE1.dnsName(), created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVER_SET)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); // we did not set it + assertNull(created.id()); + created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVERS)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertFalse(created.nameServers().isEmpty()); + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertNotNull(created.nameServers()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNotNull(created.id()); + // combination of multiple things + created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID, + Dns.ZoneField.NAME_SERVERS, Dns.ZoneField.NAME_SERVER_SET, Dns.ZoneField.DESCRIPTION)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertEquals(ZONE1.description(), created.description()); + assertFalse(created.nameServers().isEmpty()); + assertNull(created.nameServerSet()); // we did not set it + assertNotNull(created.id()); + } + + @Test + public void testGetZone() { + DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + Zone created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNotNull(created.creationTimeMillis()); + assertNull(created.description()); + assertNull(created.dnsName()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.DESCRIPTION)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertEquals(ZONE1.description(), created.description()); + assertNull(created.dnsName()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.DNS_NAME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertEquals(ZONE1.dnsName(), created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVER_SET)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); // we did not set it + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVERS)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertFalse(created.nameServers().isEmpty()); + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertNotNull(created.nameServers()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNotNull(created.id()); + // combination of multiple things + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID, + Dns.ZoneField.NAME_SERVERS, Dns.ZoneField.NAME_SERVER_SET, Dns.ZoneField.DESCRIPTION)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertEquals(ZONE1.description(), created.description()); + assertFalse(created.nameServers().isEmpty()); + assertNull(created.nameServerSet()); // we did not set it + assertNotNull(created.id()); + } + + @Test + public void testListZones() { + List zones = filter(DNS.listZones().iterateAll()); + assertEquals(0, zones.size()); + // some zones exists + Zone created = DNS.create(ZONE1); + zones = filter(DNS.listZones().iterateAll()); + assertEquals(created, zones.get(0)); + assertEquals(1, zones.size()); + created = DNS.create(ZONE_EMPTY_DESCRIPTION); + zones = filter(DNS.listZones().iterateAll()); + assertEquals(2, zones.size()); + assertTrue(zones.contains(created)); + // error in options + try { + DNS.listZones(Dns.ZoneListOption.pageSize(0)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test not-retryable + } + try { + DNS.listZones(Dns.ZoneListOption.pageSize(-1)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test not-retryable + } + // ok size + zones = filter(DNS.listZones(Dns.ZoneListOption.pageSize(1000)).iterateAll()); + assertEquals(2, zones.size()); // we still have only 2 zones + // dns name problems + try { + DNS.listZones(Dns.ZoneListOption.dnsName("aaaaa")); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test not-retryable + } + // ok name + zones = filter(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName())).iterateAll()); + assertEquals(1, zones.size()); + // field options + zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.ZONE_ID)).iterateAll()); + assertEquals(1, zones.size()); + Zone zone = zones.get(0); + assertNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNull(zone.dnsName()); + assertNull(zone.description()); + assertNull(zone.nameServerSet()); + assertTrue(zone.nameServers().isEmpty()); + assertNotNull(zone.id()); + zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.CREATION_TIME)).iterateAll()); + assertEquals(1, zones.size()); + zone = zones.get(0); + assertNotNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNull(zone.dnsName()); + assertNull(zone.description()); + assertNull(zone.nameServerSet()); + assertTrue(zone.nameServers().isEmpty()); + assertNull(zone.id()); + zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.DNS_NAME)).iterateAll()); + assertEquals(1, zones.size()); + zone = zones.get(0); + assertNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNotNull(zone.dnsName()); + assertNull(zone.description()); + assertNull(zone.nameServerSet()); + assertTrue(zone.nameServers().isEmpty()); + assertNull(zone.id()); + zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION)).iterateAll()); + assertEquals(1, zones.size()); + zone = zones.get(0); + assertNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNull(zone.dnsName()); + assertNotNull(zone.description()); + assertNull(zone.nameServerSet()); + assertTrue(zone.nameServers().isEmpty()); + assertNull(zone.id()); + zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.NAME_SERVERS)).iterateAll()); + assertEquals(1, zones.size()); + zone = zones.get(0); + assertNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNull(zone.dnsName()); + assertNull(zone.description()); + assertNull(zone.nameServerSet()); + assertTrue(!zone.nameServers().isEmpty()); + assertNull(zone.id()); + zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.NAME_SERVER_SET)).iterateAll()); + assertEquals(1, zones.size()); + zone = zones.get(0); + assertNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNull(zone.dnsName()); + assertNull(zone.description()); + assertNull(zone.nameServerSet()); // we cannot set it using gcloud java + assertTrue(zone.nameServers().isEmpty()); + assertNull(zone.id()); + // several combined + zones = filter(DNS.listZones(Dns.ZoneListOption.fields(Dns.ZoneField.ZONE_ID, + Dns.ZoneField.DESCRIPTION), + Dns.ZoneListOption.pageSize(1)).iterateAll()); + assertEquals(2, zones.size()); + for (Zone current : zones) { + assertNull(current.creationTimeMillis()); + assertNotNull(current.name()); + assertNull(current.dnsName()); + assertNotNull(current.description()); + assertNull(current.nameServerSet()); + assertTrue(zone.nameServers().isEmpty()); + assertNotNull(current.id()); + } + } + + @Test + public void testDeleteZoneUsingServiceObject() { + Zone created = DNS.create(ZONE1); + assertEquals(created, DNS.getZone(ZONE1.name())); + DNS.delete(ZONE1.name()); + assertNull(DNS.getZone(ZONE1.name())); + } + + @Test + public void testDeleteZoneUsingZoneObject() { + Zone created = DNS.create(ZONE1); + assertEquals(created, DNS.getZone(ZONE1.name())); + created.delete(); + assertNull(DNS.getZone(ZONE1.name())); + } + + private void assertEqChangesIgnoreStatus(ChangeRequest expected, ChangeRequest actual) { + ChangeRequest unifiedEx = ChangeRequest.fromPb(expected.toPb().setStatus("pending")); + ChangeRequest unifiedAct = ChangeRequest.fromPb(actual.toPb().setStatus("pending")); + assertEquals(unifiedEx, unifiedAct); + } + + private static void checkChangeComplete(String zoneName, String changeId) { + for (int i = 0; i < TIME_LIMIT; i++) { + ChangeRequest changeRequest = DNS.getChangeRequest(zoneName, changeId, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + if (ChangeRequest.Status.DONE.equals(changeRequest.status())) { + break; + } else { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + throw new RuntimeException("Thread was interrupted while waiting for change."); + } + } + } + } + + @Test + public void testCreateChangeUsingServiceObject() { + DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + ChangeRequest created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); + assertNotNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("1", created.id()); + assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) + .contains(created.status())); + assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); + checkChangeComplete(ZONE1.name(), "1"); + DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "2"); + // with options + created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); + assertTrue(created.additions().isEmpty()); + assertNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("3", created.id()); + assertNull(created.status()); + checkChangeComplete(ZONE1.name(), "3"); + DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "4"); + created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + assertTrue(created.additions().isEmpty()); + assertNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("5", created.id()); + assertNotNull(created.status()); + checkChangeComplete(ZONE1.name(), "5"); + DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "6"); + created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); + assertTrue(created.additions().isEmpty()); + assertNotNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("7", created.id()); + assertNull(created.status()); + checkChangeComplete(ZONE1.name(), "7"); + DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "8"); + created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); + assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); + assertNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("9", created.id()); + assertNull(created.status()); + // finishes with delete otherwise we cannot delete the zone + checkChangeComplete(ZONE1.name(), "9"); + created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); + checkChangeComplete(ZONE1.name(), "10"); + assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); + assertNull(created.startTimeMillis()); + assertTrue(created.additions().isEmpty()); + assertEquals("10", created.id()); + assertNull(created.status()); + checkChangeComplete(ZONE1.name(), "10"); + } + + @Test + public void testCreateChangeUsingZoneObject() { + Zone zone = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); + assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); + assertNotNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("1", created.id()); + assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) + .contains(created.status())); + assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); + checkChangeComplete(ZONE1.name(), "1"); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "2"); + // with options + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); + assertTrue(created.additions().isEmpty()); + assertNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("3", created.id()); + assertNull(created.status()); + checkChangeComplete(ZONE1.name(), "3"); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "4"); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + assertTrue(created.additions().isEmpty()); + assertNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("5", created.id()); + assertNotNull(created.status()); + checkChangeComplete(ZONE1.name(), "5"); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "6"); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); + assertTrue(created.additions().isEmpty()); + assertNotNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("7", created.id()); + assertNull(created.status()); + checkChangeComplete(ZONE1.name(), "7"); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "8"); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); + assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); + assertNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("9", created.id()); + assertNull(created.status()); + // finishes with delete otherwise we cannot delete the zone + checkChangeComplete(ZONE1.name(), "9"); + created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); + checkChangeComplete(ZONE1.name(), "10"); + assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); + assertNull(created.startTimeMillis()); + assertTrue(created.additions().isEmpty()); + assertEquals("10", created.id()); + assertNull(created.status()); + checkChangeComplete(ZONE1.name(), "10"); + } + + @Test + public void testListChangesUsingService() { + // no such zone exists + try { + DNS.listChangeRequests(ZONE1.name()); + fail(); + } catch (DnsException ex) { + // expected + assertEquals(404, ex.code()); + // todo(mderka) test retry functionality + } + // zone exists but has no changes + DNS.create(ZONE1); + ImmutableList changes = ImmutableList.copyOf( + DNS.listChangeRequests(ZONE1.name()).iterateAll()); + assertEquals(1, changes.size()); // default change creating SOA and NS + // zone has changes + ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name()).iterateAll()); + assertEquals(5, changes.size()); + // error in options + try { + DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(0)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality + } + try { + DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(-1)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality + } + // sorting order + ImmutableList ascending = ImmutableList.copyOf(DNS.listChangeRequests( + ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)).iterateAll()); + ImmutableList descending = ImmutableList.copyOf(DNS.listChangeRequests( + ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.DESCENDING)).iterateAll()); + int size = 5; + assertEquals(size, descending.size()); + assertEquals(size, ascending.size()); + for (int i = 0; i < size; i++) { + assertEquals(descending.get(i), ascending.get(size - i - 1)); + } + // field options + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.ADDITIONS)).iterateAll()); + change = changes.get(1); + assertEquals(CHANGE_ADD_ZONE1.additions(), change.additions()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.DELETIONS)).iterateAll()); + change = changes.get(2); + assertTrue(change.additions().isEmpty()); + assertNotNull(change.deletions()); + assertEquals("2", change.id()); + assertNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.ID)).iterateAll()); + change = changes.get(1); + assertTrue(change.additions().isEmpty()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.START_TIME)).iterateAll()); + change = changes.get(1); + assertTrue(change.additions().isEmpty()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNotNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS)).iterateAll()); + change = changes.get(1); + assertTrue(change.additions().isEmpty()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNull(change.startTimeMillis()); + assertEquals(ChangeRequest.Status.DONE, change.status()); + } + + @Test + public void testListChangesUsingZoneObject() { + // zone exists but has no changes + Zone created = DNS.create(ZONE1); + ImmutableList changes = ImmutableList.copyOf( + created.listChangeRequests().iterateAll()); + assertEquals(1, changes.size()); // default change creating SOA and NS + // zone has changes + ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + changes = ImmutableList.copyOf(created.listChangeRequests().iterateAll()); + assertEquals(5, changes.size()); + // error in options + try { + created.listChangeRequests(Dns.ChangeRequestListOption.pageSize(0)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality + } + try { + created.listChangeRequests(Dns.ChangeRequestListOption.pageSize(-1)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality + } + // sorting order + ImmutableList ascending = ImmutableList.copyOf(created.listChangeRequests( + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)).iterateAll()); + ImmutableList descending = ImmutableList.copyOf(created.listChangeRequests( + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.DESCENDING)).iterateAll()); + int size = 5; + assertEquals(size, descending.size()); + assertEquals(size, ascending.size()); + for (int i = 0; i < size; i++) { + assertEquals(descending.get(i), ascending.get(size - i - 1)); + } + // field options + changes = ImmutableList.copyOf(created.listChangeRequests( + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.ADDITIONS)).iterateAll()); + change = changes.get(1); + assertEquals(CHANGE_ADD_ZONE1.additions(), change.additions()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(created.listChangeRequests( + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.DELETIONS)).iterateAll()); + change = changes.get(2); + assertTrue(change.additions().isEmpty()); + assertNotNull(change.deletions()); + assertEquals("2", change.id()); + assertNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(created.listChangeRequests( + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.ID)).iterateAll()); + change = changes.get(1); + assertTrue(change.additions().isEmpty()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(created.listChangeRequests( + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.START_TIME)).iterateAll()); + change = changes.get(1); + assertTrue(change.additions().isEmpty()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNotNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(created.listChangeRequests( + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS)).iterateAll()); + change = changes.get(1); + assertTrue(change.additions().isEmpty()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNull(change.startTimeMillis()); + assertEquals(ChangeRequest.Status.DONE, change.status()); + } + + @Test + public void testGetChangeUsingZoneObject() { + Zone zone = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); + ChangeRequest retrieved = zone.getChangeRequest(created.id()); + assertEqChangesIgnoreStatus(created, retrieved); + checkChangeComplete(ZONE1.name(), "1"); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "2"); + // with options + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); + retrieved = zone.getChangeRequest(created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); + assertEqChangesIgnoreStatus(created, retrieved); + checkChangeComplete(ZONE1.name(), "3"); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "4"); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + retrieved = zone.getChangeRequest(created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + assertEqChangesIgnoreStatus(created, retrieved); + checkChangeComplete(ZONE1.name(), "5"); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "6"); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); + retrieved = zone.getChangeRequest(created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); + assertEqChangesIgnoreStatus(created, retrieved); + checkChangeComplete(ZONE1.name(), "7"); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "8"); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); + retrieved = zone.getChangeRequest(created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); + assertEqChangesIgnoreStatus(created, retrieved); + // finishes with delete otherwise we cannot delete the zone + checkChangeComplete(ZONE1.name(), "9"); + created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); + retrieved = zone.getChangeRequest(created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); + assertEqChangesIgnoreStatus(created, retrieved); + checkChangeComplete(ZONE1.name(), "10"); + } + + @Test + public void testGetChangeUsingServiceObject() { + Zone zone = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); + ChangeRequest retrieved = DNS.getChangeRequest(zone.name(), created.id()); + assertEqChangesIgnoreStatus(created, retrieved); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + // with options + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); + retrieved = DNS.getChangeRequest(zone.name(), created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); + assertEqChangesIgnoreStatus(created, retrieved); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + retrieved = DNS.getChangeRequest(zone.name(), created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + assertEqChangesIgnoreStatus(created, retrieved); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); + retrieved = DNS.getChangeRequest(zone.name(), created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); + assertEqChangesIgnoreStatus(created, retrieved); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); + retrieved = DNS.getChangeRequest(zone.name(), created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); + assertEqChangesIgnoreStatus(created, retrieved); + // finishes with delete otherwise we cannot delete the zone + created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); + retrieved = DNS.getChangeRequest(zone.name(), created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); + assertEqChangesIgnoreStatus(created, retrieved); + } + + @Test + public void testGetProject() { + // fetches all fields + ProjectInfo project = DNS.getProject(); + assertNotNull(project.quota()); + assertNotNull(project.number()); + assertNotNull(project.id()); + assertEquals(PROJECT_ID, project.id()); + // options + project = DNS.getProject(Dns.ProjectOption.fields(Dns.ProjectField.QUOTA)); + assertNotNull(project.quota()); + assertNull(project.number()); + assertNotNull(project.id()); // id is always returned + project = DNS.getProject(Dns.ProjectOption.fields(Dns.ProjectField.PROJECT_ID)); + assertNull(project.quota()); + assertNull(project.number()); + assertNotNull(project.id()); + project = DNS.getProject(Dns.ProjectOption.fields(Dns.ProjectField.PROJECT_NUMBER)); + assertNull(project.quota()); + assertNotNull(project.number()); + assertNotNull(project.id()); + project = DNS.getProject(Dns.ProjectOption.fields(Dns.ProjectField.PROJECT_NUMBER, + Dns.ProjectField.QUOTA, Dns.ProjectField.PROJECT_ID)); + assertNotNull(project.quota()); + assertNotNull(project.number()); + assertNotNull(project.id()); + } + + @Test + public void testListDnsRecordsUsingService() { + Zone zone = DNS.create(ZONE1); + ImmutableList dnsRecords = ImmutableList.copyOf( + DNS.listDnsRecords(zone.name()).iterateAll()); + assertEquals(2, dnsRecords.size()); + ImmutableList defaultRecords = + ImmutableList.of(DnsRecord.Type.NS, DnsRecord.Type.SOA); + for (DnsRecord record : dnsRecords) { + assertTrue(defaultRecords.contains(record.type())); + } + // field options + Iterator dnsRecordIterator = DNS.listDnsRecords(zone.name(), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL)).iterateAll(); + int counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).ttl(), record.ttl()); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertTrue(record.records().isEmpty()); + counter++; + } + assertEquals(2, counter); + dnsRecordIterator = DNS.listDnsRecords(zone.name(), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.NAME)).iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertTrue(record.records().isEmpty()); + assertNull(record.ttl()); + counter++; + } + assertEquals(2, counter); + dnsRecordIterator = DNS.listDnsRecords(zone.name(), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.DNS_RECORDS)).iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).records(), record.records()); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertNull(record.ttl()); + counter++; + } + assertEquals(2, counter); + dnsRecordIterator = DNS.listDnsRecords(zone.name(), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), + Dns.DnsRecordListOption.pageSize(1)).iterateAll(); // also test paging + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertTrue(record.records().isEmpty()); + assertNull(record.ttl()); + counter++; + } + assertEquals(2, counter); + // test page size + Page dnsRecordPage = DNS.listDnsRecords(zone.name(), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), + Dns.DnsRecordListOption.pageSize(1)); + assertEquals(1, ImmutableList.copyOf(dnsRecordPage.values().iterator()).size()); + // test name filter + ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), + Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name())).iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertTrue(ImmutableList.of(A_RECORD_ZONE1.type(), AAAA_RECORD_ZONE1.type()) + .contains(record.type())); + counter++; + } + assertEquals(2, counter); + // test type filter + checkChangeComplete(ZONE1.name(), change.id()); + dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), + Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name()), + Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())) + .iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(A_RECORD_ZONE1, record); + counter++; + } + assertEquals(1, counter); + change = zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + // check wrong arguments + try { + // name is not set + DNS.listDnsRecords(ZONE1.name(), + Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality when available + } + try { + DNS.listDnsRecords(ZONE1.name(), + Dns.DnsRecordListOption.pageSize(0)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality when available + } + try { + DNS.listDnsRecords(ZONE1.name(), + Dns.DnsRecordListOption.pageSize(-1)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality when available + } + checkChangeComplete(ZONE1.name(), change.id()); + } + + @Test + public void testListDnsRecordsUsingZoneObject() { + Zone zone = DNS.create(ZONE1); + ImmutableList dnsRecords = ImmutableList.copyOf( + zone.listDnsRecords().iterateAll()); + assertEquals(2, dnsRecords.size()); + ImmutableList defaultRecords = + ImmutableList.of(DnsRecord.Type.NS, DnsRecord.Type.SOA); + for (DnsRecord record : dnsRecords) { + assertTrue(defaultRecords.contains(record.type())); + } + // field options + Iterator dnsRecordIterator = zone.listDnsRecords( + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL)).iterateAll(); + int counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).ttl(), record.ttl()); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertTrue(record.records().isEmpty()); + counter++; + } + assertEquals(2, counter); + dnsRecordIterator = zone.listDnsRecords( + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.NAME)).iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertTrue(record.records().isEmpty()); + assertNull(record.ttl()); + counter++; + } + assertEquals(2, counter); + dnsRecordIterator = zone.listDnsRecords( + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.DNS_RECORDS)).iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).records(), record.records()); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertNull(record.ttl()); + counter++; + } + assertEquals(2, counter); + dnsRecordIterator = zone.listDnsRecords( + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), + Dns.DnsRecordListOption.pageSize(1)).iterateAll(); // also test paging + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertTrue(record.records().isEmpty()); + assertNull(record.ttl()); + counter++; + } + assertEquals(2, counter); + // test page size + Page dnsRecordPage = zone.listDnsRecords( + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), + Dns.DnsRecordListOption.pageSize(1)); + assertEquals(1, ImmutableList.copyOf(dnsRecordPage.values().iterator()).size()); + // test name filter + ChangeRequest change = zone.applyChangeRequest(CHANGE_ADD_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + dnsRecordIterator = zone.listDnsRecords(Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name())) + .iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertTrue(ImmutableList.of(A_RECORD_ZONE1.type(), AAAA_RECORD_ZONE1.type()) + .contains(record.type())); + counter++; + } + assertEquals(2, counter); + // test type filter + checkChangeComplete(ZONE1.name(), change.id()); + dnsRecordIterator = zone.listDnsRecords(Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name()), + Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())) + .iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(A_RECORD_ZONE1, record); + counter++; + } + assertEquals(1, counter); + change = zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + // check wrong arguments + try { + // name is not set + zone.listDnsRecords(Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality when available + } + try { + zone.listDnsRecords(Dns.DnsRecordListOption.pageSize(0)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality when available + } + try { + zone.listDnsRecords(Dns.DnsRecordListOption.pageSize(-1)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality when available + } + checkChangeComplete(ZONE1.name(), change.id()); + } +} From a43962846940a6369ce25209470f5de2c6005e67 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 25 Feb 2016 23:53:46 +0100 Subject: [PATCH 092/203] Remove non-necessary commaNeeded variable --- .../resourcemanager/testing/LocalResourceManagerHelper.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java index 438439c44dd0..a077eb6144a5 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -400,17 +400,15 @@ Response list(Map options) { String[] listFields = (String[]) options.get("listFields"); StringBuilder responseBody = new StringBuilder(); responseBody.append('{'); - boolean commaNeeded = false; // If fields parameter is set but no project field is selected we must return no projects. if (!(projectFields != null && projectFields.length == 0)) { responseBody.append("\"projects\": ["); Joiner.on(",").appendTo(responseBody, projectsSerialized); responseBody.append(']'); - commaNeeded = true; } if (nextPageToken != null && (listFields == null || ImmutableSet.copyOf(listFields).contains("nextPageToken"))) { - if (commaNeeded) { + if (responseBody.length() > 1) { responseBody.append(','); } responseBody.append("\"nextPageToken\": \""); From 7d87d3ce92d781a5c3fbb204f1e99ba9ff500ef4 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Fri, 26 Feb 2016 08:05:10 -0800 Subject: [PATCH 093/203] Use enum for legacy roles, add input checks --- .../java/com/google/gcloud/IamPolicy.java | 50 +++++++++++++---- .../main/java/com/google/gcloud/Identity.java | 39 +++++++++---- .../java/com/google/gcloud/IamPolicyTest.java | 29 ++++++---- .../google/gcloud/resourcemanager/Policy.java | 56 ++++++++++++++++--- .../gcloud/resourcemanager/PolicyTest.java | 4 +- .../resourcemanager/SerializationTest.java | 2 +- 6 files changed, 137 insertions(+), 43 deletions(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java index 73c3e3fec6ac..748eaba2ab4c 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java @@ -23,8 +23,11 @@ import java.io.Serializable; import java.util.Arrays; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; @@ -65,8 +68,14 @@ protected Builder() {} /** * Replaces the builder's map of bindings with the given map of bindings. + * + * @throws IllegalArgumentException if the provided map is null or contain any null values */ public final B bindings(Map> bindings) { + checkArgument(bindings != null, "The provided map of bindings cannot be null."); + for (Map.Entry> binding : bindings.entrySet()) { + verifyBinding(binding.getKey(), binding.getValue()); + } this.bindings.clear(); for (Map.Entry> binding : bindings.entrySet()) { this.bindings.put(binding.getKey(), new HashSet(binding.getValue())); @@ -78,10 +87,12 @@ public final B bindings(Map> bindings) { * Adds a binding to the policy. * * @throws IllegalArgumentException if the policy already contains a binding with the same role + * or if the role or any identities are null */ public final B addBinding(R role, Set identities) { + verifyBinding(role, identities); checkArgument(!bindings.containsKey(role), - "The policy already contains a binding with the role " + role.toString()); + "The policy already contains a binding with the role " + role.toString() + "."); bindings.put(role, new HashSet(identities)); return self(); } @@ -90,15 +101,23 @@ public final B addBinding(R role, Set identities) { * Adds a binding to the policy. * * @throws IllegalArgumentException if the policy already contains a binding with the same role + * or if the role or any identities are null */ public final B addBinding(R role, Identity first, Identity... others) { - checkArgument(!bindings.containsKey(role), - "The policy already contains a binding with the role " + role.toString()); HashSet identities = new HashSet<>(); identities.add(first); identities.addAll(Arrays.asList(others)); - bindings.put(role, identities); - return self(); + return addBinding(role, identities); + } + + private void verifyBinding(R role, Collection identities) { + checkArgument(role != null, "The role cannot be null."); + verifyIdentities(identities); + } + + private void verifyIdentities(Collection identities) { + checkArgument(identities != null, "A role cannot be assigned to a null set of identities."); + checkArgument(!identities.contains(null), "Null identities are not permitted."); } /** @@ -113,13 +132,16 @@ public final B removeBinding(R role) { * Adds one or more identities to an existing binding. * * @throws IllegalArgumentException if the policy doesn't contain a binding with the specified - * role + * role or any identities are null */ public final B addIdentity(R role, Identity first, Identity... others) { - checkArgument(bindings.containsKey(role), "The policy doesn't contain the specified role."); - Set identities = bindings.get(role); - identities.add(first); - identities.addAll(Arrays.asList(others)); + checkArgument(bindings.containsKey(role), + "The policy doesn't contain the role " + role.toString() + "."); + List toAdd = new LinkedList<>(); + toAdd.add(first); + toAdd.addAll(Arrays.asList(others)); + verifyIdentities(toAdd); + bindings.get(role).addAll(toAdd); return self(); } @@ -130,7 +152,8 @@ public final B addIdentity(R role, Identity first, Identity... others) { * role */ public final B removeIdentity(R role, Identity first, Identity... others) { - checkArgument(bindings.containsKey(role), "The policy doesn't contain the specified role."); + checkArgument(bindings.containsKey(role), + "The policy doesn't contain the role " + role.toString() + "."); bindings.get(role).remove(first); bindings.get(role).removeAll(Arrays.asList(others)); return self(); @@ -179,6 +202,11 @@ protected IamPolicy(Builder> builder) { this.version = builder.version; } + /** + * Returns a builder containing the properties of this IAM Policy. + */ + public abstract Builder> toBuilder(); + /** * The map of bindings that comprises the policy. */ diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java b/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java index 0513916cc8b4..d1644198f759 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java @@ -18,11 +18,26 @@ import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.CaseFormat; + import java.io.Serializable; import java.util.Objects; /** - * An identity in an {@link IamPolicy}. + * An identity in an {@link IamPolicy}. The following types of identities are permitted in IAM + * policies: + *

    + *
  • Google account + *
  • Service account + *
  • Google group + *
  • Google Apps domain + *
+ * + *

There are also two special identities that represent all users and all Google-authenticated + * accounts. + * + * @see Concepts + * related to identity */ public final class Identity implements Serializable { @@ -82,7 +97,8 @@ public Type type() { *

  • email address (for identities of type {@code USER}, {@code SERVICE_ACCOUNT}, and * {@code GROUP}) *
  • domain (for identities of type {@code DOMAIN}) - *
  • null (for identities of type {@code ALL_USERS} and {@code ALL_AUTHENTICATED_USERS}) + *
  • {@code null} (for identities of type {@code ALL_USERS} and + * {@code ALL_AUTHENTICATED_USERS}) * */ public String id() { @@ -178,7 +194,7 @@ public String strValue() { case DOMAIN: return "domain:" + id; default: - throw new IllegalArgumentException("Unexpected identity type: " + type); + throw new IllegalStateException("Unexpected identity type: " + type); } } @@ -188,21 +204,22 @@ public String strValue() { */ public static Identity valueOf(String identityStr) { String[] info = identityStr.split(":"); - switch (info[0]) { - case "allUsers": + Type type = Type.valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, info[0])); + switch (type) { + case ALL_USERS: return Identity.allUsers(); - case "allAuthenticatedUsers": + case ALL_AUTHENTICATED_USERS: return Identity.allAuthenticatedUsers(); - case "user": + case USER: return Identity.user(info[1]); - case "serviceAccount": + case SERVICE_ACCOUNT: return Identity.serviceAccount(info[1]); - case "group": + case GROUP: return Identity.group(info[1]); - case "domain": + case DOMAIN: return Identity.domain(info[1]); default: - throw new IllegalArgumentException("Unexpected identity type: " + info[0]); + throw new IllegalStateException("Unexpected identity type " + type); } } } diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java index b77b5e2df7fa..db0935c4766d 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java @@ -18,6 +18,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -71,7 +72,8 @@ public PolicyImpl build() { super(builder); } - Builder toBuilder() { + @Override + public Builder toBuilder() { return new Builder(bindings(), etag(), version()); } @@ -93,38 +95,38 @@ public void testBuilder() { assertEquals(1, policy.version().intValue()); policy = SIMPLE_POLICY.toBuilder().removeBinding("editor").build(); assertEquals(ImmutableMap.of("viewer", BINDINGS.get("viewer")), policy.bindings()); - assertEquals(null, policy.etag()); - assertEquals(null, policy.version()); + assertNull(policy.etag()); + assertNull(policy.version()); policy = policy.toBuilder() .removeIdentity("viewer", USER, ALL_USERS) .addIdentity("viewer", DOMAIN, GROUP) .build(); assertEquals(ImmutableMap.of("viewer", ImmutableSet.of(SERVICE_ACCOUNT, DOMAIN, GROUP)), policy.bindings()); - assertEquals(null, policy.etag()); - assertEquals(null, policy.version()); + assertNull(policy.etag()); + assertNull(policy.version()); policy = PolicyImpl.builder().addBinding("owner", USER, SERVICE_ACCOUNT).build(); assertEquals( ImmutableMap.of("owner", ImmutableSet.of(USER, SERVICE_ACCOUNT)), policy.bindings()); - assertEquals(null, policy.etag()); - assertEquals(null, policy.version()); + assertNull(policy.etag()); + assertNull(policy.version()); try { SIMPLE_POLICY.toBuilder().addBinding("viewer", USER); fail("Should have failed due to duplicate role."); } catch (IllegalArgumentException e) { - assertEquals("The policy already contains a binding with the role viewer", e.getMessage()); + assertEquals("The policy already contains a binding with the role viewer.", e.getMessage()); } try { SIMPLE_POLICY.toBuilder().addBinding("editor", ImmutableSet.of(USER)); fail("Should have failed due to duplicate role."); } catch (IllegalArgumentException e) { - assertEquals("The policy already contains a binding with the role editor", e.getMessage()); + assertEquals("The policy already contains a binding with the role editor.", e.getMessage()); } } @Test public void testEqualsHashCode() { - assertNotEquals(FULL_POLICY, null); + assertNotNull(FULL_POLICY); PolicyImpl emptyPolicy = PolicyImpl.builder().build(); AnotherPolicyImpl anotherPolicy = new AnotherPolicyImpl.Builder().build(); assertNotEquals(emptyPolicy, anotherPolicy); @@ -151,7 +153,7 @@ public void testEtag() { @Test public void testVersion() { assertNull(SIMPLE_POLICY.version()); - assertEquals(null, SIMPLE_POLICY.version()); + assertEquals(1, FULL_POLICY.version().intValue()); } static class AnotherPolicyImpl extends IamPolicy { @@ -169,5 +171,10 @@ public AnotherPolicyImpl build() { AnotherPolicyImpl(Builder builder) { super(builder); } + + @Override + public Builder toBuilder() { + return new Builder(); + } } } diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java index 09cbfa1db554..0d7118dcbbd7 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java @@ -17,6 +17,7 @@ package com.google.gcloud.resourcemanager; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.CaseFormat; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; @@ -40,19 +41,59 @@ * * @see Policy */ -public class Policy extends IamPolicy { +public class Policy extends IamPolicy { private static final long serialVersionUID = -5573557282693961850L; + /** + * Represents legacy roles in an IAM Policy. + */ + public enum Role { + + /** + * Permissions for read-only actions that preserve state. + */ + VIEWER("roles/viewer"), + + /** + * All viewer permissions and permissions for actions that modify state. + */ + EDITOR("roles/editor"), + + /** + * All editor permissions and permissions for the following actions: + *
      + *
    • Manage access control for a resource. + *
    • Set up billing (for a project). + *
    + */ + OWNER("roles/owner"); + + private String strValue; + + private Role(String strValue) { + this.strValue = strValue; + } + + String strValue() { + return strValue; + } + + static Role fromStr(String roleStr) { + return Role.valueOf(CaseFormat.LOWER_CAMEL.to( + CaseFormat.UPPER_UNDERSCORE, roleStr.substring("roles/".length()))); + } + } + /** * Builder for an IAM Policy. */ - public static class Builder extends IamPolicy.Builder { + public static class Builder extends IamPolicy.Builder { private Builder() {} @VisibleForTesting - Builder(Map> bindings, String etag, Integer version) { + Builder(Map> bindings, String etag, Integer version) { bindings(bindings).etag(etag).version(version); } @@ -70,6 +111,7 @@ public static Builder builder() { return new Builder(); } + @Override public Builder toBuilder() { return new Builder(bindings(), etag(), version()); } @@ -79,10 +121,10 @@ com.google.api.services.cloudresourcemanager.model.Policy toPb() { new com.google.api.services.cloudresourcemanager.model.Policy(); List bindingPbList = new LinkedList<>(); - for (Map.Entry> binding : bindings().entrySet()) { + for (Map.Entry> binding : bindings().entrySet()) { com.google.api.services.cloudresourcemanager.model.Binding bindingPb = new com.google.api.services.cloudresourcemanager.model.Binding(); - bindingPb.setRole("roles/" + binding.getKey()); + bindingPb.setRole(binding.getKey().strValue()); bindingPb.setMembers( Lists.transform( new ArrayList<>(binding.getValue()), @@ -102,11 +144,11 @@ public String apply(Identity identity) { static Policy fromPb( com.google.api.services.cloudresourcemanager.model.Policy policyPb) { - Map> bindings = new HashMap<>(); + Map> bindings = new HashMap<>(); for (com.google.api.services.cloudresourcemanager.model.Binding bindingPb : policyPb.getBindings()) { bindings.put( - bindingPb.getRole().substring("roles/".length()), + Role.fromStr(bindingPb.getRole()), ImmutableSet.copyOf( Lists.transform( bindingPb.getMembers(), diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java index 3383eebf470c..05d1b85bdbed 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java @@ -33,8 +33,8 @@ public class PolicyTest { private static final Identity GROUP = Identity.group("group@gmail.com"); private static final Identity DOMAIN = Identity.domain("google.com"); private static final Policy SIMPLE_POLICY = Policy.builder() - .addBinding("viewer", ImmutableSet.of(USER, SERVICE_ACCOUNT, ALL_USERS)) - .addBinding("editor", ImmutableSet.of(ALL_AUTH_USERS, GROUP, DOMAIN)) + .addBinding(Policy.Role.VIEWER, ImmutableSet.of(USER, SERVICE_ACCOUNT, ALL_USERS)) + .addBinding(Policy.Role.EDITOR, ImmutableSet.of(ALL_AUTH_USERS, GROUP, DOMAIN)) .build(); private static final Policy FULL_POLICY = new Policy.Builder(SIMPLE_POLICY.bindings(), "etag", 1).build(); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index 99c0fd7572c0..35b72ae1713f 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -56,7 +56,7 @@ public class SerializationTest { private static final ResourceManager.ProjectListOption PROJECT_LIST_OPTION = ResourceManager.ProjectListOption.filter("name:*"); private static final Policy POLICY = Policy.builder() - .addBinding("viewer", ImmutableSet.of(Identity.user("abc@gmail.com"))) + .addBinding(Policy.Role.VIEWER, ImmutableSet.of(Identity.user("abc@gmail.com"))) .build(); @Test From 75269ff6a0b2b8518ad4dc562905089c20236412 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 26 Feb 2016 18:21:53 -0500 Subject: [PATCH 094/203] Removed unnecessary integration tests. Adjusted deleting objects. --- .../java/com/google/gcloud/dns/ITDnsTest.java | 1763 +++++++---------- 1 file changed, 700 insertions(+), 1063 deletions(-) diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ITDnsTest.java index 07475c52cfda..e473d1c4912c 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ITDnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ITDnsTest.java @@ -26,10 +26,11 @@ import com.google.common.collect.ImmutableList; import com.google.gcloud.Page; -import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.Timeout; import java.util.Iterator; import java.util.LinkedList; @@ -41,7 +42,6 @@ public class ITDnsTest { // todo(mderka) Implement test for creating invalid change when DnsException is finished. #673 - public static final int TIME_LIMIT = 10; public static final String PREFIX = "gcldjvit-"; public static final Dns DNS = DnsOptions.builder().build().service(); public static final String PROJECT_ID = DNS.options().projectId(); @@ -80,16 +80,16 @@ public class ITDnsTest { .description(ZONE_DESCRIPTION1) .dnsName(ZONE_DNS_NAME_NO_PERIOD) .build(); - public static final DnsRecord A_RECORD_ZONE1 = DnsRecord - .builder("www." + ZONE1.dnsName(), DnsRecord.Type.A) - .records(ImmutableList.of("123.123.55.1")) - .ttl(25, TimeUnit.SECONDS) - .build(); - public static final DnsRecord AAAA_RECORD_ZONE1 = DnsRecord - .builder("www." + ZONE1.dnsName(), DnsRecord.Type.AAAA) - .records(ImmutableList.of("ed:ed:12:aa:36:3:3:105")) - .ttl(25, TimeUnit.SECONDS) - .build(); + public static final DnsRecord A_RECORD_ZONE1 = + DnsRecord.builder("www." + ZONE1.dnsName(), DnsRecord.Type.A) + .records(ImmutableList.of("123.123.55.1")) + .ttl(25, TimeUnit.SECONDS) + .build(); + public static final DnsRecord AAAA_RECORD_ZONE1 = + DnsRecord.builder("www." + ZONE1.dnsName(), DnsRecord.Type.AAAA) + .records(ImmutableList.of("ed:ed:12:aa:36:3:3:105")) + .ttl(25, TimeUnit.SECONDS) + .build(); public static final ChangeRequest CHANGE_ADD_ZONE1 = ChangeRequest.builder() .add(A_RECORD_ZONE1) .add(AAAA_RECORD_ZONE1) @@ -99,7 +99,7 @@ public class ITDnsTest { .delete(AAAA_RECORD_ZONE1) .build(); - public static void purge() { + public static void clear() { Page zones = DNS.listZones(); Iterator zoneIterator = zones.iterateAll(); while (zoneIterator.hasNext()) { @@ -114,7 +114,9 @@ public static void purge() { } } if (!toDelete.isEmpty()) { - zone.applyChangeRequest(ChangeRequest.builder().deletions(toDelete).build()); + ChangeRequest deletion = + zone.applyChangeRequest(ChangeRequest.builder().deletions(toDelete).build()); + checkChangeComplete(zone.name(), deletion.id()); } zone.delete(); } @@ -134,868 +136,617 @@ private static List filter(Iterator iterator) { @BeforeClass public static void before() { - purge(); + clear(); } @AfterClass public static void after() { - purge(); + clear(); } - @Test - public void testCreateValidZone() { - Zone created = DNS.create(ZONE1); - assertEquals(ZONE1.description(), created.description()); - assertEquals(ZONE1.dnsName(), created.dnsName()); - assertEquals(ZONE1.name(), created.name()); - assertNotNull(created.creationTimeMillis()); - assertNotNull(created.nameServers()); - assertNull(created.nameServerSet()); - assertNotNull(created.id()); - Zone retrieved = DNS.getZone(ZONE1.name()); - assertEquals(created, retrieved); - created = DNS.create(ZONE_EMPTY_DESCRIPTION); - assertEquals(ZONE_EMPTY_DESCRIPTION.description(), created.description()); - assertEquals(ZONE_EMPTY_DESCRIPTION.dnsName(), created.dnsName()); - assertEquals(ZONE_EMPTY_DESCRIPTION.name(), created.name()); - assertNotNull(created.creationTimeMillis()); - assertNotNull(created.nameServers()); - assertNull(created.nameServerSet()); - assertNotNull(created.id()); - retrieved = DNS.getZone(ZONE_EMPTY_DESCRIPTION.name()); - assertEquals(created, retrieved); + private static void assertEqChangesIgnoreStatus(ChangeRequest expected, ChangeRequest actual) { + ChangeRequest unifiedEx = ChangeRequest.fromPb(expected.toPb().setStatus("pending")); + ChangeRequest unifiedAct = ChangeRequest.fromPb(actual.toPb().setStatus("pending")); + assertEquals(unifiedEx, unifiedAct); } - @After - public void tearDown() { - purge(); + private static void checkChangeComplete(String zoneName, String changeId) { + while (true) { + ChangeRequest changeRequest = DNS.getChangeRequest(zoneName, changeId, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + if (ChangeRequest.Status.DONE.equals(changeRequest.status())) { + break; + } + } } + @Rule + public Timeout globalTimeout = Timeout.seconds(300); + @Test - public void testCreateZoneWithErrors() { - try { - DNS.create(ZONE_MISSING_DNS_NAME); - fail("Zone is missing DNS name. The service returns an error."); - } catch (DnsException ex) { - // expected - // todo(mderka) test non-retryable when implemented within #593 - } - try { - DNS.create(ZONE_MISSING_DESCRIPTION); - fail("Zone is missing description name. The service returns an error."); - } catch (DnsException ex) { - // expected - // todo(mderka) test non-retryable when implemented within #593 - } - try { - DNS.create(ZONE_NAME_ERROR); - fail("Zone name is missing a period. The service returns an error."); - } catch (DnsException ex) { - // expected - // todo(mderka) test non-retryable when implemented within #593 - } + public void testCreateValidZone() { try { - DNS.create(ZONE_DNS_NO_PERIOD); - fail("Zone name is missing a period. The service returns an error."); - } catch (DnsException ex) { - // expected - // todo(mderka) test non-retryable when implemented within #593 + Zone created = DNS.create(ZONE1); + assertEquals(ZONE1.description(), created.description()); + assertEquals(ZONE1.dnsName(), created.dnsName()); + assertEquals(ZONE1.name(), created.name()); + assertNotNull(created.creationTimeMillis()); + assertNotNull(created.nameServers()); + assertNull(created.nameServerSet()); + assertNotNull(created.id()); + Zone retrieved = DNS.getZone(ZONE1.name()); + assertEquals(created, retrieved); + created = DNS.create(ZONE_EMPTY_DESCRIPTION); + assertEquals(ZONE_EMPTY_DESCRIPTION.description(), created.description()); + assertEquals(ZONE_EMPTY_DESCRIPTION.dnsName(), created.dnsName()); + assertEquals(ZONE_EMPTY_DESCRIPTION.name(), created.name()); + assertNotNull(created.creationTimeMillis()); + assertNotNull(created.nameServers()); + assertNull(created.nameServerSet()); + assertNotNull(created.id()); + retrieved = DNS.getZone(ZONE_EMPTY_DESCRIPTION.name()); + assertEquals(created, retrieved); + } finally { + DNS.delete(ZONE1.name()); + DNS.delete(ZONE_EMPTY_DESCRIPTION.name()); } } @Test - public void testCreateZoneWithOptions() { - Zone created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNotNull(created.creationTimeMillis()); - assertNull(created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created.delete(); - created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.DESCRIPTION)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.description(), created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created.delete(); - created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.DNS_NAME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.dnsName(), created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created.delete(); - created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created.delete(); - created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVER_SET)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); // we did not set it - assertNull(created.id()); - created.delete(); - created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVERS)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); - assertNull(created.id()); - created.delete(); - created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertNotNull(created.nameServers()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNotNull(created.id()); - created.delete(); - // combination of multiple things - created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID, - Dns.ZoneField.NAME_SERVERS, Dns.ZoneField.NAME_SERVER_SET, Dns.ZoneField.DESCRIPTION)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertEquals(ZONE1.description(), created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); // we did not set it - assertNotNull(created.id()); + public void testCreateZoneWithErrors() { + try { + try { + DNS.create(ZONE_MISSING_DNS_NAME); + fail("Zone is missing DNS name. The service returns an error."); + } catch (DnsException ex) { + // expected + // todo(mderka) test non-retryable when implemented within #593 + } + try { + DNS.create(ZONE_MISSING_DESCRIPTION); + fail("Zone is missing description name. The service returns an error."); + } catch (DnsException ex) { + // expected + // todo(mderka) test non-retryable when implemented within #593 + } + try { + DNS.create(ZONE_NAME_ERROR); + fail("Zone name is missing a period. The service returns an error."); + } catch (DnsException ex) { + // expected + // todo(mderka) test non-retryable when implemented within #593 + } + try { + DNS.create(ZONE_DNS_NO_PERIOD); + fail("Zone name is missing a period. The service returns an error."); + } catch (DnsException ex) { + // expected + // todo(mderka) test non-retryable when implemented within #593 + } + } finally { + DNS.delete(ZONE_MISSING_DNS_NAME.name()); + DNS.delete(ZONE_MISSING_DESCRIPTION.name()); + DNS.delete(ZONE_NAME_ERROR.name()); + DNS.delete(ZONE_DNS_NO_PERIOD.name()); + } } @Test - public void testZoneReload() { - Zone created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); - created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNotNull(created.creationTimeMillis()); - assertNull(created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.DESCRIPTION)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.description(), created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.DNS_NAME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.dnsName(), created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.NAME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVER_SET)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); // we did not set it - assertNull(created.id()); - created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVERS)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); - assertNull(created.id()); - created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertNotNull(created.nameServers()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNotNull(created.id()); - // combination of multiple things - created = created.reload(Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID, - Dns.ZoneField.NAME_SERVERS, Dns.ZoneField.NAME_SERVER_SET, Dns.ZoneField.DESCRIPTION)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertEquals(ZONE1.description(), created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); // we did not set it - assertNotNull(created.id()); + public void testCreateZoneWithOptions() { + try { + Zone created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNotNull(created.creationTimeMillis()); + assertNull(created.description()); + assertNull(created.dnsName()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.DESCRIPTION)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertEquals(ZONE1.description(), created.description()); + assertNull(created.dnsName()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.DNS_NAME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertEquals(ZONE1.dnsName(), created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVER_SET)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); // we did not set it + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVERS)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertFalse(created.nameServers().isEmpty()); + assertNull(created.nameServerSet()); + assertNull(created.id()); + created.delete(); + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertNotNull(created.nameServers()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNotNull(created.id()); + created.delete(); + // combination of multiple things + created = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID, + Dns.ZoneField.NAME_SERVERS, Dns.ZoneField.NAME_SERVER_SET, Dns.ZoneField.DESCRIPTION)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertEquals(ZONE1.description(), created.description()); + assertFalse(created.nameServers().isEmpty()); + assertNull(created.nameServerSet()); // we did not set it + assertNotNull(created.id()); + } finally { + DNS.delete(ZONE1.name()); + } } @Test public void testGetZone() { - DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); - Zone created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNotNull(created.creationTimeMillis()); - assertNull(created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.DESCRIPTION)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.description(), created.description()); - assertNull(created.dnsName()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.DNS_NAME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertEquals(ZONE1.dnsName(), created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); - assertNull(created.id()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVER_SET)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNull(created.nameServerSet()); // we did not set it - assertNull(created.id()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVERS)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); - assertNull(created.id()); - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertNull(created.description()); - assertNotNull(created.nameServers()); - assertTrue(created.nameServers().isEmpty()); // never returns null - assertNotNull(created.id()); - // combination of multiple things - created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID, - Dns.ZoneField.NAME_SERVERS, Dns.ZoneField.NAME_SERVER_SET, Dns.ZoneField.DESCRIPTION)); - assertEquals(ZONE1.name(), created.name()); // always returned - assertNull(created.creationTimeMillis()); - assertNull(created.dnsName()); - assertEquals(ZONE1.description(), created.description()); - assertFalse(created.nameServers().isEmpty()); - assertNull(created.nameServerSet()); // we did not set it - assertNotNull(created.id()); + try { + DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + Zone created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNotNull(created.creationTimeMillis()); + assertNull(created.description()); + assertNull(created.dnsName()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.DESCRIPTION)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertEquals(ZONE1.description(), created.description()); + assertNull(created.dnsName()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.DNS_NAME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertEquals(ZONE1.dnsName(), created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVER_SET)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNull(created.nameServerSet()); // we did not set it + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.NAME_SERVERS)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertFalse(created.nameServers().isEmpty()); + assertNull(created.nameServerSet()); + assertNull(created.id()); + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertNull(created.description()); + assertNotNull(created.nameServers()); + assertTrue(created.nameServers().isEmpty()); // never returns null + assertNotNull(created.id()); + // combination of multiple things + created = DNS.getZone(ZONE1.name(), Dns.ZoneOption.fields(Dns.ZoneField.ZONE_ID, + Dns.ZoneField.NAME_SERVERS, Dns.ZoneField.NAME_SERVER_SET, Dns.ZoneField.DESCRIPTION)); + assertEquals(ZONE1.name(), created.name()); // always returned + assertNull(created.creationTimeMillis()); + assertNull(created.dnsName()); + assertEquals(ZONE1.description(), created.description()); + assertFalse(created.nameServers().isEmpty()); + assertNull(created.nameServerSet()); // we did not set it + assertNotNull(created.id()); + } finally { + DNS.delete(ZONE1.name()); + } } @Test public void testListZones() { - List zones = filter(DNS.listZones().iterateAll()); - assertEquals(0, zones.size()); - // some zones exists - Zone created = DNS.create(ZONE1); - zones = filter(DNS.listZones().iterateAll()); - assertEquals(created, zones.get(0)); - assertEquals(1, zones.size()); - created = DNS.create(ZONE_EMPTY_DESCRIPTION); - zones = filter(DNS.listZones().iterateAll()); - assertEquals(2, zones.size()); - assertTrue(zones.contains(created)); - // error in options - try { - DNS.listZones(Dns.ZoneListOption.pageSize(0)); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test not-retryable - } - try { - DNS.listZones(Dns.ZoneListOption.pageSize(-1)); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test not-retryable - } - // ok size - zones = filter(DNS.listZones(Dns.ZoneListOption.pageSize(1000)).iterateAll()); - assertEquals(2, zones.size()); // we still have only 2 zones - // dns name problems try { - DNS.listZones(Dns.ZoneListOption.dnsName("aaaaa")); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test not-retryable - } - // ok name - zones = filter(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName())).iterateAll()); - assertEquals(1, zones.size()); - // field options - zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), - Dns.ZoneListOption.fields(Dns.ZoneField.ZONE_ID)).iterateAll()); - assertEquals(1, zones.size()); - Zone zone = zones.get(0); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNotNull(zone.id()); - zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), - Dns.ZoneListOption.fields(Dns.ZoneField.CREATION_TIME)).iterateAll()); - assertEquals(1, zones.size()); - zone = zones.get(0); - assertNotNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.id()); - zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), - Dns.ZoneListOption.fields(Dns.ZoneField.DNS_NAME)).iterateAll()); - assertEquals(1, zones.size()); - zone = zones.get(0); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNotNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.id()); - zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), - Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION)).iterateAll()); - assertEquals(1, zones.size()); - zone = zones.get(0); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNotNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.id()); - zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), - Dns.ZoneListOption.fields(Dns.ZoneField.NAME_SERVERS)).iterateAll()); - assertEquals(1, zones.size()); - zone = zones.get(0); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); - assertTrue(!zone.nameServers().isEmpty()); - assertNull(zone.id()); - zones = ImmutableList.copyOf(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), - Dns.ZoneListOption.fields(Dns.ZoneField.NAME_SERVER_SET)).iterateAll()); - assertEquals(1, zones.size()); - zone = zones.get(0); - assertNull(zone.creationTimeMillis()); - assertNotNull(zone.name()); - assertNull(zone.dnsName()); - assertNull(zone.description()); - assertNull(zone.nameServerSet()); // we cannot set it using gcloud java - assertTrue(zone.nameServers().isEmpty()); - assertNull(zone.id()); - // several combined - zones = filter(DNS.listZones(Dns.ZoneListOption.fields(Dns.ZoneField.ZONE_ID, - Dns.ZoneField.DESCRIPTION), - Dns.ZoneListOption.pageSize(1)).iterateAll()); - assertEquals(2, zones.size()); - for (Zone current : zones) { - assertNull(current.creationTimeMillis()); - assertNotNull(current.name()); - assertNull(current.dnsName()); - assertNotNull(current.description()); - assertNull(current.nameServerSet()); + List zones = filter(DNS.listZones().iterateAll()); + assertEquals(0, zones.size()); + // some zones exists + Zone created = DNS.create(ZONE1); + zones = filter(DNS.listZones().iterateAll()); + assertEquals(created, zones.get(0)); + assertEquals(1, zones.size()); + created = DNS.create(ZONE_EMPTY_DESCRIPTION); + zones = filter(DNS.listZones().iterateAll()); + assertEquals(2, zones.size()); + assertTrue(zones.contains(created)); + // error in options + try { + DNS.listZones(Dns.ZoneListOption.pageSize(0)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test not-retryable + } + try { + DNS.listZones(Dns.ZoneListOption.pageSize(-1)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test not-retryable + } + // ok size + zones = filter(DNS.listZones(Dns.ZoneListOption.pageSize(1000)).iterateAll()); + assertEquals(2, zones.size()); // we still have only 2 zones + // dns name problems + try { + DNS.listZones(Dns.ZoneListOption.dnsName("aaaaa")); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test not-retryable + } + // ok name + zones = filter(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName())).iterateAll()); + assertEquals(1, zones.size()); + // field options + Iterator zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.ZONE_ID)).iterateAll(); + Zone zone = zoneIterator.next(); + assertNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNull(zone.dnsName()); + assertNull(zone.description()); + assertNull(zone.nameServerSet()); assertTrue(zone.nameServers().isEmpty()); - assertNotNull(current.id()); - } - } - - @Test - public void testDeleteZoneUsingServiceObject() { - Zone created = DNS.create(ZONE1); - assertEquals(created, DNS.getZone(ZONE1.name())); - DNS.delete(ZONE1.name()); - assertNull(DNS.getZone(ZONE1.name())); - } - - @Test - public void testDeleteZoneUsingZoneObject() { - Zone created = DNS.create(ZONE1); - assertEquals(created, DNS.getZone(ZONE1.name())); - created.delete(); - assertNull(DNS.getZone(ZONE1.name())); - } - - private void assertEqChangesIgnoreStatus(ChangeRequest expected, ChangeRequest actual) { - ChangeRequest unifiedEx = ChangeRequest.fromPb(expected.toPb().setStatus("pending")); - ChangeRequest unifiedAct = ChangeRequest.fromPb(actual.toPb().setStatus("pending")); - assertEquals(unifiedEx, unifiedAct); - } - - private static void checkChangeComplete(String zoneName, String changeId) { - for (int i = 0; i < TIME_LIMIT; i++) { - ChangeRequest changeRequest = DNS.getChangeRequest(zoneName, changeId, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); - if (ChangeRequest.Status.DONE.equals(changeRequest.status())) { - break; - } else { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - throw new RuntimeException("Thread was interrupted while waiting for change."); - } + assertNotNull(zone.id()); + assertFalse(zoneIterator.hasNext()); + zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.CREATION_TIME)).iterateAll(); + zone = zoneIterator.next(); + assertNotNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNull(zone.dnsName()); + assertNull(zone.description()); + assertNull(zone.nameServerSet()); + assertTrue(zone.nameServers().isEmpty()); + assertNull(zone.id()); + assertFalse(zoneIterator.hasNext()); + zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.DNS_NAME)).iterateAll(); + zone = zoneIterator.next(); + assertNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNotNull(zone.dnsName()); + assertNull(zone.description()); + assertNull(zone.nameServerSet()); + assertTrue(zone.nameServers().isEmpty()); + assertNull(zone.id()); + assertFalse(zoneIterator.hasNext()); + zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.DESCRIPTION)).iterateAll(); + zone = zoneIterator.next(); + assertNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNull(zone.dnsName()); + assertNotNull(zone.description()); + assertNull(zone.nameServerSet()); + assertTrue(zone.nameServers().isEmpty()); + assertNull(zone.id()); + assertFalse(zoneIterator.hasNext()); + zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.NAME_SERVERS)).iterateAll(); + zone = zoneIterator.next(); + assertNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNull(zone.dnsName()); + assertNull(zone.description()); + assertNull(zone.nameServerSet()); + assertTrue(!zone.nameServers().isEmpty()); + assertNull(zone.id()); + assertFalse(zoneIterator.hasNext()); + zoneIterator = DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName()), + Dns.ZoneListOption.fields(Dns.ZoneField.NAME_SERVER_SET)).iterateAll(); + zone = zoneIterator.next(); + assertNull(zone.creationTimeMillis()); + assertNotNull(zone.name()); + assertNull(zone.dnsName()); + assertNull(zone.description()); + assertNull(zone.nameServerSet()); // we cannot set it using gcloud java + assertTrue(zone.nameServers().isEmpty()); + assertNull(zone.id()); + assertFalse(zoneIterator.hasNext()); + // several combined + zones = filter(DNS.listZones(Dns.ZoneListOption.fields(Dns.ZoneField.ZONE_ID, + Dns.ZoneField.DESCRIPTION), + Dns.ZoneListOption.pageSize(1)).iterateAll()); + assertEquals(2, zones.size()); + for (Zone current : zones) { + assertNull(current.creationTimeMillis()); + assertNotNull(current.name()); + assertNull(current.dnsName()); + assertNotNull(current.description()); + assertNull(current.nameServerSet()); + assertTrue(zone.nameServers().isEmpty()); + assertNotNull(current.id()); } + } finally { + DNS.delete(ZONE1.name()); + DNS.delete(ZONE_EMPTY_DESCRIPTION.name()); } } @Test - public void testCreateChangeUsingServiceObject() { - DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); - ChangeRequest created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); - assertNotNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertEquals("1", created.id()); - assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) - .contains(created.status())); - assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); - checkChangeComplete(ZONE1.name(), "1"); - DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "2"); - // with options - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); - assertTrue(created.additions().isEmpty()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertEquals("3", created.id()); - assertNull(created.status()); - checkChangeComplete(ZONE1.name(), "3"); - DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "4"); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); - assertTrue(created.additions().isEmpty()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertEquals("5", created.id()); - assertNotNull(created.status()); - checkChangeComplete(ZONE1.name(), "5"); - DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "6"); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); - assertTrue(created.additions().isEmpty()); - assertNotNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertEquals("7", created.id()); - assertNull(created.status()); - checkChangeComplete(ZONE1.name(), "7"); - DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "8"); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); - assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertEquals("9", created.id()); - assertNull(created.status()); - // finishes with delete otherwise we cannot delete the zone - checkChangeComplete(ZONE1.name(), "9"); - created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); - checkChangeComplete(ZONE1.name(), "10"); - assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); - assertNull(created.startTimeMillis()); - assertTrue(created.additions().isEmpty()); - assertEquals("10", created.id()); - assertNull(created.status()); - checkChangeComplete(ZONE1.name(), "10"); + public void testDeleteZone() { + try { + Zone created = DNS.create(ZONE1); + assertEquals(created, DNS.getZone(ZONE1.name())); + DNS.delete(ZONE1.name()); + assertNull(DNS.getZone(ZONE1.name())); + } finally { + DNS.delete(ZONE1.name()); + } } - @Test - public void testCreateChangeUsingZoneObject() { - Zone zone = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); - ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); - assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); - assertNotNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertEquals("1", created.id()); - assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) - .contains(created.status())); - assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); - checkChangeComplete(ZONE1.name(), "1"); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "2"); - // with options - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); - assertTrue(created.additions().isEmpty()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertEquals("3", created.id()); - assertNull(created.status()); - checkChangeComplete(ZONE1.name(), "3"); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "4"); - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); - assertTrue(created.additions().isEmpty()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertEquals("5", created.id()); - assertNotNull(created.status()); - checkChangeComplete(ZONE1.name(), "5"); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "6"); - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); - assertTrue(created.additions().isEmpty()); - assertNotNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertEquals("7", created.id()); - assertNull(created.status()); - checkChangeComplete(ZONE1.name(), "7"); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "8"); - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); - assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); - assertNull(created.startTimeMillis()); - assertTrue(created.deletions().isEmpty()); - assertEquals("9", created.id()); - assertNull(created.status()); - // finishes with delete otherwise we cannot delete the zone - checkChangeComplete(ZONE1.name(), "9"); - created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); - checkChangeComplete(ZONE1.name(), "10"); - assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); - assertNull(created.startTimeMillis()); - assertTrue(created.additions().isEmpty()); - assertEquals("10", created.id()); - assertNull(created.status()); - checkChangeComplete(ZONE1.name(), "10"); - } @Test - public void testListChangesUsingService() { - // no such zone exists + public void testCreateChange() { try { - DNS.listChangeRequests(ZONE1.name()); - fail(); - } catch (DnsException ex) { - // expected - assertEquals(404, ex.code()); - // todo(mderka) test retry functionality - } - // zone exists but has no changes - DNS.create(ZONE1); - ImmutableList changes = ImmutableList.copyOf( - DNS.listChangeRequests(ZONE1.name()).iterateAll()); - assertEquals(1, changes.size()); // default change creating SOA and NS - // zone has changes - ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); - change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); - change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); - change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name()).iterateAll()); - assertEquals(5, changes.size()); - // error in options - try { - DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(0)); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test retry functionality - } - try { - DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(-1)); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test retry functionality - } - // sorting order - ImmutableList ascending = ImmutableList.copyOf(DNS.listChangeRequests( - ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)).iterateAll()); - ImmutableList descending = ImmutableList.copyOf(DNS.listChangeRequests( - ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.DESCENDING)).iterateAll()); - int size = 5; - assertEquals(size, descending.size()); - assertEquals(size, ascending.size()); - for (int i = 0; i < size; i++) { - assertEquals(descending.get(i), ascending.get(size - i - 1)); + DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + ChangeRequest created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); + assertNotNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("1", created.id()); + assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) + .contains(created.status())); + assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); + checkChangeComplete(ZONE1.name(), "1"); + DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "2"); + // with options + created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); + assertTrue(created.additions().isEmpty()); + assertNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("3", created.id()); + assertNull(created.status()); + checkChangeComplete(ZONE1.name(), "3"); + DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "4"); + created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + assertTrue(created.additions().isEmpty()); + assertNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("5", created.id()); + assertNotNull(created.status()); + checkChangeComplete(ZONE1.name(), "5"); + DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "6"); + created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); + assertTrue(created.additions().isEmpty()); + assertNotNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("7", created.id()); + assertNull(created.status()); + checkChangeComplete(ZONE1.name(), "7"); + DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), "8"); + created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); + assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); + assertNull(created.startTimeMillis()); + assertTrue(created.deletions().isEmpty()); + assertEquals("9", created.id()); + assertNull(created.status()); + // finishes with delete otherwise we cannot delete the zone + checkChangeComplete(ZONE1.name(), "9"); + created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); + checkChangeComplete(ZONE1.name(), "10"); + assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); + assertNull(created.startTimeMillis()); + assertTrue(created.additions().isEmpty()); + assertEquals("10", created.id()); + assertNull(created.status()); + checkChangeComplete(ZONE1.name(), "10"); + } finally { + clear(); } - // field options - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.ADDITIONS)).iterateAll()); - change = changes.get(1); - assertEquals(CHANGE_ADD_ZONE1.additions(), change.additions()); - assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); - assertNull(change.startTimeMillis()); - assertNull(change.status()); - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.DELETIONS)).iterateAll()); - change = changes.get(2); - assertTrue(change.additions().isEmpty()); - assertNotNull(change.deletions()); - assertEquals("2", change.id()); - assertNull(change.startTimeMillis()); - assertNull(change.status()); - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.ID)).iterateAll()); - change = changes.get(1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); - assertNull(change.startTimeMillis()); - assertNull(change.status()); - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.START_TIME)).iterateAll()); - change = changes.get(1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); - assertNotNull(change.startTimeMillis()); - assertNull(change.status()); - changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS)).iterateAll()); - change = changes.get(1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); - assertNull(change.startTimeMillis()); - assertEquals(ChangeRequest.Status.DONE, change.status()); } @Test - public void testListChangesUsingZoneObject() { - // zone exists but has no changes - Zone created = DNS.create(ZONE1); - ImmutableList changes = ImmutableList.copyOf( - created.listChangeRequests().iterateAll()); - assertEquals(1, changes.size()); // default change creating SOA and NS - // zone has changes - ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); - change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); - change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); - change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); - changes = ImmutableList.copyOf(created.listChangeRequests().iterateAll()); - assertEquals(5, changes.size()); - // error in options - try { - created.listChangeRequests(Dns.ChangeRequestListOption.pageSize(0)); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test retry functionality - } + public void testListChanges() { try { - created.listChangeRequests(Dns.ChangeRequestListOption.pageSize(-1)); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test retry functionality - } - // sorting order - ImmutableList ascending = ImmutableList.copyOf(created.listChangeRequests( - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)).iterateAll()); - ImmutableList descending = ImmutableList.copyOf(created.listChangeRequests( - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.DESCENDING)).iterateAll()); - int size = 5; - assertEquals(size, descending.size()); - assertEquals(size, ascending.size()); - for (int i = 0; i < size; i++) { - assertEquals(descending.get(i), ascending.get(size - i - 1)); + // no such zone exists + try { + DNS.listChangeRequests(ZONE1.name()); + fail(); + } catch (DnsException ex) { + // expected + assertEquals(404, ex.code()); + // todo(mderka) test retry functionality + } + // zone exists but has no changes + DNS.create(ZONE1); + ImmutableList changes = ImmutableList.copyOf( + DNS.listChangeRequests(ZONE1.name()).iterateAll()); + assertEquals(1, changes.size()); // default change creating SOA and NS + // zone has changes + ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name()).iterateAll()); + assertEquals(5, changes.size()); + // error in options + try { + DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(0)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality + } + try { + DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(-1)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality + } + // sorting order + ImmutableList ascending = ImmutableList.copyOf(DNS.listChangeRequests( + ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)).iterateAll()); + ImmutableList descending = ImmutableList.copyOf(DNS.listChangeRequests( + ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.DESCENDING)).iterateAll()); + int size = 5; + assertEquals(size, descending.size()); + assertEquals(size, ascending.size()); + for (int i = 0; i < size; i++) { + assertEquals(descending.get(i), ascending.get(size - i - 1)); + } + // field options + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.ADDITIONS)).iterateAll()); + change = changes.get(1); + assertEquals(CHANGE_ADD_ZONE1.additions(), change.additions()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.DELETIONS)).iterateAll()); + change = changes.get(2); + assertTrue(change.additions().isEmpty()); + assertNotNull(change.deletions()); + assertEquals("2", change.id()); + assertNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.ID)).iterateAll()); + change = changes.get(1); + assertTrue(change.additions().isEmpty()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.START_TIME)).iterateAll()); + change = changes.get(1); + assertTrue(change.additions().isEmpty()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNotNull(change.startTimeMillis()); + assertNull(change.status()); + changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name(), + Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), + Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS)).iterateAll()); + change = changes.get(1); + assertTrue(change.additions().isEmpty()); + assertTrue(change.deletions().isEmpty()); + assertEquals("1", change.id()); + assertNull(change.startTimeMillis()); + assertEquals(ChangeRequest.Status.DONE, change.status()); + } finally { + clear(); } - // field options - changes = ImmutableList.copyOf(created.listChangeRequests( - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.ADDITIONS)).iterateAll()); - change = changes.get(1); - assertEquals(CHANGE_ADD_ZONE1.additions(), change.additions()); - assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); - assertNull(change.startTimeMillis()); - assertNull(change.status()); - changes = ImmutableList.copyOf(created.listChangeRequests( - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.DELETIONS)).iterateAll()); - change = changes.get(2); - assertTrue(change.additions().isEmpty()); - assertNotNull(change.deletions()); - assertEquals("2", change.id()); - assertNull(change.startTimeMillis()); - assertNull(change.status()); - changes = ImmutableList.copyOf(created.listChangeRequests( - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.ID)).iterateAll()); - change = changes.get(1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); - assertNull(change.startTimeMillis()); - assertNull(change.status()); - changes = ImmutableList.copyOf(created.listChangeRequests( - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.START_TIME)).iterateAll()); - change = changes.get(1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); - assertNotNull(change.startTimeMillis()); - assertNull(change.status()); - changes = ImmutableList.copyOf(created.listChangeRequests( - Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING), - Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS)).iterateAll()); - change = changes.get(1); - assertTrue(change.additions().isEmpty()); - assertTrue(change.deletions().isEmpty()); - assertEquals("1", change.id()); - assertNull(change.startTimeMillis()); - assertEquals(ChangeRequest.Status.DONE, change.status()); - } - - @Test - public void testGetChangeUsingZoneObject() { - Zone zone = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); - ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); - ChangeRequest retrieved = zone.getChangeRequest(created.id()); - assertEqChangesIgnoreStatus(created, retrieved); - checkChangeComplete(ZONE1.name(), "1"); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "2"); - // with options - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); - retrieved = zone.getChangeRequest(created.id(), - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); - assertEqChangesIgnoreStatus(created, retrieved); - checkChangeComplete(ZONE1.name(), "3"); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "4"); - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); - retrieved = zone.getChangeRequest(created.id(), - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); - assertEqChangesIgnoreStatus(created, retrieved); - checkChangeComplete(ZONE1.name(), "5"); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "6"); - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); - retrieved = zone.getChangeRequest(created.id(), - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); - assertEqChangesIgnoreStatus(created, retrieved); - checkChangeComplete(ZONE1.name(), "7"); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "8"); - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); - retrieved = zone.getChangeRequest(created.id(), - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); - assertEqChangesIgnoreStatus(created, retrieved); - // finishes with delete otherwise we cannot delete the zone - checkChangeComplete(ZONE1.name(), "9"); - created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); - retrieved = zone.getChangeRequest(created.id(), - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); - assertEqChangesIgnoreStatus(created, retrieved); - checkChangeComplete(ZONE1.name(), "10"); } @Test - public void testGetChangeUsingServiceObject() { - Zone zone = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); - ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); - ChangeRequest retrieved = DNS.getChangeRequest(zone.name(), created.id()); - assertEqChangesIgnoreStatus(created, retrieved); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - // with options - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); - retrieved = DNS.getChangeRequest(zone.name(), created.id(), - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); - assertEqChangesIgnoreStatus(created, retrieved); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); - retrieved = DNS.getChangeRequest(zone.name(), created.id(), - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); - assertEqChangesIgnoreStatus(created, retrieved); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); - retrieved = DNS.getChangeRequest(zone.name(), created.id(), - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); - assertEqChangesIgnoreStatus(created, retrieved); - zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); - retrieved = DNS.getChangeRequest(zone.name(), created.id(), - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); - assertEqChangesIgnoreStatus(created, retrieved); - // finishes with delete otherwise we cannot delete the zone - created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); - retrieved = DNS.getChangeRequest(zone.name(), created.id(), - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); - assertEqChangesIgnoreStatus(created, retrieved); + public void testGetChange() { + try { + Zone zone = DNS.create(ZONE1, Dns.ZoneOption.fields(Dns.ZoneField.NAME)); + ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); + ChangeRequest retrieved = DNS.getChangeRequest(zone.name(), created.id()); + assertEqChangesIgnoreStatus(created, retrieved); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + // with options + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); + retrieved = DNS.getChangeRequest(zone.name(), created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); + assertEqChangesIgnoreStatus(created, retrieved); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + retrieved = DNS.getChangeRequest(zone.name(), created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); + assertEqChangesIgnoreStatus(created, retrieved); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); + retrieved = DNS.getChangeRequest(zone.name(), created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); + assertEqChangesIgnoreStatus(created, retrieved); + zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); + retrieved = DNS.getChangeRequest(zone.name(), created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); + assertEqChangesIgnoreStatus(created, retrieved); + // finishes with delete otherwise we cannot delete the zone + created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); + retrieved = DNS.getChangeRequest(zone.name(), created.id(), + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); + assertEqChangesIgnoreStatus(created, retrieved); + } finally { + clear(); + } } @Test @@ -1027,242 +778,128 @@ public void testGetProject() { } @Test - public void testListDnsRecordsUsingService() { - Zone zone = DNS.create(ZONE1); - ImmutableList dnsRecords = ImmutableList.copyOf( - DNS.listDnsRecords(zone.name()).iterateAll()); - assertEquals(2, dnsRecords.size()); - ImmutableList defaultRecords = - ImmutableList.of(DnsRecord.Type.NS, DnsRecord.Type.SOA); - for (DnsRecord record : dnsRecords) { - assertTrue(defaultRecords.contains(record.type())); - } - // field options - Iterator dnsRecordIterator = DNS.listDnsRecords(zone.name(), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL)).iterateAll(); - int counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).ttl(), record.ttl()); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertTrue(record.records().isEmpty()); - counter++; - } - assertEquals(2, counter); - dnsRecordIterator = DNS.listDnsRecords(zone.name(), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.NAME)).iterateAll(); - counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertTrue(record.records().isEmpty()); - assertNull(record.ttl()); - counter++; - } - assertEquals(2, counter); - dnsRecordIterator = DNS.listDnsRecords(zone.name(), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.DNS_RECORDS)).iterateAll(); - counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).records(), record.records()); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertNull(record.ttl()); - counter++; - } - assertEquals(2, counter); - dnsRecordIterator = DNS.listDnsRecords(zone.name(), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), - Dns.DnsRecordListOption.pageSize(1)).iterateAll(); // also test paging - counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertTrue(record.records().isEmpty()); - assertNull(record.ttl()); - counter++; - } - assertEquals(2, counter); - // test page size - Page dnsRecordPage = DNS.listDnsRecords(zone.name(), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), - Dns.DnsRecordListOption.pageSize(1)); - assertEquals(1, ImmutableList.copyOf(dnsRecordPage.values().iterator()).size()); - // test name filter - ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); - dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), - Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name())).iterateAll(); - counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertTrue(ImmutableList.of(A_RECORD_ZONE1.type(), AAAA_RECORD_ZONE1.type()) - .contains(record.type())); - counter++; - } - assertEquals(2, counter); - // test type filter - checkChangeComplete(ZONE1.name(), change.id()); - dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), - Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name()), - Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())) - .iterateAll(); - counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(A_RECORD_ZONE1, record); - counter++; - } - assertEquals(1, counter); - change = zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - // check wrong arguments - try { - // name is not set - DNS.listDnsRecords(ZONE1.name(), - Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test retry functionality when available - } - try { - DNS.listDnsRecords(ZONE1.name(), - Dns.DnsRecordListOption.pageSize(0)); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test retry functionality when available - } - try { - DNS.listDnsRecords(ZONE1.name(), - Dns.DnsRecordListOption.pageSize(-1)); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test retry functionality when available - } - checkChangeComplete(ZONE1.name(), change.id()); - } - - @Test - public void testListDnsRecordsUsingZoneObject() { - Zone zone = DNS.create(ZONE1); - ImmutableList dnsRecords = ImmutableList.copyOf( - zone.listDnsRecords().iterateAll()); - assertEquals(2, dnsRecords.size()); - ImmutableList defaultRecords = - ImmutableList.of(DnsRecord.Type.NS, DnsRecord.Type.SOA); - for (DnsRecord record : dnsRecords) { - assertTrue(defaultRecords.contains(record.type())); - } - // field options - Iterator dnsRecordIterator = zone.listDnsRecords( - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL)).iterateAll(); - int counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).ttl(), record.ttl()); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertTrue(record.records().isEmpty()); - counter++; - } - assertEquals(2, counter); - dnsRecordIterator = zone.listDnsRecords( - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.NAME)).iterateAll(); - counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertTrue(record.records().isEmpty()); - assertNull(record.ttl()); - counter++; - } - assertEquals(2, counter); - dnsRecordIterator = zone.listDnsRecords( - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.DNS_RECORDS)).iterateAll(); - counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).records(), record.records()); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertNull(record.ttl()); - counter++; - } - assertEquals(2, counter); - dnsRecordIterator = zone.listDnsRecords( - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), - Dns.DnsRecordListOption.pageSize(1)).iterateAll(); // also test paging - counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertTrue(record.records().isEmpty()); - assertNull(record.ttl()); - counter++; - } - assertEquals(2, counter); - // test page size - Page dnsRecordPage = zone.listDnsRecords( - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), - Dns.DnsRecordListOption.pageSize(1)); - assertEquals(1, ImmutableList.copyOf(dnsRecordPage.values().iterator()).size()); - // test name filter - ChangeRequest change = zone.applyChangeRequest(CHANGE_ADD_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); - dnsRecordIterator = zone.listDnsRecords(Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name())) - .iterateAll(); - counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertTrue(ImmutableList.of(A_RECORD_ZONE1.type(), AAAA_RECORD_ZONE1.type()) - .contains(record.type())); - counter++; - } - assertEquals(2, counter); - // test type filter - checkChangeComplete(ZONE1.name(), change.id()); - dnsRecordIterator = zone.listDnsRecords(Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name()), - Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())) - .iterateAll(); - counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(A_RECORD_ZONE1, record); - counter++; - } - assertEquals(1, counter); - change = zone.applyChangeRequest(CHANGE_DELETE_ZONE1); - // check wrong arguments - try { - // name is not set - zone.listDnsRecords(Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test retry functionality when available - } + public void testListDnsRecords() { try { - zone.listDnsRecords(Dns.DnsRecordListOption.pageSize(0)); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test retry functionality when available - } - try { - zone.listDnsRecords(Dns.DnsRecordListOption.pageSize(-1)); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - // todo(mderka) test retry functionality when available + Zone zone = DNS.create(ZONE1); + ImmutableList dnsRecords = ImmutableList.copyOf( + DNS.listDnsRecords(zone.name()).iterateAll()); + assertEquals(2, dnsRecords.size()); + ImmutableList defaultRecords = + ImmutableList.of(DnsRecord.Type.NS, DnsRecord.Type.SOA); + for (DnsRecord record : dnsRecords) { + assertTrue(defaultRecords.contains(record.type())); + } + // field options + Iterator dnsRecordIterator = DNS.listDnsRecords(zone.name(), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL)).iterateAll(); + int counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).ttl(), record.ttl()); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertTrue(record.records().isEmpty()); + counter++; + } + assertEquals(2, counter); + dnsRecordIterator = DNS.listDnsRecords(zone.name(), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.NAME)).iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertTrue(record.records().isEmpty()); + assertNull(record.ttl()); + counter++; + } + assertEquals(2, counter); + dnsRecordIterator = DNS.listDnsRecords(zone.name(), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.DNS_RECORDS)).iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).records(), record.records()); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertNull(record.ttl()); + counter++; + } + assertEquals(2, counter); + dnsRecordIterator = DNS.listDnsRecords(zone.name(), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), + Dns.DnsRecordListOption.pageSize(1)).iterateAll(); // also test paging + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(dnsRecords.get(counter).type(), record.type()); + assertEquals(dnsRecords.get(counter).name(), record.name()); + assertTrue(record.records().isEmpty()); + assertNull(record.ttl()); + counter++; + } + assertEquals(2, counter); + // test page size + Page dnsRecordPage = DNS.listDnsRecords(zone.name(), + Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), + Dns.DnsRecordListOption.pageSize(1)); + assertEquals(1, ImmutableList.copyOf(dnsRecordPage.values().iterator()).size()); + // test name filter + ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); + checkChangeComplete(ZONE1.name(), change.id()); + dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), + Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name())).iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertTrue(ImmutableList.of(A_RECORD_ZONE1.type(), AAAA_RECORD_ZONE1.type()) + .contains(record.type())); + counter++; + } + assertEquals(2, counter); + // test type filter + checkChangeComplete(ZONE1.name(), change.id()); + dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), + Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name()), + Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())) + .iterateAll(); + counter = 0; + while (dnsRecordIterator.hasNext()) { + DnsRecord record = dnsRecordIterator.next(); + assertEquals(A_RECORD_ZONE1, record); + counter++; + } + assertEquals(1, counter); + change = zone.applyChangeRequest(CHANGE_DELETE_ZONE1); + // check wrong arguments + try { + // name is not set + DNS.listDnsRecords(ZONE1.name(), + Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality when available + } + try { + DNS.listDnsRecords(ZONE1.name(), + Dns.DnsRecordListOption.pageSize(0)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality when available + } + try { + DNS.listDnsRecords(ZONE1.name(), + Dns.DnsRecordListOption.pageSize(-1)); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + // todo(mderka) test retry functionality when available + } + checkChangeComplete(ZONE1.name(), change.id()); + } finally { + clear(); } - checkChangeComplete(ZONE1.name(), change.id()); } } From 992a371006c8e723137b57933b72824754e98869 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Mon, 29 Feb 2016 19:54:57 +0100 Subject: [PATCH 095/203] Remove tabs from storage and bigquery poms --- gcloud-java-bigquery/pom.xml | 8 ++++---- gcloud-java-storage/pom.xml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gcloud-java-bigquery/pom.xml b/gcloud-java-bigquery/pom.xml index f7304e276d75..34ddd7679e97 100644 --- a/gcloud-java-bigquery/pom.xml +++ b/gcloud-java-bigquery/pom.xml @@ -33,10 +33,10 @@ v2-rev270-1.21.0 compile - - com.google.guava - guava-jdk5 - + + com.google.guava + guava-jdk5 + diff --git a/gcloud-java-storage/pom.xml b/gcloud-java-storage/pom.xml index d98fcd2647e2..f18283b70bc8 100644 --- a/gcloud-java-storage/pom.xml +++ b/gcloud-java-storage/pom.xml @@ -27,10 +27,10 @@ v1-rev62-1.21.0 compile - - com.google.guava - guava-jdk5 - + + com.google.guava + guava-jdk5 + com.google.api-client google-api-client From 72b4f44859400fe9e7a1f42ed20bb15b431ca301 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Mon, 29 Feb 2016 20:22:36 +0100 Subject: [PATCH 096/203] Fix links to examples javadoc in READMEs --- README.md | 8 ++++---- gcloud-java-bigquery/README.md | 2 +- gcloud-java-datastore/README.md | 2 +- gcloud-java-resourcemanager/README.md | 2 +- gcloud-java-storage/README.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b6c2473f9794..810e8aecbbf2 100644 --- a/README.md +++ b/README.md @@ -45,17 +45,17 @@ Example Applications -------------------- - [`BigQueryExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/BigQueryExample.java) - A simple command line interface providing some of Cloud BigQuery's functionality - - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/BigQueryExample.html). + - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/bigquery/BigQueryExample.html). - [`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/bookshelf) - An App Engine app that manages a virtual bookshelf. - This app uses `gcloud-java` to interface with Cloud Datastore and Cloud Storage. It also uses Cloud SQL, another Google Cloud Platform service. - [`DatastoreExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) - A simple command line interface for the Cloud Datastore - - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/DatastoreExample.html). + - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/datastore/DatastoreExample.html). - [`ResourceManagerExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/ResourceManagerExample.java) - A simple command line interface providing some of Cloud Resource Manager's functionality - - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/ResourceManagerExample.html). + - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/resourcemanager/ResourceManagerExample.html). - [`SparkDemo`](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/managed_vms/sparkjava) - An example of using gcloud-java-datastore from within the SparkJava and App Engine Managed VM frameworks. - Read about how it works on the example's [README page](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/managed_vms/sparkjava#how-does-it-work). - [`StorageExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java) - A simple command line interface providing some of Cloud Storage's functionality - - 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). + - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/storage/StorageExample.html). Specifying a Project ID ----------------------- diff --git a/gcloud-java-bigquery/README.md b/gcloud-java-bigquery/README.md index b406fb5496d2..9a1c6e539dae 100644 --- a/gcloud-java-bigquery/README.md +++ b/gcloud-java-bigquery/README.md @@ -37,7 +37,7 @@ libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.4" Example Application ------------------- - [`BigQueryExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/BigQueryExample.java) - A simple command line interface providing some of Cloud BigQuery's functionality. -Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/BigQueryExample.html). +Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/bigquery/BigQueryExample.html). Authentication -------------- diff --git a/gcloud-java-datastore/README.md b/gcloud-java-datastore/README.md index a1d024fcc96d..c27aea21e3a8 100644 --- a/gcloud-java-datastore/README.md +++ b/gcloud-java-datastore/README.md @@ -36,7 +36,7 @@ libraryDependencies += "com.google.gcloud" % "gcloud-java-datastore" % "0.1.4" Example Application -------------------- -[`DatastoreExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) is a simple command line interface for the Cloud Datastore. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/DatastoreExample.html). +[`DatastoreExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) is a simple command line interface for the Cloud Datastore. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/datastore/DatastoreExample.html). Authentication -------------- diff --git a/gcloud-java-resourcemanager/README.md b/gcloud-java-resourcemanager/README.md index 9637b37d3bb8..ab4eb012066b 100644 --- a/gcloud-java-resourcemanager/README.md +++ b/gcloud-java-resourcemanager/README.md @@ -36,7 +36,7 @@ libraryDependencies += "com.google.gcloud" % "gcloud-java-resourcemanager" % "0. Example Application -------------------- -[`ResourceManagerExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/ResourceManagerExample.java) is a simple command line interface for the Cloud Resource Manager. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/ResourceManagerExample.html). +[`ResourceManagerExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/ResourceManagerExample.java) is a simple command line interface for the Cloud Resource Manager. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/resourcemanager/ResourceManagerExample.html). Authentication -------------- diff --git a/gcloud-java-storage/README.md b/gcloud-java-storage/README.md index 3b013eb03724..bd7427444c92 100644 --- a/gcloud-java-storage/README.md +++ b/gcloud-java-storage/README.md @@ -37,7 +37,7 @@ libraryDependencies += "com.google.gcloud" % "gcloud-java-storage" % "0.1.4" Example Application ------------------- -[`StorageExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java) is a simple command line interface that provides some of Cloud Storage's functionality. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/StorageExample.html). +[`StorageExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java) is a simple command line interface that provides some of Cloud Storage's functionality. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/storage/StorageExample.html). Authentication -------------- From 5c3bd9ff6d19701777cdd09270e62e2ff3c0275b Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Mon, 29 Feb 2016 23:05:41 +0100 Subject: [PATCH 097/203] Use better link names for examples javadoc --- README.md | 8 ++++---- gcloud-java-bigquery/README.md | 2 +- gcloud-java-datastore/README.md | 2 +- gcloud-java-resourcemanager/README.md | 2 +- gcloud-java-storage/README.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 810e8aecbbf2..32a0f539425e 100644 --- a/README.md +++ b/README.md @@ -45,17 +45,17 @@ Example Applications -------------------- - [`BigQueryExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/BigQueryExample.java) - A simple command line interface providing some of Cloud BigQuery's functionality - - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/bigquery/BigQueryExample.html). + - Read more about using this application on the [`BigQueryExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/bigquery/BigQueryExample.html). - [`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/bookshelf) - An App Engine app that manages a virtual bookshelf. - This app uses `gcloud-java` to interface with Cloud Datastore and Cloud Storage. It also uses Cloud SQL, another Google Cloud Platform service. - [`DatastoreExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) - A simple command line interface for the Cloud Datastore - - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/datastore/DatastoreExample.html). + - Read more about using this application on the [`DatastoreExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/datastore/DatastoreExample.html). - [`ResourceManagerExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/ResourceManagerExample.java) - A simple command line interface providing some of Cloud Resource Manager's functionality - - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/resourcemanager/ResourceManagerExample.html). + - Read more about using this application on the [`ResourceManagerExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/resourcemanager/ResourceManagerExample.html). - [`SparkDemo`](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/managed_vms/sparkjava) - An example of using gcloud-java-datastore from within the SparkJava and App Engine Managed VM frameworks. - Read about how it works on the example's [README page](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/managed_vms/sparkjava#how-does-it-work). - [`StorageExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java) - A simple command line interface providing some of Cloud Storage's functionality - - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/storage/StorageExample.html). + - Read more about using this application on the [`StorageExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/storage/StorageExample.html). Specifying a Project ID ----------------------- diff --git a/gcloud-java-bigquery/README.md b/gcloud-java-bigquery/README.md index 9a1c6e539dae..58633ba635f9 100644 --- a/gcloud-java-bigquery/README.md +++ b/gcloud-java-bigquery/README.md @@ -37,7 +37,7 @@ libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.4" Example Application ------------------- - [`BigQueryExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/BigQueryExample.java) - A simple command line interface providing some of Cloud BigQuery's functionality. -Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/bigquery/BigQueryExample.html). +Read more about using this application on the [`BigQueryExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/bigquery/BigQueryExample.html). Authentication -------------- diff --git a/gcloud-java-datastore/README.md b/gcloud-java-datastore/README.md index c27aea21e3a8..dd341ba244c3 100644 --- a/gcloud-java-datastore/README.md +++ b/gcloud-java-datastore/README.md @@ -36,7 +36,7 @@ libraryDependencies += "com.google.gcloud" % "gcloud-java-datastore" % "0.1.4" Example Application -------------------- -[`DatastoreExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) is a simple command line interface for the Cloud Datastore. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/datastore/DatastoreExample.html). +[`DatastoreExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) is a simple command line interface for the Cloud Datastore. Read more about using the application on the [`DatastoreExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/datastore/DatastoreExample.html). Authentication -------------- diff --git a/gcloud-java-resourcemanager/README.md b/gcloud-java-resourcemanager/README.md index ab4eb012066b..cd48d6699311 100644 --- a/gcloud-java-resourcemanager/README.md +++ b/gcloud-java-resourcemanager/README.md @@ -36,7 +36,7 @@ libraryDependencies += "com.google.gcloud" % "gcloud-java-resourcemanager" % "0. Example Application -------------------- -[`ResourceManagerExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/ResourceManagerExample.java) is a simple command line interface for the Cloud Resource Manager. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/resourcemanager/ResourceManagerExample.html). +[`ResourceManagerExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/ResourceManagerExample.java) is a simple command line interface for the Cloud Resource Manager. Read more about using the application on the [`ResourceManagerExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/resourcemanager/ResourceManagerExample.html). Authentication -------------- diff --git a/gcloud-java-storage/README.md b/gcloud-java-storage/README.md index bd7427444c92..f7973544bba2 100644 --- a/gcloud-java-storage/README.md +++ b/gcloud-java-storage/README.md @@ -37,7 +37,7 @@ libraryDependencies += "com.google.gcloud" % "gcloud-java-storage" % "0.1.4" Example Application ------------------- -[`StorageExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java) is a simple command line interface that provides some of Cloud Storage's functionality. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/storage/StorageExample.html). +[`StorageExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java) is a simple command line interface that provides some of Cloud Storage's functionality. Read more about using the application on the [`StorageExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/storage/StorageExample.html). Authentication -------------- From 21e68cce2c133463fcc4d74e06e3114c5e25ef65 Mon Sep 17 00:00:00 2001 From: aozarov Date: Mon, 29 Feb 2016 15:10:12 -0800 Subject: [PATCH 098/203] Add a versions option to BlobListOption --- .../main/java/com/google/gcloud/storage/Storage.java | 10 ++++++++++ .../com/google/gcloud/storage/StorageImplTest.java | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 4acc1dbcad07..4fa4ba3658be 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -700,6 +700,16 @@ public static BlobListOption recursive(boolean recursive) { return new BlobListOption(StorageRpc.Option.DELIMITER, recursive); } + /** + * If set to {@code true}, lists all versions of a blob. + * The default is {@code false}. + * + * @see Object Versioning + */ + public static BlobListOption versions(boolean versions) { + return new BlobListOption(StorageRpc.Option.VERSIONS, versions); + } + /** * Returns an option to specify the blob's fields to be returned by the RPC call. If this option * is not provided all blob's fields are returned. {@code BlobListOption.fields}) can be used to diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java index b14dcd057438..612664de14ae 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java @@ -200,11 +200,14 @@ public class StorageImplTest { Storage.BlobListOption.prefix("prefix"); private static final Storage.BlobListOption BLOB_LIST_FIELDS = Storage.BlobListOption.fields(Storage.BlobField.CONTENT_TYPE, Storage.BlobField.MD5HASH); + private static final Storage.BlobListOption BLOB_LIST_VERSIONS = + Storage.BlobListOption.versions(false); private static final Storage.BlobListOption BLOB_LIST_EMPTY_FIELDS = Storage.BlobListOption.fields(); private static final Map BLOB_LIST_OPTIONS = ImmutableMap.of( StorageRpc.Option.MAX_RESULTS, BLOB_LIST_MAX_RESULT.value(), - StorageRpc.Option.PREFIX, BLOB_LIST_PREFIX.value()); + StorageRpc.Option.PREFIX, BLOB_LIST_PREFIX.value(), + StorageRpc.Option.VERSIONS, BLOB_LIST_VERSIONS.value()); private static final String PRIVATE_KEY_STRING = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoG" + "BAL2xolH1zrISQ8+GzOV29BNjjzq4/HIP8Psd1+cZb81vDklSF+95wB250MSE0BDc81pvIMwj5OmIfLg1NY6uB" @@ -650,7 +653,8 @@ public void testListBlobsWithOptions() { EasyMock.replay(storageRpcMock); initializeService(); ImmutableList blobList = ImmutableList.of(expectedBlob1, expectedBlob2); - Page page = storage.list(BUCKET_NAME1, BLOB_LIST_MAX_RESULT, BLOB_LIST_PREFIX); + Page page = + storage.list(BUCKET_NAME1, BLOB_LIST_MAX_RESULT, BLOB_LIST_PREFIX, BLOB_LIST_VERSIONS); assertEquals(cursor, page.nextPageCursor()); assertArrayEquals(blobList.toArray(), Iterables.toArray(page.values(), Blob.class)); } From 438896b96ded6829c3fe869a145ab3cf2c9bcaf9 Mon Sep 17 00:00:00 2001 From: Arie Ozarov Date: Mon, 29 Feb 2016 20:12:00 -0800 Subject: [PATCH 099/203] add list versioned blobs to integration tests --- .../storage/testing/RemoteGcsHelper.java | 5 +- .../gcloud/storage/RemoteGcsHelperTest.java | 23 +++++--- .../gcloud/storage/it/ITStorageTest.java | 55 ++++++++++++++----- 3 files changed, 57 insertions(+), 26 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java index 024aa04eba1b..1287ede746d5 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java @@ -20,6 +20,7 @@ import com.google.gcloud.RetryParams; import com.google.gcloud.storage.BlobInfo; import com.google.gcloud.storage.Storage; +import com.google.gcloud.storage.Storage.BlobListOption; import com.google.gcloud.storage.StorageException; import com.google.gcloud.storage.StorageOptions; @@ -173,8 +174,8 @@ public DeleteBucketTask(Storage storage, String bucket) { @Override public Boolean call() { while (true) { - for (BlobInfo info : storage.list(bucket).values()) { - storage.delete(bucket, info.name()); + for (BlobInfo info : storage.list(bucket, BlobListOption.versions(true)).values()) { + storage.delete(info.blobId()); } try { storage.delete(bucket); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelperTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelperTest.java index 2f56bbda7bd9..154554a029fe 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelperTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelperTest.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList; import com.google.gcloud.Page; +import com.google.gcloud.storage.Storage.BlobListOption; import com.google.gcloud.storage.testing.RemoteGcsHelper; import org.easymock.EasyMock; @@ -117,9 +118,10 @@ public Iterator iterateAll() { @Test public void testForceDelete() throws InterruptedException, ExecutionException { Storage storageMock = EasyMock.createMock(Storage.class); - EasyMock.expect(storageMock.list(BUCKET_NAME)).andReturn(blobPage); + EasyMock.expect(storageMock.list(BUCKET_NAME, BlobListOption.versions(true))) + .andReturn(blobPage); for (BlobInfo info : blobList) { - EasyMock.expect(storageMock.delete(BUCKET_NAME, info.name())).andReturn(true); + EasyMock.expect(storageMock.delete(info.blobId())).andReturn(true); } EasyMock.expect(storageMock.delete(BUCKET_NAME)).andReturn(true); EasyMock.replay(storageMock); @@ -132,7 +134,7 @@ public void testForceDeleteTimeout() throws InterruptedException, ExecutionExcep Storage storageMock = EasyMock.createMock(Storage.class); EasyMock.expect(storageMock.list(BUCKET_NAME)).andReturn(blobPage).anyTimes(); for (BlobInfo info : blobList) { - EasyMock.expect(storageMock.delete(BUCKET_NAME, info.name())).andReturn(true).anyTimes(); + EasyMock.expect(storageMock.delete(info.blobId())).andReturn(true).anyTimes(); } EasyMock.expect(storageMock.delete(BUCKET_NAME)).andThrow(RETRYABLE_EXCEPTION).anyTimes(); EasyMock.replay(storageMock); @@ -143,9 +145,10 @@ public void testForceDeleteTimeout() throws InterruptedException, ExecutionExcep @Test public void testForceDeleteFail() throws InterruptedException, ExecutionException { Storage storageMock = EasyMock.createMock(Storage.class); - EasyMock.expect(storageMock.list(BUCKET_NAME)).andReturn(blobPage); + EasyMock.expect(storageMock.list(BUCKET_NAME, BlobListOption.versions(true))) + .andReturn(blobPage); for (BlobInfo info : blobList) { - EasyMock.expect(storageMock.delete(BUCKET_NAME, info.name())).andReturn(true); + EasyMock.expect(storageMock.delete(info.blobId())).andReturn(true); } EasyMock.expect(storageMock.delete(BUCKET_NAME)).andThrow(FATAL_EXCEPTION); EasyMock.replay(storageMock); @@ -160,9 +163,10 @@ public void testForceDeleteFail() throws InterruptedException, ExecutionExceptio @Test public void testForceDeleteNoTimeout() { Storage storageMock = EasyMock.createMock(Storage.class); - EasyMock.expect(storageMock.list(BUCKET_NAME)).andReturn(blobPage); + EasyMock.expect(storageMock.list(BUCKET_NAME, BlobListOption.versions(true))) + .andReturn(blobPage); for (BlobInfo info : blobList) { - EasyMock.expect(storageMock.delete(BUCKET_NAME, info.name())).andReturn(true); + EasyMock.expect(storageMock.delete(info.blobId())).andReturn(true); } EasyMock.expect(storageMock.delete(BUCKET_NAME)).andReturn(true); EasyMock.replay(storageMock); @@ -173,9 +177,10 @@ public void testForceDeleteNoTimeout() { @Test public void testForceDeleteNoTimeoutFail() { Storage storageMock = EasyMock.createMock(Storage.class); - EasyMock.expect(storageMock.list(BUCKET_NAME)).andReturn(blobPage); + EasyMock.expect(storageMock.list(BUCKET_NAME, BlobListOption.versions(true))) + .andReturn(blobPage); for (BlobInfo info : blobList) { - EasyMock.expect(storageMock.delete(BUCKET_NAME, info.name())).andReturn(true); + EasyMock.expect(storageMock.delete(info.blobId())).andReturn(true); } EasyMock.expect(storageMock.delete(BUCKET_NAME)).andThrow(FATAL_EXCEPTION); EasyMock.replay(storageMock); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index 43c2cf6d372b..1adf48a6cf68 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -28,23 +28,14 @@ import com.google.api.client.util.Lists; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.gcloud.Page; import com.google.gcloud.ReadChannel; import com.google.gcloud.RestorableState; import com.google.gcloud.WriteChannel; -import com.google.gcloud.storage.BatchRequest; -import com.google.gcloud.storage.BatchResponse; -import com.google.gcloud.storage.Blob; -import com.google.gcloud.storage.BlobId; -import com.google.gcloud.storage.BlobInfo; -import com.google.gcloud.storage.Bucket; -import com.google.gcloud.storage.BucketInfo; -import com.google.gcloud.storage.CopyWriter; -import com.google.gcloud.storage.HttpMethod; -import com.google.gcloud.storage.Storage; +import com.google.gcloud.storage.*; import com.google.gcloud.storage.Storage.BlobField; import com.google.gcloud.storage.Storage.BucketField; -import com.google.gcloud.storage.StorageException; import com.google.gcloud.storage.testing.RemoteGcsHelper; import org.junit.AfterClass; @@ -63,6 +54,7 @@ import java.util.List; import java.util.Map; import java.util.Random; +import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -302,8 +294,7 @@ public void testListBlobsSelectedFields() { Blob remoteBlob2 = storage.create(blob2); assertNotNull(remoteBlob1); assertNotNull(remoteBlob2); - Page page = - storage.list(BUCKET, + Page page = storage.list(BUCKET, Storage.BlobListOption.prefix("test-list-blobs-selected-fields-blob"), Storage.BlobListOption.fields(BlobField.METADATA)); int index = 0; @@ -331,8 +322,7 @@ public void testListBlobsEmptySelectedFields() { Blob remoteBlob2 = storage.create(blob2); assertNotNull(remoteBlob1); assertNotNull(remoteBlob2); - Page page = storage.list( - BUCKET, + Page page = storage.list(BUCKET, Storage.BlobListOption.prefix("test-list-blobs-empty-selected-fields-blob"), Storage.BlobListOption.fields()); int index = 0; @@ -345,6 +335,41 @@ public void testListBlobsEmptySelectedFields() { assertTrue(remoteBlob2.delete()); } + @Test + public void testListBlobsVersioned() throws ExecutionException, InterruptedException { + String bucketName = RemoteGcsHelper.generateBucketName(); + Bucket bucket = storage.create(BucketInfo.builder(bucketName).versioningEnabled(true).build()); + try { + String[] blobNames = {"test-list-blobs-versioned-blob1", "test-list-blobs-versioned-blob2"}; + BlobInfo blob1 = BlobInfo.builder(bucket, blobNames[0]) + .contentType(CONTENT_TYPE) + .build(); + BlobInfo blob2 = BlobInfo.builder(bucket, blobNames[1]) + .contentType(CONTENT_TYPE) + .build(); + Blob remoteBlob1 = storage.create(blob1); + Blob remoteBlob2 = storage.create(blob2); + Blob remoteBlob3 = storage.create(blob2); + assertNotNull(remoteBlob1); + assertNotNull(remoteBlob2); + assertNotNull(remoteBlob3); + Page page = storage.list(bucketName, + Storage.BlobListOption.prefix("test-list-blobs-versioned-blob"), + Storage.BlobListOption.versions(true)); + Set blobSet = ImmutableSet.of(blobNames[0], blobNames[1]); + for (Blob remoteBlob : page.values()) { + assertEquals(bucketName, remoteBlob.bucket()); + assertTrue(blobSet.contains(remoteBlob.name())); + assertNotNull(remoteBlob.generation()); + } + assertTrue(remoteBlob1.delete()); + assertTrue(remoteBlob2.delete()); + assertTrue(remoteBlob3.delete()); + } finally { + RemoteGcsHelper.forceDelete(storage, bucketName, 5, TimeUnit.SECONDS); + } + } + @Test public void testUpdateBlob() { String blobName = "test-update-blob"; From e66c9a48fc3dc6e952922d01375a2943161f7fca Mon Sep 17 00:00:00 2001 From: Arie Ozarov Date: Tue, 1 Mar 2016 07:13:29 -0800 Subject: [PATCH 100/203] fix style and formatting issue --- .../main/java/com/google/gcloud/storage/Storage.java | 3 +-- .../com/google/gcloud/storage/it/ITStorageTest.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 4fa4ba3658be..98f3450b7f10 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -701,8 +701,7 @@ public static BlobListOption recursive(boolean recursive) { } /** - * If set to {@code true}, lists all versions of a blob. - * The default is {@code false}. + * If set to {@code true}, lists all versions of a blob. The default is {@code false}. * * @see Object Versioning */ diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index 1adf48a6cf68..d239e40246d8 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -33,9 +33,19 @@ import com.google.gcloud.ReadChannel; import com.google.gcloud.RestorableState; import com.google.gcloud.WriteChannel; -import com.google.gcloud.storage.*; +import com.google.gcloud.storage.BatchRequest; +import com.google.gcloud.storage.BatchResponse; +import com.google.gcloud.storage.Blob; +import com.google.gcloud.storage.BlobId; +import com.google.gcloud.storage.BlobInfo; +import com.google.gcloud.storage.Bucket; +import com.google.gcloud.storage.BucketInfo; +import com.google.gcloud.storage.CopyWriter; +import com.google.gcloud.storage.HttpMethod; +import com.google.gcloud.storage.Storage; import com.google.gcloud.storage.Storage.BlobField; import com.google.gcloud.storage.Storage.BucketField; +import com.google.gcloud.storage.StorageException; import com.google.gcloud.storage.testing.RemoteGcsHelper; import org.junit.AfterClass; From 93810ca74ca1ff26fc86dc03125fb9381076576b Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Tue, 1 Mar 2016 16:50:29 +0100 Subject: [PATCH 101/203] Replace com.google.api.client.util.Lists with Guava's Lists --- .../src/main/java/com/google/gcloud/bigquery/FieldValue.java | 2 +- .../test/java/com/google/gcloud/storage/it/ITStorageTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/FieldValue.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/FieldValue.java index 24c4b28b7613..8b27c70db782 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/FieldValue.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/FieldValue.java @@ -20,9 +20,9 @@ import static com.google.common.base.Preconditions.checkState; import com.google.api.client.util.Data; -import com.google.api.client.util.Lists; import com.google.common.base.Function; import com.google.common.base.MoreObjects; +import com.google.common.collect.Lists; import java.io.Serializable; import java.util.List; diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index d239e40246d8..8e954de57e68 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -25,10 +25,10 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import com.google.api.client.util.Lists; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; import com.google.gcloud.Page; import com.google.gcloud.ReadChannel; import com.google.gcloud.RestorableState; From 8a3d5d8122496d6a5fe492a3052e49feb3ba60ae Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Tue, 1 Mar 2016 17:33:06 +0100 Subject: [PATCH 102/203] Replace repackaged checkNotNull inclusion with Guava's --- .../src/main/java/com/google/gcloud/storage/BucketInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java index bf34413f417f..a1de1a07e03e 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BucketInfo.java @@ -16,8 +16,8 @@ package com.google.gcloud.storage; -import static com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.MoreObjects.firstNonNull; +import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Lists.transform; import com.google.api.client.json.jackson2.JacksonFactory; From 9b6929bbfdc9dc376fd52464f1df0cda4b5da7e3 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 1 Mar 2016 11:57:36 -0800 Subject: [PATCH 103/203] Added retryable errors. --- .../java/com/google/gcloud/dns/DnsException.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java index 2092d5909d37..70d7254e9502 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java @@ -16,27 +16,39 @@ package com.google.gcloud.dns; +import com.google.common.collect.ImmutableSet; import com.google.gcloud.BaseServiceException; import com.google.gcloud.RetryHelper.RetryHelperException; import com.google.gcloud.RetryHelper.RetryInterruptedException; import java.io.IOException; +import java.util.Set; /** * DNS service exception. */ public class DnsException extends BaseServiceException { + // see: https://cloud.google.com/dns/troubleshooting + private static final Set RETRYABLE_ERRORS = ImmutableSet.of( + new Error(500, null), + new Error(502, null), + new Error(503, null)); private static final long serialVersionUID = 490302380416260252L; public DnsException(IOException exception) { super(exception, true); } - public DnsException(int code, String message) { + private DnsException(int code, String message) { super(code, message, null, true); } + @Override + protected Set retryableErrors() { + return RETRYABLE_ERRORS; + } + /** * Translate RetryHelperException to the DnsException that caused the error. This method will * always throw an exception. @@ -48,6 +60,4 @@ static DnsException translateAndThrow(RetryHelperException ex) { BaseServiceException.translateAndPropagateIfPossible(ex); throw new DnsException(UNKNOWN_CODE, ex.getMessage()); } - - //TODO(mderka) Add translation and retry functionality. Created issue #593. } From 452e27495dfae67fb43adc96b020fc1bbaa10961 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Wed, 2 Mar 2016 15:52:06 +0100 Subject: [PATCH 104/203] Handle eventally consistent blob lists in storage ITs --- .../gcloud/storage/it/ITStorageTest.java | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index 8e954de57e68..1bdd14dd79f8 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -28,6 +28,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.gcloud.Page; import com.google.gcloud.ReadChannel; @@ -287,8 +288,8 @@ public void testGetBlobFailNonExistingGeneration() { assertTrue(remoteBlob.delete()); } - @Test - public void testListBlobsSelectedFields() { + @Test(timeout = 5000) + public void testListBlobsSelectedFields() throws InterruptedException { String[] blobNames = {"test-list-blobs-selected-fields-blob1", "test-list-blobs-selected-fields-blob2"}; ImmutableMap metadata = ImmutableMap.of("k", "v"); @@ -307,10 +308,18 @@ public void testListBlobsSelectedFields() { Page page = storage.list(BUCKET, Storage.BlobListOption.prefix("test-list-blobs-selected-fields-blob"), Storage.BlobListOption.fields(BlobField.METADATA)); - int index = 0; + // Listing blobs is eventually consistent, we loop until the list is of the expected size. The + // test fails if timeout is reached. + while (Iterators.size(page.values().iterator()) != 2) { + Thread.sleep(500); + page = storage.list(BUCKET, + Storage.BlobListOption.prefix("test-list-blobs-selected-fields-blob"), + Storage.BlobListOption.fields(BlobField.METADATA)); + } + Set blobSet = ImmutableSet.of(blobNames[0], blobNames[1]); for (Blob remoteBlob : page.values()) { assertEquals(BUCKET, remoteBlob.bucket()); - assertEquals(blobNames[index++], remoteBlob.name()); + assertTrue(blobSet.contains(remoteBlob.name())); assertEquals(metadata, remoteBlob.metadata()); assertNull(remoteBlob.contentType()); } @@ -318,8 +327,8 @@ public void testListBlobsSelectedFields() { assertTrue(remoteBlob2.delete()); } - @Test - public void testListBlobsEmptySelectedFields() { + @Test(timeout = 5000) + public void testListBlobsEmptySelectedFields() throws InterruptedException { String[] blobNames = {"test-list-blobs-empty-selected-fields-blob1", "test-list-blobs-empty-selected-fields-blob2"}; BlobInfo blob1 = BlobInfo.builder(BUCKET, blobNames[0]) @@ -335,17 +344,25 @@ public void testListBlobsEmptySelectedFields() { Page page = storage.list(BUCKET, Storage.BlobListOption.prefix("test-list-blobs-empty-selected-fields-blob"), Storage.BlobListOption.fields()); - int index = 0; + // Listing blobs is eventually consistent, we loop until the list is of the expected size. The + // test fails if timeout is reached. + while (Iterators.size(page.values().iterator()) != 2) { + Thread.sleep(500); + page = storage.list(BUCKET, + Storage.BlobListOption.prefix("test-list-blobs-empty-selected-fields-blob"), + Storage.BlobListOption.fields()); + } + Set blobSet = ImmutableSet.of(blobNames[0], blobNames[1]); for (Blob remoteBlob : page.values()) { assertEquals(BUCKET, remoteBlob.bucket()); - assertEquals(blobNames[index++], remoteBlob.name()); + assertTrue(blobSet.contains(remoteBlob.name())); assertNull(remoteBlob.contentType()); } assertTrue(remoteBlob1.delete()); assertTrue(remoteBlob2.delete()); } - @Test + @Test(timeout = 10000) public void testListBlobsVersioned() throws ExecutionException, InterruptedException { String bucketName = RemoteGcsHelper.generateBucketName(); Bucket bucket = storage.create(BucketInfo.builder(bucketName).versioningEnabled(true).build()); @@ -366,6 +383,14 @@ public void testListBlobsVersioned() throws ExecutionException, InterruptedExcep Page page = storage.list(bucketName, Storage.BlobListOption.prefix("test-list-blobs-versioned-blob"), Storage.BlobListOption.versions(true)); + // Listing blobs is eventually consistent, we loop until the list is of the expected size. The + // test fails if timeout is reached. + while (Iterators.size(page.values().iterator()) != 3) { + Thread.sleep(500); + page = storage.list(bucketName, + Storage.BlobListOption.prefix("test-list-blobs-versioned-blob"), + Storage.BlobListOption.versions(true)); + } Set blobSet = ImmutableSet.of(blobNames[0], blobNames[1]); for (Blob remoteBlob : page.values()) { assertEquals(bucketName, remoteBlob.bucket()); From 22153aa90264ef13758435b541ec6ee8f17cd620 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 1 Mar 2016 10:17:19 -0800 Subject: [PATCH 105/203] Added sleep and renamed change completion check. Moved integration test to a separate package and adjusted accordingly. Added missing fails. --- .../google/gcloud/dns/{ => it}/ITDnsTest.java | 125 +++++++++--------- 1 file changed, 64 insertions(+), 61 deletions(-) rename gcloud-java-dns/src/test/java/com/google/gcloud/dns/{ => it}/ITDnsTest.java (92%) diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java similarity index 92% rename from gcloud-java-dns/src/test/java/com/google/gcloud/dns/ITDnsTest.java rename to gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java index e473d1c4912c..ae721e742ae8 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ITDnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.dns; +package com.google.gcloud.dns.it; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -25,6 +25,14 @@ import com.google.common.collect.ImmutableList; import com.google.gcloud.Page; +import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.Dns; +import com.google.gcloud.dns.DnsException; +import com.google.gcloud.dns.DnsOptions; +import com.google.gcloud.dns.DnsRecord; +import com.google.gcloud.dns.ProjectInfo; +import com.google.gcloud.dns.Zone; +import com.google.gcloud.dns.ZoneInfo; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -62,24 +70,20 @@ public class ITDnsTest { .description(ZONE_DESCRIPTION1) .dnsName(ZONE_DNS_NAME1) .build(); - public static final ZoneInfo ZONE_NAME_ERROR = - ZoneInfo.builder(ZONE_NAME_TOO_LONG) - .description(ZONE_DESCRIPTION1) - .dnsName(ZONE_DNS_NAME1) - .build(); - public static final ZoneInfo ZONE_MISSING_DESCRIPTION = - ZoneInfo.builder(ZONE_NAME1) - .dnsName(ZONE_DNS_NAME1) - .build(); - public static final ZoneInfo ZONE_MISSING_DNS_NAME = - ZoneInfo.builder(ZONE_NAME1) - .description(ZONE_DESCRIPTION1) - .build(); - public static final ZoneInfo ZONE_DNS_NO_PERIOD = - ZoneInfo.builder(ZONE_NAME1) - .description(ZONE_DESCRIPTION1) - .dnsName(ZONE_DNS_NAME_NO_PERIOD) - .build(); + public static final ZoneInfo ZONE_NAME_ERROR = ZoneInfo.builder(ZONE_NAME_TOO_LONG) + .description(ZONE_DESCRIPTION1) + .dnsName(ZONE_DNS_NAME1) + .build(); + public static final ZoneInfo ZONE_MISSING_DESCRIPTION = ZoneInfo.builder(ZONE_NAME1) + .dnsName(ZONE_DNS_NAME1) + .build(); + public static final ZoneInfo ZONE_MISSING_DNS_NAME = ZoneInfo.builder(ZONE_NAME1) + .description(ZONE_DESCRIPTION1) + .build(); + public static final ZoneInfo ZONE_DNS_NO_PERIOD = ZoneInfo.builder(ZONE_NAME1) + .description(ZONE_DESCRIPTION1) + .dnsName(ZONE_DNS_NAME_NO_PERIOD) + .build(); public static final DnsRecord A_RECORD_ZONE1 = DnsRecord.builder("www." + ZONE1.dnsName(), DnsRecord.Type.A) .records(ImmutableList.of("123.123.55.1")) @@ -116,7 +120,7 @@ public static void clear() { if (!toDelete.isEmpty()) { ChangeRequest deletion = zone.applyChangeRequest(ChangeRequest.builder().deletions(toDelete).build()); - checkChangeComplete(zone.name(), deletion.id()); + waitUntilComplete(zone.name(), deletion.id()); } zone.delete(); } @@ -145,17 +149,23 @@ public static void after() { } private static void assertEqChangesIgnoreStatus(ChangeRequest expected, ChangeRequest actual) { - ChangeRequest unifiedEx = ChangeRequest.fromPb(expected.toPb().setStatus("pending")); - ChangeRequest unifiedAct = ChangeRequest.fromPb(actual.toPb().setStatus("pending")); - assertEquals(unifiedEx, unifiedAct); + assertEquals(expected.additions(), actual.additions()); + assertEquals(expected.deletions(), actual.deletions()); + assertEquals(expected.id(), actual.id()); + assertEquals(expected.startTimeMillis(), actual.startTimeMillis()); } - private static void checkChangeComplete(String zoneName, String changeId) { + private static void waitUntilComplete(String zoneName, String changeId) { while (true) { ChangeRequest changeRequest = DNS.getChangeRequest(zoneName, changeId, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); if (ChangeRequest.Status.DONE.equals(changeRequest.status())) { - break; + return; + } + try { + Thread.sleep(500); + } catch (InterruptedException e) { + fail("Thread was interrupted while waiting for change processing."); } } } @@ -404,6 +414,7 @@ public void testListZones() { // error in options try { DNS.listZones(Dns.ZoneListOption.pageSize(0)); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); @@ -411,6 +422,7 @@ public void testListZones() { } try { DNS.listZones(Dns.ZoneListOption.pageSize(-1)); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); @@ -422,6 +434,7 @@ public void testListZones() { // dns name problems try { DNS.listZones(Dns.ZoneListOption.dnsName("aaaaa")); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); @@ -529,7 +542,6 @@ public void testDeleteZone() { } } - @Test public void testCreateChange() { try { @@ -542,9 +554,9 @@ public void testCreateChange() { assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) .contains(created.status())); assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); - checkChangeComplete(ZONE1.name(), "1"); + waitUntilComplete(ZONE1.name(), "1"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "2"); + waitUntilComplete(ZONE1.name(), "2"); // with options created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); @@ -553,9 +565,9 @@ public void testCreateChange() { assertTrue(created.deletions().isEmpty()); assertEquals("3", created.id()); assertNull(created.status()); - checkChangeComplete(ZONE1.name(), "3"); + waitUntilComplete(ZONE1.name(), "3"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "4"); + waitUntilComplete(ZONE1.name(), "4"); created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); assertTrue(created.additions().isEmpty()); @@ -563,9 +575,9 @@ public void testCreateChange() { assertTrue(created.deletions().isEmpty()); assertEquals("5", created.id()); assertNotNull(created.status()); - checkChangeComplete(ZONE1.name(), "5"); + waitUntilComplete(ZONE1.name(), "5"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "6"); + waitUntilComplete(ZONE1.name(), "6"); created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); assertTrue(created.additions().isEmpty()); @@ -573,9 +585,9 @@ public void testCreateChange() { assertTrue(created.deletions().isEmpty()); assertEquals("7", created.id()); assertNull(created.status()); - checkChangeComplete(ZONE1.name(), "7"); + waitUntilComplete(ZONE1.name(), "7"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), "8"); + waitUntilComplete(ZONE1.name(), "8"); created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); @@ -584,16 +596,16 @@ public void testCreateChange() { assertEquals("9", created.id()); assertNull(created.status()); // finishes with delete otherwise we cannot delete the zone - checkChangeComplete(ZONE1.name(), "9"); + waitUntilComplete(ZONE1.name(), "9"); created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); - checkChangeComplete(ZONE1.name(), "10"); + waitUntilComplete(ZONE1.name(), "10"); assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); assertNull(created.startTimeMillis()); assertTrue(created.additions().isEmpty()); assertEquals("10", created.id()); assertNull(created.status()); - checkChangeComplete(ZONE1.name(), "10"); + waitUntilComplete(ZONE1.name(), "10"); } finally { clear(); } @@ -618,18 +630,19 @@ public void testListChanges() { assertEquals(1, changes.size()); // default change creating SOA and NS // zone has changes ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); + waitUntilComplete(ZONE1.name(), change.id()); change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); + waitUntilComplete(ZONE1.name(), change.id()); change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); + waitUntilComplete(ZONE1.name(), change.id()); change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); + waitUntilComplete(ZONE1.name(), change.id()); changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name()).iterateAll()); assertEquals(5, changes.size()); // error in options try { DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(0)); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); @@ -637,6 +650,7 @@ public void testListChanges() { } try { DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(-1)); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); @@ -754,27 +768,16 @@ public void testGetProject() { // fetches all fields ProjectInfo project = DNS.getProject(); assertNotNull(project.quota()); - assertNotNull(project.number()); - assertNotNull(project.id()); - assertEquals(PROJECT_ID, project.id()); // options project = DNS.getProject(Dns.ProjectOption.fields(Dns.ProjectField.QUOTA)); assertNotNull(project.quota()); - assertNull(project.number()); - assertNotNull(project.id()); // id is always returned project = DNS.getProject(Dns.ProjectOption.fields(Dns.ProjectField.PROJECT_ID)); assertNull(project.quota()); - assertNull(project.number()); - assertNotNull(project.id()); project = DNS.getProject(Dns.ProjectOption.fields(Dns.ProjectField.PROJECT_NUMBER)); assertNull(project.quota()); - assertNotNull(project.number()); - assertNotNull(project.id()); project = DNS.getProject(Dns.ProjectOption.fields(Dns.ProjectField.PROJECT_NUMBER, Dns.ProjectField.QUOTA, Dns.ProjectField.PROJECT_ID)); assertNotNull(project.quota()); - assertNotNull(project.number()); - assertNotNull(project.id()); } @Test @@ -846,7 +849,7 @@ public void testListDnsRecords() { assertEquals(1, ImmutableList.copyOf(dnsRecordPage.values().iterator()).size()); // test name filter ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - checkChangeComplete(ZONE1.name(), change.id()); + waitUntilComplete(ZONE1.name(), change.id()); dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name())).iterateAll(); counter = 0; @@ -858,7 +861,7 @@ public void testListDnsRecords() { } assertEquals(2, counter); // test type filter - checkChangeComplete(ZONE1.name(), change.id()); + waitUntilComplete(ZONE1.name(), change.id()); dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name()), Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())) @@ -874,30 +877,30 @@ public void testListDnsRecords() { // check wrong arguments try { // name is not set - DNS.listDnsRecords(ZONE1.name(), - Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())); + DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); // todo(mderka) test retry functionality when available } try { - DNS.listDnsRecords(ZONE1.name(), - Dns.DnsRecordListOption.pageSize(0)); + DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.pageSize(0)); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); // todo(mderka) test retry functionality when available } try { - DNS.listDnsRecords(ZONE1.name(), - Dns.DnsRecordListOption.pageSize(-1)); + DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.pageSize(-1)); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); // todo(mderka) test retry functionality when available } - checkChangeComplete(ZONE1.name(), change.id()); + waitUntilComplete(ZONE1.name(), change.id()); } finally { clear(); } From 4f2810143b17838a75c59bc5615ec44b86a58cab Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 1 Mar 2016 16:09:49 -0800 Subject: [PATCH 106/203] Added retries for userRateLimitExceeded and rateLimitExceeded. --- .../src/main/java/com/google/gcloud/dns/DnsException.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java index 70d7254e9502..1ecb98a3fdc6 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java @@ -31,9 +31,12 @@ public class DnsException extends BaseServiceException { // see: https://cloud.google.com/dns/troubleshooting private static final Set RETRYABLE_ERRORS = ImmutableSet.of( + new Error(429, null), new Error(500, null), new Error(502, null), - new Error(503, null)); + new Error(503, null), + new Error(null, "userRateLimitExceeded"), + new Error(null, "rateLimitExceeded")); private static final long serialVersionUID = 490302380416260252L; public DnsException(IOException exception) { From a3fdbbc697b5923848f6d3609b82232994a2433f Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Wed, 2 Mar 2016 21:41:08 +0100 Subject: [PATCH 107/203] Add BlobTargetOption and BlobWriteOption classes to Bucket --- .../com/google/gcloud/storage/Bucket.java | 301 +++++++++++++++++- .../com/google/gcloud/storage/BucketTest.java | 145 +++++++++ 2 files changed, 440 insertions(+), 6 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java index c438f497730e..db255e23db57 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java @@ -16,26 +16,30 @@ package com.google.gcloud.storage; +import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.gcloud.storage.Bucket.BucketSourceOption.toGetOptions; import static com.google.gcloud.storage.Bucket.BucketSourceOption.toSourceOptions; +import com.google.common.base.Function; import com.google.common.base.MoreObjects; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import com.google.gcloud.Page; import com.google.gcloud.spi.StorageRpc; import com.google.gcloud.storage.Storage.BlobGetOption; -import com.google.gcloud.storage.Storage.BlobTargetOption; -import com.google.gcloud.storage.Storage.BlobWriteOption; import com.google.gcloud.storage.Storage.BucketTargetOption; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; +import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.Set; /** * A Google cloud storage bucket. @@ -64,7 +68,7 @@ private BucketSourceOption(StorageRpc.Option rpcOption) { super(rpcOption, null); } - private Storage.BucketSourceOption toSourceOptions(BucketInfo bucketInfo) { + private Storage.BucketSourceOption toSourceOption(BucketInfo bucketInfo) { switch (rpcOption()) { case IF_METAGENERATION_MATCH: return Storage.BucketSourceOption.metagenerationMatch(bucketInfo.metageneration()); @@ -108,7 +112,7 @@ static Storage.BucketSourceOption[] toSourceOptions(BucketInfo bucketInfo, new Storage.BucketSourceOption[options.length]; int index = 0; for (BucketSourceOption option : options) { - convertedOptions[index++] = option.toSourceOptions(bucketInfo); + convertedOptions[index++] = option.toSourceOption(bucketInfo); } return convertedOptions; } @@ -124,6 +128,287 @@ static Storage.BucketGetOption[] toGetOptions(BucketInfo bucketInfo, } } + /** + * Class for specifying blob target options when {@code Bucket} methods are used. + */ + public static class BlobTargetOption extends Option { + + private static final Function TO_ENUM = + new Function() { + @Override + public StorageRpc.Option apply(BlobTargetOption blobTargetOption) { + return blobTargetOption.rpcOption(); + } + }; + private static final long serialVersionUID = 8345296337342509425L; + + private BlobTargetOption(StorageRpc.Option rpcOption, Object value) { + super(rpcOption, value); + } + + private StorageRpc.Tuple toTargetOption(BlobInfo blobInfo) { + BlobId blobId = blobInfo.blobId(); + switch (rpcOption()) { + case PREDEFINED_ACL: + return StorageRpc.Tuple.of(blobInfo, + Storage.BlobTargetOption.predefinedAcl((Storage.PredefinedAcl) value())); + case IF_GENERATION_MATCH: + blobId = BlobId.of(blobId.bucket(), blobId.name(), (Long) value()); + return StorageRpc.Tuple.of(blobInfo.toBuilder().blobId(blobId).build(), + Storage.BlobTargetOption.generationMatch()); + case IF_GENERATION_NOT_MATCH: + blobId = BlobId.of(blobId.bucket(), blobId.name(), (Long) value()); + return StorageRpc.Tuple.of(blobInfo.toBuilder().blobId(blobId).build(), + Storage.BlobTargetOption.generationNotMatch()); + case IF_METAGENERATION_MATCH: + return StorageRpc.Tuple.of(blobInfo.toBuilder().metageneration((Long) value()).build(), + Storage.BlobTargetOption.metagenerationMatch()); + case IF_METAGENERATION_NOT_MATCH: + return StorageRpc.Tuple.of(blobInfo.toBuilder().metageneration((Long) value()).build(), + Storage.BlobTargetOption.metagenerationNotMatch()); + default: + throw new AssertionError("Unexpected enum value"); + } + } + + /** + * Returns an option for specifying blob's predefined ACL configuration. + */ + public static BlobTargetOption predefinedAcl(Storage.PredefinedAcl acl) { + return new BlobTargetOption(StorageRpc.Option.PREDEFINED_ACL, acl); + } + + /** + * Returns an option that causes an operation to succeed only if the target blob does not exist. + * This option can not be provided together with {@link #generationMatch(long)} or + * {@link #generationNotMatch(long)}. + */ + public static BlobTargetOption doesNotExist() { + return new BlobTargetOption(StorageRpc.Option.IF_GENERATION_MATCH, 0L); + } + + /** + * Returns an option for blob's data generation match. If this option is used the request will + * fail if generation does not match the provided value. This option can not be provided + * together with {@link #generationNotMatch(long)} or {@link #doesNotExist()}. + */ + public static BlobTargetOption generationMatch(long generation) { + return new BlobTargetOption(StorageRpc.Option.IF_GENERATION_MATCH, generation); + } + + /** + * Returns an option for blob's data generation mismatch. If this option is used the request + * will fail if blob's generation matches the provided value. This option can not be provided + * together with {@link #generationMatch(long)} or {@link #doesNotExist()}. + */ + public static BlobTargetOption generationNotMatch(long generation) { + return new BlobTargetOption(StorageRpc.Option.IF_GENERATION_NOT_MATCH, generation); + } + + /** + * Returns an option for blob's metageneration match. If this option is used the request will + * fail if metageneration does not match the provided value. Either this option or + * {@link #metagenerationNotMatch(long)} can be provided at the same time. + */ + public static BlobTargetOption metagenerationMatch(long metageneration) { + return new BlobTargetOption(StorageRpc.Option.IF_METAGENERATION_MATCH, metageneration); + } + + /** + * Returns an option for blob's metageneration mismatch. If this option is used the request will + * fail if metageneration matches the provided value. Either this option or + * {@link #metagenerationMatch(long)} can be provided at the same time. + */ + public static BlobTargetOption metagenerationNotMatch(long metageneration) { + return new BlobTargetOption(StorageRpc.Option.IF_METAGENERATION_NOT_MATCH, metageneration); + } + + static StorageRpc.Tuple toTargetOptions( + BlobInfo info, BlobTargetOption... options) { + Set optionSet = + Sets.immutableEnumSet(Lists.transform(Arrays.asList(options), TO_ENUM)); + checkArgument(!(optionSet.contains(StorageRpc.Option.IF_METAGENERATION_NOT_MATCH) + && optionSet.contains(StorageRpc.Option.IF_METAGENERATION_MATCH)), + "metagenerationMatch and metagenerationNotMatch options can not be both provided"); + checkArgument(!(optionSet.contains(StorageRpc.Option.IF_GENERATION_NOT_MATCH) + && optionSet.contains(StorageRpc.Option.IF_GENERATION_MATCH)), + "Only one option of generationMatch, doesNotExist or generationNotMatch can be provided"); + Storage.BlobTargetOption[] convertedOptions = new Storage.BlobTargetOption[options.length]; + BlobInfo targetInfo = info; + int index = 0; + for (BlobTargetOption option : options) { + StorageRpc.Tuple target = + option.toTargetOption(targetInfo); + targetInfo = target.x(); + convertedOptions[index++] = target.y(); + } + return StorageRpc.Tuple.of(targetInfo, convertedOptions); + } + } + + /** + * Class for specifying blob write options when {@code Bucket} methods are used. + */ + public static class BlobWriteOption implements Serializable { + + private static final Function TO_ENUM = + new Function() { + @Override + public Storage.BlobWriteOption.Option apply(BlobWriteOption blobWriteOption) { + return blobWriteOption.option; + } + }; + private static final long serialVersionUID = 4722190734541993114L; + + private final Storage.BlobWriteOption.Option option; + private final Object value; + + private StorageRpc.Tuple toWriteOption(BlobInfo blobInfo) { + BlobId blobId = blobInfo.blobId(); + switch (option) { + case PREDEFINED_ACL: + return StorageRpc.Tuple.of(blobInfo, + Storage.BlobWriteOption.predefinedAcl((Storage.PredefinedAcl) value)); + case IF_GENERATION_MATCH: + blobId = BlobId.of(blobId.bucket(), blobId.name(), (Long) value); + return StorageRpc.Tuple.of(blobInfo.toBuilder().blobId(blobId).build(), + Storage.BlobWriteOption.generationMatch()); + case IF_GENERATION_NOT_MATCH: + blobId = BlobId.of(blobId.bucket(), blobId.name(), (Long) value); + return StorageRpc.Tuple.of(blobInfo.toBuilder().blobId(blobId).build(), + Storage.BlobWriteOption.generationNotMatch()); + case IF_METAGENERATION_MATCH: + return StorageRpc.Tuple.of(blobInfo.toBuilder().metageneration((Long) value).build(), + Storage.BlobWriteOption.metagenerationMatch()); + case IF_METAGENERATION_NOT_MATCH: + return StorageRpc.Tuple.of(blobInfo.toBuilder().metageneration((Long) value).build(), + Storage.BlobWriteOption.metagenerationNotMatch()); + case IF_MD5_MATCH: + return StorageRpc.Tuple.of(blobInfo.toBuilder().md5((String) value).build(), + Storage.BlobWriteOption.md5Match()); + case IF_CRC32C_MATCH: + return StorageRpc.Tuple.of(blobInfo.toBuilder().crc32c((String) value).build(), + Storage.BlobWriteOption.crc32cMatch()); + default: + throw new AssertionError("Unexpected enum value"); + } + } + + private BlobWriteOption(Storage.BlobWriteOption.Option option, Object value) { + this.option = option; + this.value = value; + } + + @Override + public int hashCode() { + return Objects.hash(option, value); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (!(obj instanceof BlobWriteOption)) { + return false; + } + final BlobWriteOption other = (BlobWriteOption) obj; + return this.option == other.option && Objects.equals(this.value, other.value); + } + + /** + * Returns an option for specifying blob's predefined ACL configuration. + */ + public static BlobWriteOption predefinedAcl(Storage.PredefinedAcl acl) { + return new BlobWriteOption(Storage.BlobWriteOption.Option.PREDEFINED_ACL, acl); + } + + /** + * Returns an option that causes an operation to succeed only if the target blob does not exist. + * This option can not be provided together with {@link #generationMatch(long)} or + * {@link #generationNotMatch(long)}. + */ + public static BlobWriteOption doesNotExist() { + return new BlobWriteOption(Storage.BlobWriteOption.Option.IF_GENERATION_MATCH, 0L); + } + + /** + * Returns an option for blob's data generation match. If this option is used the request will + * fail if generation does not match the provided value. This option can not be provided + * together with {@link #generationNotMatch(long)} or {@link #doesNotExist()}. + */ + public static BlobWriteOption generationMatch(long generation) { + return new BlobWriteOption(Storage.BlobWriteOption.Option.IF_GENERATION_MATCH, generation); + } + + /** + * Returns an option for blob's data generation mismatch. If this option is used the request + * will fail if generation matches the provided value. This option can not be provided + * together with {@link #generationMatch(long)} or {@link #doesNotExist()}. + */ + public static BlobWriteOption generationNotMatch(long generation) { + return new BlobWriteOption(Storage.BlobWriteOption.Option.IF_GENERATION_NOT_MATCH, + generation); + } + + /** + * Returns an option for blob's metageneration match. If this option is used the request will + * fail if metageneration does not match the provided value. Either this option or + * {@link #metagenerationNotMatch(long)} can be provided at the same time. + */ + public static BlobWriteOption metagenerationMatch(long metageneration) { + return new BlobWriteOption(Storage.BlobWriteOption.Option.IF_METAGENERATION_MATCH, + metageneration); + } + + /** + * Returns an option for blob's metageneration mismatch. If this option is used the request will + * fail if metageneration matches the provided value. Either this option or + * {@link #metagenerationMatch(long)} can be provided at the same time. + */ + public static BlobWriteOption metagenerationNotMatch(long metageneration) { + return new BlobWriteOption(Storage.BlobWriteOption.Option.IF_METAGENERATION_NOT_MATCH, + metageneration); + } + + /** + * Returns an option for blob's data MD5 hash match. If this option is used the request will + * fail if blobs' data MD5 hash does not match the provided value. + */ + public static BlobWriteOption md5Match(String md5) { + return new BlobWriteOption(Storage.BlobWriteOption.Option.IF_MD5_MATCH, md5); + } + + /** + * Returns an option for blob's data CRC32C checksum match. If this option is used the request + * will fail if blobs' data CRC32C checksum does not match the provided value. + */ + public static BlobWriteOption crc32cMatch(String crc32c) { + return new BlobWriteOption(Storage.BlobWriteOption.Option.IF_CRC32C_MATCH, crc32c); + } + + static StorageRpc.Tuple toWriteOptions( + BlobInfo info, BlobWriteOption... options) { + Set optionSet = + Sets.immutableEnumSet(Lists.transform(Arrays.asList(options), TO_ENUM)); + checkArgument(!(optionSet.contains(Storage.BlobWriteOption.Option.IF_METAGENERATION_NOT_MATCH) + && optionSet.contains(Storage.BlobWriteOption.Option.IF_METAGENERATION_MATCH)), + "metagenerationMatch and metagenerationNotMatch options can not be both provided"); + checkArgument(!(optionSet.contains(Storage.BlobWriteOption.Option.IF_GENERATION_NOT_MATCH) + && optionSet.contains(Storage.BlobWriteOption.Option.IF_GENERATION_MATCH)), + "Only one option of generationMatch, doesNotExist or generationNotMatch can be provided"); + Storage.BlobWriteOption[] convertedOptions = new Storage.BlobWriteOption[options.length]; + BlobInfo writeInfo = info; + int index = 0; + for (BlobWriteOption option : options) { + StorageRpc.Tuple write = option.toWriteOption(writeInfo); + writeInfo = write.x(); + convertedOptions[index++] = write.y(); + } + return StorageRpc.Tuple.of(writeInfo, convertedOptions); + } + } + /** * Builder for {@code Bucket}. */ @@ -357,7 +642,9 @@ public List get(String blobName1, String blobName2, String... blobNames) { public Blob create(String blob, byte[] content, String contentType, BlobTargetOption... options) { BlobInfo blobInfo = BlobInfo.builder(BlobId.of(name(), blob)) .contentType(MoreObjects.firstNonNull(contentType, Storage.DEFAULT_CONTENT_TYPE)).build(); - return storage.create(blobInfo, content, options); + StorageRpc.Tuple target = + BlobTargetOption.toTargetOptions(blobInfo, options); + return storage.create(target.x(), content, target.y()); } /** @@ -377,7 +664,9 @@ public Blob create(String blob, InputStream content, String contentType, BlobWriteOption... options) { BlobInfo blobInfo = BlobInfo.builder(BlobId.of(name(), blob)) .contentType(MoreObjects.firstNonNull(contentType, Storage.DEFAULT_CONTENT_TYPE)).build(); - return storage.create(blobInfo, content, options); + StorageRpc.Tuple write = + BlobWriteOption.toWriteOptions(blobInfo, options); + return storage.create(write.x(), content, write.y()); } /** diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java index aac8a79d3a47..236411e0c2d8 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java @@ -42,7 +42,9 @@ import org.easymock.Capture; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -99,6 +101,9 @@ public class BucketTest { private Bucket expectedBucket; private Iterable blobResults; + @Rule + public ExpectedException thrown = ExpectedException.none(); + @Before public void setUp() { storage = createStrictMock(Storage.class); @@ -301,6 +306,72 @@ public void testCreateNullContentType() throws Exception { assertEquals(expectedBlob, blob); } + @Test + public void testCreateWithOptions() throws Exception { + initializeExpectedBucket(5); + BlobInfo info = BlobInfo.builder(BlobId.of("b", "n", 42L)) + .contentType(CONTENT_TYPE) + .metageneration(24L) + .build(); + Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info)); + byte[] content = {0xD, 0xE, 0xA, 0xD}; + Storage.PredefinedAcl acl = Storage.PredefinedAcl.ALL_AUTHENTICATED_USERS; + expect(storage.options()).andReturn(mockOptions); + expect(storage.create(info, content, Storage.BlobTargetOption.generationMatch(), + Storage.BlobTargetOption.metagenerationMatch(), + Storage.BlobTargetOption.predefinedAcl(acl))).andReturn(expectedBlob); + replay(storage); + initializeBucket(); + Blob blob = bucket.create("n", content, CONTENT_TYPE, + Bucket.BlobTargetOption.generationMatch(42L), + Bucket.BlobTargetOption.metagenerationMatch(24L), + Bucket.BlobTargetOption.predefinedAcl(acl)); + assertEquals(expectedBlob, blob); + } + + @Test + public void testCreateNotExists() throws Exception { + initializeExpectedBucket(5); + BlobInfo info = BlobInfo.builder(BlobId.of("b", "n", 0L)).contentType(CONTENT_TYPE).build(); + Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info)); + byte[] content = {0xD, 0xE, 0xA, 0xD}; + expect(storage.options()).andReturn(mockOptions); + expect(storage.create(info, content, Storage.BlobTargetOption.generationMatch())) + .andReturn(expectedBlob); + replay(storage); + initializeBucket(); + Blob blob = bucket.create("n", content, CONTENT_TYPE, Bucket.BlobTargetOption.doesNotExist()); + assertEquals(expectedBlob, blob); + } + + @Test + public void testCreateWithWrongGenerationOptions() throws Exception { + initializeExpectedBucket(4); + expect(storage.options()).andReturn(mockOptions); + replay(storage); + initializeBucket(); + byte[] content = {0xD, 0xE, 0xA, 0xD}; + thrown.expect(IllegalArgumentException.class); + thrown.expectMessage( + "Only one option of generationMatch, doesNotExist or generationNotMatch can be provided"); + bucket.create("n", content, CONTENT_TYPE, Bucket.BlobTargetOption.generationMatch(42L), + Bucket.BlobTargetOption.generationNotMatch(24L)); + } + + @Test + public void testCreateWithWrongMetagenerationOptions() throws Exception { + initializeExpectedBucket(4); + expect(storage.options()).andReturn(mockOptions); + replay(storage); + initializeBucket(); + byte[] content = {0xD, 0xE, 0xA, 0xD}; + thrown.expect(IllegalArgumentException.class); + thrown.expectMessage( + "metagenerationMatch and metagenerationNotMatch options can not be both provided"); + bucket.create("n", content, CONTENT_TYPE, Bucket.BlobTargetOption.metagenerationMatch(42L), + Bucket.BlobTargetOption.metagenerationNotMatch(24L)); + } + @Test public void testCreateFromStream() throws Exception { initializeExpectedBucket(5); @@ -331,6 +402,80 @@ public void testCreateFromStreamNullContentType() throws Exception { assertEquals(expectedBlob, blob); } + @Test + public void testCreateFromStreamWithOptions() throws Exception { + initializeExpectedBucket(5); + BlobInfo info = BlobInfo.builder(BlobId.of("b", "n", 42L)) + .contentType(CONTENT_TYPE) + .metageneration(24L) + .crc32c("crc") + .md5("md5") + .build(); + Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info)); + byte[] content = {0xD, 0xE, 0xA, 0xD}; + Storage.PredefinedAcl acl = Storage.PredefinedAcl.ALL_AUTHENTICATED_USERS; + InputStream streamContent = new ByteArrayInputStream(content); + expect(storage.options()).andReturn(mockOptions); + expect(storage.create(info, streamContent, Storage.BlobWriteOption.generationMatch(), + Storage.BlobWriteOption.metagenerationMatch(), Storage.BlobWriteOption.predefinedAcl(acl), + Storage.BlobWriteOption.crc32cMatch(), Storage.BlobWriteOption.md5Match())) + .andReturn(expectedBlob); + replay(storage); + initializeBucket(); + Blob blob = bucket.create("n", streamContent, CONTENT_TYPE, + Bucket.BlobWriteOption.generationMatch(42L), + Bucket.BlobWriteOption.metagenerationMatch(24L), Bucket.BlobWriteOption.predefinedAcl(acl), + Bucket.BlobWriteOption.crc32cMatch("crc"), Bucket.BlobWriteOption.md5Match("md5")); + assertEquals(expectedBlob, blob); + } + + @Test + public void testCreateFromStreamNotExists() throws Exception { + initializeExpectedBucket(5); + BlobInfo info = BlobInfo.builder(BlobId.of("b", "n", 0L)).contentType(CONTENT_TYPE).build(); + Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info)); + byte[] content = {0xD, 0xE, 0xA, 0xD}; + InputStream streamContent = new ByteArrayInputStream(content); + expect(storage.options()).andReturn(mockOptions); + expect(storage.create(info, streamContent, Storage.BlobWriteOption.generationMatch())) + .andReturn(expectedBlob); + replay(storage); + initializeBucket(); + Blob blob = + bucket.create("n", streamContent, CONTENT_TYPE, Bucket.BlobWriteOption.doesNotExist()); + assertEquals(expectedBlob, blob); + } + + @Test + public void testCreateFromStreamWithWrongGenerationOptions() throws Exception { + initializeExpectedBucket(4); + expect(storage.options()).andReturn(mockOptions); + replay(storage); + initializeBucket(); + byte[] content = {0xD, 0xE, 0xA, 0xD}; + InputStream streamContent = new ByteArrayInputStream(content); + thrown.expect(IllegalArgumentException.class); + thrown.expectMessage( + "Only one option of generationMatch, doesNotExist or generationNotMatch can be provided"); + bucket.create("n", streamContent, CONTENT_TYPE, Bucket.BlobWriteOption.generationMatch(42L), + Bucket.BlobWriteOption.generationNotMatch(24L)); + } + + @Test + public void testCreateFromStreamWithWrongMetagenerationOptions() throws Exception { + initializeExpectedBucket(4); + expect(storage.options()).andReturn(mockOptions); + replay(storage); + initializeBucket(); + byte[] content = {0xD, 0xE, 0xA, 0xD}; + InputStream streamContent = new ByteArrayInputStream(content); + thrown.expect(IllegalArgumentException.class); + thrown.expectMessage( + "metagenerationMatch and metagenerationNotMatch options can not be both provided"); + bucket.create("n", streamContent, CONTENT_TYPE, Bucket.BlobWriteOption.metagenerationMatch(42L), + Bucket.BlobWriteOption.metagenerationNotMatch(24L)); + } + @Test public void testToBuilder() { expect(storage.options()).andReturn(mockOptions).times(4); From 36003385f3fb321a52af6533374fa7b3489b1ec7 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 3 Mar 2016 00:32:08 +0100 Subject: [PATCH 108/203] Reword javadoc in BlobTargetOption and BlobWriteOption --- .../java/com/google/gcloud/storage/Bucket.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java index db255e23db57..d318626f4207 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java @@ -207,8 +207,8 @@ public static BlobTargetOption generationNotMatch(long generation) { /** * Returns an option for blob's metageneration match. If this option is used the request will - * fail if metageneration does not match the provided value. Either this option or - * {@link #metagenerationNotMatch(long)} can be provided at the same time. + * fail if metageneration does not match the provided value. This option can not be provided + * together with {@link #metagenerationNotMatch(long)}. */ public static BlobTargetOption metagenerationMatch(long metageneration) { return new BlobTargetOption(StorageRpc.Option.IF_METAGENERATION_MATCH, metageneration); @@ -216,8 +216,8 @@ public static BlobTargetOption metagenerationMatch(long metageneration) { /** * Returns an option for blob's metageneration mismatch. If this option is used the request will - * fail if metageneration matches the provided value. Either this option or - * {@link #metagenerationMatch(long)} can be provided at the same time. + * fail if metageneration matches the provided value. This option can not be provided together + * with {@link #metagenerationMatch(long)}. */ public static BlobTargetOption metagenerationNotMatch(long metageneration) { return new BlobTargetOption(StorageRpc.Option.IF_METAGENERATION_NOT_MATCH, metageneration); @@ -353,8 +353,8 @@ public static BlobWriteOption generationNotMatch(long generation) { /** * Returns an option for blob's metageneration match. If this option is used the request will - * fail if metageneration does not match the provided value. Either this option or - * {@link #metagenerationNotMatch(long)} can be provided at the same time. + * fail if metageneration does not match the provided value. This option can not be provided + * together with {@link #metagenerationNotMatch(long)}. */ public static BlobWriteOption metagenerationMatch(long metageneration) { return new BlobWriteOption(Storage.BlobWriteOption.Option.IF_METAGENERATION_MATCH, @@ -363,8 +363,8 @@ public static BlobWriteOption metagenerationMatch(long metageneration) { /** * Returns an option for blob's metageneration mismatch. If this option is used the request will - * fail if metageneration matches the provided value. Either this option or - * {@link #metagenerationMatch(long)} can be provided at the same time. + * fail if metageneration matches the provided value. This option can not be provided together + * with {@link #metagenerationMatch(long)}. */ public static BlobWriteOption metagenerationNotMatch(long metageneration) { return new BlobWriteOption(Storage.BlobWriteOption.Option.IF_METAGENERATION_NOT_MATCH, From 5858809c9eee2c561f9496552328e6ab1b4bdb40 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 2 Mar 2016 17:32:17 -0800 Subject: [PATCH 109/203] pom.xml version edit --- gcloud-java-dns/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud-java-dns/pom.xml b/gcloud-java-dns/pom.xml index 5f04f261d500..1a559473cc82 100644 --- a/gcloud-java-dns/pom.xml +++ b/gcloud-java-dns/pom.xml @@ -13,7 +13,7 @@ com.google.gcloud gcloud-java-pom - 0.1.3-SNAPSHOT + 0.1.5-SNAPSHOT gcloud-java-dns From 622dcc9055f082b44ed32abfda9e585c7e76ce8e Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 3 Mar 2016 10:13:17 +0100 Subject: [PATCH 110/203] Replace values().iterator() with iterateAll() in blob list ITs --- .../gcloud/storage/it/ITStorageTest.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index 1bdd14dd79f8..38521ae5e137 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -101,13 +101,12 @@ public static void afterClass() throws ExecutionException, InterruptedException @Test(timeout = 5000) public void testListBuckets() throws InterruptedException { - Iterator bucketIterator = - storage.list(Storage.BucketListOption.prefix(BUCKET), - Storage.BucketListOption.fields()).values().iterator(); + Iterator bucketIterator = storage.list(Storage.BucketListOption.prefix(BUCKET), + Storage.BucketListOption.fields()).iterateAll(); while (!bucketIterator.hasNext()) { Thread.sleep(500); bucketIterator = storage.list(Storage.BucketListOption.prefix(BUCKET), - Storage.BucketListOption.fields()).values().iterator(); + Storage.BucketListOption.fields()).iterateAll(); } while (bucketIterator.hasNext()) { Bucket remoteBucket = bucketIterator.next(); @@ -310,14 +309,16 @@ public void testListBlobsSelectedFields() throws InterruptedException { Storage.BlobListOption.fields(BlobField.METADATA)); // Listing blobs is eventually consistent, we loop until the list is of the expected size. The // test fails if timeout is reached. - while (Iterators.size(page.values().iterator()) != 2) { + while (Iterators.size(page.iterateAll()) != 2) { Thread.sleep(500); page = storage.list(BUCKET, Storage.BlobListOption.prefix("test-list-blobs-selected-fields-blob"), Storage.BlobListOption.fields(BlobField.METADATA)); } Set blobSet = ImmutableSet.of(blobNames[0], blobNames[1]); - for (Blob remoteBlob : page.values()) { + Iterator iterator = page.iterateAll(); + while (iterator.hasNext()) { + Blob remoteBlob = iterator.next(); assertEquals(BUCKET, remoteBlob.bucket()); assertTrue(blobSet.contains(remoteBlob.name())); assertEquals(metadata, remoteBlob.metadata()); @@ -346,14 +347,16 @@ public void testListBlobsEmptySelectedFields() throws InterruptedException { Storage.BlobListOption.fields()); // Listing blobs is eventually consistent, we loop until the list is of the expected size. The // test fails if timeout is reached. - while (Iterators.size(page.values().iterator()) != 2) { + while (Iterators.size(page.iterateAll()) != 2) { Thread.sleep(500); page = storage.list(BUCKET, Storage.BlobListOption.prefix("test-list-blobs-empty-selected-fields-blob"), Storage.BlobListOption.fields()); } Set blobSet = ImmutableSet.of(blobNames[0], blobNames[1]); - for (Blob remoteBlob : page.values()) { + Iterator iterator = page.iterateAll(); + while (iterator.hasNext()) { + Blob remoteBlob = iterator.next(); assertEquals(BUCKET, remoteBlob.bucket()); assertTrue(blobSet.contains(remoteBlob.name())); assertNull(remoteBlob.contentType()); @@ -362,7 +365,7 @@ public void testListBlobsEmptySelectedFields() throws InterruptedException { assertTrue(remoteBlob2.delete()); } - @Test(timeout = 10000) + @Test(timeout = 15000) public void testListBlobsVersioned() throws ExecutionException, InterruptedException { String bucketName = RemoteGcsHelper.generateBucketName(); Bucket bucket = storage.create(BucketInfo.builder(bucketName).versioningEnabled(true).build()); @@ -385,14 +388,16 @@ public void testListBlobsVersioned() throws ExecutionException, InterruptedExcep Storage.BlobListOption.versions(true)); // Listing blobs is eventually consistent, we loop until the list is of the expected size. The // test fails if timeout is reached. - while (Iterators.size(page.values().iterator()) != 3) { + while (Iterators.size(page.iterateAll()) != 3) { Thread.sleep(500); page = storage.list(bucketName, Storage.BlobListOption.prefix("test-list-blobs-versioned-blob"), Storage.BlobListOption.versions(true)); } Set blobSet = ImmutableSet.of(blobNames[0], blobNames[1]); - for (Blob remoteBlob : page.values()) { + Iterator iterator = page.iterateAll(); + while (iterator.hasNext()) { + Blob remoteBlob = iterator.next(); assertEquals(bucketName, remoteBlob.bucket()); assertTrue(blobSet.contains(remoteBlob.name())); assertNotNull(remoteBlob.generation()); From 86845061f481d0125ba18ce044cd242e396f40af Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 3 Mar 2016 09:48:50 -0800 Subject: [PATCH 111/203] Added missing waits for change completion. --- .../test/java/com/google/gcloud/dns/it/ITDnsTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java index ae721e742ae8..fd257c681225 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java @@ -52,11 +52,10 @@ public class ITDnsTest { public static final String PREFIX = "gcldjvit-"; public static final Dns DNS = DnsOptions.builder().build().service(); - public static final String PROJECT_ID = DNS.options().projectId(); public static final String ZONE_NAME1 = (PREFIX + UUID.randomUUID()).substring(0, 32); public static final String ZONE_NAME_EMPTY_DESCRIPTION = - ("gcldjvit-" + UUID.randomUUID()).substring(0, 32); - public static final String ZONE_NAME_TOO_LONG = (PREFIX + UUID.randomUUID()); + (PREFIX + UUID.randomUUID()).substring(0, 32); + public static final String ZONE_NAME_TOO_LONG = PREFIX + UUID.randomUUID(); public static final String ZONE_DESCRIPTION1 = "first zone"; public static final String ZONE_DNS_NAME1 = ZONE_NAME1 + ".com."; public static final String ZONE_DNS_EMPTY_DESCRIPTION = ZONE_NAME_EMPTY_DESCRIPTION + ".com."; @@ -727,6 +726,7 @@ public void testGetChange() { ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); ChangeRequest retrieved = DNS.getChangeRequest(zone.name(), created.id()); assertEqChangesIgnoreStatus(created, retrieved); + waitUntilComplete(zone.name(), created.id()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); // with options created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, @@ -734,30 +734,35 @@ public void testGetChange() { retrieved = DNS.getChangeRequest(zone.name(), created.id(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); assertEqChangesIgnoreStatus(created, retrieved); + waitUntilComplete(zone.name(), created.id()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); retrieved = DNS.getChangeRequest(zone.name(), created.id(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); assertEqChangesIgnoreStatus(created, retrieved); + waitUntilComplete(zone.name(), created.id()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); retrieved = DNS.getChangeRequest(zone.name(), created.id(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); assertEqChangesIgnoreStatus(created, retrieved); + waitUntilComplete(zone.name(), created.id()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); retrieved = DNS.getChangeRequest(zone.name(), created.id(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); assertEqChangesIgnoreStatus(created, retrieved); + waitUntilComplete(zone.name(), created.id()); // finishes with delete otherwise we cannot delete the zone created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); retrieved = DNS.getChangeRequest(zone.name(), created.id(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); assertEqChangesIgnoreStatus(created, retrieved); + waitUntilComplete(zone.name(), created.id()); } finally { clear(); } From 8dd8786a5e9a38c7738889a2a6bca23848d3a3ee Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 4 Mar 2016 15:32:20 +0100 Subject: [PATCH 112/203] Remove redundant throws from services method signatures --- .../com/google/gcloud/bigquery/BigQuery.java | 53 ++++---- .../google/gcloud/bigquery/BigQueryImpl.java | 59 ++++----- .../com/google/gcloud/spi/BigQueryRpc.java | 87 +++++++++--- .../google/gcloud/spi/DefaultBigQueryRpc.java | 45 +++---- .../com/google/gcloud/spi/DatastoreRpc.java | 40 +++++- .../gcloud/spi/DefaultDatastoreRpc.java | 14 +- .../resourcemanager/ResourceManager.java | 2 +- .../gcloud/spi/DefaultResourceManagerRpc.java | 13 +- .../google/gcloud/spi/ResourceManagerRpc.java | 56 ++++++-- .../google/gcloud/spi/DefaultStorageRpc.java | 24 ++-- .../com/google/gcloud/spi/StorageRpc.java | 125 ++++++++++++++---- .../com/google/gcloud/storage/Storage.java | 44 +++--- 12 files changed, 364 insertions(+), 198 deletions(-) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java index 4b5d3ef0c81a..986c595e350d 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java @@ -457,35 +457,35 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) { * * @throws BigQueryException upon failure */ - Dataset create(DatasetInfo dataset, DatasetOption... options) throws BigQueryException; + Dataset create(DatasetInfo dataset, DatasetOption... options); /** * Creates a new table. * * @throws BigQueryException upon failure */ - Table create(TableInfo table, TableOption... options) throws BigQueryException; + Table create(TableInfo table, TableOption... options); /** * Creates a new job. * * @throws BigQueryException upon failure */ - Job create(JobInfo job, JobOption... options) throws BigQueryException; + Job create(JobInfo job, JobOption... options); /** * Returns the requested dataset or {@code null} if not found. * * @throws BigQueryException upon failure */ - Dataset getDataset(String datasetId, DatasetOption... options) throws BigQueryException; + Dataset getDataset(String datasetId, DatasetOption... options); /** * Returns the requested dataset or {@code null} if not found. * * @throws BigQueryException upon failure */ - Dataset getDataset(DatasetId datasetId, DatasetOption... options) throws BigQueryException; + Dataset getDataset(DatasetId datasetId, DatasetOption... options); /** * Lists the project's datasets. This method returns partial information on each dataset @@ -495,7 +495,7 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) { * * @throws BigQueryException upon failure */ - Page listDatasets(DatasetListOption... options) throws BigQueryException; + Page listDatasets(DatasetListOption... options); /** * Deletes the requested dataset. @@ -503,7 +503,7 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) { * @return {@code true} if dataset was deleted, {@code false} if it was not found * @throws BigQueryException upon failure */ - boolean delete(String datasetId, DatasetDeleteOption... options) throws BigQueryException; + boolean delete(String datasetId, DatasetDeleteOption... options); /** * Deletes the requested dataset. @@ -511,7 +511,7 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) { * @return {@code true} if dataset was deleted, {@code false} if it was not found * @throws BigQueryException upon failure */ - boolean delete(DatasetId datasetId, DatasetDeleteOption... options) throws BigQueryException; + boolean delete(DatasetId datasetId, DatasetDeleteOption... options); /** * Deletes the requested table. @@ -519,7 +519,7 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) { * @return {@code true} if table was deleted, {@code false} if it was not found * @throws BigQueryException upon failure */ - boolean delete(String datasetId, String tableId) throws BigQueryException; + boolean delete(String datasetId, String tableId); /** * Deletes the requested table. @@ -527,35 +527,35 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) { * @return {@code true} if table was deleted, {@code false} if it was not found * @throws BigQueryException upon failure */ - boolean delete(TableId tableId) throws BigQueryException; + boolean delete(TableId tableId); /** * Updates dataset information. * * @throws BigQueryException upon failure */ - Dataset update(DatasetInfo dataset, DatasetOption... options) throws BigQueryException; + Dataset update(DatasetInfo dataset, DatasetOption... options); /** * Updates table information. * * @throws BigQueryException upon failure */ - Table update(TableInfo table, TableOption... options) throws BigQueryException; + Table update(TableInfo table, TableOption... options); /** * Returns the requested table or {@code null} if not found. * * @throws BigQueryException upon failure */ - Table getTable(String datasetId, String tableId, TableOption... options) throws BigQueryException; + Table getTable(String datasetId, String tableId, TableOption... options); /** * Returns the requested table or {@code null} if not found. * * @throws BigQueryException upon failure */ - Table getTable(TableId tableId, TableOption... options) throws BigQueryException; + Table getTable(TableId tableId, TableOption... options); /** * Lists the tables in the dataset. This method returns partial information on each table @@ -566,7 +566,7 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) { * * @throws BigQueryException upon failure */ - Page listTables(String datasetId, TableListOption... options) throws BigQueryException; + Page
    listTables(String datasetId, TableListOption... options); /** * Lists the tables in the dataset. This method returns partial information on each table @@ -577,14 +577,14 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) { * * @throws BigQueryException upon failure */ - Page
    listTables(DatasetId datasetId, TableListOption... options) throws BigQueryException; + Page
    listTables(DatasetId datasetId, TableListOption... options); /** * Sends an insert all request. * * @throws BigQueryException upon failure */ - InsertAllResponse insertAll(InsertAllRequest request) throws BigQueryException; + InsertAllResponse insertAll(InsertAllRequest request); /** * Lists the table's rows. @@ -592,36 +592,35 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) { * @throws BigQueryException upon failure */ Page> listTableData(String datasetId, String tableId, - TableDataListOption... options) throws BigQueryException; + TableDataListOption... options); /** * Lists the table's rows. * * @throws BigQueryException upon failure */ - Page> listTableData(TableId tableId, TableDataListOption... options) - throws BigQueryException; + Page> listTableData(TableId tableId, TableDataListOption... options); /** * Returns the requested job or {@code null} if not found. * * @throws BigQueryException upon failure */ - Job getJob(String jobId, JobOption... options) throws BigQueryException; + Job getJob(String jobId, JobOption... options); /** * Returns the requested job or {@code null} if not found. * * @throws BigQueryException upon failure */ - Job getJob(JobId jobId, JobOption... options) throws BigQueryException; + Job getJob(JobId jobId, JobOption... options); /** * Lists the jobs. * * @throws BigQueryException upon failure */ - Page listJobs(JobListOption... options) throws BigQueryException; + Page listJobs(JobListOption... options); /** * Sends a job cancel request. This call will return immediately. The job status can then be @@ -632,7 +631,7 @@ Page> listTableData(TableId tableId, TableDataListOption... opt * found * @throws BigQueryException upon failure */ - boolean cancel(String jobId) throws BigQueryException; + boolean cancel(String jobId); /** * Sends a job cancel request. This call will return immediately. The job status can then be @@ -643,21 +642,21 @@ Page> listTableData(TableId tableId, TableDataListOption... opt * found * @throws BigQueryException upon failure */ - boolean cancel(JobId tableId) throws BigQueryException; + boolean cancel(JobId tableId); /** * Runs the query associated with the request. * * @throws BigQueryException upon failure */ - QueryResponse query(QueryRequest request) throws BigQueryException; + QueryResponse query(QueryRequest request); /** * Returns results of the query associated with the provided job. * * @throws BigQueryException upon failure */ - QueryResponse getQueryResults(JobId job, QueryResultsOption... options) throws BigQueryException; + QueryResponse getQueryResults(JobId job, QueryResultsOption... options); /** * Returns a channel to write data to be inserted into a BigQuery table. Data format and other diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java index 1158dd86c83d..ce881c6ea079 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java @@ -153,7 +153,7 @@ public QueryResult nextPage() { } @Override - public Dataset create(DatasetInfo dataset, DatasetOption... options) throws BigQueryException { + public Dataset create(DatasetInfo dataset, DatasetOption... options) { final com.google.api.services.bigquery.model.Dataset datasetPb = dataset.setProjectId(options().projectId()).toPb(); final Map optionsMap = optionMap(options); @@ -171,7 +171,7 @@ public com.google.api.services.bigquery.model.Dataset call() { } @Override - public Table create(TableInfo table, TableOption... options) throws BigQueryException { + public Table create(TableInfo table, TableOption... options) { final com.google.api.services.bigquery.model.Table tablePb = table.setProjectId(options().projectId()).toPb(); final Map optionsMap = optionMap(options); @@ -189,7 +189,7 @@ public com.google.api.services.bigquery.model.Table call() { } @Override - public Job create(JobInfo job, JobOption... options) throws BigQueryException { + public Job create(JobInfo job, JobOption... options) { final com.google.api.services.bigquery.model.Job jobPb = job.setProjectId(options().projectId()).toPb(); final Map optionsMap = optionMap(options); @@ -207,13 +207,12 @@ public com.google.api.services.bigquery.model.Job call() { } @Override - public Dataset getDataset(String datasetId, DatasetOption... options) throws BigQueryException { + public Dataset getDataset(String datasetId, DatasetOption... options) { return getDataset(DatasetId.of(datasetId), options); } @Override - public Dataset getDataset(final DatasetId datasetId, DatasetOption... options) - throws BigQueryException { + public Dataset getDataset(final DatasetId datasetId, DatasetOption... options) { final Map optionsMap = optionMap(options); try { com.google.api.services.bigquery.model.Dataset answer = @@ -230,7 +229,7 @@ public com.google.api.services.bigquery.model.Dataset call() { } @Override - public Page listDatasets(DatasetListOption... options) throws BigQueryException { + public Page listDatasets(DatasetListOption... options) { return listDatasets(options(), optionMap(options)); } @@ -261,13 +260,12 @@ public Dataset apply(com.google.api.services.bigquery.model.Dataset dataset) { } @Override - public boolean delete(String datasetId, DatasetDeleteOption... options) throws BigQueryException { + public boolean delete(String datasetId, DatasetDeleteOption... options) { return delete(DatasetId.of(datasetId), options); } @Override - public boolean delete(final DatasetId datasetId, DatasetDeleteOption... options) - throws BigQueryException { + public boolean delete(final DatasetId datasetId, DatasetDeleteOption... options) { final Map optionsMap = optionMap(options); try { return runWithRetries(new Callable() { @@ -282,12 +280,12 @@ public Boolean call() { } @Override - public boolean delete(String datasetId, String tableId) throws BigQueryException { + public boolean delete(String datasetId, String tableId) { return delete(TableId.of(datasetId, tableId)); } @Override - public boolean delete(final TableId tableId) throws BigQueryException { + public boolean delete(final TableId tableId) { try { return runWithRetries(new Callable() { @Override @@ -301,7 +299,7 @@ public Boolean call() { } @Override - public Dataset update(DatasetInfo dataset, DatasetOption... options) throws BigQueryException { + public Dataset update(DatasetInfo dataset, DatasetOption... options) { final com.google.api.services.bigquery.model.Dataset datasetPb = dataset.setProjectId(options().projectId()).toPb(); final Map optionsMap = optionMap(options); @@ -319,7 +317,7 @@ public com.google.api.services.bigquery.model.Dataset call() { } @Override - public Table update(TableInfo table, TableOption... options) throws BigQueryException { + public Table update(TableInfo table, TableOption... options) { final com.google.api.services.bigquery.model.Table tablePb = table.setProjectId(options().projectId()).toPb(); final Map optionsMap = optionMap(options); @@ -337,13 +335,12 @@ public com.google.api.services.bigquery.model.Table call() { } @Override - public Table getTable(final String datasetId, final String tableId, TableOption... options) - throws BigQueryException { + public Table getTable(final String datasetId, final String tableId, TableOption... options) { return getTable(TableId.of(datasetId, tableId), options); } @Override - public Table getTable(final TableId tableId, TableOption... options) throws BigQueryException { + public Table getTable(final TableId tableId, TableOption... options) { final Map optionsMap = optionMap(options); try { com.google.api.services.bigquery.model.Table answer = @@ -360,14 +357,12 @@ public com.google.api.services.bigquery.model.Table call() { } @Override - public Page
    listTables(String datasetId, TableListOption... options) - throws BigQueryException { + public Page
    listTables(String datasetId, TableListOption... options) { return listTables(datasetId, options(), optionMap(options)); } @Override - public Page
    listTables(DatasetId datasetId, TableListOption... options) - throws BigQueryException { + public Page
    listTables(DatasetId datasetId, TableListOption... options) { return listTables(datasetId.dataset(), options(), optionMap(options)); } @@ -399,7 +394,7 @@ public Table apply(com.google.api.services.bigquery.model.Table table) { } @Override - public InsertAllResponse insertAll(InsertAllRequest request) throws BigQueryException { + public InsertAllResponse insertAll(InsertAllRequest request) { final TableId tableId = request.table(); final TableDataInsertAllRequest requestPb = new TableDataInsertAllRequest(); requestPb.setIgnoreUnknownValues(request.ignoreUnknownValues()); @@ -418,13 +413,12 @@ public Rows apply(RowToInsert rowToInsert) { @Override public Page> listTableData(String datasetId, String tableId, - TableDataListOption... options) throws BigQueryException { + TableDataListOption... options) { return listTableData(TableId.of(datasetId, tableId), options(), optionMap(options)); } @Override - public Page> listTableData(TableId tableId, TableDataListOption... options) - throws BigQueryException { + public Page> listTableData(TableId tableId, TableDataListOption... options) { return listTableData(tableId, options(), optionMap(options)); } @@ -459,12 +453,12 @@ public List apply(TableRow rowPb) { } @Override - public Job getJob(String jobId, JobOption... options) throws BigQueryException { + public Job getJob(String jobId, JobOption... options) { return getJob(JobId.of(jobId), options); } @Override - public Job getJob(final JobId jobId, JobOption... options) throws BigQueryException { + public Job getJob(final JobId jobId, JobOption... options) { final Map optionsMap = optionMap(options); try { com.google.api.services.bigquery.model.Job answer = @@ -481,7 +475,7 @@ public com.google.api.services.bigquery.model.Job call() { } @Override - public Page listJobs(JobListOption... options) throws BigQueryException { + public Page listJobs(JobListOption... options) { return listJobs(options(), optionMap(options)); } @@ -508,12 +502,12 @@ public Job apply(com.google.api.services.bigquery.model.Job job) { } @Override - public boolean cancel(String jobId) throws BigQueryException { + public boolean cancel(String jobId) { return cancel(JobId.of(jobId)); } @Override - public boolean cancel(final JobId jobId) throws BigQueryException { + public boolean cancel(final JobId jobId) { try { return runWithRetries(new Callable() { @Override @@ -527,7 +521,7 @@ public Boolean call() { } @Override - public QueryResponse query(final QueryRequest request) throws BigQueryException { + public QueryResponse query(final QueryRequest request) { try { com.google.api.services.bigquery.model.QueryResponse results = runWithRetries(new Callable() { @@ -566,8 +560,7 @@ public com.google.api.services.bigquery.model.QueryResponse call() { } @Override - public QueryResponse getQueryResults(JobId job, QueryResultsOption... options) - throws BigQueryException { + public QueryResponse getQueryResults(JobId job, QueryResultsOption... options) { Map optionsMap = optionMap(options); return getQueryResults(job, options(), optionsMap); } diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/BigQueryRpc.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/BigQueryRpc.java index 6062e19950e0..a1935e5ab136 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/BigQueryRpc.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/BigQueryRpc.java @@ -100,7 +100,7 @@ public Y y() { * * @throws BigQueryException upon failure */ - Dataset getDataset(String datasetId, Map options) throws BigQueryException; + Dataset getDataset(String datasetId, Map options); /** * Lists the project's datasets. Partial information is returned on a dataset (datasetReference, @@ -108,13 +108,28 @@ public Y y() { * * @throws BigQueryException upon failure */ - Tuple> listDatasets(Map options) throws BigQueryException; + Tuple> listDatasets(Map options); - Dataset create(Dataset dataset, Map options) throws BigQueryException; + /** + * Creates a new dataset. + * + * @throws BigQueryException upon failure + */ + Dataset create(Dataset dataset, Map options); - Table create(Table table, Map options) throws BigQueryException; + /** + * Creates a new table. + * + * @throws BigQueryException upon failure + */ + Table create(Table table, Map options); - Job create(Job job, Map options) throws BigQueryException; + /** + * Creates a new job. + * + * @throws BigQueryException upon failure + */ + Job create(Job job, Map options); /** * Delete the requested dataset. @@ -122,18 +137,28 @@ public Y y() { * @return {@code true} if dataset was deleted, {@code false} if it was not found * @throws BigQueryException upon failure */ - boolean deleteDataset(String datasetId, Map options) throws BigQueryException; + boolean deleteDataset(String datasetId, Map options); - Dataset patch(Dataset dataset, Map options) throws BigQueryException; + /** + * Updates dataset information. + * + * @throws BigQueryException upon failure + */ + Dataset patch(Dataset dataset, Map options); - Table patch(Table table, Map options) throws BigQueryException; + /** + * Updates table information. + * + * @throws BigQueryException upon failure + */ + Table patch(Table table, Map options); /** * Returns the requested table or {@code null} if not found. * * @throws BigQueryException upon failure */ - Table getTable(String datasetId, String tableId, Map options) throws BigQueryException; + Table getTable(String datasetId, String tableId, Map options); /** * Lists the dataset's tables. Partial information is returned on a table (tableReference, @@ -141,8 +166,7 @@ public Y y() { * * @throws BigQueryException upon failure */ - Tuple> listTables(String dataset, Map options) - throws BigQueryException; + Tuple> listTables(String dataset, Map options); /** * Delete the requested table. @@ -150,27 +174,37 @@ Tuple> listTables(String dataset, Map options * @return {@code true} if table was deleted, {@code false} if it was not found * @throws BigQueryException upon failure */ - boolean deleteTable(String datasetId, String tableId) throws BigQueryException; + boolean deleteTable(String datasetId, String tableId); + /** + * Sends an insert all request. + * + * @throws BigQueryException upon failure + */ TableDataInsertAllResponse insertAll(String datasetId, String tableId, - TableDataInsertAllRequest request) throws BigQueryException; + TableDataInsertAllRequest request); + /** + * Lists the table's rows. + * + * @throws BigQueryException upon failure + */ Tuple> listTableData(String datasetId, String tableId, - Map options) throws BigQueryException; + Map options); /** * Returns the requested job or {@code null} if not found. * * @throws BigQueryException upon failure */ - Job getJob(String jobId, Map options) throws BigQueryException; + Job getJob(String jobId, Map options); /** * Lists the project's jobs. * * @throws BigQueryException upon failure */ - Tuple> listJobs(Map options) throws BigQueryException; + Tuple> listJobs(Map options); /** * Sends a job cancel request. This call will return immediately, and the client will need to poll @@ -180,12 +214,21 @@ Tuple> listTableData(String datasetId, String tableId * found * @throws BigQueryException upon failure */ - boolean cancel(String jobId) throws BigQueryException; + boolean cancel(String jobId); - GetQueryResultsResponse getQueryResults(String jobId, Map options) - throws BigQueryException; + /** + * Returns results of the query associated with the provided job. + * + * @throws BigQueryException upon failure + */ + GetQueryResultsResponse getQueryResults(String jobId, Map options); - QueryResponse query(QueryRequest request) throws BigQueryException; + /** + * Runs the query associated with the request. + * + * @throws BigQueryException upon failure + */ + QueryResponse query(QueryRequest request); /** * Opens a resumable upload session to load data into a BigQuery table and returns an upload URI. @@ -193,7 +236,7 @@ GetQueryResultsResponse getQueryResults(String jobId, Map options) * @param configuration load configuration * @throws BigQueryException upon failure */ - String open(JobConfiguration configuration) throws BigQueryException; + String open(JobConfiguration configuration); /** * Uploads the provided data to the resumable upload session at the specified position. @@ -207,5 +250,5 @@ GetQueryResultsResponse getQueryResults(String jobId, Map options) * @throws BigQueryException upon failure */ void write(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length, - boolean last) throws BigQueryException; + boolean last); } diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java index b57f1dc8a128..a5c44129955a 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java @@ -90,7 +90,7 @@ private static BigQueryException translate(IOException exception) { } @Override - public Dataset getDataset(String datasetId, Map options) throws BigQueryException { + public Dataset getDataset(String datasetId, Map options) { try { return bigquery.datasets() .get(this.options.projectId(), datasetId) @@ -106,8 +106,7 @@ public Dataset getDataset(String datasetId, Map options) throws BigQu } @Override - public Tuple> listDatasets(Map options) - throws BigQueryException { + public Tuple> listDatasets(Map options) { try { DatasetList datasetsList = bigquery.datasets() .list(this.options.projectId()) @@ -135,7 +134,7 @@ public Dataset apply(DatasetList.Datasets datasetPb) { } @Override - public Dataset create(Dataset dataset, Map options) throws BigQueryException { + public Dataset create(Dataset dataset, Map options) { try { return bigquery.datasets().insert(this.options.projectId(), dataset) .setFields(FIELDS.getString(options)) @@ -146,8 +145,7 @@ public Dataset create(Dataset dataset, Map options) throws BigQueryEx } @Override - public Table create(Table table, Map options) - throws BigQueryException { + public Table create(Table table, Map options) { try { // unset the type, as it is output only table.setType(null); @@ -161,7 +159,7 @@ public Table create(Table table, Map options) } @Override - public Job create(Job job, Map options) throws BigQueryException { + public Job create(Job job, Map options) { try { return bigquery.jobs() .insert(this.options.projectId(), job) @@ -173,7 +171,7 @@ public Job create(Job job, Map options) throws BigQueryException { } @Override - public boolean deleteDataset(String datasetId, Map options) throws BigQueryException { + public boolean deleteDataset(String datasetId, Map options) { try { bigquery.datasets().delete(this.options.projectId(), datasetId) .setDeleteContents(DELETE_CONTENTS.getBoolean(options)) @@ -189,7 +187,7 @@ public boolean deleteDataset(String datasetId, Map options) throws Bi } @Override - public Dataset patch(Dataset dataset, Map options) throws BigQueryException { + public Dataset patch(Dataset dataset, Map options) { try { DatasetReference reference = dataset.getDatasetReference(); return bigquery.datasets() @@ -202,7 +200,7 @@ public Dataset patch(Dataset dataset, Map options) throws BigQueryExc } @Override - public Table patch(Table table, Map options) throws BigQueryException { + public Table patch(Table table, Map options) { try { // unset the type, as it is output only table.setType(null); @@ -217,8 +215,7 @@ public Table patch(Table table, Map options) throws BigQueryException } @Override - public Table getTable(String datasetId, String tableId, Map options) - throws BigQueryException { + public Table getTable(String datasetId, String tableId, Map options) { try { return bigquery.tables() .get(this.options.projectId(), datasetId, tableId) @@ -234,8 +231,7 @@ public Table getTable(String datasetId, String tableId, Map options) } @Override - public Tuple> listTables(String datasetId, Map options) - throws BigQueryException { + public Tuple> listTables(String datasetId, Map options) { try { TableList tableList = bigquery.tables() .list(this.options.projectId(), datasetId) @@ -262,7 +258,7 @@ public Table apply(TableList.Tables tablePb) { } @Override - public boolean deleteTable(String datasetId, String tableId) throws BigQueryException { + public boolean deleteTable(String datasetId, String tableId) { try { bigquery.tables().delete(this.options.projectId(), datasetId, tableId).execute(); return true; @@ -277,7 +273,7 @@ public boolean deleteTable(String datasetId, String tableId) throws BigQueryExce @Override public TableDataInsertAllResponse insertAll(String datasetId, String tableId, - TableDataInsertAllRequest request) throws BigQueryException { + TableDataInsertAllRequest request) { try { return bigquery.tabledata() .insertAll(this.options.projectId(), datasetId, tableId, request) @@ -289,7 +285,7 @@ public TableDataInsertAllResponse insertAll(String datasetId, String tableId, @Override public Tuple> listTableData(String datasetId, String tableId, - Map options) throws BigQueryException { + Map options) { try { TableDataList tableDataList = bigquery.tabledata() .list(this.options.projectId(), datasetId, tableId) @@ -306,7 +302,7 @@ public Tuple> listTableData(String datasetId, String } @Override - public Job getJob(String jobId, Map options) throws BigQueryException { + public Job getJob(String jobId, Map options) { try { return bigquery.jobs() .get(this.options.projectId(), jobId) @@ -322,7 +318,7 @@ public Job getJob(String jobId, Map options) throws BigQueryException } @Override - public Tuple> listJobs(Map options) throws BigQueryException { + public Tuple> listJobs(Map options) { try { JobList jobsList = bigquery.jobs() .list(this.options.projectId()) @@ -363,7 +359,7 @@ public Job apply(JobList.Jobs jobPb) { } @Override - public boolean cancel(String jobId) throws BigQueryException { + public boolean cancel(String jobId) { try { bigquery.jobs().cancel(this.options.projectId(), jobId).execute(); return true; @@ -377,8 +373,7 @@ public boolean cancel(String jobId) throws BigQueryException { } @Override - public GetQueryResultsResponse getQueryResults(String jobId, Map options) - throws BigQueryException { + public GetQueryResultsResponse getQueryResults(String jobId, Map options) { try { return bigquery.jobs().getQueryResults(this.options.projectId(), jobId) .setMaxResults(MAX_RESULTS.getLong(options)) @@ -397,7 +392,7 @@ public GetQueryResultsResponse getQueryResults(String jobId, Map opti } @Override - public QueryResponse query(QueryRequest request) throws BigQueryException { + public QueryResponse query(QueryRequest request) { try { return bigquery.jobs().query(this.options.projectId(), request).execute(); } catch (IOException ex) { @@ -406,7 +401,7 @@ public QueryResponse query(QueryRequest request) throws BigQueryException { } @Override - public String open(JobConfiguration configuration) throws BigQueryException { + public String open(JobConfiguration configuration) { try { Job loadJob = new Job().setConfiguration(configuration); StringBuilder builder = new StringBuilder() @@ -429,7 +424,7 @@ public String open(JobConfiguration configuration) throws BigQueryException { @Override public void write(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length, - boolean last) throws BigQueryException { + boolean last) { try { GenericUrl url = new GenericUrl(uploadId); HttpRequest httpRequest = bigquery.getRequestFactory().buildPutRequest(url, diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpc.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpc.java index fd916e0a1c87..4d4540c70196 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpc.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpc.java @@ -35,16 +35,46 @@ */ public interface DatastoreRpc { - AllocateIdsResponse allocateIds(AllocateIdsRequest request) throws DatastoreException; + /** + * Sends an allocate IDs request. + * + * @throws DatastoreException upon failure + */ + AllocateIdsResponse allocateIds(AllocateIdsRequest request); + /** + * Sends a begin transaction request. + * + * @throws DatastoreException upon failure + */ BeginTransactionResponse beginTransaction(BeginTransactionRequest request) throws DatastoreException; - CommitResponse commit(CommitRequest request) throws DatastoreException; + /** + * Sends a commit request. + * + * @throws DatastoreException upon failure + */ + CommitResponse commit(CommitRequest request); - LookupResponse lookup(LookupRequest request) throws DatastoreException; + /** + * Sends a lookup request. + * + * @throws DatastoreException upon failure + */ + LookupResponse lookup(LookupRequest request); - RollbackResponse rollback(RollbackRequest request) throws DatastoreException; + /** + * Sends a rollback request. + * + * @throws DatastoreException upon failure + */ + RollbackResponse rollback(RollbackRequest request); - RunQueryResponse runQuery(RunQueryRequest request) throws DatastoreException; + /** + * Sends a request to run a query. + * + * @throws DatastoreException upon failure + */ + RunQueryResponse runQuery(RunQueryRequest request); } diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DefaultDatastoreRpc.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DefaultDatastoreRpc.java index c82ff9689f68..f679cc0d5826 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DefaultDatastoreRpc.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DefaultDatastoreRpc.java @@ -111,8 +111,7 @@ private static DatastoreException translate( } @Override - public AllocateIdsResponse allocateIds(AllocateIdsRequest request) - throws DatastoreException { + public AllocateIdsResponse allocateIds(AllocateIdsRequest request) { try { return client.allocateIds(request); } catch (com.google.api.services.datastore.client.DatastoreException ex) { @@ -121,8 +120,7 @@ public AllocateIdsResponse allocateIds(AllocateIdsRequest request) } @Override - public BeginTransactionResponse beginTransaction(BeginTransactionRequest request) - throws DatastoreException { + public BeginTransactionResponse beginTransaction(BeginTransactionRequest request) { try { return client.beginTransaction(request); } catch (com.google.api.services.datastore.client.DatastoreException ex) { @@ -131,7 +129,7 @@ public BeginTransactionResponse beginTransaction(BeginTransactionRequest request } @Override - public CommitResponse commit(CommitRequest request) throws DatastoreException { + public CommitResponse commit(CommitRequest request) { try { return client.commit(request); } catch (com.google.api.services.datastore.client.DatastoreException ex) { @@ -140,7 +138,7 @@ public CommitResponse commit(CommitRequest request) throws DatastoreException { } @Override - public LookupResponse lookup(LookupRequest request) throws DatastoreException { + public LookupResponse lookup(LookupRequest request) { try { return client.lookup(request); } catch (com.google.api.services.datastore.client.DatastoreException ex) { @@ -149,7 +147,7 @@ public LookupResponse lookup(LookupRequest request) throws DatastoreException { } @Override - public RollbackResponse rollback(RollbackRequest request) throws DatastoreException { + public RollbackResponse rollback(RollbackRequest request) { try { return client.rollback(request); } catch (com.google.api.services.datastore.client.DatastoreException ex) { @@ -158,7 +156,7 @@ public RollbackResponse rollback(RollbackRequest request) throws DatastoreExcept } @Override - public RunQueryResponse runQuery(RunQueryRequest request) throws DatastoreException { + public RunQueryResponse runQuery(RunQueryRequest request) { try { return client.runQuery(request); } catch (com.google.api.services.datastore.client.DatastoreException ex) { diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java index 3d27f2a33ac8..f9ddf6872414 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java @@ -168,7 +168,7 @@ public static ProjectListOption fields(ProjectField... fields) { } /** - * Create a new project. + * Creates a new project. * *

    Initially, the project resource is owned by its creator exclusively. The creator can later * grant permission to others to read or update the project. Several APIs are activated diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java index 61c622fa0c33..d30cd2df3627 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java @@ -38,7 +38,7 @@ private static ResourceManagerException translate(IOException exception) { } @Override - public Project create(Project project) throws ResourceManagerException { + public Project create(Project project) { try { return resourceManager.projects().create(project).execute(); } catch (IOException ex) { @@ -47,7 +47,7 @@ public Project create(Project project) throws ResourceManagerException { } @Override - public void delete(String projectId) throws ResourceManagerException { + public void delete(String projectId) { try { resourceManager.projects().delete(projectId).execute(); } catch (IOException ex) { @@ -56,7 +56,7 @@ public void delete(String projectId) throws ResourceManagerException { } @Override - public Project get(String projectId, Map options) throws ResourceManagerException { + public Project get(String projectId, Map options) { try { return resourceManager.projects() .get(projectId) @@ -74,8 +74,7 @@ public Project get(String projectId, Map options) throws ResourceMana } @Override - public Tuple> list(Map options) - throws ResourceManagerException { + public Tuple> list(Map options) { try { ListProjectsResponse response = resourceManager.projects() .list() @@ -92,7 +91,7 @@ public Tuple> list(Map options) } @Override - public void undelete(String projectId) throws ResourceManagerException { + public void undelete(String projectId) { try { resourceManager.projects().undelete(projectId).execute(); } catch (IOException ex) { @@ -101,7 +100,7 @@ public void undelete(String projectId) throws ResourceManagerException { } @Override - public Project replace(Project project) throws ResourceManagerException { + public Project replace(Project project) { try { return resourceManager.projects().update(project.getProjectId(), project).execute(); } catch (IOException ex) { diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java index 52dfc2d2368e..e1d72a6a373e 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java @@ -75,17 +75,51 @@ public Y y() { } } - Project create(Project project) throws ResourceManagerException; - - void delete(String projectId) throws ResourceManagerException; - - Project get(String projectId, Map options) throws ResourceManagerException; - - Tuple> list(Map options) throws ResourceManagerException; - - void undelete(String projectId) throws ResourceManagerException; - - Project replace(Project project) throws ResourceManagerException; + /** + * Creates a new project. + * + * @throws ResourceManagerException upon failure + */ + Project create(Project project); + + /** + * Marks the project identified by the specified project ID for deletion. + * + * @throws ResourceManagerException upon failure + */ + void delete(String projectId); + + /** + * Retrieves the project identified by the specified project ID. Returns {@code null} if the + * project is not found or if the user doesn't have read permissions for the project. + * + * @throws ResourceManagerException upon failure + */ + Project get(String projectId, Map options); + + /** + * Lists the projects visible to the current user. + * + * @throws ResourceManagerException upon failure + */ + Tuple> list(Map options); + + /** + * Restores the project identified by the specified project ID. Undelete will only succeed if the + * project has a lifecycle state of {@code DELETE_REQUESTED} state. The caller must have modify + * permissions for this project. + * + * @throws ResourceManagerException upon failure + */ + void undelete(String projectId); + + /** + * Replaces the attributes of the project. The caller must have modify permissions for this + * project. + * + * @throws ResourceManagerException upon failure + */ + Project replace(Project project); // TODO(ajaykannan): implement "Organization" functionality when available (issue #319) } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java index dc84a1de5559..3d7febfd556b 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java @@ -99,7 +99,7 @@ private static StorageException translate(GoogleJsonError exception) { } @Override - public Bucket create(Bucket bucket, Map options) throws StorageException { + public Bucket create(Bucket bucket, Map options) { try { return storage.buckets() .insert(this.options.projectId(), bucket) @@ -114,7 +114,7 @@ public Bucket create(Bucket bucket, Map options) throws StorageExcept @Override public StorageObject create(StorageObject storageObject, final InputStream content, - Map options) throws StorageException { + Map options) { try { Storage.Objects.Insert insert = storage.objects() .insert(storageObject.getBucket(), storageObject, @@ -296,7 +296,7 @@ private Storage.Objects.Delete deleteRequest(StorageObject blob, Map @Override public StorageObject compose(Iterable sources, StorageObject target, - Map targetOptions) throws StorageException { + Map targetOptions) { ComposeRequest request = new ComposeRequest(); if (target.getContentType() == null) { target.setContentType("application/octet-stream"); @@ -327,8 +327,7 @@ public StorageObject compose(Iterable sources, StorageObject targ } @Override - public byte[] load(StorageObject from, Map options) - throws StorageException { + public byte[] load(StorageObject from, Map options) { try { Storage.Objects.Get getRequest = storage.objects() .get(from.getBucket(), from.getName()) @@ -347,7 +346,7 @@ public byte[] load(StorageObject from, Map options) } @Override - public BatchResponse batch(BatchRequest request) throws StorageException { + public BatchResponse batch(BatchRequest request) { List>>> partitionedToDelete = Lists.partition(request.toDelete, MAX_BATCH_DELETES); Iterator>>> iterator = partitionedToDelete.iterator(); @@ -437,7 +436,7 @@ public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) { @Override public Tuple read(StorageObject from, Map options, long position, - int bytes) throws StorageException { + int bytes) { try { Get req = storage.objects() .get(from.getBucket(), from.getName()) @@ -460,7 +459,7 @@ public Tuple read(StorageObject from, Map options, lo @Override public void write(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length, - boolean last) throws StorageException { + boolean last) { try { GenericUrl url = new GenericUrl(uploadId); HttpRequest httpRequest = storage.getRequestFactory().buildPutRequest(url, @@ -501,8 +500,7 @@ public void write(String uploadId, byte[] toWrite, int toWriteOffset, long destO } @Override - public String open(StorageObject object, Map options) - throws StorageException { + public String open(StorageObject object, Map options) { try { Insert req = storage.objects().insert(object.getBucket(), object); GenericUrl url = req.buildHttpRequest().getUrl(); @@ -538,16 +536,16 @@ public String open(StorageObject object, Map options) } @Override - public RewriteResponse openRewrite(RewriteRequest rewriteRequest) throws StorageException { + public RewriteResponse openRewrite(RewriteRequest rewriteRequest) { return rewrite(rewriteRequest, null); } @Override - public RewriteResponse continueRewrite(RewriteResponse previousResponse) throws StorageException { + public RewriteResponse continueRewrite(RewriteResponse previousResponse) { return rewrite(previousResponse.rewriteRequest, previousResponse.rewriteToken); } - private RewriteResponse rewrite(RewriteRequest req, String token) throws StorageException { + private RewriteResponse rewrite(RewriteRequest req, String token) { try { Long maxBytesRewrittenPerCall = req.megabytesRewrittenPerCall != null ? req.megabytesRewrittenPerCall * MEGABYTE : null; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java index e15a27114810..c76fc0f2d3b8 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java @@ -217,57 +217,134 @@ public int hashCode() { } } - Bucket create(Bucket bucket, Map options) throws StorageException; + /** + * Creates a new bucket. + * + * @throws StorageException upon failure + */ + Bucket create(Bucket bucket, Map options); - StorageObject create(StorageObject object, InputStream content, Map options) - throws StorageException; + /** + * Creates a new storage object. + * + * @throws StorageException upon failure + */ + StorageObject create(StorageObject object, InputStream content, Map options); - Tuple> list(Map options) throws StorageException; + /** + * Lists the project's buckets. + * + * @throws StorageException upon failure + */ + Tuple> list(Map options); - Tuple> list(String bucket, Map options) - throws StorageException; + /** + * Lists the bucket's blobs. + * + * @throws StorageException upon failure + */ + Tuple> list(String bucket, Map options); /** * Returns the requested bucket or {@code null} if not found. * * @throws StorageException upon failure */ - Bucket get(Bucket bucket, Map options) throws StorageException; + Bucket get(Bucket bucket, Map options); /** * Returns the requested storage object or {@code null} if not found. * * @throws StorageException upon failure */ - StorageObject get(StorageObject object, Map options) - throws StorageException; + StorageObject get(StorageObject object, Map options); - Bucket patch(Bucket bucket, Map options) throws StorageException; + /** + * Updates bucket information. + * + * @throws StorageException upon failure + */ + Bucket patch(Bucket bucket, Map options); - StorageObject patch(StorageObject storageObject, Map options) - throws StorageException; + /** + * Updates the storage object's information. Original metadata are merged with metadata in the + * provided {@code storageObject}. + * + * @throws StorageException upon failure + */ + StorageObject patch(StorageObject storageObject, Map options); - boolean delete(Bucket bucket, Map options) throws StorageException; + /** + * Deletes the requested bucket. + * + * @return {@code true} if the bucket was deleted, {@code false} if it was not found + * @throws StorageException upon failure + */ + boolean delete(Bucket bucket, Map options); - boolean delete(StorageObject object, Map options) throws StorageException; + /** + * Deletes the requested storage object. + * + * @return {@code true} if the storage object was deleted, {@code false} if it was not found + * @throws StorageException upon failure + */ + boolean delete(StorageObject object, Map options); - BatchResponse batch(BatchRequest request) throws StorageException; + /** + * Sends a batch request. + * + * @throws StorageException upon failure + */ + BatchResponse batch(BatchRequest request); + /** + * Sends a compose request. + * + * @throws StorageException upon failure + */ StorageObject compose(Iterable sources, StorageObject target, - Map targetOptions) throws StorageException; + Map targetOptions); - byte[] load(StorageObject storageObject, Map options) - throws StorageException; + /** + * Reads all the bytes from a storage object. + * + * @throws StorageException upon failure + */ + byte[] load(StorageObject storageObject, Map options); - Tuple read(StorageObject from, Map options, long position, int bytes) - throws StorageException; + /** + * Reads the given amount of bytes from a storage object at the given position. + * + * @throws StorageException upon failure + */ + Tuple read(StorageObject from, Map options, long position, int bytes); - String open(StorageObject object, Map options) throws StorageException; + /** + * Opens a resumable upload channel for a given storage object. + * + * @throws StorageException upon failure + */ + String open(StorageObject object, Map options); + /** + * Writes the provided bytes to a storage object at the provided location. + * + * @throws StorageException upon failure + */ void write(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length, - boolean last) throws StorageException; + boolean last); - RewriteResponse openRewrite(RewriteRequest rewriteRequest) throws StorageException; + /** + * Sends a rewrite request to open a rewrite channel. + * + * @throws StorageException upon failure + */ + RewriteResponse openRewrite(RewriteRequest rewriteRequest); - RewriteResponse continueRewrite(RewriteResponse previousResponse) throws StorageException; + /** + * Continues rewriting on an already open rewrite channel. + * + * @throws StorageException + */ + RewriteResponse continueRewrite(RewriteResponse previousResponse); } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 98f3450b7f10..065bcca7c9e8 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -1215,7 +1215,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx } /** - * Create a new bucket. + * Creates a new bucket. * * @return a complete bucket * @throws StorageException upon failure @@ -1223,7 +1223,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx Bucket create(BucketInfo bucketInfo, BucketTargetOption... options); /** - * Create a new blob with no content. + * Creates a new blob with no content. * * @return a [@code Blob} with complete information * @throws StorageException upon failure @@ -1231,7 +1231,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx Blob create(BlobInfo blobInfo, BlobTargetOption... options); /** - * Create a new blob. Direct upload is used to upload {@code content}. For large content, + * Creates a new blob. Direct upload is used to upload {@code content}. For large content, * {@link #writer} is recommended as it uses resumable upload. MD5 and CRC32C hashes of * {@code content} are computed and used for validating transferred data. * @@ -1242,7 +1242,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx Blob create(BlobInfo blobInfo, byte[] content, BlobTargetOption... options); /** - * Create a new blob. Direct upload is used to upload {@code content}. For large content, + * Creates a new blob. Direct upload is used to upload {@code content}. For large content, * {@link #writer} is recommended as it uses resumable upload. By default any md5 and crc32c * values in the given {@code blobInfo} are ignored unless requested via the * {@code BlobWriteOption.md5Match} and {@code BlobWriteOption.crc32cMatch} options. The given @@ -1254,49 +1254,49 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx Blob create(BlobInfo blobInfo, InputStream content, BlobWriteOption... options); /** - * Return the requested bucket or {@code null} if not found. + * Returns the requested bucket or {@code null} if not found. * * @throws StorageException upon failure */ Bucket get(String bucket, BucketGetOption... options); /** - * Return the requested blob or {@code null} if not found. + * Returns the requested blob or {@code null} if not found. * * @throws StorageException upon failure */ Blob get(String bucket, String blob, BlobGetOption... options); /** - * Return the requested blob or {@code null} if not found. + * Returns the requested blob or {@code null} if not found. * * @throws StorageException upon failure */ Blob get(BlobId blob, BlobGetOption... options); /** - * Return the requested blob or {@code null} if not found. + * Returns the requested blob or {@code null} if not found. * * @throws StorageException upon failure */ Blob get(BlobId blob); /** - * List the project's buckets. + * Lists the project's buckets. * * @throws StorageException upon failure */ Page list(BucketListOption... options); /** - * List the bucket's blobs. + * Lists the bucket's blobs. * * @throws StorageException upon failure */ Page list(String bucket, BlobListOption... options); /** - * Update bucket information. + * Updates bucket information. * * @return the updated bucket * @throws StorageException upon failure @@ -1304,7 +1304,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx Bucket update(BucketInfo bucketInfo, BucketTargetOption... options); /** - * Update blob information. Original metadata are merged with metadata in the provided + * Updates blob information. Original metadata are merged with metadata in the provided * {@code blobInfo}. To replace metadata instead you first have to unset them. Unsetting metadata * can be done by setting the provided {@code blobInfo}'s metadata to {@code null}. * @@ -1321,7 +1321,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx Blob update(BlobInfo blobInfo, BlobTargetOption... options); /** - * Update blob information. Original metadata are merged with metadata in the provided + * Updates blob information. Original metadata are merged with metadata in the provided * {@code blobInfo}. To replace metadata instead you first have to unset them. Unsetting metadata * can be done by setting the provided {@code blobInfo}'s metadata to {@code null}. * @@ -1338,7 +1338,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx Blob update(BlobInfo blobInfo); /** - * Delete the requested bucket. + * Deletes the requested bucket. * * @return {@code true} if bucket was deleted, {@code false} if it was not found * @throws StorageException upon failure @@ -1346,7 +1346,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx boolean delete(String bucket, BucketSourceOption... options); /** - * Delete the requested blob. + * Deletes the requested blob. * * @return {@code true} if blob was deleted, {@code false} if it was not found * @throws StorageException upon failure @@ -1354,7 +1354,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx boolean delete(String bucket, String blob, BlobSourceOption... options); /** - * Delete the requested blob. + * Deletes the requested blob. * * @return {@code true} if blob was deleted, {@code false} if it was not found * @throws StorageException upon failure @@ -1362,7 +1362,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx boolean delete(BlobId blob, BlobSourceOption... options); /** - * Delete the requested blob. + * Deletes the requested blob. * * @return {@code true} if blob was deleted, {@code false} if it was not found * @throws StorageException upon failure @@ -1370,7 +1370,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx boolean delete(BlobId blob); /** - * Send a compose request. + * Sends a compose request. * * @return the composed blob * @throws StorageException upon failure @@ -1422,7 +1422,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx byte[] readAllBytes(BlobId blob, BlobSourceOption... options); /** - * Send a batch request. + * Sends a batch request. * * @return the batch response * @throws StorageException upon failure @@ -1430,7 +1430,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx BatchResponse submit(BatchRequest batchRequest); /** - * Return a channel for reading the blob's content. The blob's latest generation is read. If the + * Returns a channel for reading the blob's content. The blob's latest generation is read. If the * blob changes while reading (i.e. {@link BlobInfo#etag()} changes), subsequent calls to * {@code blobReadChannel.read(ByteBuffer)} may throw {@link StorageException}. * @@ -1443,7 +1443,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx ReadChannel reader(String bucket, String blob, BlobSourceOption... options); /** - * Return a channel for reading the blob's content. If {@code blob.generation()} is set + * Returns a channel for reading the blob's content. If {@code blob.generation()} is set * data corresponding to that generation is read. If {@code blob.generation()} is {@code null} * the blob's latest generation is read. If the blob changes while reading (i.e. * {@link BlobInfo#etag()} changes), subsequent calls to {@code blobReadChannel.read(ByteBuffer)} @@ -1459,7 +1459,7 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx ReadChannel reader(BlobId blob, BlobSourceOption... options); /** - * Create a blob and return a channel for writing its content. By default any md5 and crc32c + * Creates a blob and return a channel for writing its content. By default any md5 and crc32c * values in the given {@code blobInfo} are ignored unless requested via the * {@code BlobWriteOption.md5Match} and {@code BlobWriteOption.crc32cMatch} options. * From b8031e1d1c5068f6bf9f1a5bf180de9aa94fc1d8 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 4 Mar 2016 09:29:18 -0800 Subject: [PATCH 113/203] Adjusted clear not to collide when parallel test are running. --- .../com/google/gcloud/dns/it/ITDnsTest.java | 119 +++++++++--------- 1 file changed, 63 insertions(+), 56 deletions(-) diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java index fd257c681225..fda579a4a94b 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java @@ -50,68 +50,75 @@ public class ITDnsTest { // todo(mderka) Implement test for creating invalid change when DnsException is finished. #673 - public static final String PREFIX = "gcldjvit-"; - public static final Dns DNS = DnsOptions.builder().build().service(); - public static final String ZONE_NAME1 = (PREFIX + UUID.randomUUID()).substring(0, 32); - public static final String ZONE_NAME_EMPTY_DESCRIPTION = + private static final String PREFIX = "gcldjvit-"; + private static final Dns DNS = DnsOptions.builder().build().service(); + private static final String ZONE_NAME1 = (PREFIX + UUID.randomUUID()).substring(0, 32); + private static final String ZONE_NAME_EMPTY_DESCRIPTION = (PREFIX + UUID.randomUUID()).substring(0, 32); - public static final String ZONE_NAME_TOO_LONG = PREFIX + UUID.randomUUID(); - public static final String ZONE_DESCRIPTION1 = "first zone"; - public static final String ZONE_DNS_NAME1 = ZONE_NAME1 + ".com."; - public static final String ZONE_DNS_EMPTY_DESCRIPTION = ZONE_NAME_EMPTY_DESCRIPTION + ".com."; - public static final String ZONE_DNS_NAME_NO_PERIOD = ZONE_NAME1 + ".com"; - public static final ZoneInfo ZONE1 = ZoneInfo.builder(ZONE_NAME1) + private static final String ZONE_NAME_TOO_LONG = PREFIX + UUID.randomUUID(); + private static final String ZONE_DESCRIPTION1 = "first zone"; + private static final String ZONE_DNS_NAME1 = ZONE_NAME1 + ".com."; + private static final String ZONE_DNS_EMPTY_DESCRIPTION = ZONE_NAME_EMPTY_DESCRIPTION + ".com."; + private static final String ZONE_DNS_NAME_NO_PERIOD = ZONE_NAME1 + ".com"; + private static final ZoneInfo ZONE1 = ZoneInfo.builder(ZONE_NAME1) .description(ZONE_DESCRIPTION1) .dnsName(ZONE_DNS_EMPTY_DESCRIPTION) .build(); - public static final ZoneInfo ZONE_EMPTY_DESCRIPTION = + private static final ZoneInfo ZONE_EMPTY_DESCRIPTION = ZoneInfo.builder(ZONE_NAME_EMPTY_DESCRIPTION) .description(ZONE_DESCRIPTION1) .dnsName(ZONE_DNS_NAME1) .build(); - public static final ZoneInfo ZONE_NAME_ERROR = ZoneInfo.builder(ZONE_NAME_TOO_LONG) + private static final ZoneInfo ZONE_NAME_ERROR = ZoneInfo.builder(ZONE_NAME_TOO_LONG) .description(ZONE_DESCRIPTION1) .dnsName(ZONE_DNS_NAME1) .build(); - public static final ZoneInfo ZONE_MISSING_DESCRIPTION = ZoneInfo.builder(ZONE_NAME1) + private static final ZoneInfo ZONE_MISSING_DESCRIPTION = ZoneInfo.builder(ZONE_NAME1) .dnsName(ZONE_DNS_NAME1) .build(); - public static final ZoneInfo ZONE_MISSING_DNS_NAME = ZoneInfo.builder(ZONE_NAME1) + private static final ZoneInfo ZONE_MISSING_DNS_NAME = ZoneInfo.builder(ZONE_NAME1) .description(ZONE_DESCRIPTION1) .build(); - public static final ZoneInfo ZONE_DNS_NO_PERIOD = ZoneInfo.builder(ZONE_NAME1) + private static final ZoneInfo ZONE_DNS_NO_PERIOD = ZoneInfo.builder(ZONE_NAME1) .description(ZONE_DESCRIPTION1) .dnsName(ZONE_DNS_NAME_NO_PERIOD) .build(); - public static final DnsRecord A_RECORD_ZONE1 = + private static final DnsRecord A_RECORD_ZONE1 = DnsRecord.builder("www." + ZONE1.dnsName(), DnsRecord.Type.A) .records(ImmutableList.of("123.123.55.1")) .ttl(25, TimeUnit.SECONDS) .build(); - public static final DnsRecord AAAA_RECORD_ZONE1 = + private static final DnsRecord AAAA_RECORD_ZONE1 = DnsRecord.builder("www." + ZONE1.dnsName(), DnsRecord.Type.AAAA) .records(ImmutableList.of("ed:ed:12:aa:36:3:3:105")) .ttl(25, TimeUnit.SECONDS) .build(); - public static final ChangeRequest CHANGE_ADD_ZONE1 = ChangeRequest.builder() + private static final ChangeRequest CHANGE_ADD_ZONE1 = ChangeRequest.builder() .add(A_RECORD_ZONE1) .add(AAAA_RECORD_ZONE1) .build(); - public static final ChangeRequest CHANGE_DELETE_ZONE1 = ChangeRequest.builder() + private static final ChangeRequest CHANGE_DELETE_ZONE1 = ChangeRequest.builder() .delete(A_RECORD_ZONE1) .delete(AAAA_RECORD_ZONE1) .build(); + private static final List ZONE_NAMES = ImmutableList.of(ZONE_NAME1, + ZONE_NAME_EMPTY_DESCRIPTION); - public static void clear() { - Page zones = DNS.listZones(); - Iterator zoneIterator = zones.iterateAll(); - while (zoneIterator.hasNext()) { - Zone zone = zoneIterator.next(); - List toDelete = new LinkedList<>(); - if (zone.name().startsWith(PREFIX)) { - Iterator dnsRecordIterator = zone.listDnsRecords().iterateAll(); - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); + private static void clear() { + for (String zoneName : ZONE_NAMES) { + Zone zone = DNS.getZone(zoneName); + if (zone != null) { + /* We wait for all changes to complete before retrieving a list of DNS records to be + deleted. Waiting is necessary as changes potentially might create more records between + when the list has been retrieved and executing the subsequent delete operation. */ + Iterator iterator = zone.listChangeRequests().iterateAll(); + while (iterator.hasNext()) { + waitForChangeToComplete(zoneName, iterator.next().id()); + } + Iterator recordIterator = zone.listDnsRecords().iterateAll(); + List toDelete = new LinkedList<>(); + while (recordIterator.hasNext()) { + DnsRecord record = recordIterator.next(); if (!ImmutableList.of(DnsRecord.Type.NS, DnsRecord.Type.SOA).contains(record.type())) { toDelete.add(record); } @@ -119,7 +126,7 @@ public static void clear() { if (!toDelete.isEmpty()) { ChangeRequest deletion = zone.applyChangeRequest(ChangeRequest.builder().deletions(toDelete).build()); - waitUntilComplete(zone.name(), deletion.id()); + waitForChangeToComplete(zone.name(), deletion.id()); } zone.delete(); } @@ -130,7 +137,7 @@ private static List filter(Iterator iterator) { List result = new LinkedList<>(); while (iterator.hasNext()) { Zone zone = iterator.next(); - if (zone.name().startsWith(PREFIX)) { + if (ZONE_NAMES.contains(zone.name())) { result.add(zone); } } @@ -154,7 +161,7 @@ private static void assertEqChangesIgnoreStatus(ChangeRequest expected, ChangeRe assertEquals(expected.startTimeMillis(), actual.startTimeMillis()); } - private static void waitUntilComplete(String zoneName, String changeId) { + private static void waitForChangeToComplete(String zoneName, String changeId) { while (true) { ChangeRequest changeRequest = DNS.getChangeRequest(zoneName, changeId, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); @@ -553,9 +560,9 @@ public void testCreateChange() { assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) .contains(created.status())); assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); - waitUntilComplete(ZONE1.name(), "1"); + waitForChangeToComplete(ZONE1.name(), "1"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitUntilComplete(ZONE1.name(), "2"); + waitForChangeToComplete(ZONE1.name(), "2"); // with options created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); @@ -564,9 +571,9 @@ public void testCreateChange() { assertTrue(created.deletions().isEmpty()); assertEquals("3", created.id()); assertNull(created.status()); - waitUntilComplete(ZONE1.name(), "3"); + waitForChangeToComplete(ZONE1.name(), "3"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitUntilComplete(ZONE1.name(), "4"); + waitForChangeToComplete(ZONE1.name(), "4"); created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); assertTrue(created.additions().isEmpty()); @@ -574,9 +581,9 @@ public void testCreateChange() { assertTrue(created.deletions().isEmpty()); assertEquals("5", created.id()); assertNotNull(created.status()); - waitUntilComplete(ZONE1.name(), "5"); + waitForChangeToComplete(ZONE1.name(), "5"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitUntilComplete(ZONE1.name(), "6"); + waitForChangeToComplete(ZONE1.name(), "6"); created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); assertTrue(created.additions().isEmpty()); @@ -584,9 +591,9 @@ public void testCreateChange() { assertTrue(created.deletions().isEmpty()); assertEquals("7", created.id()); assertNull(created.status()); - waitUntilComplete(ZONE1.name(), "7"); + waitForChangeToComplete(ZONE1.name(), "7"); DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitUntilComplete(ZONE1.name(), "8"); + waitForChangeToComplete(ZONE1.name(), "8"); created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); @@ -595,16 +602,16 @@ public void testCreateChange() { assertEquals("9", created.id()); assertNull(created.status()); // finishes with delete otherwise we cannot delete the zone - waitUntilComplete(ZONE1.name(), "9"); + waitForChangeToComplete(ZONE1.name(), "9"); created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); - waitUntilComplete(ZONE1.name(), "10"); + waitForChangeToComplete(ZONE1.name(), "10"); assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); assertNull(created.startTimeMillis()); assertTrue(created.additions().isEmpty()); assertEquals("10", created.id()); assertNull(created.status()); - waitUntilComplete(ZONE1.name(), "10"); + waitForChangeToComplete(ZONE1.name(), "10"); } finally { clear(); } @@ -629,13 +636,13 @@ public void testListChanges() { assertEquals(1, changes.size()); // default change creating SOA and NS // zone has changes ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - waitUntilComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.id()); change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitUntilComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.id()); change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - waitUntilComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.id()); change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); - waitUntilComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.id()); changes = ImmutableList.copyOf(DNS.listChangeRequests(ZONE1.name()).iterateAll()); assertEquals(5, changes.size()); // error in options @@ -726,7 +733,7 @@ public void testGetChange() { ChangeRequest created = zone.applyChangeRequest(CHANGE_ADD_ZONE1); ChangeRequest retrieved = DNS.getChangeRequest(zone.name(), created.id()); assertEqChangesIgnoreStatus(created, retrieved); - waitUntilComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.id()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); // with options created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, @@ -734,35 +741,35 @@ public void testGetChange() { retrieved = DNS.getChangeRequest(zone.name(), created.id(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); assertEqChangesIgnoreStatus(created, retrieved); - waitUntilComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.id()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); retrieved = DNS.getChangeRequest(zone.name(), created.id(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); assertEqChangesIgnoreStatus(created, retrieved); - waitUntilComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.id()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); retrieved = DNS.getChangeRequest(zone.name(), created.id(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); assertEqChangesIgnoreStatus(created, retrieved); - waitUntilComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.id()); zone.applyChangeRequest(CHANGE_DELETE_ZONE1); created = zone.applyChangeRequest(CHANGE_ADD_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); retrieved = DNS.getChangeRequest(zone.name(), created.id(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); assertEqChangesIgnoreStatus(created, retrieved); - waitUntilComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.id()); // finishes with delete otherwise we cannot delete the zone created = zone.applyChangeRequest(CHANGE_DELETE_ZONE1, Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); retrieved = DNS.getChangeRequest(zone.name(), created.id(), Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); assertEqChangesIgnoreStatus(created, retrieved); - waitUntilComplete(zone.name(), created.id()); + waitForChangeToComplete(zone.name(), created.id()); } finally { clear(); } @@ -854,7 +861,7 @@ public void testListDnsRecords() { assertEquals(1, ImmutableList.copyOf(dnsRecordPage.values().iterator()).size()); // test name filter ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); - waitUntilComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.id()); dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name())).iterateAll(); counter = 0; @@ -866,7 +873,7 @@ public void testListDnsRecords() { } assertEquals(2, counter); // test type filter - waitUntilComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.id()); dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name()), Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())) @@ -905,7 +912,7 @@ public void testListDnsRecords() { assertEquals(400, ex.code()); // todo(mderka) test retry functionality when available } - waitUntilComplete(ZONE1.name(), change.id()); + waitForChangeToComplete(ZONE1.name(), change.id()); } finally { clear(); } From c486452b4c81da7f077e2573b1f29dee3994bd86 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Sun, 6 Mar 2016 08:54:43 -0800 Subject: [PATCH 114/203] Add NoAuthCredentials --- .../com/google/gcloud/AuthCredentials.java | 34 +++++++++++++++++++ .../com/google/gcloud/ServiceOptions.java | 7 ++-- .../gcloud/datastore/DatastoreTest.java | 2 ++ .../testing/LocalResourceManagerHelper.java | 11 ++++-- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java b/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java index fc5d74d0896c..f4f6b6938531 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java @@ -243,6 +243,33 @@ public RestorableState capture() { } } + public static class NoAuthCredentials extends AuthCredentials { + + private static final AuthCredentials INSTANCE = new NoAuthCredentials(); + private static final NoAuthCredentialsState STATE = new NoAuthCredentialsState(); + + private static class NoAuthCredentialsState + implements RestorableState, Serializable { + + private static final long serialVersionUID = -4022100563954640465L; + + @Override + public AuthCredentials restore() { + return INSTANCE; + } + } + + @Override + public GoogleCredentials credentials() { + return null; + } + + @Override + public RestorableState capture() { + return STATE; + } + } + public abstract GoogleCredentials credentials(); public static AuthCredentials createForAppEngine() { @@ -281,6 +308,13 @@ public static ServiceAccountAuthCredentials createFor(String account, PrivateKey return new ServiceAccountAuthCredentials(account, privateKey); } + /** + * Creates a placeholder denoting that no credentials should be used. + */ + public static AuthCredentials noAuth() { + return NoAuthCredentials.INSTANCE; + } + /** * Creates Service Account Credentials given a stream for credentials in JSON format. * diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java b/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java index 31e543809464..d45069434a26 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java @@ -523,9 +523,10 @@ public RetryParams retryParams() { * options. */ public HttpRequestInitializer httpRequestInitializer() { - final HttpRequestInitializer delegate = authCredentials() != null - ? new HttpCredentialsAdapter(authCredentials().credentials().createScoped(scopes())) - : null; + final HttpRequestInitializer delegate = + authCredentials() != null && authCredentials.credentials() != null + ? new HttpCredentialsAdapter(authCredentials().credentials().createScoped(scopes())) + : null; return new HttpRequestInitializer() { @Override public void initialize(HttpRequest httpRequest) throws IOException { diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java index a289610fe841..5d106fc7d31d 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java @@ -32,6 +32,7 @@ import com.google.api.services.datastore.DatastoreV1.RunQueryResponse; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; +import com.google.gcloud.AuthCredentials; import com.google.gcloud.RetryParams; import com.google.gcloud.datastore.Query.ResultType; import com.google.gcloud.datastore.StructuredQuery.OrderBy; @@ -128,6 +129,7 @@ public void setUp() { options = DatastoreOptions.builder() .projectId(PROJECT_ID) .host("http://localhost:" + PORT) + .authCredentials(AuthCredentials.noAuth()) .retryParams(RetryParams.noRetries()) .build(); datastore = options.service(); diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java index a077eb6144a5..cda2dd1e00ea 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -12,6 +12,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.io.ByteStreams; +import com.google.gcloud.AuthCredentials; import com.google.gcloud.resourcemanager.ResourceManagerOptions; import com.sun.net.httpserver.Headers; @@ -550,17 +551,21 @@ private LocalResourceManagerHelper() { } /** - * Creates a LocalResourceManagerHelper object that listens to requests on the local machine. + * Creates a {@code LocalResourceManagerHelper} object that listens to requests on the local + * machine. */ public static LocalResourceManagerHelper create() { return new LocalResourceManagerHelper(); } /** - * Returns a ResourceManagerOptions instance that sets the host to use the mock server. + * Returns a {@link ResourceManagerOptions} instance that sets the host to use the mock server. */ public ResourceManagerOptions options() { - return ResourceManagerOptions.builder().host("http://localhost:" + port).build(); + return ResourceManagerOptions.builder() + .host("http://localhost:" + port) + .authCredentials(AuthCredentials.noAuth()) + .build(); } /** From 8c353ecbc62a9f8d7784ba8f99ee2f3cf15a4c00 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 7 Mar 2016 08:27:49 -0800 Subject: [PATCH 115/203] Add javadoc --- .../com/google/gcloud/AuthCredentials.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java b/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java index f4f6b6938531..1f8a56f8e68c 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java @@ -132,6 +132,12 @@ public RestorableState capture() { } } + /** + * Represents service account credentials. + * + * @see + * User accounts and service accounts + */ public static class ServiceAccountAuthCredentials extends AuthCredentials { private final String account; @@ -195,6 +201,14 @@ public RestorableState capture() { } } + /** + * Represents Application Default Credentials, which are credentials that are inferred from the + * runtime environment. + * + * @see + * Google Application Default Credentials + */ public static class ApplicationDefaultAuthCredentials extends AuthCredentials { private GoogleCredentials googleCredentials; @@ -243,6 +257,11 @@ public RestorableState capture() { } } + /** + * Represents that requests sent to the server should not be authenticated. This is typically + * useful when using the local service emulators, such as {@code LocalGcdHelper} and + * {@code LocalResourceManagerHelper}. + */ public static class NoAuthCredentials extends AuthCredentials { private static final AuthCredentials INSTANCE = new NoAuthCredentials(); @@ -309,7 +328,9 @@ public static ServiceAccountAuthCredentials createFor(String account, PrivateKey } /** - * Creates a placeholder denoting that no credentials should be used. + * Creates a placeholder denoting that no credentials should be used. This is typically useful + * when using the local service emulators, such as {@code LocalGcdHelper} and + * {@code LocalResourceManagerHelper}. */ public static AuthCredentials noAuth() { return NoAuthCredentials.INSTANCE; From 0c4af89295be8709d63776ee4c65d4d64fa282ce Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 7 Mar 2016 08:50:26 -0800 Subject: [PATCH 116/203] change NoAuthCredentials javadoc wording --- .../src/main/java/com/google/gcloud/AuthCredentials.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java b/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java index 1f8a56f8e68c..6f9e09ca04bc 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java @@ -258,9 +258,9 @@ public RestorableState capture() { } /** - * Represents that requests sent to the server should not be authenticated. This is typically - * useful when using the local service emulators, such as {@code LocalGcdHelper} and - * {@code LocalResourceManagerHelper}. + * A placeholder for credentials to signify that requests sent to the server should not be + * authenticated. This is typically useful when using the local service emulators, such as + * {@code LocalGcdHelper} and {@code LocalResourceManagerHelper}. */ public static class NoAuthCredentials extends AuthCredentials { From cded23436465bb5fb1233eb5cd6740b4561357f9 Mon Sep 17 00:00:00 2001 From: aozarov Date: Mon, 7 Mar 2016 15:28:21 -0800 Subject: [PATCH 117/203] Fix writes with 0 length --- .../google/gcloud/spi/DefaultStorageRpc.java | 10 +++++++- .../gcloud/storage/it/ITStorageTest.java | 23 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java index 3d7febfd556b..4d9214ef5929 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java @@ -461,12 +461,20 @@ public Tuple read(StorageObject from, Map options, lo public void write(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, int length, boolean last) { try { + if (length == 0 && !last) { + return; + } GenericUrl url = new GenericUrl(uploadId); HttpRequest httpRequest = storage.getRequestFactory().buildPutRequest(url, new ByteArrayContent(null, toWrite, toWriteOffset, length)); long limit = destOffset + length; StringBuilder range = new StringBuilder("bytes "); - range.append(destOffset).append('-').append(limit - 1).append('/'); + if (length == 0) { + range.append('*'); + } else { + range.append(destOffset).append('-').append(limit - 1); + } + range.append('/'); if (last) { range.append(limit); } else { diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index 38521ae5e137..a411cdd60bfb 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -823,6 +823,29 @@ public void testReadAndWriteChannels() throws IOException { assertTrue(storage.delete(BUCKET, blobName)); } + @Test + public void testReadAndWriteChannelsWithDifferentFileSize() throws IOException { + String blobNamePrefix = "test-read-and-write-channels-blob-"; + int[] blobSizes = {0, 700, 1024 * 256, 2 * 1024 * 1024, 4 * 1024 * 1024, 4 * 1024 * 1024 + 1}; + Random rnd = new Random(); + for (int blobSize : blobSizes) { + String blobName = blobNamePrefix + blobSize; + BlobInfo blob = BlobInfo.builder(BUCKET, blobName).build(); + byte[] bytes = new byte[blobSize]; + rnd.nextBytes(bytes); + try (WriteChannel writer = storage.writer(blob)) { + writer.write(ByteBuffer.wrap(BLOB_BYTE_CONTENT)); + } + ByteBuffer readBytes; + try (ReadChannel reader = storage.reader(blob.blobId())) { + readBytes = ByteBuffer.allocate(BLOB_BYTE_CONTENT.length); + reader.read(readBytes); + } + assertArrayEquals(BLOB_BYTE_CONTENT, readBytes.array()); + assertTrue(storage.delete(BUCKET, blobName)); + } + } + @Test public void testReadAndWriteCaptureChannels() throws IOException { String blobName = "test-read-and-write-capture-channels-blob"; From 36ebabda8ae8f075e5b83128344c5a92c84c3715 Mon Sep 17 00:00:00 2001 From: aozarov Date: Mon, 7 Mar 2016 17:00:03 -0800 Subject: [PATCH 118/203] Fix test and issue #723 --- .../google/gcloud/BaseServiceException.java | 23 ++++++++++++------- .../google/gcloud/spi/DefaultStorageRpc.java | 7 +++++- .../gcloud/storage/BlobReadChannel.java | 2 +- .../gcloud/storage/it/ITStorageTest.java | 15 ++++++++---- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/BaseServiceException.java b/gcloud-java-core/src/main/java/com/google/gcloud/BaseServiceException.java index 579340f1256e..365243904436 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/BaseServiceException.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/BaseServiceException.java @@ -97,13 +97,17 @@ public BaseServiceException(IOException exception, boolean idempotent) { String debugInfo = null; if (exception instanceof GoogleJsonResponseException) { GoogleJsonError jsonError = ((GoogleJsonResponseException) exception).getDetails(); - Error error = error(jsonError); - code = error.code; - reason = error.reason; - if (reason != null) { - GoogleJsonError.ErrorInfo errorInfo = jsonError.getErrors().get(0); - location = errorInfo.getLocation(); - debugInfo = (String) errorInfo.get("debugInfo"); + if (jsonError != null) { + Error error = error(jsonError); + code = error.code; + reason = error.reason; + if (reason != null) { + GoogleJsonError.ErrorInfo errorInfo = jsonError.getErrors().get(0); + location = errorInfo.getLocation(); + debugInfo = (String) errorInfo.get("debugInfo"); + } + } else { + code = ((GoogleJsonResponseException) exception).getStatusCode(); } } this.code = code; @@ -207,7 +211,10 @@ protected static Error error(GoogleJsonError error) { protected static String message(IOException exception) { if (exception instanceof GoogleJsonResponseException) { - return ((GoogleJsonResponseException) exception).getDetails().getMessage(); + GoogleJsonError details = ((GoogleJsonResponseException) exception).getDetails(); + if (details != null) { + return details.getMessage(); + } } return exception.getMessage(); } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java index 4d9214ef5929..cac47b4bd248 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java @@ -31,6 +31,7 @@ import static com.google.gcloud.spi.StorageRpc.Option.PREFIX; import static com.google.gcloud.spi.StorageRpc.Option.VERSIONS; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; +import static javax.servlet.http.HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE; import com.google.api.client.googleapis.batch.json.JsonBatchCallback; import com.google.api.client.googleapis.json.GoogleJsonError; @@ -453,7 +454,11 @@ public Tuple read(StorageObject from, Map options, lo String etag = req.getLastResponseHeaders().getETag(); return Tuple.of(etag, output.toByteArray()); } catch (IOException ex) { - throw translate(ex); + StorageException serviceException = translate(ex); + if (serviceException.code() == SC_REQUESTED_RANGE_NOT_SATISFIABLE) { + return Tuple.of(null, new byte[0]); + } + throw serviceException; } } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java index 2b9643434ecc..52b8c39321da 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java @@ -127,7 +127,7 @@ public Tuple call() { return storageRpc.read(storageObject, requestOptions, position, toRead); } }, serviceOptions.retryParams(), StorageImpl.EXCEPTION_HANDLER); - if (lastEtag != null && !Objects.equals(result.x(), lastEtag)) { + if (result.y().length > 0 && lastEtag != null && !Objects.equals(result.x(), lastEtag)) { StringBuilder messageBuilder = new StringBuilder(); messageBuilder.append("Blob ").append(blob).append(" was updated while reading"); throw new StorageException(0, messageBuilder.toString()); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index a411cdd60bfb..b62a54aff818 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -54,6 +54,7 @@ import org.junit.Test; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -834,14 +835,18 @@ public void testReadAndWriteChannelsWithDifferentFileSize() throws IOException { byte[] bytes = new byte[blobSize]; rnd.nextBytes(bytes); try (WriteChannel writer = storage.writer(blob)) { - writer.write(ByteBuffer.wrap(BLOB_BYTE_CONTENT)); + writer.write(ByteBuffer.wrap(bytes)); } - ByteBuffer readBytes; + ByteArrayOutputStream output = new ByteArrayOutputStream(); try (ReadChannel reader = storage.reader(blob.blobId())) { - readBytes = ByteBuffer.allocate(BLOB_BYTE_CONTENT.length); - reader.read(readBytes); + ByteBuffer buffer = ByteBuffer.allocate(64 * 1024); + while (reader.read(buffer) > 0) { + buffer.flip(); + output.write(buffer.array(), 0, buffer.limit()); + buffer.clear(); + } } - assertArrayEquals(BLOB_BYTE_CONTENT, readBytes.array()); + assertArrayEquals(bytes, output.toByteArray()); assertTrue(storage.delete(BUCKET, blobName)); } } From d930b4bbc2833d82ce84c13e3c6704695aebd91c Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Tue, 8 Mar 2016 12:29:17 +0100 Subject: [PATCH 119/203] Remove BlobListOption.recursive option and fix delimiter handling - Add BlobListOption.currentDirectory option that sets the '/' delimiter - Add isDirectory method to BlobInfo objects - Change StorageRpc.list(bucket) method to add prefixes to the list of storage objects - Add unit and integration tests --- .../google/gcloud/spi/DefaultStorageRpc.java | 21 ++++++- .../com/google/gcloud/spi/StorageRpc.java | 2 +- .../java/com/google/gcloud/storage/Blob.java | 6 ++ .../com/google/gcloud/storage/BlobInfo.java | 27 ++++++++ .../com/google/gcloud/storage/Storage.java | 16 +++-- .../google/gcloud/storage/StorageImpl.java | 3 +- .../google/gcloud/storage/StorageOptions.java | 31 +--------- .../google/gcloud/storage/BlobInfoTest.java | 62 +++++++++++++++++++ .../com/google/gcloud/storage/BlobTest.java | 38 +++++++++++- .../gcloud/storage/SerializationTest.java | 1 - .../gcloud/storage/StorageImplTest.java | 16 +++++ .../gcloud/storage/it/ITStorageTest.java | 46 ++++++++++++++ 12 files changed, 228 insertions(+), 41 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java index cac47b4bd248..fcbfe5514d1e 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java @@ -57,8 +57,10 @@ import com.google.api.services.storage.model.ComposeRequest.SourceObjects.ObjectPreconditions; import com.google.api.services.storage.model.Objects; import com.google.api.services.storage.model.StorageObject; +import com.google.common.base.Function; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gcloud.storage.StorageException; @@ -67,6 +69,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -151,7 +154,7 @@ public Tuple> list(Map options) { } @Override - public Tuple> list(String bucket, Map options) { + public Tuple> list(final String bucket, Map options) { try { Objects objects = storage.objects() .list(bucket) @@ -163,8 +166,20 @@ public Tuple> list(String bucket, Map .setPageToken(PAGE_TOKEN.getString(options)) .setFields(FIELDS.getString(options)) .execute(); - return Tuple.>of( - objects.getNextPageToken(), objects.getItems()); + Iterable storageObjects = Iterables.concat( + objects.getItems() != null ? objects.getItems() : ImmutableList.of(), + objects.getPrefixes() != null + ? Lists.transform(objects.getPrefixes(), new Function() { + @Override + public StorageObject apply(String prefix) { + return new StorageObject() + .set("isDirectory", true) + .setBucket(bucket) + .setName(prefix) + .setSize(BigInteger.ZERO); + } + }) : ImmutableList.of()); + return Tuple.of(objects.getNextPageToken(), storageObjects); } catch (IOException ex) { throw translate(ex); } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java index c76fc0f2d3b8..ab4a7a9d0acb 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java @@ -344,7 +344,7 @@ void write(String uploadId, byte[] toWrite, int toWriteOffset, long destOffset, /** * Continues rewriting on an already open rewrite channel. * - * @throws StorageException + * @throws StorageException upon failure */ RewriteResponse continueRewrite(RewriteResponse previousResponse); } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java index aea424ca4063..79ad3804faf0 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java @@ -290,6 +290,12 @@ Builder updateTime(Long updateTime) { return this; } + @Override + Builder isDirectory(boolean isDirectory) { + infoBuilder.isDirectory(isDirectory); + return this; + } + @Override public Blob build() { return new Blob(storage, infoBuilder); diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java index 54fabe87d766..9d981aeeafda 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java @@ -78,6 +78,7 @@ public StorageObject apply(BlobInfo blobInfo) { private final String contentDisposition; private final String contentLanguage; private final Integer componentCount; + private final boolean isDirectory; /** * This class is meant for internal use only. Users are discouraged from using this class. @@ -187,6 +188,8 @@ public abstract static class Builder { abstract Builder updateTime(Long updateTime); + abstract Builder isDirectory(boolean isDirectory); + /** * Creates a {@code BlobInfo} object. */ @@ -215,6 +218,7 @@ static final class BuilderImpl extends Builder { private Long metageneration; private Long deleteTime; private Long updateTime; + private Boolean isDirectory; BuilderImpl(BlobId blobId) { this.blobId = blobId; @@ -241,6 +245,7 @@ static final class BuilderImpl extends Builder { metageneration = blobInfo.metageneration; deleteTime = blobInfo.deleteTime; updateTime = blobInfo.updateTime; + isDirectory = blobInfo.isDirectory; } @Override @@ -364,6 +369,12 @@ Builder updateTime(Long updateTime) { return this; } + @Override + Builder isDirectory(boolean isDirectory) { + this.isDirectory = isDirectory; + return this; + } + @Override public BlobInfo build() { checkNotNull(blobId); @@ -392,6 +403,7 @@ public BlobInfo build() { metageneration = builder.metageneration; deleteTime = builder.deleteTime; updateTime = builder.updateTime; + isDirectory = firstNonNull(builder.isDirectory, Boolean.FALSE); } /** @@ -588,6 +600,18 @@ public Long updateTime() { return updateTime; } + /** + * Returns {@code true} if the current blob represents a directory. This can only happen if the + * blob is returned by {@link Storage#list(String, Storage.BlobListOption...)} when the + * {@link Storage.BlobListOption#currentDirectory()} option is used. If {@code true} only + * {@link #blobId()} and {@link #size()} are set for the current blob: {@link BlobId#name()} ends + * with the '/' character, {@link BlobId#generation()} returns {@code null} and {@link #size()} is + * {@code 0}. + */ + public boolean isDirectory() { + return isDirectory; + } + /** * Returns a builder for the current blob. */ @@ -761,6 +785,9 @@ public Acl apply(ObjectAccessControl objectAccessControl) { } })); } + if (storageObject.get("isDirectory") != null) { + builder.isDirectory(Boolean.TRUE); + } return builder.build(); } } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 065bcca7c9e8..e1ab337cdbdf 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -694,10 +694,17 @@ public static BlobListOption prefix(String prefix) { } /** - * Returns an option to specify whether blob listing should include subdirectories or not. + * If specified, results are returned in a directory-like mode. Blobs whose names, aside from + * a possible {@link #prefix(String)}, do not contain the '/' delimiter are returned as is. + * Blobs whose names, aside from a possible {@link #prefix(String)}, contain the '/' delimiter, + * will have their name truncated after the delimiter and will be returned as {@link Blob} + * objects where only {@link Blob#blobId()}, {@link Blob#size()} and {@link Blob#isDirectory()} + * are set. For such directory blobs, ({@link BlobId#generation()} returns {@code null}), + * {@link Blob#size()} returns {@code 0} while {@link Blob#isDirectory()} returns {@code true}. + * Duplicate directory blobs are omitted. */ - public static BlobListOption recursive(boolean recursive) { - return new BlobListOption(StorageRpc.Option.DELIMITER, recursive); + public static BlobListOption currentDirectory() { + return new BlobListOption(StorageRpc.Option.DELIMITER, true); } /** @@ -1289,7 +1296,8 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx Page list(BucketListOption... options); /** - * Lists the bucket's blobs. + * Lists the bucket's blobs. If the {@link BlobListOption#currentDirectory()} option is provided, + * results are returned in a directory-like mode. * * @throws StorageException upon failure */ diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java index de77cba021a1..788072905871 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java @@ -76,6 +76,7 @@ final class StorageImpl extends BaseService implements Storage { private static final byte[] EMPTY_BYTE_ARRAY = {}; private static final String EMPTY_BYTE_ARRAY_MD5 = "1B2M2Y8AsgTpgAmY7PhCfg=="; private static final String EMPTY_BYTE_ARRAY_CRC32C = "AAAAAA=="; + private static final String PATH_DELIMITER = "/"; private static final Function, Boolean> DELETE_FUNCTION = new Function, Boolean>() { @@ -669,7 +670,7 @@ private static void addToOptionMap(StorageRpc.Option getOption, StorageRpc.O } Boolean value = (Boolean) temp.remove(DELIMITER); if (Boolean.TRUE.equals(value)) { - temp.put(DELIMITER, options().pathDelimiter()); + temp.put(DELIMITER, PATH_DELIMITER); } if (useAsSource) { addToOptionMap(IF_GENERATION_MATCH, IF_SOURCE_GENERATION_MATCH, generation, temp); diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java index bd30cb173366..ca9b8944ea8b 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java @@ -16,14 +16,12 @@ package com.google.gcloud.storage; -import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableSet; import com.google.gcloud.ServiceOptions; import com.google.gcloud.spi.DefaultStorageRpc; import com.google.gcloud.spi.StorageRpc; import com.google.gcloud.spi.StorageRpcFactory; -import java.util.Objects; import java.util.Set; public class StorageOptions extends ServiceOptions { @@ -31,9 +29,6 @@ public class StorageOptions extends ServiceOptions SCOPES = ImmutableSet.of(GCS_SCOPE); - private static final String DEFAULT_PATH_DELIMITER = "/"; - - private final String pathDelimiter; public static class DefaultStorageFactory implements StorageFactory { @@ -58,24 +53,10 @@ public StorageRpc create(StorageOptions options) { public static class Builder extends ServiceOptions.Builder { - private String pathDelimiter; - private Builder() {} private Builder(StorageOptions options) { super(options); - pathDelimiter = options.pathDelimiter; - } - - /** - * Sets the path delimiter for the storage service. - * - * @param pathDelimiter the path delimiter to set - * @return the builder - */ - public Builder pathDelimiter(String pathDelimiter) { - this.pathDelimiter = pathDelimiter; - return this; } @Override @@ -86,7 +67,6 @@ public StorageOptions build() { private StorageOptions(Builder builder) { super(StorageFactory.class, StorageRpcFactory.class, builder); - pathDelimiter = MoreObjects.firstNonNull(builder.pathDelimiter, DEFAULT_PATH_DELIMITER); } @SuppressWarnings("unchecked") @@ -106,13 +86,6 @@ protected Set scopes() { return SCOPES; } - /** - * Returns the storage service's path delimiter. - */ - public String pathDelimiter() { - return pathDelimiter; - } - /** * Returns a default {@code StorageOptions} instance. */ @@ -128,7 +101,7 @@ public Builder toBuilder() { @Override public int hashCode() { - return baseHashCode() ^ Objects.hash(pathDelimiter); + return baseHashCode(); } @Override @@ -137,7 +110,7 @@ public boolean equals(Object obj) { return false; } StorageOptions other = (StorageOptions) obj; - return baseEquals(other) && Objects.equals(pathDelimiter, other.pathDelimiter); + return baseEquals(other); } public static Builder builder() { diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobInfoTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobInfoTest.java index a1cc01f4287c..029181c6c07b 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobInfoTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobInfoTest.java @@ -20,7 +20,11 @@ import static com.google.gcloud.storage.Acl.Role.READER; import static com.google.gcloud.storage.Acl.Role.WRITER; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import com.google.api.services.storage.model.StorageObject; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gcloud.storage.Acl.Project; @@ -28,6 +32,7 @@ import org.junit.Test; +import java.math.BigInteger; import java.util.List; import java.util.Map; @@ -76,6 +81,10 @@ public class BlobInfoTest { .size(SIZE) .updateTime(UPDATE_TIME) .build(); + private static final BlobInfo DIRECTORY_INFO = BlobInfo.builder("b", "n/") + .size(0L) + .isDirectory(true) + .build(); @Test public void testToBuilder() { @@ -118,6 +127,30 @@ public void testBuilder() { assertEquals(SELF_LINK, BLOB_INFO.selfLink()); assertEquals(SIZE, BLOB_INFO.size()); assertEquals(UPDATE_TIME, BLOB_INFO.updateTime()); + assertFalse(BLOB_INFO.isDirectory()); + assertEquals("b", DIRECTORY_INFO.bucket()); + assertEquals("n/", DIRECTORY_INFO.name()); + assertNull(DIRECTORY_INFO.acl()); + assertNull(DIRECTORY_INFO.componentCount()); + assertNull(DIRECTORY_INFO.contentType()); + assertNull(DIRECTORY_INFO.cacheControl()); + assertNull(DIRECTORY_INFO.contentDisposition()); + assertNull(DIRECTORY_INFO.contentEncoding()); + assertNull(DIRECTORY_INFO.contentLanguage()); + assertNull(DIRECTORY_INFO.crc32c()); + assertNull(DIRECTORY_INFO.deleteTime()); + assertNull(DIRECTORY_INFO.etag()); + assertNull(DIRECTORY_INFO.generation()); + assertNull(DIRECTORY_INFO.id()); + assertNull(DIRECTORY_INFO.md5()); + assertNull(DIRECTORY_INFO.mediaLink()); + assertNull(DIRECTORY_INFO.metadata()); + assertNull(DIRECTORY_INFO.metageneration()); + assertNull(DIRECTORY_INFO.owner()); + assertNull(DIRECTORY_INFO.selfLink()); + assertEquals(0L, (long) DIRECTORY_INFO.size()); + assertNull(DIRECTORY_INFO.updateTime()); + assertTrue(DIRECTORY_INFO.isDirectory()); } private void compareBlobs(BlobInfo expected, BlobInfo value) { @@ -151,6 +184,35 @@ public void testToPbAndFromPb() { compareBlobs(BLOB_INFO, BlobInfo.fromPb(BLOB_INFO.toPb())); BlobInfo blobInfo = BlobInfo.builder(BlobId.of("b", "n")).build(); compareBlobs(blobInfo, BlobInfo.fromPb(blobInfo.toPb())); + StorageObject object = new StorageObject() + .setName("n/") + .setBucket("b") + .setSize(BigInteger.ZERO) + .set("isDirectory", true); + blobInfo = BlobInfo.fromPb(object); + assertEquals("b", blobInfo.bucket()); + assertEquals("n/", blobInfo.name()); + assertNull(blobInfo.acl()); + assertNull(blobInfo.componentCount()); + assertNull(blobInfo.contentType()); + assertNull(blobInfo.cacheControl()); + assertNull(blobInfo.contentDisposition()); + assertNull(blobInfo.contentEncoding()); + assertNull(blobInfo.contentLanguage()); + assertNull(blobInfo.crc32c()); + assertNull(blobInfo.deleteTime()); + assertNull(blobInfo.etag()); + assertNull(blobInfo.generation()); + assertNull(blobInfo.id()); + assertNull(blobInfo.md5()); + assertNull(blobInfo.mediaLink()); + assertNull(blobInfo.metadata()); + assertNull(blobInfo.metageneration()); + assertNull(blobInfo.owner()); + assertNull(blobInfo.selfLink()); + assertEquals(0L, (long) blobInfo.size()); + assertNull(blobInfo.updateTime()); + assertTrue(blobInfo.isDirectory()); } @Test diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java index c7508593f8c9..5a6173c08199 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java @@ -95,6 +95,10 @@ public class BlobTest { .updateTime(UPDATE_TIME) .build(); private static final BlobInfo BLOB_INFO = BlobInfo.builder("b", "n").metageneration(42L).build(); + private static final BlobInfo DIRECTORY_INFO = BlobInfo.builder("b", "n/") + .size(0L) + .isDirectory(true) + .build(); private Storage storage; private Blob blob; @@ -305,18 +309,20 @@ public void testSignUrl() throws Exception { @Test public void testToBuilder() { - expect(storage.options()).andReturn(mockOptions).times(4); + expect(storage.options()).andReturn(mockOptions).times(6); replay(storage); Blob fullBlob = new Blob(storage, new BlobInfo.BuilderImpl(FULL_BLOB_INFO)); assertEquals(fullBlob, fullBlob.toBuilder().build()); Blob simpleBlob = new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO)); assertEquals(simpleBlob, simpleBlob.toBuilder().build()); + Blob directory = new Blob(storage, new BlobInfo.BuilderImpl(DIRECTORY_INFO)); + assertEquals(directory, directory.toBuilder().build()); } @Test public void testBuilder() { initializeExpectedBlob(4); - expect(storage.options()).andReturn(mockOptions).times(2); + expect(storage.options()).andReturn(mockOptions).times(4); replay(storage); Blob.Builder builder = new Blob.Builder(new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO))); Blob blob = builder.acl(ACL) @@ -360,5 +366,33 @@ public void testBuilder() { assertEquals(SELF_LINK, blob.selfLink()); assertEquals(SIZE, blob.size()); assertEquals(UPDATE_TIME, blob.updateTime()); + assertFalse(blob.isDirectory()); + builder = new Blob.Builder(new Blob(storage, new BlobInfo.BuilderImpl(DIRECTORY_INFO))); + blob = builder.blobId(BlobId.of("b", "n/")) + .isDirectory(true) + .size(0L) + .build(); + assertEquals("b", blob.bucket()); + assertEquals("n/", blob.name()); + assertNull(blob.acl()); + assertNull(blob.componentCount()); + assertNull(blob.contentType()); + assertNull(blob.cacheControl()); + assertNull(blob.contentDisposition()); + assertNull(blob.contentEncoding()); + assertNull(blob.contentLanguage()); + assertNull(blob.crc32c()); + assertNull(blob.deleteTime()); + assertNull(blob.etag()); + assertNull(blob.id()); + assertNull(blob.md5()); + assertNull(blob.mediaLink()); + assertNull(blob.metadata()); + assertNull(blob.metageneration()); + assertNull(blob.owner()); + assertNull(blob.selfLink()); + assertEquals(0L, (long) blob.size()); + assertNull(blob.updateTime()); + assertTrue(blob.isDirectory()); } } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java index c9b957bb936a..ac096375b120 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java @@ -90,7 +90,6 @@ public void testServiceOptions() throws Exception { .projectId("p2") .retryParams(RetryParams.defaultInstance()) .authCredentials(null) - .pathDelimiter(":") .build(); serializedCopy = serializeAndDeserialize(options); assertEquals(options, serializedCopy); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java index 612664de14ae..4050e7d6267b 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java @@ -719,6 +719,22 @@ public void testListBlobsWithEmptyFields() { assertArrayEquals(blobList.toArray(), Iterables.toArray(page.values(), Blob.class)); } + @Test + public void testListBlobsCurrentDirectory() { + String cursor = "cursor"; + Map options = ImmutableMap.of(StorageRpc.Option.DELIMITER, "/"); + ImmutableList blobInfoList = ImmutableList.of(BLOB_INFO1, BLOB_INFO2); + Tuple> result = + Tuple.of(cursor, Iterables.transform(blobInfoList, BlobInfo.INFO_TO_PB_FUNCTION)); + EasyMock.expect(storageRpcMock.list(BUCKET_NAME1, options)).andReturn(result); + EasyMock.replay(storageRpcMock); + initializeService(); + ImmutableList blobList = ImmutableList.of(expectedBlob1, expectedBlob2); + Page page = storage.list(BUCKET_NAME1, Storage.BlobListOption.currentDirectory()); + assertEquals(cursor, page.nextPageCursor()); + assertArrayEquals(blobList.toArray(), Iterables.toArray(page.values(), Blob.class)); + } + @Test public void testUpdateBucket() { BucketInfo updatedBucketInfo = BUCKET_INFO1.toBuilder().indexPage("some-page").build(); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index b62a54aff818..563a621c48fb 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -411,6 +411,52 @@ public void testListBlobsVersioned() throws ExecutionException, InterruptedExcep } } + @Test(timeout = 5000) + public void testListBlobsCurrentDirectory() throws InterruptedException { + String directoryName = "test-list-blobs-current-directory/"; + String subdirectoryName = "subdirectory/"; + String[] blobNames = {directoryName + subdirectoryName + "blob1", + directoryName + "blob2"}; + BlobInfo blob1 = BlobInfo.builder(BUCKET, blobNames[0]) + .contentType(CONTENT_TYPE) + .build(); + BlobInfo blob2 = BlobInfo.builder(BUCKET, blobNames[1]) + .contentType(CONTENT_TYPE) + .build(); + Blob remoteBlob1 = storage.create(blob1, BLOB_BYTE_CONTENT); + Blob remoteBlob2 = storage.create(blob2, BLOB_BYTE_CONTENT); + assertNotNull(remoteBlob1); + assertNotNull(remoteBlob2); + Page page = storage.list(BUCKET, + Storage.BlobListOption.prefix("test-list-blobs-current-directory/"), + Storage.BlobListOption.currentDirectory()); + // Listing blobs is eventually consistent, we loop until the list is of the expected size. The + // test fails if timeout is reached. + while (Iterators.size(page.iterateAll()) != 2) { + Thread.sleep(500); + page = storage.list(BUCKET, + Storage.BlobListOption.prefix("test-list-blobs-current-directory/"), + Storage.BlobListOption.currentDirectory()); + } + Iterator iterator = page.iterateAll(); + while (iterator.hasNext()) { + Blob remoteBlob = iterator.next(); + assertEquals(BUCKET, remoteBlob.bucket()); + if (remoteBlob.name().equals(blobNames[1])) { + assertEquals(CONTENT_TYPE, remoteBlob.contentType()); + assertEquals(BLOB_BYTE_CONTENT.length, (long) remoteBlob.size()); + assertFalse(remoteBlob.isDirectory()); + } else if (remoteBlob.name().equals(directoryName + subdirectoryName)) { + assertEquals(0L, (long) remoteBlob.size()); + assertTrue(remoteBlob.isDirectory()); + } else { + fail("Unexpected blob with name " + remoteBlob.name()); + } + } + assertTrue(remoteBlob1.delete()); + assertTrue(remoteBlob2.delete()); + } + @Test public void testUpdateBlob() { String blobName = "test-update-blob"; From 0f4a7a0fd9d2927fd35c09712e7f531411322739 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Tue, 8 Mar 2016 18:41:22 +0100 Subject: [PATCH 120/203] Release version 0.1.5 --- gcloud-java-bigquery/pom.xml | 2 +- gcloud-java-contrib/pom.xml | 2 +- gcloud-java-core/pom.xml | 2 +- gcloud-java-datastore/pom.xml | 2 +- gcloud-java-examples/pom.xml | 2 +- gcloud-java-resourcemanager/pom.xml | 2 +- gcloud-java-storage/pom.xml | 2 +- gcloud-java/pom.xml | 2 +- pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcloud-java-bigquery/pom.xml b/gcloud-java-bigquery/pom.xml index 34ddd7679e97..ac42c839bdb7 100644 --- a/gcloud-java-bigquery/pom.xml +++ b/gcloud-java-bigquery/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5-SNAPSHOT + 0.1.5 gcloud-java-bigquery diff --git a/gcloud-java-contrib/pom.xml b/gcloud-java-contrib/pom.xml index dd976991e2af..78e7670d3ae8 100644 --- a/gcloud-java-contrib/pom.xml +++ b/gcloud-java-contrib/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5-SNAPSHOT + 0.1.5 gcloud-java-contrib diff --git a/gcloud-java-core/pom.xml b/gcloud-java-core/pom.xml index d07a567b7e5a..8525fde68174 100644 --- a/gcloud-java-core/pom.xml +++ b/gcloud-java-core/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5-SNAPSHOT + 0.1.5 gcloud-java-core diff --git a/gcloud-java-datastore/pom.xml b/gcloud-java-datastore/pom.xml index 452986ba5ea3..67e72245df25 100644 --- a/gcloud-java-datastore/pom.xml +++ b/gcloud-java-datastore/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5-SNAPSHOT + 0.1.5 gcloud-java-datastore diff --git a/gcloud-java-examples/pom.xml b/gcloud-java-examples/pom.xml index 862d48c89eaa..9586536e3624 100644 --- a/gcloud-java-examples/pom.xml +++ b/gcloud-java-examples/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5-SNAPSHOT + 0.1.5 gcloud-java-examples diff --git a/gcloud-java-resourcemanager/pom.xml b/gcloud-java-resourcemanager/pom.xml index 40a865f4db68..513da0b67b7e 100644 --- a/gcloud-java-resourcemanager/pom.xml +++ b/gcloud-java-resourcemanager/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5-SNAPSHOT + 0.1.5 gcloud-java-resourcemanager diff --git a/gcloud-java-storage/pom.xml b/gcloud-java-storage/pom.xml index f18283b70bc8..01b8f5e01c3f 100644 --- a/gcloud-java-storage/pom.xml +++ b/gcloud-java-storage/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5-SNAPSHOT + 0.1.5 gcloud-java-storage diff --git a/gcloud-java/pom.xml b/gcloud-java/pom.xml index adfa716fe27b..927455dfb159 100644 --- a/gcloud-java/pom.xml +++ b/gcloud-java/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5-SNAPSHOT + 0.1.5 diff --git a/pom.xml b/pom.xml index 28bcba708f7f..b656f5853972 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.gcloud gcloud-java-pom pom - 0.1.5-SNAPSHOT + 0.1.5 GCloud Java https://github.com/GoogleCloudPlatform/gcloud-java From 1f1f4b05c8a5073bcf91da1160da5aac16cab96a Mon Sep 17 00:00:00 2001 From: travis-ci Date: Tue, 8 Mar 2016 18:26:13 +0000 Subject: [PATCH 121/203] Updating version in README files. [ci skip] --- README.md | 6 +++--- gcloud-java-bigquery/README.md | 6 +++--- gcloud-java-contrib/README.md | 6 +++--- gcloud-java-core/README.md | 6 +++--- gcloud-java-datastore/README.md | 6 +++--- gcloud-java-examples/README.md | 6 +++--- gcloud-java-resourcemanager/README.md | 6 +++--- gcloud-java-storage/README.md | 6 +++--- gcloud-java/README.md | 6 +++--- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 32a0f539425e..68c624c37489 100644 --- a/README.md +++ b/README.md @@ -29,16 +29,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java - 0.1.4 + 0.1.5 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java:0.1.4' +compile 'com.google.gcloud:gcloud-java:0.1.5' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.4" +libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.5" ``` Example Applications diff --git a/gcloud-java-bigquery/README.md b/gcloud-java-bigquery/README.md index 58633ba635f9..3387cd8c4f41 100644 --- a/gcloud-java-bigquery/README.md +++ b/gcloud-java-bigquery/README.md @@ -22,16 +22,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-bigquery - 0.1.4 + 0.1.5 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-bigquery:0.1.4' +compile 'com.google.gcloud:gcloud-java-bigquery:0.1.5' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.4" +libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.5" ``` Example Application diff --git a/gcloud-java-contrib/README.md b/gcloud-java-contrib/README.md index 7a935192891d..426417d54e87 100644 --- a/gcloud-java-contrib/README.md +++ b/gcloud-java-contrib/README.md @@ -16,16 +16,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-contrib - 0.1.4 + 0.1.5 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-contrib:0.1.4' +compile 'com.google.gcloud:gcloud-java-contrib:0.1.5' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-contrib" % "0.1.4" +libraryDependencies += "com.google.gcloud" % "gcloud-java-contrib" % "0.1.5" ``` Java Versions diff --git a/gcloud-java-core/README.md b/gcloud-java-core/README.md index bc9463b9cc2b..fc5f481f8ec3 100644 --- a/gcloud-java-core/README.md +++ b/gcloud-java-core/README.md @@ -19,16 +19,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-core - 0.1.4 + 0.1.5 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-core:0.1.4' +compile 'com.google.gcloud:gcloud-java-core:0.1.5' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-core" % "0.1.4" +libraryDependencies += "com.google.gcloud" % "gcloud-java-core" % "0.1.5" ``` Troubleshooting diff --git a/gcloud-java-datastore/README.md b/gcloud-java-datastore/README.md index dd341ba244c3..0d89a0a07e3e 100644 --- a/gcloud-java-datastore/README.md +++ b/gcloud-java-datastore/README.md @@ -22,16 +22,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-datastore - 0.1.4 + 0.1.5 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-datastore:0.1.4' +compile 'com.google.gcloud:gcloud-java-datastore:0.1.5' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-datastore" % "0.1.4" +libraryDependencies += "com.google.gcloud" % "gcloud-java-datastore" % "0.1.5" ``` Example Application diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md index 59fbca11e219..7d54b8f3e1a9 100644 --- a/gcloud-java-examples/README.md +++ b/gcloud-java-examples/README.md @@ -19,16 +19,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-examples - 0.1.4 + 0.1.5 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-examples:0.1.4' +compile 'com.google.gcloud:gcloud-java-examples:0.1.5' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-examples" % "0.1.4" +libraryDependencies += "com.google.gcloud" % "gcloud-java-examples" % "0.1.5" ``` To run examples from your command line: diff --git a/gcloud-java-resourcemanager/README.md b/gcloud-java-resourcemanager/README.md index cd48d6699311..94037e27a709 100644 --- a/gcloud-java-resourcemanager/README.md +++ b/gcloud-java-resourcemanager/README.md @@ -22,16 +22,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-resourcemanager - 0.1.4 + 0.1.5 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-resourcemanager:0.1.4' +compile 'com.google.gcloud:gcloud-java-resourcemanager:0.1.5' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-resourcemanager" % "0.1.4" +libraryDependencies += "com.google.gcloud" % "gcloud-java-resourcemanager" % "0.1.5" ``` Example Application diff --git a/gcloud-java-storage/README.md b/gcloud-java-storage/README.md index f7973544bba2..0ee05b31c10c 100644 --- a/gcloud-java-storage/README.md +++ b/gcloud-java-storage/README.md @@ -22,16 +22,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java-storage - 0.1.4 + 0.1.5 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java-storage:0.1.4' +compile 'com.google.gcloud:gcloud-java-storage:0.1.5' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java-storage" % "0.1.4" +libraryDependencies += "com.google.gcloud" % "gcloud-java-storage" % "0.1.5" ``` Example Application diff --git a/gcloud-java/README.md b/gcloud-java/README.md index c51b4e8fe7bc..e296d0c0c565 100644 --- a/gcloud-java/README.md +++ b/gcloud-java/README.md @@ -27,16 +27,16 @@ If you are using Maven, add this to your pom.xml file com.google.gcloud gcloud-java - 0.1.4 + 0.1.5 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.gcloud:gcloud-java:0.1.4' +compile 'com.google.gcloud:gcloud-java:0.1.5' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.4" +libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.5" ``` Troubleshooting From aa6c173871113775725082517ba113fc0306a619 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Tue, 8 Mar 2016 20:27:32 +0100 Subject: [PATCH 122/203] Update version to 0.1.6-SNAPSHOT --- gcloud-java-bigquery/pom.xml | 2 +- gcloud-java-contrib/pom.xml | 2 +- gcloud-java-core/pom.xml | 2 +- gcloud-java-datastore/pom.xml | 2 +- gcloud-java-examples/pom.xml | 2 +- gcloud-java-resourcemanager/pom.xml | 2 +- gcloud-java-storage/pom.xml | 2 +- gcloud-java/pom.xml | 2 +- pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcloud-java-bigquery/pom.xml b/gcloud-java-bigquery/pom.xml index ac42c839bdb7..9a2137cb987d 100644 --- a/gcloud-java-bigquery/pom.xml +++ b/gcloud-java-bigquery/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5 + 0.1.6-SNAPSHOT gcloud-java-bigquery diff --git a/gcloud-java-contrib/pom.xml b/gcloud-java-contrib/pom.xml index 78e7670d3ae8..bd4a6458dc38 100644 --- a/gcloud-java-contrib/pom.xml +++ b/gcloud-java-contrib/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5 + 0.1.6-SNAPSHOT gcloud-java-contrib diff --git a/gcloud-java-core/pom.xml b/gcloud-java-core/pom.xml index 8525fde68174..6d0ed675b423 100644 --- a/gcloud-java-core/pom.xml +++ b/gcloud-java-core/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5 + 0.1.6-SNAPSHOT gcloud-java-core diff --git a/gcloud-java-datastore/pom.xml b/gcloud-java-datastore/pom.xml index 67e72245df25..977b6db22b14 100644 --- a/gcloud-java-datastore/pom.xml +++ b/gcloud-java-datastore/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5 + 0.1.6-SNAPSHOT gcloud-java-datastore diff --git a/gcloud-java-examples/pom.xml b/gcloud-java-examples/pom.xml index 9586536e3624..111308658c2e 100644 --- a/gcloud-java-examples/pom.xml +++ b/gcloud-java-examples/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5 + 0.1.6-SNAPSHOT gcloud-java-examples diff --git a/gcloud-java-resourcemanager/pom.xml b/gcloud-java-resourcemanager/pom.xml index 513da0b67b7e..c10691d3b07d 100644 --- a/gcloud-java-resourcemanager/pom.xml +++ b/gcloud-java-resourcemanager/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5 + 0.1.6-SNAPSHOT gcloud-java-resourcemanager diff --git a/gcloud-java-storage/pom.xml b/gcloud-java-storage/pom.xml index 01b8f5e01c3f..d5f0f6d98660 100644 --- a/gcloud-java-storage/pom.xml +++ b/gcloud-java-storage/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5 + 0.1.6-SNAPSHOT gcloud-java-storage diff --git a/gcloud-java/pom.xml b/gcloud-java/pom.xml index 927455dfb159..19536faa8c8d 100644 --- a/gcloud-java/pom.xml +++ b/gcloud-java/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5 + 0.1.6-SNAPSHOT diff --git a/pom.xml b/pom.xml index b656f5853972..b9d979c4d467 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.gcloud gcloud-java-pom pom - 0.1.5 + 0.1.6-SNAPSHOT GCloud Java https://github.com/GoogleCloudPlatform/gcloud-java From de9b0d60eee8079223feb6f1f30b069e91e67431 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Wed, 9 Mar 2016 12:34:48 +0100 Subject: [PATCH 123/203] Refactor Storage's delimiter support - Minor fixes to javadoc - Favor firstNonNull over ternary operator when possible - Move prefix-object transformer to static function - Simplify StorageOptions equals method --- .../google/gcloud/spi/DefaultStorageRpc.java | 31 +++++++++++-------- .../com/google/gcloud/storage/BlobInfo.java | 4 +-- .../com/google/gcloud/storage/Storage.java | 16 +++++----- .../google/gcloud/storage/StorageOptions.java | 6 +--- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java index fcbfe5514d1e..ec4447d406cb 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java @@ -14,6 +14,7 @@ package com.google.gcloud.spi; +import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.gcloud.spi.StorageRpc.Option.DELIMITER; import static com.google.gcloud.spi.StorageRpc.Option.FIELDS; import static com.google.gcloud.spi.StorageRpc.Option.IF_GENERATION_MATCH; @@ -58,7 +59,6 @@ import com.google.api.services.storage.model.Objects; import com.google.api.services.storage.model.StorageObject; import com.google.common.base.Function; -import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -167,24 +167,29 @@ public Tuple> list(final String bucket, Map storageObjects = Iterables.concat( - objects.getItems() != null ? objects.getItems() : ImmutableList.of(), + firstNonNull(objects.getItems(), ImmutableList.of()), objects.getPrefixes() != null - ? Lists.transform(objects.getPrefixes(), new Function() { - @Override - public StorageObject apply(String prefix) { - return new StorageObject() - .set("isDirectory", true) - .setBucket(bucket) - .setName(prefix) - .setSize(BigInteger.ZERO); - } - }) : ImmutableList.of()); + ? Lists.transform(objects.getPrefixes(), objectFromPrefix(bucket)) + : ImmutableList.of()); return Tuple.of(objects.getNextPageToken(), storageObjects); } catch (IOException ex) { throw translate(ex); } } + private static Function objectFromPrefix(final String bucket) { + return new Function() { + @Override + public StorageObject apply(String prefix) { + return new StorageObject() + .set("isDirectory", true) + .setBucket(bucket) + .setName(prefix) + .setSize(BigInteger.ZERO); + } + }; + } + @Override public Bucket get(Bucket bucket, Map options) { try { @@ -549,7 +554,7 @@ public String open(StorageObject object, Map options) { HttpRequest httpRequest = requestFactory.buildPostRequest(url, new JsonHttpContent(jsonFactory, object)); httpRequest.getHeaders().set("X-Upload-Content-Type", - MoreObjects.firstNonNull(object.getContentType(), "application/octet-stream")); + firstNonNull(object.getContentType(), "application/octet-stream")); HttpResponse response = httpRequest.execute(); if (response.getStatusCode() != 200) { GoogleJsonError error = new GoogleJsonError(); diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java index 9d981aeeafda..cf509c8f0961 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java @@ -603,7 +603,7 @@ public Long updateTime() { /** * Returns {@code true} if the current blob represents a directory. This can only happen if the * blob is returned by {@link Storage#list(String, Storage.BlobListOption...)} when the - * {@link Storage.BlobListOption#currentDirectory()} option is used. If {@code true} only + * {@link Storage.BlobListOption#currentDirectory()} option is used. When this is the case only * {@link #blobId()} and {@link #size()} are set for the current blob: {@link BlobId#name()} ends * with the '/' character, {@link BlobId#generation()} returns {@code null} and {@link #size()} is * {@code 0}. @@ -785,7 +785,7 @@ public Acl apply(ObjectAccessControl objectAccessControl) { } })); } - if (storageObject.get("isDirectory") != null) { + if (storageObject.containsKey("isDirectory")) { builder.isDirectory(Boolean.TRUE); } return builder.build(); diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index e1ab337cdbdf..0ee18f541284 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -694,14 +694,14 @@ public static BlobListOption prefix(String prefix) { } /** - * If specified, results are returned in a directory-like mode. Blobs whose names, aside from - * a possible {@link #prefix(String)}, do not contain the '/' delimiter are returned as is. - * Blobs whose names, aside from a possible {@link #prefix(String)}, contain the '/' delimiter, - * will have their name truncated after the delimiter and will be returned as {@link Blob} - * objects where only {@link Blob#blobId()}, {@link Blob#size()} and {@link Blob#isDirectory()} - * are set. For such directory blobs, ({@link BlobId#generation()} returns {@code null}), - * {@link Blob#size()} returns {@code 0} while {@link Blob#isDirectory()} returns {@code true}. - * Duplicate directory blobs are omitted. + * If specified, results are returned in a directory-like mode. Blobs whose names, after a + * possible {@link #prefix(String)}, do not contain the '/' delimiter are returned as is. Blobs + * whose names, after a possible {@link #prefix(String)}, contain the '/' delimiter, will have + * their name truncated after the delimiter and will be returned as {@link Blob} objects where + * only {@link Blob#blobId()}, {@link Blob#size()} and {@link Blob#isDirectory()} are set. For + * such directory blobs, ({@link BlobId#generation()} returns {@code null}), {@link Blob#size()} + * returns {@code 0} while {@link Blob#isDirectory()} returns {@code true}. Duplicate directory + * blobs are omitted. */ public static BlobListOption currentDirectory() { return new BlobListOption(StorageRpc.Option.DELIMITER, true); diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java index ca9b8944ea8b..86ce18eb71ec 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java @@ -106,11 +106,7 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (!(obj instanceof StorageOptions)) { - return false; - } - StorageOptions other = (StorageOptions) obj; - return baseEquals(other); + return obj instanceof StorageOptions && baseEquals((StorageOptions) obj); } public static Builder builder() { From 1f06caf21d73921280ce6e724cbaebb6f22169d4 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 24 Feb 2016 10:11:02 -0800 Subject: [PATCH 124/203] The following has been done within multiple iterations: Refactored URL parsing and removed unnecessary doc in local helper. Refactored to use AtomicReference instead of singleton Map. Adjusted tests of paging to test that pages contain expected objects. Added check and test for deleting non-empy zone. Removed RrsetWapper and used tailMap in listing. Added @VisibleForTesting annotations. Added fails to expected exceptions. Added error message checks. Addressed codacy suggestions. Assigned project ID to the helper and test. Added pool of executors instead of spawning one threads. Reduced number of threads. --- .../{ => dns}/testing/LocalDnsHelper.java | 719 ++++------- .../testing/OptionParsers.java} | 63 +- .../com/google/gcloud/spi/DefaultDnsRpc.java | 6 +- .../{ => dns}/testing/LocalDnsHelperTest.java | 1116 ++++++----------- 4 files changed, 678 insertions(+), 1226 deletions(-) rename gcloud-java-dns/src/main/java/com/google/gcloud/{ => dns}/testing/LocalDnsHelper.java (63%) rename gcloud-java-dns/src/main/java/com/google/gcloud/{testing/OptionParsersAndExtractors.java => dns/testing/OptionParsers.java} (80%) rename gcloud-java-dns/src/test/java/com/google/gcloud/{ => dns}/testing/LocalDnsHelperTest.java (63%) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/testing/LocalDnsHelper.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java similarity index 63% rename from gcloud-java-dns/src/main/java/com/google/gcloud/testing/LocalDnsHelper.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java index b8483bc4fcd7..f9cd1a11281e 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/testing/LocalDnsHelper.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.google.gcloud.testing; +package com.google.gcloud.dns.testing; -import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.net.InetAddresses.isInetAddress; import static java.net.HttpURLConnection.HTTP_NO_CONTENT; import static java.net.HttpURLConnection.HTTP_OK; @@ -27,12 +27,12 @@ import com.google.api.services.dns.model.Project; import com.google.api.services.dns.model.Quota; import com.google.api.services.dns.model.ResourceRecordSet; -import com.google.common.base.Function; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; -import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.io.ByteStreams; @@ -54,26 +54,32 @@ import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.NavigableMap; import java.util.NavigableSet; -import java.util.Objects; import java.util.Random; import java.util.Set; +import java.util.SortedMap; import java.util.TreeMap; import java.util.TreeSet; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ConcurrentNavigableMap; import java.util.concurrent.ConcurrentSkipListMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; -import javax.annotation.Nullable; - /** - * A utility to create local Google Cloud DNS mock. + * A local Google Cloud DNS mock. * *

    The mock runs in a separate thread, listening for HTTP requests on the local machine at an * ephemeral port. @@ -81,7 +87,7 @@ *

    While the mock attempts to simulate the service, there are some differences in the behaviour. * The mock will accept any project ID and never returns a notFound or another error because of * project ID. It assumes that all project IDs exist and that the user has all the necessary - * privileges to manipulate any project. Similarly, the local simulation does not work with any + * privileges to manipulate any project. Similarly, the local simulation does not require * verification of domain name ownership. Any request for creating a managed zone will be approved. * The mock does not track quota and will allow the user to exceed it. The mock provides only basic * validation of the DNS data for records of type A and AAAA. It does not validate any other record @@ -97,16 +103,21 @@ public class LocalDnsHelper { private static final Random ID_GENERATOR = new Random(); private static final String VERSION = "v1"; private static final String CONTEXT = "/dns/" + VERSION + "/projects"; - private static final Set SUPPORTED_COMPRESSION_ENCODINGS = - ImmutableSet.of("gzip", "x-gzip"); + private static final Set ENCODINGS = ImmutableSet.of("gzip", "x-gzip"); private static final List TYPES = ImmutableList.of("A", "AAAA", "CNAME", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"); + private static final TreeSet FORBIDDEN = Sets.newTreeSet( + ImmutableList.of("google.com.", "com.", "example.com.", "net.", "org.")); + private static final Pattern ZONE_NAME_RE = Pattern.compile("[a-z][a-z0-9-]*"); + private static final ScheduledExecutorService EXECUTORS = + Executors.newScheduledThreadPool(2, Executors.defaultThreadFactory()); + private static final String PROJECT_ID = "dummyprojectid"; static { try { BASE_CONTEXT = new URI(CONTEXT); } catch (URISyntaxException e) { - throw new RuntimeException( + throw new IllegalArgumentException( "Could not initialize LocalDnsHelper due to URISyntaxException.", e); } } @@ -139,67 +150,7 @@ private enum CallRegex { } /** - * Wraps DNS data by adding a timestamp and id which is used for paging and listing. - */ - static class RrsetWrapper { - static final Function WRAP_FUNCTION = - new Function() { - @Nullable - @Override - public RrsetWrapper apply(@Nullable ResourceRecordSet input) { - return new RrsetWrapper(input); - } - }; - private final ResourceRecordSet rrset; - private final Long timestamp = System.currentTimeMillis(); - private String id; - - RrsetWrapper(ResourceRecordSet rrset) { - // The constructor creates a copy in order to prevent side effects. - this.rrset = new ResourceRecordSet(); - this.rrset.setName(rrset.getName()); - this.rrset.setTtl(rrset.getTtl()); - this.rrset.setRrdatas(ImmutableList.copyOf(rrset.getRrdatas())); - this.rrset.setType(rrset.getType()); - } - - void setId(String id) { - this.id = id; - } - - String id() { - return id; - } - - /** - * Equals does not care about the listing id and timestamp metadata, just the rrset. - */ - @Override - public boolean equals(Object other) { - return (other instanceof RrsetWrapper) && Objects.equals(rrset, ((RrsetWrapper) other).rrset); - } - - @Override - public int hashCode() { - return Objects.hash(rrset); - } - - ResourceRecordSet rrset() { - return rrset; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("rrset", rrset) - .add("timestamp", timestamp) - .add("id", id) - .toString(); - } - } - - /** - * Associates a project with a collection of ManagedZones. Thread safe. + * Associates a project with a collection of ManagedZones. */ static class ProjectContainer { private final Project project; @@ -220,29 +171,24 @@ ConcurrentSkipListMap zones() { } /** - * Associates a zone with a collection of changes and dns records. Thread safe. + * Associates a zone with a collection of changes and dns records. */ static class ZoneContainer { private final ManagedZone zone; - /** - * DNS records are held in a map to allow for atomic replacement of record sets when applying - * changes. The key for the map is always the zone name. The collection of records is immutable - * and must always exist, i.e., dnsRecords.get(zone.getName()) is never {@code null}. - */ - private final ConcurrentSkipListMap> - dnsRecords = new ConcurrentSkipListMap<>(); + private final AtomicReference> + dnsRecords = new AtomicReference<>(ImmutableSortedMap.of()); private final ConcurrentLinkedQueue changes = new ConcurrentLinkedQueue<>(); ZoneContainer(ManagedZone zone) { this.zone = zone; - this.dnsRecords.put(zone.getName(), ImmutableList.of()); + this.dnsRecords.set(ImmutableSortedMap.of()); } ManagedZone zone() { return zone; } - ConcurrentSkipListMap> dnsRecords() { + AtomicReference> dnsRecords() { return dnsRecords; } @@ -283,6 +229,7 @@ private enum Error { INTERNAL_ERROR(500, "global", "internalError", "INTERNAL_ERROR"), BAD_REQUEST(400, "global", "badRequest", "BAD_REQUEST"), INVALID(400, "global", "invalid", "INVALID"), + CONTAINER_NOT_EMPTY(400, "global", "containerNotEmpty", "CONTAINER_NOT_EMPTY"), NOT_AVAILABLE(400, "global", "managedZoneDnsNameNotAvailable", "NOT_AVAILABLE"), NOT_FOUND(404, "global", "notFound", "NOT_FOUND"), ALREADY_EXISTS(409, "global", "alreadyExists", "ALREADY_EXISTS"), @@ -325,34 +272,38 @@ private String toJson(String message) throws IOException { private class RequestHandler implements HttpHandler { - /** - * Chooses the proper handler for a request. - */ private Response pickHandler(HttpExchange exchange, CallRegex regex) { + URI relative = BASE_CONTEXT.relativize(exchange.getRequestURI()); + String path = relative.getPath(); + String[] tokens = path.split("/"); + String projectId = tokens.length > 0 ? tokens[0] : null; + String zoneName = tokens.length > 2 ? tokens[2] : null; + String changeId = tokens.length > 4 ? tokens[4] : null; + String query = relative.getQuery(); switch (regex) { case CHANGE_GET: - return handleChangeGet(exchange); + return getChange(projectId, zoneName, changeId, query); case CHANGE_LIST: - return handleChangeList(exchange); + return listChanges(projectId, zoneName, query); case ZONE_GET: - return handleZoneGet(exchange); + return getZone(projectId, zoneName, query); case ZONE_DELETE: - return handleZoneDelete(exchange); + return deleteZone(projectId, zoneName); case ZONE_LIST: - return handleZoneList(exchange); + return listZones(projectId, query); case PROJECT_GET: - return handleProjectGet(exchange); + return getProject(projectId, query); case RECORD_LIST: - return handleDnsRecordList(exchange); + return listDnsRecords(projectId, zoneName, query); case ZONE_CREATE: try { - return handleZoneCreate(exchange); + return handleZoneCreate(exchange, projectId, query); } catch (IOException ex) { return Error.BAD_REQUEST.response(ex.getMessage()); } case CHANGE_CREATE: try { - return handleChangeCreate(exchange); + return handleChangeCreate(exchange, projectId, zoneName, query); } catch (IOException ex) { return Error.BAD_REQUEST.response(ex.getMessage()); } @@ -367,122 +318,53 @@ public void handle(HttpExchange exchange) throws IOException { String rawPath = exchange.getRequestURI().getRawPath(); for (CallRegex regex : CallRegex.values()) { if (requestMethod.equals(regex.method) && rawPath.matches(regex.pathRegex)) { - // there is a match, pass the handling accordingly Response response = pickHandler(exchange, regex); writeResponse(exchange, response); - return; // only one match is possible + return; } } - // could not be matched, the service returns 404 page not found here - writeResponse(exchange, Error.NOT_FOUND.response("The url does not match any API call.")); - } - - private Response handleZoneDelete(HttpExchange exchange) { - String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); - String[] tokens = path.split("/"); - String projectId = tokens[0]; - String zoneName = tokens[2]; - return deleteZone(projectId, zoneName); - } - - private Response handleZoneGet(HttpExchange exchange) { - String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); - String[] tokens = path.split("/"); - String projectId = tokens[0]; - String zoneName = tokens[2]; - String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); - String[] fields = OptionParsersAndExtractors.parseGetOptions(query); - return getZone(projectId, zoneName, fields); - } - - private Response handleZoneList(HttpExchange exchange) { - String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); - String[] tokens = path.split("/"); - String projectId = tokens[0]; - String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); - Map options = OptionParsersAndExtractors.parseListZonesOptions(query); - return listZones(projectId, options); - } - - private Response handleProjectGet(HttpExchange exchange) { - String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); - String[] tokens = path.split("/"); - String projectId = tokens[0]; - String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); - String[] fields = OptionParsersAndExtractors.parseGetOptions(query); - return getProject(projectId, fields); + writeResponse(exchange, Error.NOT_FOUND.response(String.format( + "The url %s for %s method does not match any API call.", + requestMethod, exchange.getRequestURI()))); } /** * @throws IOException if the request cannot be parsed. */ - private Response handleChangeCreate(HttpExchange exchange) throws IOException { - String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); - String[] tokens = path.split("/"); - String projectId = tokens[0]; - String zoneName = tokens[2]; - String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); - String[] fields = OptionParsersAndExtractors.parseGetOptions(query); + private Response handleChangeCreate(HttpExchange exchange, String projectId, String zoneName, + String query) throws IOException { String requestBody = decodeContent(exchange.getRequestHeaders(), exchange.getRequestBody()); - Change change = jsonFactory.fromString(requestBody, Change.class); + Change change; + try { + change = jsonFactory.fromString(requestBody, Change.class); + } catch (IllegalArgumentException ex) { + return Error.REQUIRED.response( + "The 'entity.change' parameter is required but was missing."); + } + String[] fields = OptionParsers.parseGetOptions(query); return createChange(projectId, zoneName, change, fields); } - private Response handleChangeGet(HttpExchange exchange) { - String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); - String[] tokens = path.split("/"); - String projectId = tokens[0]; - String zoneName = tokens[2]; - String changeId = tokens[4]; - String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); - String[] fields = OptionParsersAndExtractors.parseGetOptions(query); - return getChange(projectId, zoneName, changeId, fields); - } - - private Response handleChangeList(HttpExchange exchange) { - String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); - String[] tokens = path.split("/"); - String projectId = tokens[0]; - String zoneName = tokens[2]; - String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); - Map options = OptionParsersAndExtractors.parseListChangesOptions(query); - return listChanges(projectId, zoneName, options); - } - - private Response handleDnsRecordList(HttpExchange exchange) { - String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); - String[] tokens = path.split("/"); - String projectId = tokens[0]; - String zoneName = tokens[2]; - String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); - Map options = OptionParsersAndExtractors.parseListDnsRecordsOptions(query); - return listDnsRecords(projectId, zoneName, options); - } - /** * @throws IOException if the request cannot be parsed. */ - private Response handleZoneCreate(HttpExchange exchange) throws IOException { - String path = BASE_CONTEXT.relativize(exchange.getRequestURI()).getPath(); - String[] tokens = path.split("/"); - String projectId = tokens[0]; - String query = BASE_CONTEXT.relativize(exchange.getRequestURI()).getQuery(); - String[] options = OptionParsersAndExtractors.parseGetOptions(query); + private Response handleZoneCreate(HttpExchange exchange, String projectId, String query) + throws IOException { String requestBody = decodeContent(exchange.getRequestHeaders(), exchange.getRequestBody()); ManagedZone zone; try { - // IllegalArgumentException if the request body is an empty string zone = jsonFactory.fromString(requestBody, ManagedZone.class); } catch (IllegalArgumentException ex) { return Error.REQUIRED.response( "The 'entity.managedZone' parameter is required but was missing."); } + String[] options = OptionParsers.parseGetOptions(query); return createZone(projectId, zone, options); } } private LocalDnsHelper(long delay) { - this.delayChange = delay; // 0 makes this synchronous + this.delayChange = delay; try { server = HttpServer.create(new InetSocketAddress(0), 0); port = server.getAddress().getPort(); @@ -501,9 +383,9 @@ ConcurrentSkipListMap projects() { /** * Creates new {@link LocalDnsHelper} instance that listens to requests on the local machine. This - * instance processes changes separate threads. The parameter determines how long a thread should - * wait before processing a change. If it is set to 0, the threading is turned off and the mock - * will behave synchronously. + * instance processes changes in separate thread. The parameter determines how long a thread + * should wait before processing a change. If it is set to 0, the threading is turned off and the + * mock will behave synchronously. * * @param delay delay for processing changes in ms or 0 for synchronous processing */ @@ -512,10 +394,10 @@ public static LocalDnsHelper create(Long delay) { } /** - * Returns a DnsOptions instance that sets the host to use the mock server. + * Returns a {@link DnsOptions} instance that sets the host to use the mock server. */ public DnsOptions options() { - return DnsOptions.builder().host("http://localhost:" + port).build(); + return DnsOptions.builder().projectId(PROJECT_ID).host("http://localhost:" + port).build(); } /** @@ -539,6 +421,7 @@ private static void writeResponse(HttpExchange exchange, Response response) { exchange.getResponseHeaders().add("Connection", "close"); exchange.sendResponseHeaders(response.code(), response.body().length()); if (response.code() != 204) { + // the server automatically sends headers and closes output stream when 204 is returned outputStream.write(response.body().getBytes(StandardCharsets.UTF_8)); } outputStream.close(); @@ -547,18 +430,15 @@ private static void writeResponse(HttpExchange exchange, Response response) { } } - /** - * Decodes content of the HttpRequest. - */ private static String decodeContent(Headers headers, InputStream inputStream) throws IOException { List contentEncoding = headers.get("Content-encoding"); InputStream input = inputStream; try { if (contentEncoding != null && !contentEncoding.isEmpty()) { String encoding = contentEncoding.get(0); - if (SUPPORTED_COMPRESSION_ENCODINGS.contains(encoding)) { + if (ENCODINGS.contains(encoding)) { input = new GZIPInputStream(inputStream); - } else if (!encoding.equals("identity")) { + } else if (!"identity".equals(encoding)) { throw new IOException( "The request has the following unsupported HTTP content encoding: " + encoding); } @@ -574,25 +454,25 @@ private static String decodeContent(Headers headers, InputStream inputStream) th * * @param context managedZones | projects | rrsets | changes */ + @VisibleForTesting static Response toListResponse(List serializedObjects, String context, String pageToken, boolean includePageToken) { - // start building response StringBuilder responseBody = new StringBuilder(); responseBody.append("{\"").append(context).append("\": ["); Joiner.on(",").appendTo(responseBody, serializedObjects); - responseBody.append("]"); - // add page token only if exists and is asked for + responseBody.append(']'); + // add page token only if it exists and is asked for if (pageToken != null && includePageToken) { - responseBody.append(",\"nextPageToken\": \"").append(pageToken).append("\""); + responseBody.append(",\"nextPageToken\": \"").append(pageToken).append('"'); } - responseBody.append("}"); + responseBody.append('}'); return new Response(HTTP_OK, responseBody.toString()); } /** * Prepares DNS records that are created by default for each zone. */ - private static ImmutableList defaultRecords(ManagedZone zone) { + private static ImmutableSortedMap defaultRecords(ManagedZone zone) { ResourceRecordSet soa = new ResourceRecordSet(); soa.setTtl(21600); soa.setName(zone.getDnsName()); @@ -606,17 +486,15 @@ private static ImmutableList defaultRecords(ManagedZone zone) { ns.setName(zone.getDnsName()); ns.setRrdatas(zone.getNameServers()); ns.setType("NS"); - RrsetWrapper nsWrapper = new RrsetWrapper(ns); - RrsetWrapper soaWrapper = new RrsetWrapper(soa); - ImmutableList results = ImmutableList.of(nsWrapper, soaWrapper); - nsWrapper.setId(getUniqueId(results)); - soaWrapper.setId(getUniqueId(results)); - return results; + String nsId = getUniqueId(ImmutableSet.of()); + String soaId = getUniqueId(ImmutableSet.of(nsId)); + return ImmutableSortedMap.of(nsId, ns, soaId, soa); } /** * Returns a list of four nameservers randomly chosen from the predefined set. */ + @VisibleForTesting static List randomNameservers() { ArrayList nameservers = Lists.newArrayList( "dns1.googlecloud.com", "dns2.googlecloud.com", "dns3.googlecloud.com", @@ -630,23 +508,14 @@ static List randomNameservers() { } /** - * Returns a hex string id (used for a dns record) unique within the set of wrappers. + * Returns a hex string id (used for a dns record) unique within the set of ids. */ - static String getUniqueId(List wrappers) { - TreeSet ids = Sets.newTreeSet(Lists.transform(wrappers, - new Function() { - @Override - public String apply(RrsetWrapper input) { - return input.id() == null ? "null" : input.id(); - } - })); + @VisibleForTesting + static String getUniqueId(Set ids) { String id; do { id = Long.toHexString(System.currentTimeMillis()) + Long.toHexString(Math.abs(ID_GENERATOR.nextLong())); - if (!ids.contains(id)) { - return id; - } } while (ids.contains(id)); return id; } @@ -654,21 +523,19 @@ public String apply(RrsetWrapper input) { /** * Tests if a DNS record matches name and type (if provided). Used for filtering. */ + @VisibleForTesting static boolean matchesCriteria(ResourceRecordSet record, String name, String type) { if (type != null && !record.getType().equals(type)) { return false; } - if (name != null && !record.getName().equals(name)) { - return false; - } - return true; + return name == null || record.getName().equals(name); } /** * Returns a project container. Never returns {@code null} because we assume that all projects * exists. */ - ProjectContainer findProject(String projectId) { + private ProjectContainer findProject(String projectId) { ProjectContainer defaultProject = createProject(projectId); projects.putIfAbsent(projectId, defaultProject); return projects.get(projectId); @@ -677,6 +544,7 @@ ProjectContainer findProject(String projectId) { /** * Returns a zone container. Returns {@code null} if zone does not exist within project. */ + @VisibleForTesting ZoneContainer findZone(String projectId, String zoneName) { ProjectContainer projectContainer = findProject(projectId); // never null return projectContainer.zones().get(zoneName); @@ -685,6 +553,7 @@ ZoneContainer findZone(String projectId, String zoneName) { /** * Returns a change found by its id. Returns {@code null} if such a change does not exist. */ + @VisibleForTesting Change findChange(String projectId, String zoneName, String changeId) { ZoneContainer wrapper = findZone(projectId, zoneName); return wrapper == null ? null : wrapper.findChange(changeId); @@ -693,20 +562,20 @@ Change findChange(String projectId, String zoneName, String changeId) { /** * Returns a response to getChange service call. */ - Response getChange(String projectId, String zoneName, String changeId, String[] fields) { + @VisibleForTesting + Response getChange(String projectId, String zoneName, String changeId, String query) { Change change = findChange(projectId, zoneName, changeId); if (change == null) { ZoneContainer zone = findZone(projectId, zoneName); if (zone == null) { - // zone does not exist return Error.NOT_FOUND.response(String.format( "The 'parameters.managedZone' resource named '%s' does not exist.", zoneName)); } - // zone exists but change does not return Error.NOT_FOUND.response(String.format( "The 'parameters.changeId' resource named '%s' does not exist.", changeId)); } - Change result = OptionParsersAndExtractors.extractFields(change, fields); + String[] fields = OptionParsers.parseGetOptions(query); + Change result = OptionParsers.extractFields(change, fields); try { return new Response(HTTP_OK, jsonFactory.toString(result)); } catch (IOException e) { @@ -719,13 +588,15 @@ Response getChange(String projectId, String zoneName, String changeId, String[] /** * Returns a response to getZone service call. */ - Response getZone(String projectId, String zoneName, String[] fields) { + @VisibleForTesting + Response getZone(String projectId, String zoneName, String query) { ZoneContainer container = findZone(projectId, zoneName); if (container == null) { return Error.NOT_FOUND.response(String.format( "The 'parameters.managedZone' resource named '%s' does not exist.", zoneName)); } - ManagedZone result = OptionParsersAndExtractors.extractFields(container.zone(), fields); + String[] fields = OptionParsers.parseGetOptions(query); + ManagedZone result = OptionParsers.extractFields(container.zone(), fields); try { return new Response(HTTP_OK, jsonFactory.toString(result)); } catch (IOException e) { @@ -738,11 +609,11 @@ Response getZone(String projectId, String zoneName, String[] fields) { * We assume that every project exists. If we do not have it in the collection yet, we just create * a new default project instance with default quota. */ - Response getProject(String projectId, String[] fields) { - ProjectContainer defaultProject = createProject(projectId); - projects.putIfAbsent(projectId, defaultProject); - Project project = projects.get(projectId).project(); // project is now guaranteed to exist - Project result = OptionParsersAndExtractors.extractFields(project, fields); + @VisibleForTesting + Response getProject(String projectId, String query) { + String[] fields = OptionParsers.parseGetOptions(query); + Project project = findProject(projectId).project(); // creates project if needed + Project result = OptionParsers.extractFields(project, fields); try { return new Response(HTTP_OK, jsonFactory.toString(result)); } catch (IOException e) { @@ -752,8 +623,7 @@ Response getProject(String projectId, String[] fields) { } /** - * Creates a project. It generates a project number randomly (we do not have project numbers - * available). + * Creates a project. It generates a project number randomly. */ private ProjectContainer createProject(String projectId) { Quota quota = new Quota(); @@ -771,14 +641,21 @@ private ProjectContainer createProject(String projectId) { return new ProjectContainer(project); } - /** - * Deletes a zone. - */ + @VisibleForTesting Response deleteZone(String projectId, String zoneName) { + ZoneContainer zone = findZone(projectId, zoneName); + ImmutableSortedMap rrsets = zone == null + ? ImmutableSortedMap.of() : zone.dnsRecords().get(); + ImmutableList defaults = ImmutableList.of("NS", "SOA"); + for (ResourceRecordSet current : rrsets.values()) { + if (!defaults.contains(current.getType())) { + return Error.CONTAINER_NOT_EMPTY.response(String.format( + "The resource named '%s' cannot be deleted because it is not empty", zoneName)); + } + } ProjectContainer projectContainer = projects.get(projectId); ZoneContainer previous = projectContainer.zones.remove(zoneName); return previous == null - // map was not in the collection ? Error.NOT_FOUND.response(String.format( "The 'parameters.managedZone' resource named '%s' does not exist.", zoneName)) : new Response(HTTP_NO_CONTENT, "{}"); @@ -787,14 +664,12 @@ Response deleteZone(String projectId, String zoneName) { /** * Creates new managed zone and stores it in the collection. Assumes that project exists. */ - Response createZone(String projectId, ManagedZone zone, String[] fields) { - checkNotNull(zone, "Zone to create cannot be null"); - // check if the provided data is valid + @VisibleForTesting + Response createZone(String projectId, ManagedZone zone, String... fields) { Response errorResponse = checkZone(zone); if (errorResponse != null) { return errorResponse; } - // create a copy of the managed zone in order to avoid side effects ManagedZone completeZone = new ManagedZone(); completeZone.setName(zone.getName()); completeZone.setDnsName(zone.getDnsName()); @@ -802,13 +677,10 @@ Response createZone(String projectId, ManagedZone zone, String[] fields) { completeZone.setNameServerSet(zone.getNameServerSet()); completeZone.setCreationTime(ISODateTimeFormat.dateTime().withZoneUTC() .print(System.currentTimeMillis())); - completeZone.setId( - new BigInteger(String.valueOf(Math.abs(ID_GENERATOR.nextLong() % Long.MAX_VALUE)))); + completeZone.setId(BigInteger.valueOf(Math.abs(ID_GENERATOR.nextLong() % Long.MAX_VALUE))); completeZone.setNameServers(randomNameservers()); ZoneContainer zoneContainer = new ZoneContainer(completeZone); - // create the default NS and SOA records - zoneContainer.dnsRecords().put(zone.getName(), defaultRecords(completeZone)); - // place the zone in the data collection + zoneContainer.dnsRecords().set(defaultRecords(completeZone)); ProjectContainer projectContainer = findProject(projectId); ZoneContainer oldValue = projectContainer.zones().putIfAbsent( completeZone.getName(), zoneContainer); @@ -816,8 +688,7 @@ Response createZone(String projectId, ManagedZone zone, String[] fields) { return Error.ALREADY_EXISTS.response(String.format( "The resource 'entity.managedZone' named '%s' already exists", completeZone.getName())); } - // now return the desired attributes - ManagedZone result = OptionParsersAndExtractors.extractFields(completeZone, fields); + ManagedZone result = OptionParsers.extractFields(completeZone, fields); try { return new Response(HTTP_OK, jsonFactory.toString(result)); } catch (IOException e) { @@ -827,30 +698,28 @@ Response createZone(String projectId, ManagedZone zone, String[] fields) { } /** - * Creates a new change, stores it, and invokes processing in a new thread. + * Creates a new change, stores it, and if delayChange > 0, invokes processing in a new thread. */ - Response createChange(String projectId, String zoneName, Change change, String[] fields) { + Response createChange(String projectId, String zoneName, Change change, String... fields) { ZoneContainer zoneContainer = findZone(projectId, zoneName); if (zoneContainer == null) { return Error.NOT_FOUND.response(String.format( "The 'parameters.managedZone' resource named %s does not exist.", zoneName)); } - // check that the change to be applied is valid Response response = checkChange(change, zoneContainer); if (response != null) { return response; } - // start applying - Change completeChange = new Change(); // copy to avoid side effects + Change completeChange = new Change(); if (change.getAdditions() != null) { completeChange.setAdditions(ImmutableList.copyOf(change.getAdditions())); } if (change.getDeletions() != null) { completeChange.setDeletions(ImmutableList.copyOf(change.getDeletions())); } - /* we need to get the proper ID in concurrent environment - the element fell on an index between 0 and maxId - we will reset all IDs in this range (all of them are valid) */ + /* We need to set ID for the change. We are working in concurrent environment. We know that the + element fell on an index between 0 and maxId, so we will reset all IDs in this range (all of + them are valid for the respective objects). */ ConcurrentLinkedQueue changeSequence = zoneContainer.changes(); changeSequence.add(completeChange); int maxId = changeSequence.size(); @@ -859,13 +728,13 @@ we will reset all IDs in this range (all of them are valid) */ if (index == maxId) { break; } - c.setId(String.valueOf(++index)); // indexing from 1 + c.setId(String.valueOf(++index)); } - completeChange.setStatus("pending"); // not finished yet + completeChange.setStatus("pending"); completeChange.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC() - .print(System.currentTimeMillis())); // accepted + .print(System.currentTimeMillis())); invokeChange(projectId, zoneName, completeChange.getId()); - Change result = OptionParsersAndExtractors.extractFields(completeChange, fields); + Change result = OptionParsers.extractFields(completeChange, fields); try { return new Response(HTTP_OK, jsonFactory.toString(result)); } catch (IOException e) { @@ -876,28 +745,20 @@ we will reset all IDs in this range (all of them are valid) */ } /** - * Applies change. Uses a new thread which applies the change only if DELAY_CHANGE is > 0. + * Applies change. Uses a different pooled thread which applies the change only if {@code + * delayChange} is > 0. */ - private Thread invokeChange(final String projectId, final String zoneName, + private void invokeChange(final String projectId, final String zoneName, final String changeId) { if (delayChange > 0) { - Thread thread = new Thread() { + EXECUTORS.schedule(new Runnable() { @Override public void run() { - try { - Thread.sleep(delayChange); // simulate delayed execution - } catch (InterruptedException ex) { - log.log(Level.WARNING, "Thread was interrupted while sleeping.", ex); - } - // start applying the changes applyExistingChange(projectId, zoneName, changeId); } - }; - thread.start(); - return thread; + }, delayChange, TimeUnit.MILLISECONDS); } else { applyExistingChange(projectId, zoneName, changeId); - return null; } } @@ -910,44 +771,55 @@ private void applyExistingChange(String projectId, String zoneName, String chang return; // no such change exists, nothing to do } ZoneContainer wrapper = findZone(projectId, zoneName); - ConcurrentSkipListMap> dnsRecords = wrapper.dnsRecords(); + if (wrapper == null) { + return; // no such zone exists; it might have been deleted by another thread + } + AtomicReference> dnsRecords = + wrapper.dnsRecords(); while (true) { // managed zone must have a set of records which is not null - ImmutableList original = dnsRecords.get(zoneName); - assert original != null; - List copy = Lists.newLinkedList(original); + ImmutableSortedMap original = dnsRecords.get(); + // the copy will be populated when handling deletions + SortedMap copy = new TreeMap<>(); // apply deletions first List deletions = change.getDeletions(); if (deletions != null) { - List transformedDeletions = Lists.transform(deletions, - RrsetWrapper.WRAP_FUNCTION); - copy.removeAll(transformedDeletions); + for (Map.Entry entry : original.entrySet()) { + if (!deletions.contains(entry.getValue())) { + copy.put(entry.getKey(), entry.getValue()); + } + } + } else { + copy.putAll(original); } // apply additions List additions = change.getAdditions(); if (additions != null) { for (ResourceRecordSet addition : additions) { - String id = getUniqueId(copy); - RrsetWrapper rrsetWrapper = new RrsetWrapper(addition); - rrsetWrapper.setId(id); - copy.add(rrsetWrapper); + ResourceRecordSet rrset = new ResourceRecordSet(); + rrset.setName(addition.getName()); + rrset.setRrdatas(ImmutableList.copyOf(addition.getRrdatas())); + rrset.setTtl(addition.getTtl()); + rrset.setType(addition.getType()); + String id = getUniqueId(copy.keySet()); + copy.put(id, rrset); } } - // make it immutable and replace - boolean success = dnsRecords.replace(zoneName, original, ImmutableList.copyOf(copy)); + boolean success = dnsRecords.compareAndSet(original, ImmutableSortedMap.copyOf(copy)); if (success) { break; // success if no other thread modified the value in the meantime } } - // set status to done change.setStatus("done"); } /** * Lists zones. Next page token is the last listed zone name and is returned only of there is more - * to list. + * to list and if the user does not exclude nextPageToken from field options. */ - Response listZones(String projectId, Map options) { + @VisibleForTesting + Response listZones(String projectId, String query) { + Map options = OptionParsers.parseListZonesOptions(query); Response response = checkListOptions(options); if (response != null) { return response; @@ -958,46 +830,43 @@ Response listZones(String projectId, Map options) { String pageToken = (String) options.get("pageToken"); Integer maxResults = options.get("maxResults") == null ? null : Integer.valueOf((String) options.get("maxResults")); - // matches will be included in the result if true - boolean listing = (pageToken == null || !containers.containsKey(pageToken)); - boolean sizeReached = false; // maximum result size was reached, we should not return more - boolean hasMorePages = false; // should next page token be included in the response? + boolean sizeReached = false; + boolean hasMorePages = false; LinkedList serializedZones = new LinkedList<>(); String lastZoneName = null; - for (ZoneContainer zoneContainer : containers.values()) { + ConcurrentNavigableMap fragment = + pageToken != null ? containers.tailMap(pageToken, false) : containers; + for (ZoneContainer zoneContainer : fragment.values()) { ManagedZone zone = zoneContainer.zone(); - if (listing) { - if (dnsName == null || zone.getDnsName().equals(dnsName)) { - if (sizeReached) { - // we do not add this, just note that there would be more and there should be a token - hasMorePages = true; - break; - } else { - try { - lastZoneName = zone.getName(); - serializedZones.addLast(jsonFactory.toString( - OptionParsersAndExtractors.extractFields(zone, fields))); - } catch (IOException e) { - return Error.INTERNAL_ERROR.response(String.format( - "Error when serializing managed zone %s in project %s", zone.getName(), - projectId)); - } + if (dnsName == null || zone.getDnsName().equals(dnsName)) { + if (sizeReached) { + // we do not add this, just note that there would be more and there should be a token + hasMorePages = true; + break; + } else { + try { + lastZoneName = zone.getName(); + serializedZones.addLast(jsonFactory.toString( + OptionParsers.extractFields(zone, fields))); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response(String.format( + "Error when serializing managed zone %s in project %s", lastZoneName, projectId)); } } } - // either we are listing already, or we check if we should start in the next iteration - listing = zone.getName().equals(pageToken) || listing; - sizeReached = (maxResults != null) && maxResults.equals(serializedZones.size()); + sizeReached = maxResults != null && maxResults.equals(serializedZones.size()); } boolean includePageToken = - hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("nextPageToken")); + hasMorePages && (fields == null || Arrays.asList(fields).contains("nextPageToken")); return toListResponse(serializedZones, "managedZones", lastZoneName, includePageToken); } /** - * Lists DNS records for a zone. Next page token is ID of the last record listed. + * Lists DNS records for a zone. Next page token is the ID of the last record listed. */ - Response listDnsRecords(String projectId, String zoneName, Map options) { + @VisibleForTesting + Response listDnsRecords(String projectId, String zoneName, String query) { + Map options = OptionParsers.parseListDnsRecordsOptions(query); Response response = checkListOptions(options); if (response != null) { return response; @@ -1007,52 +876,51 @@ Response listDnsRecords(String projectId, String zoneName, Map o return Error.NOT_FOUND.response(String.format( "The 'parameters.managedZone' resource named '%s' does not exist.", zoneName)); } - List dnsRecords = zoneContainer.dnsRecords().get(zoneName); + ImmutableSortedMap dnsRecords = zoneContainer.dnsRecords().get(); String[] fields = (String[]) options.get("fields"); String name = (String) options.get("name"); String type = (String) options.get("type"); String pageToken = (String) options.get("pageToken"); + ImmutableSortedMap fragment = + pageToken != null ? dnsRecords.tailMap(pageToken, false) : dnsRecords; Integer maxResults = options.get("maxResults") == null ? null : Integer.valueOf((String) options.get("maxResults")); - boolean listing = (pageToken == null); // matches will be included in the result if true - boolean sizeReached = false; // maximum result size was reached, we should not return more - boolean hasMorePages = false; // should next page token be included in the response? + boolean sizeReached = false; + boolean hasMorePages = false; LinkedList serializedRrsets = new LinkedList<>(); String lastRecordId = null; - for (RrsetWrapper recordWrapper : dnsRecords) { - ResourceRecordSet record = recordWrapper.rrset(); - if (listing) { - if (matchesCriteria(record, name, type)) { - if (sizeReached) { - // we do not add this, just note that there would be more and there should be a token - hasMorePages = true; - break; - } else { - lastRecordId = recordWrapper.id(); - try { - serializedRrsets.addLast(jsonFactory.toString( - OptionParsersAndExtractors.extractFields(record, fields))); - } catch (IOException e) { - return Error.INTERNAL_ERROR.response(String.format( - "Error when serializing resource record set in managed zone %s in project %s", - zoneName, projectId)); - } + for (String recordId : fragment.keySet()) { + ResourceRecordSet record = fragment.get(recordId); + if (matchesCriteria(record, name, type)) { + if (sizeReached) { + // we do not add this, just note that there would be more and there should be a token + hasMorePages = true; + break; + } else { + lastRecordId = recordId; + try { + serializedRrsets.addLast(jsonFactory.toString( + OptionParsers.extractFields(record, fields))); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response(String.format( + "Error when serializing resource record set in managed zone %s in project %s", + zoneName, projectId)); } } } - // either we are listing already, or we check if we should start in the next iteration - listing = recordWrapper.id().equals(pageToken) || listing; - sizeReached = (maxResults != null) && maxResults.equals(serializedRrsets.size()); + sizeReached = maxResults != null && maxResults.equals(serializedRrsets.size()); } boolean includePageToken = - hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("nextPageToken")); + hasMorePages && (fields == null || Arrays.asList(fields).contains("nextPageToken")); return toListResponse(serializedRrsets, "rrsets", lastRecordId, includePageToken); } /** - * Lists changes. Next page token is ID of the last change listed. + * Lists changes. Next page token is the ID of the last change listed. */ - Response listChanges(String projectId, String zoneName, Map options) { + @VisibleForTesting + Response listChanges(String projectId, String zoneName, String query) { + Map options = OptionParsers.parseListChangesOptions(query); Response response = checkListOptions(options); if (response != null) { return response; @@ -1063,7 +931,7 @@ Response listChanges(String projectId, String zoneName, Map opti "The 'parameters.managedZone' resource named '%s' does not exist", zoneName)); } // take a sorted snapshot of the current change list - TreeMap changes = new TreeMap<>(); + NavigableMap changes = new TreeMap<>(); for (Change c : zoneContainer.changes()) { if (c.getId() != null) { changes.put(Integer.valueOf(c.getId()), c); @@ -1074,51 +942,54 @@ Response listChanges(String projectId, String zoneName, Map opti String pageToken = (String) options.get("pageToken"); Integer maxResults = options.get("maxResults") == null ? null : Integer.valueOf((String) options.get("maxResults")); - // we are not reading sort by as it the only key is the change sequence + // as the only supported field is change sequence, we are not reading sortBy NavigableSet keys; if ("descending".equals(sortOrder)) { keys = changes.descendingKeySet(); } else { keys = changes.navigableKeySet(); } - boolean listing = (pageToken == null); // matches will be included in the result if true - boolean sizeReached = false; // maximum result size was reached, we should not return more - boolean hasMorePages = false; // should next page token be included in the response? + Integer from = null; + try { + from = Integer.valueOf(pageToken); + } catch (NumberFormatException ex) { + // ignore page token + } + keys = from != null ? keys.tailSet(from, false) : keys; + NavigableMap fragment = + from != null && changes.containsKey(from) ? changes.tailMap(from, false) : changes; + boolean sizeReached = false; + boolean hasMorePages = false; LinkedList serializedResults = new LinkedList<>(); String lastChangeId = null; for (Integer key : keys) { - Change change = changes.get(key); - if (listing) { - if (sizeReached) { - // we do not add this, just note that there would be more and there should be a token - hasMorePages = true; - break; - } else { - lastChangeId = change.getId(); - try { - serializedResults.addLast(jsonFactory.toString( - OptionParsersAndExtractors.extractFields(change, fields))); - } catch (IOException e) { - return Error.INTERNAL_ERROR.response(String.format( - "Error when serializing change %s in managed zone %s in project %s", - change.getId(), zoneName, projectId)); - } + Change change = fragment.get(key); + if (sizeReached) { + // we do not add this, just note that there would be more and there should be a token + hasMorePages = true; + break; + } else { + lastChangeId = change.getId(); + try { + serializedResults.addLast(jsonFactory.toString( + OptionParsers.extractFields(change, fields))); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response(String.format( + "Error when serializing change %s in managed zone %s in project %s", + lastChangeId, zoneName, projectId)); } } - - // either we are listing already, or we check if we should start in the next iteration - listing = change.getId().equals(pageToken) || listing; - sizeReached = (maxResults != null) && maxResults.equals(serializedResults.size()); + sizeReached = maxResults != null && maxResults.equals(serializedResults.size()); } boolean includePageToken = - hasMorePages && (fields == null || ImmutableList.copyOf(fields).contains("nextPageToken")); + hasMorePages && (fields == null || Arrays.asList(fields).contains("nextPageToken")); return toListResponse(serializedResults, "changes", lastChangeId, includePageToken); } /** * Validates a zone to be created. */ - static Response checkZone(ManagedZone zone) { + private static Response checkZone(ManagedZone zone) { if (zone.getName() == null) { return Error.REQUIRED.response( "The 'entity.managedZone.name' parameter is required but was missing."); @@ -1138,7 +1009,8 @@ static Response checkZone(ManagedZone zone) { } catch (NumberFormatException ex) { // expected } - if (zone.getName().isEmpty()) { + if (zone.getName().isEmpty() || zone.getName().length() > 32 + || !ZONE_NAME_RE.matcher(zone.getName()).matches()) { return Error.INVALID.response( String.format("Invalid value for 'entity.managedZone.name': '%s'", zone.getName())); } @@ -1146,9 +1018,7 @@ static Response checkZone(ManagedZone zone) { return Error.INVALID.response( String.format("Invalid value for 'entity.managedZone.dnsName': '%s'", zone.getDnsName())); } - TreeSet forbidden = Sets.newTreeSet( - ImmutableList.of("google.com.", "com.", "example.com.", "net.", "org.")); - if (forbidden.contains(zone.getDnsName())) { + if (FORBIDDEN.contains(zone.getDnsName())) { return Error.NOT_AVAILABLE.response(String.format( "The '%s' managed zone is not available to be created.", zone.getDnsName())); } @@ -1158,12 +1028,10 @@ static Response checkZone(ManagedZone zone) { /** * Validates a change to be created. */ + @VisibleForTesting static Response checkChange(Change change, ZoneContainer zone) { - checkNotNull(zone); - if ((change.getDeletions() != null && change.getDeletions().size() > 0) - || (change.getAdditions() != null && change.getAdditions().size() > 0)) { - // ok, this is what we want - } else { + if ((change.getDeletions() == null || change.getDeletions().size() <= 0) + && (change.getAdditions() == null || change.getAdditions().size() <= 0)) { return Error.REQUIRED.response("The 'entity.change' parameter is required but was missing."); } if (change.getAdditions() != null) { @@ -1186,7 +1054,7 @@ static Response checkChange(Change change, ZoneContainer zone) { counter++; } } - return additionsMeetDeletions(change.getAdditions(), change.getDeletions(), zone); + return checkAdditionsDeletions(change.getAdditions(), change.getDeletions(), zone); // null if everything is ok } @@ -1197,6 +1065,7 @@ static Response checkChange(Change change, ZoneContainer zone) { * @param index the index or addition or deletion in the list * @param zone the zone that this change is applied to */ + @VisibleForTesting static Response checkRrset(ResourceRecordSet rrset, ZoneContainer zone, int index, String type) { if (rrset.getName() == null || !rrset.getName().endsWith(zone.zone().getDnsName())) { return Error.INVALID.response(String.format( @@ -1226,8 +1095,7 @@ static Response checkRrset(ResourceRecordSet rrset, ZoneContainer zone, int inde if ("deletions".equals(type)) { // check that deletion has a match by name and type boolean found = false; - for (RrsetWrapper rrsetWrapper : zone.dnsRecords().get(zone.zone().getName())) { - ResourceRecordSet wrappedRrset = rrsetWrapper.rrset(); + for (ResourceRecordSet wrappedRrset : zone.dnsRecords().get().values()) { if (rrset.getName().equals(wrappedRrset.getName()) && rrset.getType().equals(wrappedRrset.getType())) { found = true; @@ -1241,7 +1109,7 @@ static Response checkRrset(ResourceRecordSet rrset, ZoneContainer zone, int inde } // if found, we still need an exact match if ("deletions".equals(type) - && !zone.dnsRecords().get(zone.zone().getName()).contains(new RrsetWrapper(rrset))) { + && !zone.dnsRecords().get().containsValue(rrset)) { // such a record does not exist return Error.CONDITION_NOT_MET.response(String.format( "Precondition not met for 'entity.change.deletions[%s]", index)); @@ -1251,24 +1119,22 @@ static Response checkRrset(ResourceRecordSet rrset, ZoneContainer zone, int inde } /** - * Checks that for each record that already exists, we have a matching deletion. Furthermore, - * check that mandatory SOA and NS records stay. + * Checks against duplicate additions (for each record to be added that already exists, we must + * have a matching deletion. Furthermore, check that mandatory SOA and NS records stay. */ - static Response additionsMeetDeletions(List additions, + static Response checkAdditionsDeletions(List additions, List deletions, ZoneContainer zone) { if (additions != null) { int index = 0; for (ResourceRecordSet rrset : additions) { - for (RrsetWrapper wrapper : zone.dnsRecords().get(zone.zone().getName())) { - ResourceRecordSet wrappedRrset = wrapper.rrset(); + for (ResourceRecordSet wrappedRrset : zone.dnsRecords().get().values()) { if (rrset.getName().equals(wrappedRrset.getName()) - && rrset.getType().equals(wrappedRrset.getType())) { - // such a record exist and we must have a deletion - if (deletions == null || !deletions.contains(wrappedRrset)) { - return Error.ALREADY_EXISTS.response(String.format( - "The 'entity.change.additions[%s]' resource named '%s (%s)' already exists.", - index, rrset.getName(), rrset.getType())); - } + && rrset.getType().equals(wrappedRrset.getType()) + // such a record exist and we must have a deletion + && (deletions == null || !deletions.contains(wrappedRrset))) { + return Error.ALREADY_EXISTS.response(String.format( + "The 'entity.change.additions[%s]' resource named '%s (%s)' already exists.", + index, rrset.getName(), rrset.getType())); } } if (rrset.getType().equals("SOA") && findByNameAndType(deletions, null, "SOA") == null) { @@ -1323,44 +1189,11 @@ private static ResourceRecordSet findByNameAndType(Iterable r * We only provide the most basic validation for A and AAAA records. */ static boolean checkRrData(String data, String type) { - // todo add validation for other records - String[] tokens; switch (type) { case "A": - tokens = data.split("\\."); - if (tokens.length != 4) { - return false; - } - for (String token : tokens) { - try { - Integer number = Integer.valueOf(token); - if (number < 0 || number > 255) { - return false; - } - } catch (NumberFormatException ex) { - return false; - } - } - return true; + return !data.contains(":") && isInetAddress(data); case "AAAA": - tokens = data.split(":", -1); - if (tokens.length != 8) { - return false; - } - for (String token : tokens) { - try { - if (!token.isEmpty()) { - // empty is ok - Long number = Long.parseLong(token, 16); - if (number < 0 || number > 0xFFFF) { - return false; - } - } - } catch (NumberFormatException ex) { - return false; - } - } - return true; + return data.contains(":") && isInetAddress(data); default: return true; } @@ -1369,11 +1202,12 @@ static boolean checkRrData(String data, String type) { /** * Check supplied listing options. */ + @VisibleForTesting static Response checkListOptions(Map options) { // for general listing String maxResultsString = (String) options.get("maxResults"); if (maxResultsString != null) { - Integer maxResults = null; + Integer maxResults; try { maxResults = Integer.valueOf(maxResultsString); } catch (NumberFormatException ex) { @@ -1386,24 +1220,21 @@ static Response checkListOptions(Map options) { } } String dnsName = (String) options.get("dnsName"); - if (dnsName != null) { - if (!dnsName.endsWith(".")) { - return Error.INVALID.response(String.format( - "Invalid value for 'parameters.dnsName': '%s'", dnsName)); - } + if (dnsName != null && !dnsName.endsWith(".")) { + return Error.INVALID.response(String.format( + "Invalid value for 'parameters.dnsName': '%s'", dnsName)); } // for listing dns records, name must be fully qualified String name = (String) options.get("name"); - if (name != null) { - if (!name.endsWith(".")) { - return Error.INVALID.response(String.format( - "Invalid value for 'parameters.name': '%s'", name)); - } + if (name != null && !name.endsWith(".")) { + return Error.INVALID.response(String.format( + "Invalid value for 'parameters.name': '%s'", name)); } String type = (String) options.get("type"); // must be provided with name if (type != null) { if (name == null) { - return Error.INVALID.response("Invalid value for 'parameters.name': ''"); + return Error.INVALID.response("Invalid value for 'parameters.name': '' " + + "(name must be specified if type is specified)"); } if (!TYPES.contains(type)) { return Error.INVALID.response(String.format( diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java similarity index 80% rename from gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java index 26759f7e3ccc..ecd7e8179efe 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/testing/OptionParsersAndExtractors.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.testing; +package com.google.gcloud.dns.testing; import com.google.api.services.dns.model.Change; import com.google.api.services.dns.model.ManagedZone; @@ -27,12 +27,8 @@ /** * Utility helpers for LocalDnsHelper. */ -class OptionParsersAndExtractors { +class OptionParsers { - /** - * Makes a map of list options. Expects query to be only query part of the url (i.e., what follows - * the '?'). - */ static Map parseListZonesOptions(String query) { Map options = new HashMap<>(); if (query != null) { @@ -41,20 +37,15 @@ static Map parseListZonesOptions(String query) { String[] argEntry = arg.split("="); switch (argEntry[0]) { case "fields": - // List fields are in the form "managedZones(field1, field2, ...)" + // List fields are in the form "managedZones(field1, field2, ...),nextPageToken" String replaced = argEntry[1].replace("managedZones(", ","); replaced = replaced.replace(")", ","); // we will get empty strings, but it does not matter, they will be ignored - options.put( - "fields", - replaced.split(",")); + options.put("fields", replaced.split(",")); break; case "dnsName": options.put("dnsName", argEntry[1]); break; - case "nextPageToken": - options.put("nextPageToken", argEntry[1]); - break; case "pageToken": options.put("pageToken", argEntry[1]); break; @@ -70,10 +61,6 @@ static Map parseListZonesOptions(String query) { return options; } - /** - * Makes a map of list options. Expects query to be only query part of the url (i.e., what follows - * the '?'). This format is common for all of zone, change and project. - */ static String[] parseGetOptions(String query) { if (query != null) { String[] args = query.split("&"); @@ -85,14 +72,11 @@ static String[] parseGetOptions(String query) { } } } - return null; + return new String[0]; } - /** - * Extracts only request fields. - */ - static ManagedZone extractFields(ManagedZone fullZone, String[] fields) { - if (fields == null) { + static ManagedZone extractFields(ManagedZone fullZone, String... fields) { + if (fields == null || fields.length == 0) { return fullZone; } ManagedZone managedZone = new ManagedZone(); @@ -126,22 +110,17 @@ static ManagedZone extractFields(ManagedZone fullZone, String[] fields) { return managedZone; } - /** - * Extracts only request fields. - */ - static Change extractFields(Change fullChange, String[] fields) { - if (fields == null) { + static Change extractFields(Change fullChange, String... fields) { + if (fields == null || fields.length == 0) { return fullChange; } Change change = new Change(); for (String field : fields) { switch (field) { case "additions": - // todo the fragmentation is ignored here as our api does not support it change.setAdditions(fullChange.getAdditions()); break; case "deletions": - // todo the fragmentation is ignored here as our api does not support it change.setDeletions(fullChange.getDeletions()); break; case "id": @@ -160,11 +139,8 @@ static Change extractFields(Change fullChange, String[] fields) { return change; } - /** - * Extracts only request fields. - */ - static Project extractFields(Project fullProject, String[] fields) { - if (fields == null) { + static Project extractFields(Project fullProject, String... fields) { + if (fields == null || fields.length == 0) { return fullProject; } Project project = new Project(); @@ -186,11 +162,8 @@ static Project extractFields(Project fullProject, String[] fields) { return project; } - /** - * Extracts only request fields. - */ - static ResourceRecordSet extractFields(ResourceRecordSet fullRecord, String[] fields) { - if (fields == null) { + static ResourceRecordSet extractFields(ResourceRecordSet fullRecord, String... fields) { + if (fields == null || fields.length == 0) { return fullRecord; } ResourceRecordSet record = new ResourceRecordSet(); @@ -223,16 +196,9 @@ static Map parseListChangesOptions(String query) { String[] argEntry = arg.split("="); switch (argEntry[0]) { case "fields": - // todo we do not support fragmentation in deletions and additions in the library String replaced = argEntry[1].replace("changes(", ",").replace(")", ","); options.put("fields", replaced.split(",")); // empty strings will be ignored break; - case "name": - options.put("name", argEntry[1]); - break; - case "nextPageToken": - options.put("nextPageToken", argEntry[1]); - break; case "pageToken": options.put("pageToken", argEntry[1]); break; @@ -275,9 +241,6 @@ static Map parseListDnsRecordsOptions(String query) { case "pageToken": options.put("pageToken", argEntry[1]); break; - case "nextPageToken": - options.put("nextPageToken", argEntry[1]); - break; case "maxResults": // parsing to int is done while handling options.put("maxResults", argEntry[1]); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java index b72a21445a80..1df0a8a2f831 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java @@ -162,9 +162,9 @@ public Change getChangeRequest(String zoneName, String changeRequestId, Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); - private static final DnsRpc RPC = - new DefaultDnsRpc(LOCAL_DNS_HELPER.options()); + private static final DnsRpc RPC = new DefaultDnsRpc(LOCAL_DNS_HELPER.options()); private static final String REAL_PROJECT_ID = LOCAL_DNS_HELPER.options().projectId(); private Map optionsMap; - private ManagedZone minimalZone = new ManagedZone(); // to be adjusted as needed - @BeforeClass public static void before() { - RRSET1.setName(DNS_NAME); - RRSET1.setType(RRSET_TYPE); - RRSET1.setRrdatas(ImmutableList.of("1.1.1.1")); ZONE1.setName(ZONE_NAME1); ZONE1.setDescription(""); ZONE1.setDnsName(DNS_NAME); - ZONE1.setNameServerSet("somenameserveset"); + ZONE1.setNameServerSet("somenameserverset"); ZONE2.setName(ZONE_NAME2); ZONE2.setDescription(""); ZONE2.setDnsName(DNS_NAME); - ZONE2.setNameServerSet("somenameserveset"); + ZONE2.setNameServerSet("somenameserverset"); + RRSET1.setName(DNS_NAME); + RRSET1.setType(RRSET_TYPE); + RRSET1.setRrdatas(ImmutableList.of("1.1.1.1")); RRSET2.setName(DNS_NAME); RRSET2.setType(RRSET_TYPE); + RRSET2.setRrdatas(ImmutableList.of("123.132.153.156")); RRSET_KEEP.setName(DNS_NAME); RRSET_KEEP.setType("MX"); RRSET_KEEP.setRrdatas(ImmutableList.of("255.255.255.254")); - RRSET2.setRrdatas(ImmutableList.of("123.132.153.156")); CHANGE1.setAdditions(ImmutableList.of(RRSET1, RRSET2)); CHANGE2.setDeletions(ImmutableList.of(RRSET2)); CHANGE_KEEP.setAdditions(ImmutableList.of(RRSET_KEEP)); @@ -98,17 +99,13 @@ public static void before() { LOCAL_DNS_HELPER.start(); } + @Rule + public Timeout globalTimeout = Timeout.seconds(60); + @Before public void setUp() { resetProjects(); optionsMap = new HashMap<>(); - minimalZone = copyZone(ZONE1); - } - - private static void resetProjects() { - for (String project : LOCAL_DNS_HELPER.projects().keySet()) { - LOCAL_DNS_HELPER.projects().remove(project); - } } @AfterClass @@ -116,279 +113,55 @@ public static void after() { LOCAL_DNS_HELPER.stop(); } - @Test - public void testMatchesCriteria() { - assertTrue(LocalDnsHelper.matchesCriteria(RRSET1, RRSET1.getName(), RRSET1.getType())); - assertFalse(LocalDnsHelper.matchesCriteria(RRSET1, RRSET1.getName(), "anothertype")); - assertTrue(LocalDnsHelper.matchesCriteria(RRSET1, null, RRSET1.getType())); - assertTrue(LocalDnsHelper.matchesCriteria(RRSET1, RRSET1.getName(), null)); - assertFalse(LocalDnsHelper.matchesCriteria(RRSET1, "anothername", RRSET1.getType())); - } - - @Test - public void testGetUniqueId() { - assertNotNull(LocalDnsHelper.getUniqueId(Lists.newLinkedList())); - } - - @Test - public void testFindProject() { - assertEquals(0, LOCAL_DNS_HELPER.projects().size()); - LocalDnsHelper.ProjectContainer project = LOCAL_DNS_HELPER.findProject(PROJECT_ID1); - assertNotNull(project); - assertTrue(LOCAL_DNS_HELPER.projects().containsKey(PROJECT_ID1)); - assertNotNull(LOCAL_DNS_HELPER.findProject(PROJECT_ID2)); - assertTrue(LOCAL_DNS_HELPER.projects().containsKey(PROJECT_ID2)); - assertTrue(LOCAL_DNS_HELPER.projects().containsKey(PROJECT_ID1)); - assertNotNull(project.zones()); - assertEquals(0, project.zones().size()); - assertNotNull(project.project()); - assertNotNull(project.project().getQuota()); + private static void resetProjects() { + for (String project : LOCAL_DNS_HELPER.projects().keySet()) { + LOCAL_DNS_HELPER.projects().remove(project); + } } - @Test - public void testCreateAndFindZone() { - LocalDnsHelper.ZoneContainer zone1 = LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE_NAME1); - assertTrue(LOCAL_DNS_HELPER.projects().containsKey(PROJECT_ID1)); - assertNull(zone1); - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); // we do not care about options - zone1 = LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE1.getName()); - assertNotNull(zone1); - // cannot call equals because id and timestamp got assigned - assertEquals(ZONE_NAME1, zone1.zone().getName()); - assertNotNull(zone1.changes()); - assertTrue(zone1.changes().isEmpty()); - assertNotNull(zone1.dnsRecords()); - assertEquals(2, zone1.dnsRecords().get(ZONE_NAME1).size()); // default SOA and NS - LOCAL_DNS_HELPER.createZone(PROJECT_ID2, ZONE1, null); // project does not exits yet - assertEquals(ZONE1.getName(), - LOCAL_DNS_HELPER.findZone(PROJECT_ID2, ZONE_NAME1).zone().getName()); + private static void assertEqChangesIgnoreStatus(Change expected, Change actual) { + assertEquals(expected.getAdditions(), actual.getAdditions()); + assertEquals(expected.getDeletions(), actual.getDeletions()); + assertEquals(expected.getId(), actual.getId()); + assertEquals(expected.getStartTime(), actual.getStartTime()); } @Test - public void testCreateAndFindZoneUsingRpc() { - // zone does not exist yet - ManagedZone zone1 = RPC.getZone(ZONE_NAME1, EMPTY_RPC_OPTIONS); - assertTrue(LOCAL_DNS_HELPER.projects().containsKey(REAL_PROJECT_ID)); // check internal state - assertNull(zone1); - // create zone - ManagedZone createdZone = RPC.create(ZONE1, EMPTY_RPC_OPTIONS); - assertEquals(ZONE1.getName(), createdZone.getName()); - assertEquals(ZONE1.getDescription(), createdZone.getDescription()); - assertEquals(ZONE1.getDnsName(), createdZone.getDnsName()); - assertEquals(4, createdZone.getNameServers().size()); - // get the same zone zone - ManagedZone zone = RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS); - assertEquals(createdZone, zone); + public void testCreateZone() { + ManagedZone created = RPC.create(ZONE1, EMPTY_RPC_OPTIONS); // check that default records were created - DnsRpc.ListResult resourceRecordSetListResult + DnsRpc.ListResult listResult = RPC.listDnsRecords(ZONE1.getName(), EMPTY_RPC_OPTIONS); - assertEquals(2, Lists.newLinkedList(resourceRecordSetListResult.results()).size()); - } - - @Test - public void testDeleteZone() { - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - LocalDnsHelper.Response response = LOCAL_DNS_HELPER.deleteZone(PROJECT_ID1, ZONE1.getName()); - assertEquals(204, response.code()); - // deleting non-existent zone - response = LOCAL_DNS_HELPER.deleteZone(PROJECT_ID1, ZONE1.getName()); - assertEquals(404, response.code()); - assertNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE1.getName())); - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE2, null); - assertNotNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE1.getName())); - assertNotNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE2.getName())); - // delete in reverse order - response = LOCAL_DNS_HELPER.deleteZone(PROJECT_ID1, ZONE1.getName()); - assertEquals(204, response.code()); - assertNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE1.getName())); - assertNotNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE2.getName())); - LOCAL_DNS_HELPER.deleteZone(PROJECT_ID1, ZONE2.getName()); - assertEquals(204, response.code()); - assertNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE1.getName())); - assertNull(LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE2.getName())); - } - - @Test - public void testDeleteZoneUsingRpc() { - RPC.create(ZONE1, EMPTY_RPC_OPTIONS); - assertTrue(RPC.deleteZone(ZONE1.getName())); - assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); - // deleting non-existent zone - assertFalse(RPC.deleteZone(ZONE1.getName())); - assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); - RPC.create(ZONE1, EMPTY_RPC_OPTIONS); - RPC.create(ZONE2, EMPTY_RPC_OPTIONS); - assertNotNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); - assertNotNull(RPC.getZone(ZONE2.getName(), EMPTY_RPC_OPTIONS)); - // delete in reverse order - assertTrue(RPC.deleteZone(ZONE1.getName())); - assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); - assertNotNull(RPC.getZone(ZONE2.getName(), EMPTY_RPC_OPTIONS)); - assertTrue(RPC.deleteZone(ZONE2.getName())); - assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); - assertNull(RPC.getZone(ZONE2.getName(), EMPTY_RPC_OPTIONS)); - } - - @Test - public void testCreateAndApplyChange() { - LocalDnsHelper localDnsThreaded = LocalDnsHelper.create(5 * 1000L); // using threads here - localDnsThreaded.createZone(PROJECT_ID1, ZONE1, null); - assertNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); - LocalDnsHelper.Response response - = localDnsThreaded.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add - assertEquals(200, response.code()); - assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); - assertNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); - localDnsThreaded.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add - response = localDnsThreaded.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); // add - assertEquals(200, response.code()); - assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); - assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); - localDnsThreaded.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); // delete - assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("1")); - assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("2")); - assertNotNull(localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).findChange("3")); - localDnsThreaded.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE_KEEP, null); // id is "4" - // check execution - Change change = localDnsThreaded.findChange(PROJECT_ID1, ZONE_NAME1, "4"); - for (int i = 0; i < 10 && !change.getStatus().equals("done"); i++) { - // change has not been finished yet; wait at most 20 seconds - // it takes 5 seconds for the thread to kick in in the first place - try { - Thread.sleep(2 * 1000); - } catch (InterruptedException e) { - fail("Test was interrupted"); - } + ImmutableList defaultTypes = ImmutableList.of("SOA", "NS"); + Iterator iterator = listResult.results().iterator(); + assertTrue(defaultTypes.contains(iterator.next().getType())); + assertTrue(defaultTypes.contains(iterator.next().getType())); + assertFalse(iterator.hasNext()); + assertEquals(created, LOCAL_DNS_HELPER.findZone(REAL_PROJECT_ID, ZONE1.getName()).zone()); + ManagedZone zone = RPC.getZone(ZONE_NAME1, EMPTY_RPC_OPTIONS); + assertEquals(created, zone); + try { + RPC.create(null, EMPTY_RPC_OPTIONS); + fail("Zone cannot be null"); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("entity.managedZone")); } - assertEquals("done", change.getStatus()); - List list = - localDnsThreaded.findZone(PROJECT_ID1, ZONE_NAME1).dnsRecords().get(ZONE_NAME1); - assertTrue(list.contains(new LocalDnsHelper.RrsetWrapper(RRSET_KEEP))); - localDnsThreaded.stop(); - } - - @Test - public void testCreateAndApplyChangeUsingRpc() { - // not using threads - RPC.create(ZONE1, EMPTY_RPC_OPTIONS); - assertNull(RPC.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS)); - //add - Change createdChange = RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); - assertEquals(createdChange.getAdditions(), CHANGE1.getAdditions()); - assertEquals(createdChange.getDeletions(), CHANGE1.getDeletions()); - assertNotNull(createdChange.getStartTime()); - assertEquals("1", createdChange.getId()); - Change retrievedChange = RPC.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS); - assertEquals(createdChange, retrievedChange); - assertNull(RPC.getChangeRequest(ZONE1.getName(), "2", EMPTY_RPC_OPTIONS)); + // create zone twice try { - Change anotherChange = RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + fail("Zone already exists."); } catch (DnsException ex) { + // expected assertEquals(409, ex.code()); + assertTrue(ex.getMessage().contains("already exists")); } - assertNotNull(RPC.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS)); - assertNull(RPC.getChangeRequest(ZONE1.getName(), "2", EMPTY_RPC_OPTIONS)); - // delete - RPC.applyChangeRequest(ZONE1.getName(), CHANGE2, EMPTY_RPC_OPTIONS); - assertNotNull(RPC.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS)); - assertNotNull(RPC.getChangeRequest(ZONE1.getName(), "2", EMPTY_RPC_OPTIONS)); - Change last = RPC.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); - assertEquals("done", last.getStatus()); - // todo(mderka) replace with real call - List list = - LOCAL_DNS_HELPER.findZone(REAL_PROJECT_ID, ZONE_NAME1).dnsRecords().get(ZONE_NAME1); - assertTrue(list.contains(new LocalDnsHelper.RrsetWrapper(RRSET_KEEP))); - Iterable results = - RPC.listDnsRecords(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); - boolean ok = false; - for (ResourceRecordSet dnsRecord : results) { - if (dnsRecord.getName().equals(RRSET_KEEP.getName()) - && dnsRecord.getType().equals(RRSET_KEEP.getType())) { - ok = true; - } - } - assertTrue(ok); - } - - @Test - public void testFindChange() { - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - Change change = LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE1.getName(), "somerandomchange"); - assertNull(change); - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE1.getName(), CHANGE1, null); - // changes are sequential so we should find ID 1 - assertNotNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE1.getName(), "1")); - // add another - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); - assertNotNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE1.getName(), "1")); - assertNotNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE1.getName(), "2")); - // try to find non-existent change - assertNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE1.getName(), "3")); - // try to find a change in yet non-existent project - assertNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID2, ZONE1.getName(), "3")); - } - - @Test - public void testRandomNameServers() { - assertEquals(4, LocalDnsHelper.randomNameservers().size()); - assertEquals(4, LocalDnsHelper.randomNameservers().size()); - assertEquals(4, LocalDnsHelper.randomNameservers().size()); - assertEquals(4, LocalDnsHelper.randomNameservers().size()); - } - - @Test - public void testGetProject() { - // only interested in no exceptions and non-null response here - assertNotNull(LOCAL_DNS_HELPER.getProject(PROJECT_ID1, null)); - assertNotNull(LOCAL_DNS_HELPER.getProject(PROJECT_ID2, null)); - Project project = RPC.getProject(EMPTY_RPC_OPTIONS); - assertNotNull(project.getQuota()); - assertEquals(REAL_PROJECT_ID, project.getId()); - // fields options - Map options = new HashMap<>(); - options.put(DnsRpc.Option.FIELDS, "number"); - project = RPC.getProject(options); - assertNull(project.getId()); - assertNotNull(project.getNumber()); - assertNull(project.getQuota()); - options.put(DnsRpc.Option.FIELDS, "id"); - project = RPC.getProject(options); - assertNotNull(project.getId()); - assertNull(project.getNumber()); - assertNull(project.getQuota()); - options.put(DnsRpc.Option.FIELDS, "quota"); - project = RPC.getProject(options); - assertNull(project.getId()); - assertNull(project.getNumber()); - assertNotNull(project.getQuota()); - } - - @Test - public void testGetZone() { - // non-existent - LocalDnsHelper.Response response = LOCAL_DNS_HELPER.getZone(PROJECT_ID1, ZONE_NAME1, null); - assertEquals(404, response.code()); - assertTrue(response.body().contains("does not exist")); - // existent - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - response = LOCAL_DNS_HELPER.getZone(PROJECT_ID1, ZONE1.getName(), null); - assertEquals(200, response.code()); - } - - @Test - public void testGetZoneUsingRpc() { - // non-existent - assertNull(RPC.getZone(ZONE_NAME1, EMPTY_RPC_OPTIONS)); - // existent - ManagedZone created = RPC.create(ZONE1, EMPTY_RPC_OPTIONS); - ManagedZone zone = RPC.getZone(ZONE_NAME1, EMPTY_RPC_OPTIONS); - assertEquals(created, zone); - assertEquals(ZONE1.getName(), zone.getName()); // field options + resetProjects(); Map options = new HashMap<>(); options.put(DnsRpc.Option.FIELDS, "id"); - zone = RPC.getZone(ZONE1.getName(), options); + zone = RPC.create(ZONE1, options); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -396,8 +169,9 @@ public void testGetZoneUsingRpc() { assertNull(zone.getNameServers()); assertNull(zone.getNameServerSet()); assertNotNull(zone.getId()); + resetProjects(); options.put(DnsRpc.Option.FIELDS, "creationTime"); - zone = RPC.getZone(ZONE1.getName(), options); + zone = RPC.create(ZONE1, options); assertNotNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -406,7 +180,8 @@ public void testGetZoneUsingRpc() { assertNull(zone.getNameServerSet()); assertNull(zone.getId()); options.put(DnsRpc.Option.FIELDS, "dnsName"); - zone = RPC.getZone(ZONE1.getName(), options); + resetProjects(); + zone = RPC.create(ZONE1, options); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNotNull(zone.getDnsName()); @@ -415,7 +190,8 @@ public void testGetZoneUsingRpc() { assertNull(zone.getNameServerSet()); assertNull(zone.getId()); options.put(DnsRpc.Option.FIELDS, "description"); - zone = RPC.getZone(ZONE1.getName(), options); + resetProjects(); + zone = RPC.create(ZONE1, options); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -424,7 +200,8 @@ public void testGetZoneUsingRpc() { assertNull(zone.getNameServerSet()); assertNull(zone.getId()); options.put(DnsRpc.Option.FIELDS, "nameServers"); - zone = RPC.getZone(ZONE1.getName(), options); + resetProjects(); + zone = RPC.create(ZONE1, options); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -433,7 +210,8 @@ public void testGetZoneUsingRpc() { assertNull(zone.getNameServerSet()); assertNull(zone.getId()); options.put(DnsRpc.Option.FIELDS, "nameServerSet"); - zone = RPC.getZone(ZONE1.getName(), options); + resetProjects(); + zone = RPC.create(ZONE1, options); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -443,7 +221,8 @@ public void testGetZoneUsingRpc() { assertNull(zone.getId()); // several combined options.put(DnsRpc.Option.FIELDS, "nameServerSet,description,id,name"); - zone = RPC.getZone(ZONE1.getName(), options); + resetProjects(); + zone = RPC.create(ZONE1, options); assertNull(zone.getCreationTime()); assertNotNull(zone.getName()); assertNull(zone.getDnsName()); @@ -454,50 +233,18 @@ public void testGetZoneUsingRpc() { } @Test - public void testCreateZone() { - // only interested in no exceptions and non-null response here - LocalDnsHelper.Response response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - assertEquals(200, response.code()); - assertEquals(1, LOCAL_DNS_HELPER.projects().get(PROJECT_ID1).zones().size()); - try { - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, null, null); - fail("Zone cannot be null"); - } catch (NullPointerException ex) { - // expected - } - // create zone twice - response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - assertEquals(409, response.code()); - assertTrue(response.body().contains("already exists")); - } - - @Test - public void testCreateZoneUsingRpc() { + public void testGetZone() { + // non-existent + assertNull(RPC.getZone(ZONE_NAME1, EMPTY_RPC_OPTIONS)); + // existent ManagedZone created = RPC.create(ZONE1, EMPTY_RPC_OPTIONS); - assertEquals(created, LOCAL_DNS_HELPER.findZone(REAL_PROJECT_ID, ZONE1.getName()).zone()); ManagedZone zone = RPC.getZone(ZONE_NAME1, EMPTY_RPC_OPTIONS); assertEquals(created, zone); - try { - RPC.create(null, EMPTY_RPC_OPTIONS); - fail("Zone cannot be null"); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - assertTrue(ex.getMessage().contains("entity.managedZone")); - } - // create zone twice - try { - RPC.create(ZONE1, EMPTY_RPC_OPTIONS); - } catch (DnsException ex) { - // expected - assertEquals(409, ex.code()); - assertTrue(ex.getMessage().contains("already exists")); - } + assertEquals(ZONE1.getName(), zone.getName()); // field options - resetProjects(); Map options = new HashMap<>(); options.put(DnsRpc.Option.FIELDS, "id"); - zone = RPC.create(ZONE1, options); + zone = RPC.getZone(ZONE1.getName(), options); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -505,9 +252,8 @@ public void testCreateZoneUsingRpc() { assertNull(zone.getNameServers()); assertNull(zone.getNameServerSet()); assertNotNull(zone.getId()); - resetProjects(); options.put(DnsRpc.Option.FIELDS, "creationTime"); - zone = RPC.create(ZONE1, options); + zone = RPC.getZone(ZONE1.getName(), options); assertNotNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -516,8 +262,7 @@ public void testCreateZoneUsingRpc() { assertNull(zone.getNameServerSet()); assertNull(zone.getId()); options.put(DnsRpc.Option.FIELDS, "dnsName"); - resetProjects(); - zone = RPC.create(ZONE1, options); + zone = RPC.getZone(ZONE1.getName(), options); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNotNull(zone.getDnsName()); @@ -526,8 +271,7 @@ public void testCreateZoneUsingRpc() { assertNull(zone.getNameServerSet()); assertNull(zone.getId()); options.put(DnsRpc.Option.FIELDS, "description"); - resetProjects(); - zone = RPC.create(ZONE1, options); + zone = RPC.getZone(ZONE1.getName(), options); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -536,8 +280,7 @@ public void testCreateZoneUsingRpc() { assertNull(zone.getNameServerSet()); assertNull(zone.getId()); options.put(DnsRpc.Option.FIELDS, "nameServers"); - resetProjects(); - zone = RPC.create(ZONE1, options); + zone = RPC.getZone(ZONE1.getName(), options); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -546,8 +289,7 @@ public void testCreateZoneUsingRpc() { assertNull(zone.getNameServerSet()); assertNull(zone.getId()); options.put(DnsRpc.Option.FIELDS, "nameServerSet"); - resetProjects(); - zone = RPC.create(ZONE1, options); + zone = RPC.getZone(ZONE1.getName(), options); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -557,8 +299,7 @@ public void testCreateZoneUsingRpc() { assertNull(zone.getId()); // several combined options.put(DnsRpc.Option.FIELDS, "nameServerSet,description,id,name"); - resetProjects(); - zone = RPC.create(ZONE1, options); + zone = RPC.getZone(ZONE1.getName(), options); assertNull(zone.getCreationTime()); assertNotNull(zone.getName()); assertNull(zone.getDnsName()); @@ -568,25 +309,144 @@ public void testCreateZoneUsingRpc() { assertNotNull(zone.getId()); } + @Test + public void testDeleteZone() { + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + assertTrue(RPC.deleteZone(ZONE1.getName())); + assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); + // deleting non-existent zone + assertFalse(RPC.deleteZone(ZONE1.getName())); + assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + RPC.create(ZONE2, EMPTY_RPC_OPTIONS); + assertNotNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); + assertNotNull(RPC.getZone(ZONE2.getName(), EMPTY_RPC_OPTIONS)); + // delete in reverse order + assertTrue(RPC.deleteZone(ZONE1.getName())); + assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); + assertNotNull(RPC.getZone(ZONE2.getName(), EMPTY_RPC_OPTIONS)); + assertTrue(RPC.deleteZone(ZONE2.getName())); + assertNull(RPC.getZone(ZONE1.getName(), EMPTY_RPC_OPTIONS)); + assertNull(RPC.getZone(ZONE2.getName(), EMPTY_RPC_OPTIONS)); + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + RPC.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); + try { + RPC.deleteZone(ZONE1.getName()); + fail(); + } catch (DnsException ex) { + // expected + assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("not empty")); + } + } + + @Test + public void testCreateAndApplyChange() { + executeCreateAndApplyChangeTest(RPC); + } + + @Test + public void testCreateAndApplyChangeWithThreads() { + LocalDnsHelper localDnsThreaded = LocalDnsHelper.create(50L); + localDnsThreaded.start(); + DnsRpc rpc = new DefaultDnsRpc(localDnsThreaded.options()); + executeCreateAndApplyChangeTest(rpc); + localDnsThreaded.stop(); + } + + private static void waitForChangeToComplete(DnsRpc rpc, String zoneName, String changeId) { + while (true) { + Change change = rpc.getChangeRequest(zoneName, changeId, EMPTY_RPC_OPTIONS); + if ("done".equals(change.getStatus())) { + return; + } + try { + Thread.sleep(50L); + } catch (InterruptedException e) { + fail("Thread was interrupted while waiting for change processing."); + } + } + } + + private static void executeCreateAndApplyChangeTest(DnsRpc rpc) { + rpc.create(ZONE1, EMPTY_RPC_OPTIONS); + assertNull(rpc.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS)); + // add + Change createdChange = rpc.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); + assertEquals(CHANGE1.getAdditions(), createdChange.getAdditions()); + assertEquals(CHANGE1.getDeletions(), createdChange.getDeletions()); + assertNotNull(createdChange.getStartTime()); + assertEquals("1", createdChange.getId()); + waitForChangeToComplete(rpc, ZONE1.getName(), "1"); // necessary for the following to return 409 + try { + rpc.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); + fail(); + } catch (DnsException ex) { + assertEquals(409, ex.code()); + assertTrue(ex.getMessage().contains("already exists")); + } + assertNotNull(rpc.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS)); + assertNull(rpc.getChangeRequest(ZONE1.getName(), "2", EMPTY_RPC_OPTIONS)); + // delete + rpc.applyChangeRequest(ZONE1.getName(), CHANGE2, EMPTY_RPC_OPTIONS); + assertNotNull(rpc.getChangeRequest(ZONE1.getName(), "1", EMPTY_RPC_OPTIONS)); + assertNotNull(rpc.getChangeRequest(ZONE1.getName(), "2", EMPTY_RPC_OPTIONS)); + waitForChangeToComplete(rpc, ZONE1.getName(), "2"); + rpc.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); + waitForChangeToComplete(rpc, ZONE1.getName(), "3"); + Iterable results = + rpc.listDnsRecords(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); + List defaults = ImmutableList.of("SOA", "NS"); + boolean rrsetKeep = false; + boolean rrset1 = false; + for (ResourceRecordSet dnsRecord : results) { + if (dnsRecord.getName().equals(RRSET_KEEP.getName()) + && dnsRecord.getType().equals(RRSET_KEEP.getType())) { + rrsetKeep = true; + } else if (dnsRecord.getName().equals(RRSET1.getName()) + && dnsRecord.getType().equals(RRSET1.getType())) { + rrset1 = true; + } else if (!defaults.contains(dnsRecord.getType())) { + fail(String.format("Record with type %s should not exist", dnsRecord.getType())); + } + } + assertTrue(rrset1); + assertTrue(rrsetKeep); + } + + @Test + public void testGetProject() { + // the projects are automatically created when getProject is called + assertNotNull(LOCAL_DNS_HELPER.getProject(PROJECT_ID1, null)); + assertNotNull(LOCAL_DNS_HELPER.getProject(PROJECT_ID2, null)); + Project project = RPC.getProject(EMPTY_RPC_OPTIONS); + assertNotNull(project.getQuota()); + assertEquals(REAL_PROJECT_ID, project.getId()); + // fields options + Map options = new HashMap<>(); + options.put(DnsRpc.Option.FIELDS, "number"); + project = RPC.getProject(options); + assertNull(project.getId()); + assertNotNull(project.getNumber()); + assertNull(project.getQuota()); + options.put(DnsRpc.Option.FIELDS, "id"); + project = RPC.getProject(options); + assertNotNull(project.getId()); + assertNull(project.getNumber()); + assertNull(project.getQuota()); + options.put(DnsRpc.Option.FIELDS, "quota"); + project = RPC.getProject(options); + assertNull(project.getId()); + assertNull(project.getNumber()); + assertNotNull(project.getQuota()); + } + @Test public void testCreateChange() { - // non-existent zone - LocalDnsHelper.Response response = - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); - assertEquals(404, response.code()); - // existent zone - assertNotNull(LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null)); - assertNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE_NAME1, "1")); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); - assertEquals(200, response.code()); - assertNotNull(LOCAL_DNS_HELPER.findChange(PROJECT_ID1, ZONE_NAME1, "1")); - } - - @Test - public void testCreateChangeUsingRpc() { // non-existent zone try { RPC.applyChangeRequest(ZONE_NAME1, CHANGE1, EMPTY_RPC_OPTIONS); + fail("Zone was not created yet."); } catch (DnsException ex) { assertEquals(404, ex.code()); } @@ -637,23 +497,6 @@ public void testCreateChangeUsingRpc() { @Test public void testGetChange() { - // existent - assertEquals(200, LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null).code()); - assertEquals(200, LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null).code()); - assertEquals(200, LOCAL_DNS_HELPER.getChange(PROJECT_ID1, ZONE_NAME1, "1", null).code()); - // non-existent - LocalDnsHelper.Response response = - LOCAL_DNS_HELPER.getChange(PROJECT_ID1, ZONE_NAME1, "2", null); - assertEquals(404, response.code()); - assertTrue(response.body().contains("parameters.changeId")); - // non-existent zone - response = LOCAL_DNS_HELPER.getChange(PROJECT_ID1, ZONE_NAME2, "1", null); - assertEquals(404, response.code()); - assertTrue(response.body().contains("parameters.managedZone")); - } - - @Test - public void testGetChangeUsingRpc() { // existent RPC.create(ZONE1, EMPTY_RPC_OPTIONS); Change created = RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); @@ -664,9 +507,11 @@ public void testGetChangeUsingRpc() { // non-existent zone try { RPC.getChangeRequest(ZONE_NAME2, "1", EMPTY_RPC_OPTIONS); + fail(); } catch (DnsException ex) { // expected assertEquals(404, ex.code()); + assertTrue(ex.getMessage().contains("managedZone")); } // field options RPC.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); @@ -711,43 +556,6 @@ public void testGetChangeUsingRpc() { @Test public void testListZones() { - // only interested in no exceptions and non-null response here - optionsMap.put("dnsName", null); - optionsMap.put("fields", null); - optionsMap.put("pageToken", null); - optionsMap.put("maxResults", null); - LocalDnsHelper.Response response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(200, response.code()); - // some zones exists - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(200, response.code()); - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE2, null); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(200, response.code()); - // error in options - optionsMap.put("maxResults", "aaa"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("maxResults", "0"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("maxResults", "-1"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("maxResults", "15"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(200, response.code()); - optionsMap.put("dnsName", "aaa"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("dnsName", "aaa."); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(200, response.code()); - } - - @Test - public void testListZonesUsingRpc() { Iterable results = RPC.listZones(EMPTY_RPC_OPTIONS).results(); ImmutableList zones = ImmutableList.copyOf(results); assertEquals(0, zones.size()); @@ -767,32 +575,38 @@ public void testListZonesUsingRpc() { options.put(DnsRpc.Option.PAGE_SIZE, 0); try { RPC.listZones(options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.maxResults")); } options = new HashMap<>(); options.put(DnsRpc.Option.PAGE_SIZE, -1); try { RPC.listZones(options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.maxResults")); } // ok size options = new HashMap<>(); - options.put(DnsRpc.Option.PAGE_SIZE, 1); + options.put(DnsRpc.Option.PAGE_SIZE, 335); results = RPC.listZones(options).results(); zones = ImmutableList.copyOf(results); - assertEquals(1, zones.size()); + assertEquals(2, zones.size()); // dns name problems options = new HashMap<>(); options.put(DnsRpc.Option.DNS_NAME, "aaa"); try { RPC.listZones(options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.dnsName")); } // ok name options = new HashMap<>(); @@ -848,9 +662,9 @@ public void testListZonesUsingRpc() { assertNull(zone.getNameServerSet()); assertNull(zone.getId()); options.put(DnsRpc.Option.FIELDS, "managedZones(nameServerSet)"); - DnsRpc.ListResult managedZoneListResult = RPC.listZones(options); - zone = managedZoneListResult.results().iterator().next(); - assertNull(managedZoneListResult.pageToken()); + DnsRpc.ListResult listResult = RPC.listZones(options); + zone = listResult.results().iterator().next(); + assertNull(listResult.pageToken()); assertNull(zone.getCreationTime()); assertNull(zone.getName()); assertNull(zone.getDnsName()); @@ -862,8 +676,8 @@ public void testListZonesUsingRpc() { options.put(DnsRpc.Option.FIELDS, "managedZones(nameServerSet,description,id,name),nextPageToken"); options.put(DnsRpc.Option.PAGE_SIZE, 1); - managedZoneListResult = RPC.listZones(options); - zone = managedZoneListResult.results().iterator().next(); + listResult = RPC.listZones(options); + zone = listResult.results().iterator().next(); assertNull(zone.getCreationTime()); assertNotNull(zone.getName()); assertNull(zone.getDnsName()); @@ -871,80 +685,19 @@ public void testListZonesUsingRpc() { assertNull(zone.getNameServers()); assertNotNull(zone.getNameServerSet()); assertNotNull(zone.getId()); - assertEquals(zone.getName(), managedZoneListResult.pageToken()); - // paging - options = new HashMap<>(); - options.put(DnsRpc.Option.PAGE_SIZE, 1); - managedZoneListResult = RPC.listZones(options); - ImmutableList page1 = ImmutableList.copyOf(managedZoneListResult.results()); - assertEquals(1, page1.size()); - options.put(DnsRpc.Option.PAGE_TOKEN, managedZoneListResult.pageToken()); - managedZoneListResult = RPC.listZones(options); - ImmutableList page2 = ImmutableList.copyOf(managedZoneListResult.results()); - assertEquals(1, page2.size()); - assertNotEquals(page1.get(0), page2.get(0)); + assertEquals(zone.getName(), listResult.pageToken()); } @Test public void testListDnsRecords() { - // only interested in no exceptions and non-null response here - optionsMap.put("name", null); - optionsMap.put("fields", null); - optionsMap.put("type", null); - optionsMap.put("pageToken", null); - optionsMap.put("maxResults", null); - // no zone exists - LocalDnsHelper.Response response = LOCAL_DNS_HELPER.listDnsRecords(PROJECT_ID1, ZONE_NAME1, - optionsMap); - assertEquals(404, response.code()); - // zone exists but has no records - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - LOCAL_DNS_HELPER.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); - // zone has records - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); - response = LOCAL_DNS_HELPER.listDnsRecords(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(200, response.code()); - // error in options - optionsMap.put("maxResults", "aaa"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("maxResults", "0"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("maxResults", "-1"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("maxResults", "15"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(200, response.code()); - optionsMap.put("name", "aaa"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("name", "aaa."); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(200, response.code()); - optionsMap.put("name", null); - optionsMap.put("type", "A"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("name", "aaa."); - optionsMap.put("type", "a"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("name", "aaaa."); - optionsMap.put("type", "A"); - response = LOCAL_DNS_HELPER.listZones(PROJECT_ID1, optionsMap); - assertEquals(200, response.code()); - } - - @Test - public void testListDnsRecordsUsingRpc() { // no zone exists try { RPC.listDnsRecords(ZONE_NAME1, EMPTY_RPC_OPTIONS); + fail(); } catch (DnsException ex) { // expected assertEquals(404, ex.code()); + assertTrue(ex.getMessage().contains("managedZone")); } // zone exists but has no records RPC.create(ZONE1, EMPTY_RPC_OPTIONS); @@ -962,34 +715,35 @@ public void testListDnsRecordsUsingRpc() { options.put(DnsRpc.Option.PAGE_SIZE, 0); try { RPC.listDnsRecords(ZONE1.getName(), options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.maxResults")); } options.put(DnsRpc.Option.PAGE_SIZE, -1); try { RPC.listDnsRecords(ZONE1.getName(), options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.maxResults")); } - options.put(DnsRpc.Option.PAGE_SIZE, 1); - results = RPC.listDnsRecords(ZONE1.getName(), options).results(); - records = ImmutableList.copyOf(results); - assertEquals(1, records.size()); options.put(DnsRpc.Option.PAGE_SIZE, 15); results = RPC.listDnsRecords(ZONE1.getName(), options).results(); records = ImmutableList.copyOf(results); assertEquals(3, records.size()); - // dnsName filter options = new HashMap<>(); options.put(DnsRpc.Option.NAME, "aaa"); try { RPC.listDnsRecords(ZONE1.getName(), options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.name")); } options.put(DnsRpc.Option.NAME, "aaa."); results = RPC.listDnsRecords(ZONE1.getName(), options).results(); @@ -999,17 +753,21 @@ public void testListDnsRecordsUsingRpc() { options.put(DnsRpc.Option.DNS_TYPE, "A"); try { RPC.listDnsRecords(ZONE1.getName(), options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.name")); } options.put(DnsRpc.Option.NAME, "aaa."); options.put(DnsRpc.Option.DNS_TYPE, "a"); try { RPC.listDnsRecords(ZONE1.getName(), options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.type")); } options.put(DnsRpc.Option.NAME, DNS_NAME); options.put(DnsRpc.Option.DNS_TYPE, "SOA"); @@ -1019,137 +777,74 @@ public void testListDnsRecordsUsingRpc() { // field options options = new HashMap<>(); options.put(DnsRpc.Option.FIELDS, "rrsets(name)"); - DnsRpc.ListResult resourceRecordSetListResult = + DnsRpc.ListResult listResult = RPC.listDnsRecords(ZONE1.getName(), options); - records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + records = ImmutableList.copyOf(listResult.results()); ResourceRecordSet record = records.get(0); assertNotNull(record.getName()); assertNull(record.getRrdatas()); assertNull(record.getType()); assertNull(record.getTtl()); - assertNull(resourceRecordSetListResult.pageToken()); + assertNull(listResult.pageToken()); options.put(DnsRpc.Option.FIELDS, "rrsets(rrdatas)"); - resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); - records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + listResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(listResult.results()); record = records.get(0); assertNull(record.getName()); assertNotNull(record.getRrdatas()); assertNull(record.getType()); assertNull(record.getTtl()); - assertNull(resourceRecordSetListResult.pageToken()); + assertNull(listResult.pageToken()); options.put(DnsRpc.Option.FIELDS, "rrsets(ttl)"); - resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); - records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + listResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(listResult.results()); record = records.get(0); assertNull(record.getName()); assertNull(record.getRrdatas()); assertNull(record.getType()); assertNotNull(record.getTtl()); - assertNull(resourceRecordSetListResult.pageToken()); + assertNull(listResult.pageToken()); options.put(DnsRpc.Option.FIELDS, "rrsets(type)"); - resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); - records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + listResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(listResult.results()); record = records.get(0); assertNull(record.getName()); assertNull(record.getRrdatas()); assertNotNull(record.getType()); assertNull(record.getTtl()); - assertNull(resourceRecordSetListResult.pageToken()); + assertNull(listResult.pageToken()); options.put(DnsRpc.Option.FIELDS, "nextPageToken"); - resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); - records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + listResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(listResult.results()); record = records.get(0); assertNull(record.getName()); assertNull(record.getRrdatas()); assertNull(record.getType()); assertNull(record.getTtl()); - assertNull(resourceRecordSetListResult.pageToken()); + assertNull(listResult.pageToken()); options.put(DnsRpc.Option.FIELDS, "nextPageToken,rrsets(name,rrdatas)"); options.put(DnsRpc.Option.PAGE_SIZE, 1); - resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); - records = ImmutableList.copyOf(resourceRecordSetListResult.results()); + listResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(listResult.results()); assertEquals(1, records.size()); record = records.get(0); assertNotNull(record.getName()); assertNotNull(record.getRrdatas()); assertNull(record.getType()); assertNull(record.getTtl()); - assertNotNull(resourceRecordSetListResult.pageToken()); - // paging - options.put(DnsRpc.Option.PAGE_TOKEN, resourceRecordSetListResult.pageToken()); - resourceRecordSetListResult = RPC.listDnsRecords(ZONE1.getName(), options); - records = ImmutableList.copyOf(resourceRecordSetListResult.results()); - assertEquals(1, records.size()); - ResourceRecordSet nextRecord = records.get(0); - assertNotEquals(record, nextRecord); + assertNotNull(listResult.pageToken()); } @Test public void testListChanges() { - optionsMap.put("sortBy", null); - optionsMap.put("sortOrder", null); - optionsMap.put("fields", null); - optionsMap.put("pageToken", null); - optionsMap.put("maxResults", null); - // no such zone exists - LocalDnsHelper.Response response = - LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(404, response.code()); - assertTrue(response.body().contains("managedZone")); - // zone exists but has no changes - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - assertNotNull(LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); - // zone has changes - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); - assertNotNull(LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE1, null); - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, CHANGE2, null); - assertNotNull(LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap)); - // error in options - optionsMap.put("maxResults", "aaa"); - response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("maxResults", "0"); - response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("maxResults", "-1"); - response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(400, response.code()); - optionsMap.put("maxResults", "15"); - response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(200, response.code()); - optionsMap.put("sortBy", "changeSequence"); - response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(200, response.code()); - optionsMap.put("sortBy", "something else"); - response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(400, response.code()); - assertTrue(response.body().contains("Allowed values: [changesequence]")); - optionsMap.put("sortBy", "ChAnGeSeQuEnCe"); // is not case sensitive - response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(200, response.code()); - optionsMap.put("sortOrder", "ascending"); - response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(200, response.code()); - optionsMap.put("sortBy", null); - optionsMap.put("sortOrder", "descending"); - response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(200, response.code()); - optionsMap.put("sortOrder", "somethingelse"); - response = LOCAL_DNS_HELPER.listChanges(PROJECT_ID1, ZONE_NAME1, optionsMap); - assertEquals(400, response.code()); - assertTrue(response.body().contains("parameters.sortOrder")); - } - - @Test - public void testListChangesUsingRpc() { // no such zone exists try { RPC.listChangeRequests(ZONE_NAME1, EMPTY_RPC_OPTIONS); + fail(); } catch (DnsException ex) { // expected assertEquals(404, ex.code()); + assertTrue(ex.getMessage().contains("managedZone")); } // zone exists but has no changes RPC.create(ZONE1, EMPTY_RPC_OPTIONS); @@ -1168,24 +863,25 @@ public void testListChangesUsingRpc() { options.put(DnsRpc.Option.PAGE_SIZE, 0); try { RPC.listChangeRequests(ZONE1.getName(), options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.maxResults")); } options.put(DnsRpc.Option.PAGE_SIZE, -1); try { RPC.listChangeRequests(ZONE1.getName(), options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.maxResults")); } options.put(DnsRpc.Option.PAGE_SIZE, 15); - try { - RPC.listChangeRequests(ZONE1.getName(), options); - } catch (DnsException ex) { - // expected - assertEquals(400, ex.code()); - } + results = RPC.listChangeRequests(ZONE1.getName(), options).results(); + changes = ImmutableList.copyOf(results); + assertEquals(3, changes.size()); options = new HashMap<>(); options.put(DnsRpc.Option.SORTING_ORDER, "descending"); results = RPC.listChangeRequests(ZONE1.getName(), options).results(); @@ -1200,17 +896,18 @@ public void testListChangesUsingRpc() { options.put(DnsRpc.Option.SORTING_ORDER, "something else"); try { RPC.listChangeRequests(ZONE1.getName(), options); + fail(); } catch (DnsException ex) { // expected assertEquals(400, ex.code()); + assertTrue(ex.getMessage().contains("parameters.sortOrder")); } // field options RPC.applyChangeRequest(ZONE1.getName(), CHANGE_COMPLEX, EMPTY_RPC_OPTIONS); options = new HashMap<>(); options.put(DnsRpc.Option.SORTING_ORDER, "descending"); options.put(DnsRpc.Option.FIELDS, "changes(additions)"); - DnsRpc.ListResult changeListResult = - RPC.listChangeRequests(ZONE1.getName(), options); + DnsRpc.ListResult changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); changes = ImmutableList.copyOf(changeListResult.results()); Change complex = changes.get(0); assertNotNull(complex.getAdditions()); @@ -1270,20 +967,68 @@ public void testListChangesUsingRpc() { assertNull(complex.getStartTime()); assertNull(complex.getStatus()); assertNotNull(changeListResult.pageToken()); - // paging - options.put(DnsRpc.Option.FIELDS, "nextPageToken,changes(id)"); + } + + @Test + public void testDnsRecordPaging() { + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + List complete = ImmutableList.copyOf( + RPC.listDnsRecords(ZONE1.getName(), EMPTY_RPC_OPTIONS).results()); + Map options = new HashMap<>(); options.put(DnsRpc.Option.PAGE_SIZE, 1); - changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); - changes = ImmutableList.copyOf(changeListResult.results()); + DnsRpc.ListResult listResult = RPC.listDnsRecords(ZONE1.getName(), options); + ImmutableList records = ImmutableList.copyOf(listResult.results()); + assertEquals(1, records.size()); + assertEquals(complete.get(0), records.get(0)); + options.put(DnsRpc.Option.PAGE_TOKEN, listResult.pageToken()); + listResult = RPC.listDnsRecords(ZONE1.getName(), options); + records = ImmutableList.copyOf(listResult.results()); + assertEquals(1, records.size()); + assertEquals(complete.get(1), records.get(0)); + } + + @Test + public void testZonePaging() { + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + RPC.create(ZONE2, EMPTY_RPC_OPTIONS); + ImmutableList complete = ImmutableList.copyOf( + RPC.listZones(EMPTY_RPC_OPTIONS).results()); + Map options = new HashMap<>(); + options.put(DnsRpc.Option.PAGE_SIZE, 1); + DnsRpc.ListResult listResult = RPC.listZones(options); + ImmutableList page1 = ImmutableList.copyOf(listResult.results()); + assertEquals(1, page1.size()); + assertEquals(complete.get(0), page1.get(0)); + assertEquals(page1.get(0).getName(), listResult.pageToken()); + options.put(DnsRpc.Option.PAGE_TOKEN, listResult.pageToken()); + listResult = RPC.listZones(options); + ImmutableList page2 = ImmutableList.copyOf(listResult.results()); + assertEquals(1, page2.size()); + assertEquals(complete.get(1), page2.get(0)); + assertNull(listResult.pageToken()); + } + + @Test + public void testChangePaging() { + RPC.create(ZONE1, EMPTY_RPC_OPTIONS); + RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); + RPC.applyChangeRequest(ZONE1.getName(), CHANGE2, EMPTY_RPC_OPTIONS); + RPC.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); + ImmutableList complete = + ImmutableList.copyOf(RPC.listChangeRequests(ZONE1.getName(), EMPTY_RPC_OPTIONS).results()); + Map options = new HashMap<>(); + options.put(DnsRpc.Option.PAGE_SIZE, 1); + DnsRpc.ListResult changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); + List changes = ImmutableList.copyOf(changeListResult.results()); assertEquals(1, changes.size()); - final Change first = changes.get(0); - assertNotNull(changeListResult.pageToken()); + assertEquals(complete.get(0), changes.get(0)); + assertEquals(complete.get(0).getId(), changeListResult.pageToken()); options.put(DnsRpc.Option.PAGE_TOKEN, changeListResult.pageToken()); changeListResult = RPC.listChangeRequests(ZONE1.getName(), options); changes = ImmutableList.copyOf(changeListResult.results()); assertEquals(1, changes.size()); - Change second = changes.get(0); - assertNotEquals(first, second); + assertEquals(complete.get(1), changes.get(0)); + assertEquals(complete.get(1).getId(), changeListResult.pageToken()); } @Test @@ -1303,95 +1048,71 @@ public void testToListResponse() { } @Test - public void testCheckZone() { + public void testCreateZoneValidation() { + ManagedZone minimalZone = copyZone(ZONE1); // no name ManagedZone copy = copyZone(minimalZone); copy.setName(null); - LocalDnsHelper.Response response = LocalDnsHelper.checkZone(copy); + LocalDnsHelper.Response response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.name")); // no description copy = copyZone(minimalZone); copy.setDescription(null); - response = LocalDnsHelper.checkZone(copy); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.description")); - // no description + // no dns name copy = copyZone(minimalZone); copy.setDnsName(null); - response = LocalDnsHelper.checkZone(copy); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.dnsName")); - // zone name is a number + // zone name does not start with a letter copy = copyZone(minimalZone); - copy.setName("123456"); - response = LocalDnsHelper.checkZone(copy); + copy.setName("1aaaaaa"); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.name")); assertTrue(response.body().contains("Invalid")); - // dns name does not end with period + // zone name is too long copy = copyZone(minimalZone); - copy.setDnsName("aaaaaa.com"); - response = LocalDnsHelper.checkZone(copy); + copy.setName("123456aaaa123456aaaa123456aaaa123456aaaa123456aaaa123456aaaa123456aaaa123456aa"); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy); assertEquals(400, response.code()); - assertTrue(response.body().contains("entity.managedZone.dnsName")); + assertTrue(response.body().contains("entity.managedZone.name")); assertTrue(response.body().contains("Invalid")); - // dns name is reserved - copy = copyZone(minimalZone); - copy.setDnsName("com."); - response = LocalDnsHelper.checkZone(copy); - assertEquals(400, response.code()); - assertTrue(response.body().contains("not available to be created.")); - // empty description should pass + // zone name contains invalid characters copy = copyZone(minimalZone); - copy.setDescription(""); - assertNull(LocalDnsHelper.checkZone(copy)); - } - - @Test - public void testCreateZoneValidatesZone() { - // no name - ManagedZone copy = copyZone(minimalZone); - copy.setName(null); - LocalDnsHelper.Response response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); + copy.setName("x1234AA6aa"); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.name")); - // no description - copy = copyZone(minimalZone); - copy.setDescription(null); - response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); - assertEquals(400, response.code()); - assertTrue(response.body().contains("entity.managedZone.description")); - // no dns name - copy = copyZone(minimalZone); - copy.setDnsName(null); - response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); - assertEquals(400, response.code()); - assertTrue(response.body().contains("entity.managedZone.dnsName")); - // zone name is a number + assertTrue(response.body().contains("Invalid")); + // zone name contains invalid characters copy = copyZone(minimalZone); - copy.setName("123456"); - response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); + copy.setName("x a"); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.name")); assertTrue(response.body().contains("Invalid")); // dns name does not end with period copy = copyZone(minimalZone); copy.setDnsName("aaaaaa.com"); - response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy); assertEquals(400, response.code()); assertTrue(response.body().contains("entity.managedZone.dnsName")); assertTrue(response.body().contains("Invalid")); // dns name is reserved copy = copyZone(minimalZone); copy.setDnsName("com."); - response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy); assertEquals(400, response.code()); assertTrue(response.body().contains("not available to be created.")); // empty description should pass copy = copyZone(minimalZone); copy.setDescription(""); - response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy, null); + response = LOCAL_DNS_HELPER.createZone(PROJECT_ID1, copy); assertEquals(200, response.code()); } @@ -1474,8 +1195,8 @@ public void testCheckRrset() { valid.setTtl(500); Change validChange = new Change(); validChange.setAdditions(ImmutableList.of(valid)); - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange); // delete with field mismatch LocalDnsHelper.ZoneContainer zone = LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE_NAME1); valid.setTtl(valid.getTtl() + 20); @@ -1501,11 +1222,10 @@ public void testCheckRrdata() { assertFalse(LocalDnsHelper.checkRrData("111.255.12", "A")); assertFalse(LocalDnsHelper.checkRrData("111.255.12.11.11", "A")); // AAAA - assertTrue(LocalDnsHelper.checkRrData(":::::::", "AAAA")); - assertTrue(LocalDnsHelper.checkRrData("1F:fa:09fd::343:aaaa:AAAA:", "AAAA")); - assertTrue(LocalDnsHelper.checkRrData("0000:FFFF:09fd::343:aaaa:AAAA:", "AAAA")); + assertTrue(LocalDnsHelper.checkRrData("1F:fa:09fd::343:aaaa:AAAA:0", "AAAA")); + assertTrue(LocalDnsHelper.checkRrData("0000:FFFF:09fd::343:aaaa:AAAA:0", "AAAA")); assertFalse(LocalDnsHelper.checkRrData("-2:::::::", "AAAA")); - assertTrue(LocalDnsHelper.checkRrData("0:::::::", "AAAA")); + assertTrue(LocalDnsHelper.checkRrData("0::0", "AAAA")); assertFalse(LocalDnsHelper.checkRrData("::1FFFF:::::", "AAAA")); assertFalse(LocalDnsHelper.checkRrData("::aqaa:::::", "AAAA")); assertFalse(LocalDnsHelper.checkRrData("::::::::", "AAAA")); // too long @@ -1587,62 +1307,59 @@ public void testCheckChange() { ResourceRecordSet nonExistent = new ResourceRecordSet(); nonExistent.setName(ZONE1.getDnsName()); nonExistent.setType("AAAA"); - nonExistent.setRrdatas(ImmutableList.of(":::::::")); + nonExistent.setRrdatas(ImmutableList.of("0:0:0:0:5::6")); Change delete = new Change(); delete.setDeletions(ImmutableList.of(nonExistent)); response = LocalDnsHelper.checkChange(delete, zoneContainer); assertEquals(404, response.code()); assertTrue(response.body().contains("deletions[0]")); - } @Test - public void testAdditionsMeetDeletions() { + public void testCheckAdditionsDeletions() { ResourceRecordSet validA = new ResourceRecordSet(); validA.setName(ZONE1.getDnsName()); validA.setType("A"); validA.setRrdatas(ImmutableList.of("0.255.1.5")); Change validChange = new Change(); validChange.setAdditions(ImmutableList.of(validA)); - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange); LocalDnsHelper.ZoneContainer container = LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE_NAME1); LocalDnsHelper.Response response = - LocalDnsHelper.additionsMeetDeletions(ImmutableList.of(validA), null, container); + LocalDnsHelper.checkAdditionsDeletions(ImmutableList.of(validA), null, container); assertEquals(409, response.code()); assertTrue(response.body().contains("already exists")); - } @Test - public void testCreateChangeValidatesChangeContent() { + public void testCreateChangeContentValidation() { ResourceRecordSet validA = new ResourceRecordSet(); validA.setName(ZONE1.getDnsName()); validA.setType("A"); validA.setRrdatas(ImmutableList.of("0.255.1.5")); Change validChange = new Change(); validChange.setAdditions(ImmutableList.of(validA)); - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange); LocalDnsHelper.Response response = - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); + LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange); assertEquals(409, response.code()); assertTrue(response.body().contains("already exists")); // delete with field mismatch Change delete = new Change(); validA.setTtl(20); // mismatch delete.setDeletions(ImmutableList.of(validA)); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete); assertEquals(412, response.code()); assertTrue(response.body().contains("entity.change.deletions[0]")); // delete and add SOA Change addition = new Change(); - ImmutableList rrsetWrappers - = LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE_NAME1).dnsRecords().get(ZONE_NAME1); + ImmutableCollection dnsRecords = + LOCAL_DNS_HELPER.findZone(PROJECT_ID1, ZONE_NAME1).dnsRecords().get().values(); LinkedList deletions = new LinkedList<>(); LinkedList additions = new LinkedList<>(); - for (LocalDnsHelper.RrsetWrapper wrapper : rrsetWrappers) { - ResourceRecordSet rrset = wrapper.rrset(); + for (ResourceRecordSet rrset : dnsRecords) { if (rrset.getType().equals("SOA")) { deletions.add(rrset); ResourceRecordSet copy = copyRrset(rrset); @@ -1653,12 +1370,12 @@ public void testCreateChangeValidatesChangeContent() { } delete.setDeletions(deletions); addition.setAdditions(additions); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete); assertEquals(400, response.code()); assertTrue(response.body().contains( "zone must contain exactly one resource record set of type 'SOA' at the apex")); assertTrue(response.body().contains("deletions[0]")); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, addition); assertEquals(400, response.code()); assertTrue(response.body().contains( "zone must contain exactly one resource record set of type 'SOA' at the apex")); @@ -1666,8 +1383,7 @@ public void testCreateChangeValidatesChangeContent() { // delete NS deletions = new LinkedList<>(); additions = new LinkedList<>(); - for (LocalDnsHelper.RrsetWrapper wrapper : rrsetWrappers) { - ResourceRecordSet rrset = wrapper.rrset(); + for (ResourceRecordSet rrset : dnsRecords) { if (rrset.getType().equals("NS")) { deletions.add(rrset); ResourceRecordSet copy = copyRrset(rrset); @@ -1678,96 +1394,38 @@ public void testCreateChangeValidatesChangeContent() { } delete.setDeletions(deletions); addition.setAdditions(additions); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete); assertEquals(400, response.code()); assertTrue(response.body().contains( "zone must contain exactly one resource record set of type 'NS' at the apex")); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, addition); assertEquals(400, response.code()); assertTrue(response.body().contains( "zone must contain exactly one resource record set of type 'NS' at the apex")); assertTrue(response.body().contains("additions[0]")); // change (delete + add) addition.setDeletions(deletions); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, addition, null); + response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, addition); assertEquals(200, response.code()); } @Test - public void testCreateChangeValidatesChange() { - LOCAL_DNS_HELPER.createZone(PROJECT_ID1, ZONE1, null); - ResourceRecordSet validA = new ResourceRecordSet(); - validA.setName(ZONE1.getDnsName()); - validA.setType("A"); - validA.setRrdatas(ImmutableList.of("0.255.1.5")); - ResourceRecordSet invalidA = new ResourceRecordSet(); - invalidA.setName(ZONE1.getDnsName()); - invalidA.setType("A"); - invalidA.setRrdatas(ImmutableList.of("0.-255.1.5")); - Change validChange = new Change(); - validChange.setAdditions(ImmutableList.of(validA)); - Change invalidChange = new Change(); - invalidChange.setAdditions(ImmutableList.of(invalidA)); - LocalDnsHelper.Response response = - LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); - assertEquals(200, response.code()); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, invalidChange, null); - assertEquals(400, response.code()); - // only empty additions/deletions - Change empty = new Change(); - empty.setAdditions(ImmutableList.of()); - empty.setDeletions(ImmutableList.of()); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, empty, null); - assertEquals(400, response.code()); - assertTrue(response.body().contains( - "The 'entity.change' parameter is required but was missing.")); - // non-matching name - validA.setName(ZONE1.getDnsName() + ".aaa."); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); - assertEquals(400, response.code()); - assertTrue(response.body().contains("additions[0].name")); - // wrong type - validA.setName(ZONE1.getDnsName()); // revert - validA.setType("ABCD"); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); - assertEquals(400, response.code()); - assertTrue(response.body().contains("additions[0].type")); - // wrong ttl - validA.setType("A"); // revert - validA.setTtl(-1); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); - assertEquals(400, response.code()); - assertTrue(response.body().contains("additions[0].ttl")); - validA.setTtl(null); // revert - // null name - validA.setName(null); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); - assertEquals(400, response.code()); - assertTrue(response.body().contains("additions[0].name")); - validA.setName(ZONE1.getDnsName()); - // null type - validA.setType(null); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); - assertEquals(400, response.code()); - assertTrue(response.body().contains("additions[0].type")); - validA.setType("A"); - // null rrdata - final List temp = validA.getRrdatas(); // preserve - validA.setRrdatas(null); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, validChange, null); - assertEquals(400, response.code()); - assertTrue(response.body().contains("additions[0].rrdata")); - validA.setRrdatas(temp); - // delete non-existent - ResourceRecordSet nonExistent = new ResourceRecordSet(); - nonExistent.setName(ZONE1.getDnsName()); - nonExistent.setType("AAAA"); - nonExistent.setRrdatas(ImmutableList.of(":::::::")); - Change delete = new Change(); - delete.setDeletions(ImmutableList.of(nonExistent)); - response = LOCAL_DNS_HELPER.createChange(PROJECT_ID1, ZONE_NAME1, delete, null); - assertEquals(404, response.code()); - assertTrue(response.body().contains("deletions[0]")); + public void testMatchesCriteria() { + assertTrue(LocalDnsHelper.matchesCriteria(RRSET1, RRSET1.getName(), RRSET1.getType())); + assertFalse(LocalDnsHelper.matchesCriteria(RRSET1, RRSET1.getName(), "anothertype")); + assertTrue(LocalDnsHelper.matchesCriteria(RRSET1, null, RRSET1.getType())); + assertTrue(LocalDnsHelper.matchesCriteria(RRSET1, RRSET1.getName(), null)); + assertFalse(LocalDnsHelper.matchesCriteria(RRSET1, "anothername", RRSET1.getType())); + } + + @Test + public void testGetUniqueId() { + assertNotNull(LocalDnsHelper.getUniqueId(new HashSet())); + } + + @Test + public void testRandomNameServers() { + assertEquals(4, LocalDnsHelper.randomNameservers().size()); } private static ManagedZone copyZone(ManagedZone original) { From 3cf07229834282f96f84cd783b4487a323967bfc Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 1 Mar 2016 14:41:17 -0800 Subject: [PATCH 125/203] Switched ZoneInfo.builder(). to ZoneInfo.of(). Fixes #698. --- .../java/com/google/gcloud/dns/ZoneInfo.java | 6 +-- .../com/google/gcloud/dns/DnsImplTest.java | 3 +- .../google/gcloud/dns/SerializationTest.java | 10 ++--- .../com/google/gcloud/dns/ZoneInfoTest.java | 42 ++++++++--------- .../java/com/google/gcloud/dns/ZoneTest.java | 9 ++-- .../com/google/gcloud/dns/it/ITDnsTest.java | 45 +++---------------- 6 files changed, 38 insertions(+), 77 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java index 7dffbcdd365c..38a88b67777e 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ZoneInfo.java @@ -185,10 +185,10 @@ public ZoneInfo build() { } /** - * Returns a builder for {@code ZoneInfo} with an assigned {@code name}. + * Returns a ZoneInfo object with assigned {@code name}, {@code dnsName} and {@code description}. */ - public static Builder builder(String name) { - return new BuilderImpl(name); + public static ZoneInfo of(String name, String dnsName, String description) { + return new BuilderImpl(name).dnsName(dnsName).description(description).build(); } /** diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java index e1974d6cccfd..9205de8d99dd 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java @@ -44,6 +44,7 @@ public class DnsImplTest { // Dns entities private static final String ZONE_NAME = "some zone name"; private static final String DNS_NAME = "example.com."; + private static final String DESCRIPTION = "desc"; private static final String CHANGE_ID = "some change id"; private static final DnsRecord DNS_RECORD1 = DnsRecord.builder("Something", DnsRecord.Type.AAAA) .build(); @@ -51,7 +52,7 @@ public class DnsImplTest { .build(); private static final Integer MAX_SIZE = 20; private static final String PAGE_TOKEN = "some token"; - private static final ZoneInfo ZONE_INFO = ZoneInfo.builder(ZONE_NAME).build(); + private static final ZoneInfo ZONE_INFO = ZoneInfo.of(ZONE_NAME, DNS_NAME, DESCRIPTION); private static final ProjectInfo PROJECT_INFO = ProjectInfo.builder().build(); private static final ChangeRequest CHANGE_REQUEST_PARTIAL = ChangeRequest.builder() .add(DNS_RECORD1) diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java index adf5744d854e..c2bf9cfca0bb 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java @@ -35,16 +35,15 @@ public class SerializationTest { - private static final ZoneInfo FULL_ZONE_INFO = Zone.builder("some zone name") + private static final ZoneInfo FULL_ZONE_INFO = Zone.of("some zone name", "www.example.com", + "some descriptions").toBuilder() .creationTimeMillis(132L) - .description("some descriptions") - .dnsName("www.example.com") .id("123333") .nameServers(ImmutableList.of("server 1", "server 2")) .nameServerSet("specificationstring") .build(); - private static final ZoneInfo PARTIAL_ZONE_INFO = Zone.builder("some zone name") - .build(); + private static final ZoneInfo PARTIAL_ZONE_INFO = Zone.of("some zone name", "www.example.com", + "some descriptions").toBuilder().build(); private static final ProjectInfo PARTIAL_PROJECT_INFO = ProjectInfo.builder().id("13").build(); private static final ProjectInfo FULL_PROJECT_INFO = ProjectInfo.builder() .id("342") @@ -87,7 +86,6 @@ public class SerializationTest { .startTimeMillis(132L) .build(); - @Test public void testModelAndRequests() throws Exception { Serializable[] objects = {FULL_ZONE_INFO, PARTIAL_ZONE_INFO, ZONE_LIST_OPTION, diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java index 227916b46f96..b743bd385274 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java @@ -41,25 +41,23 @@ public class ZoneInfoTest { private static final String NS2 = "name server 2"; private static final String NS3 = "name server 3"; private static final List NAME_SERVERS = ImmutableList.of(NS1, NS2, NS3); - private static final ZoneInfo INFO = ZoneInfo.builder(NAME) + private static final ZoneInfo INFO = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() .creationTimeMillis(CREATION_TIME_MILLIS) .id(ID) - .dnsName(DNS_NAME) - .description(DESCRIPTION) .nameServerSet(NAME_SERVER_SET) .nameServers(NAME_SERVERS) .build(); @Test public void testDefaultBuilders() { - ZoneInfo zone = ZoneInfo.builder(NAME).build(); + ZoneInfo zone = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); assertTrue(zone.nameServers().isEmpty()); assertEquals(NAME, zone.name()); assertNull(zone.id()); assertNull(zone.creationTimeMillis()); assertNull(zone.nameServerSet()); - assertNull(zone.description()); - assertNull(zone.dnsName()); + assertEquals(DESCRIPTION, zone.description()); + assertEquals(DNS_NAME, zone.dnsName()); } @Test @@ -109,42 +107,38 @@ public void testSameHashCodeOnEquals() { @Test public void testToBuilder() { assertEquals(INFO, INFO.toBuilder().build()); - ZoneInfo partial = ZoneInfo.builder(NAME).build(); + ZoneInfo partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); assertEquals(partial, partial.toBuilder().build()); - partial = ZoneInfo.builder(NAME).id(ID).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().id(ID).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ZoneInfo.builder(NAME).description(DESCRIPTION).build(); - assertEquals(partial, partial.toBuilder().build()); - partial = ZoneInfo.builder(NAME).dnsName(DNS_NAME).build(); - assertEquals(partial, partial.toBuilder().build()); - partial = ZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() + .creationTimeMillis(CREATION_TIME_MILLIS).build(); assertEquals(partial, partial.toBuilder().build()); List nameServers = new LinkedList<>(); nameServers.add(NS1); - partial = ZoneInfo.builder(NAME).nameServers(nameServers).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().nameServers(nameServers).build(); assertEquals(partial, partial.toBuilder().build()); - partial = ZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().nameServerSet(NAME_SERVER_SET) + .build(); assertEquals(partial, partial.toBuilder().build()); } @Test public void testToAndFromPb() { assertEquals(INFO, ZoneInfo.fromPb(INFO.toPb())); - ZoneInfo partial = ZoneInfo.builder(NAME).build(); - assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); - partial = ZoneInfo.builder(NAME).id(ID).build(); - assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); - partial = ZoneInfo.builder(NAME).description(DESCRIPTION).build(); + ZoneInfo partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); - partial = ZoneInfo.builder(NAME).dnsName(DNS_NAME).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().id(ID).build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); - partial = ZoneInfo.builder(NAME).creationTimeMillis(CREATION_TIME_MILLIS).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder() + .creationTimeMillis(CREATION_TIME_MILLIS).build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); List nameServers = new LinkedList<>(); nameServers.add(NS1); - partial = ZoneInfo.builder(NAME).nameServers(nameServers).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().nameServers(nameServers).build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); - partial = ZoneInfo.builder(NAME).nameServerSet(NAME_SERVER_SET).build(); + partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION).toBuilder().nameServerSet(NAME_SERVER_SET) + .build(); assertEquals(partial, ZoneInfo.fromPb(partial.toPb())); } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index 5164dfb6001c..759c34fc1167 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -43,13 +43,13 @@ public class ZoneTest { private static final String ZONE_NAME = "dns-zone-name"; private static final String ZONE_ID = "123"; - private static final ZoneInfo ZONE_INFO = Zone.builder(ZONE_NAME) + private static final ZoneInfo ZONE_INFO = Zone.of(ZONE_NAME, "example.com", "description") + .toBuilder() .id(ZONE_ID) - .dnsName("example.com") .creationTimeMillis(123478946464L) .build(); - private static final ZoneInfo NO_ID_INFO = ZoneInfo.builder(ZONE_NAME) - .dnsName("another-example.com") + private static final ZoneInfo NO_ID_INFO = + ZoneInfo.of(ZONE_NAME, "another-example.com", "description").toBuilder() .creationTimeMillis(893123464L) .build(); private static final Dns.ZoneOption ZONE_FIELD_OPTIONS = @@ -71,7 +71,6 @@ public class ZoneTest { private Zone zone; private Zone zoneNoId; - @Before public void setUp() throws Exception { dns = createStrictMock(Dns.class); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java index fda579a4a94b..4ad17fa8b217 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java @@ -60,29 +60,14 @@ public class ITDnsTest { private static final String ZONE_DNS_NAME1 = ZONE_NAME1 + ".com."; private static final String ZONE_DNS_EMPTY_DESCRIPTION = ZONE_NAME_EMPTY_DESCRIPTION + ".com."; private static final String ZONE_DNS_NAME_NO_PERIOD = ZONE_NAME1 + ".com"; - private static final ZoneInfo ZONE1 = ZoneInfo.builder(ZONE_NAME1) - .description(ZONE_DESCRIPTION1) - .dnsName(ZONE_DNS_EMPTY_DESCRIPTION) - .build(); + private static final ZoneInfo ZONE1 = + ZoneInfo.of(ZONE_NAME1, ZONE_DNS_EMPTY_DESCRIPTION, ZONE_DESCRIPTION1); private static final ZoneInfo ZONE_EMPTY_DESCRIPTION = - ZoneInfo.builder(ZONE_NAME_EMPTY_DESCRIPTION) - .description(ZONE_DESCRIPTION1) - .dnsName(ZONE_DNS_NAME1) - .build(); - private static final ZoneInfo ZONE_NAME_ERROR = ZoneInfo.builder(ZONE_NAME_TOO_LONG) - .description(ZONE_DESCRIPTION1) - .dnsName(ZONE_DNS_NAME1) - .build(); - private static final ZoneInfo ZONE_MISSING_DESCRIPTION = ZoneInfo.builder(ZONE_NAME1) - .dnsName(ZONE_DNS_NAME1) - .build(); - private static final ZoneInfo ZONE_MISSING_DNS_NAME = ZoneInfo.builder(ZONE_NAME1) - .description(ZONE_DESCRIPTION1) - .build(); - private static final ZoneInfo ZONE_DNS_NO_PERIOD = ZoneInfo.builder(ZONE_NAME1) - .description(ZONE_DESCRIPTION1) - .dnsName(ZONE_DNS_NAME_NO_PERIOD) - .build(); + ZoneInfo.of(ZONE_NAME_EMPTY_DESCRIPTION, ZONE_DNS_NAME1, ZONE_DESCRIPTION1); + private static final ZoneInfo ZONE_NAME_ERROR = + ZoneInfo.of(ZONE_NAME_TOO_LONG, ZONE_DNS_NAME1, ZONE_DESCRIPTION1); + private static final ZoneInfo ZONE_DNS_NO_PERIOD = + ZoneInfo.of(ZONE_NAME1, ZONE_DNS_NAME_NO_PERIOD, ZONE_DESCRIPTION1); private static final DnsRecord A_RECORD_ZONE1 = DnsRecord.builder("www." + ZONE1.dnsName(), DnsRecord.Type.A) .records(ImmutableList.of("123.123.55.1")) @@ -211,20 +196,6 @@ public void testCreateValidZone() { @Test public void testCreateZoneWithErrors() { try { - try { - DNS.create(ZONE_MISSING_DNS_NAME); - fail("Zone is missing DNS name. The service returns an error."); - } catch (DnsException ex) { - // expected - // todo(mderka) test non-retryable when implemented within #593 - } - try { - DNS.create(ZONE_MISSING_DESCRIPTION); - fail("Zone is missing description name. The service returns an error."); - } catch (DnsException ex) { - // expected - // todo(mderka) test non-retryable when implemented within #593 - } try { DNS.create(ZONE_NAME_ERROR); fail("Zone name is missing a period. The service returns an error."); @@ -240,8 +211,6 @@ public void testCreateZoneWithErrors() { // todo(mderka) test non-retryable when implemented within #593 } } finally { - DNS.delete(ZONE_MISSING_DNS_NAME.name()); - DNS.delete(ZONE_MISSING_DESCRIPTION.name()); DNS.delete(ZONE_NAME_ERROR.name()); DNS.delete(ZONE_DNS_NO_PERIOD.name()); } From 90897f35fc7102456b0faecccad0a1171accc804 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 10 Mar 2016 08:01:04 -0800 Subject: [PATCH 126/203] Renamed a test method and a variable. --- .../com/google/gcloud/dns/ZoneInfoTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java index b743bd385274..923672bb85a7 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneInfoTest.java @@ -49,15 +49,15 @@ public class ZoneInfoTest { .build(); @Test - public void testDefaultBuilders() { - ZoneInfo zone = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); - assertTrue(zone.nameServers().isEmpty()); - assertEquals(NAME, zone.name()); - assertNull(zone.id()); - assertNull(zone.creationTimeMillis()); - assertNull(zone.nameServerSet()); - assertEquals(DESCRIPTION, zone.description()); - assertEquals(DNS_NAME, zone.dnsName()); + public void testOf() { + ZoneInfo partial = ZoneInfo.of(NAME, DNS_NAME, DESCRIPTION); + assertTrue(partial.nameServers().isEmpty()); + assertEquals(NAME, partial.name()); + assertNull(partial.id()); + assertNull(partial.creationTimeMillis()); + assertNull(partial.nameServerSet()); + assertEquals(DESCRIPTION, partial.description()); + assertEquals(DNS_NAME, partial.dnsName()); } @Test From 407c43604ea02902a94c4e26397ddd8e6ab4705a Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 10 Mar 2016 21:22:21 +0100 Subject: [PATCH 127/203] Create service-specific spi packages --- .../com/google/gcloud/bigquery/BigQuery.java | 2 +- .../google/gcloud/bigquery/BigQueryImpl.java | 2 +- .../gcloud/bigquery/BigQueryOptions.java | 6 +- .../com/google/gcloud/bigquery/Option.java | 2 +- .../{ => bigquery}/spi/BigQueryRpc.java | 2 +- .../spi/BigQueryRpcFactory.java | 3 +- .../spi/DefaultBigQueryRpc.java | 14 +- .../gcloud/bigquery/BigQueryImplTest.java | 6 +- .../google/gcloud/bigquery/OptionTest.java | 2 +- .../bigquery/TableDataWriteChannelTest.java | 4 +- .../gcloud/datastore/DatastoreImpl.java | 2 +- .../gcloud/datastore/DatastoreOptions.java | 6 +- .../{ => datastore}/spi/DatastoreRpc.java | 2 +- .../spi/DatastoreRpcFactory.java | 3 +- .../spi/DefaultDatastoreRpc.java | 2 +- .../datastore/DatastoreOptionsTest.java | 4 +- .../gcloud/datastore/DatastoreTest.java | 4 +- .../examples/bigquery/BigQueryExample.java | 2 +- .../examples/storage/StorageExample.java | 2 +- .../google/gcloud/resourcemanager/Option.java | 2 +- .../resourcemanager/ResourceManager.java | 2 +- .../resourcemanager/ResourceManagerImpl.java | 4 +- .../ResourceManagerOptions.java | 6 +- .../spi/DefaultResourceManagerRpc.java | 16 +-- .../spi/ResourceManagerRpc.java | 2 +- .../spi/ResourceManagerRpcFactory.java | 3 +- .../LocalResourceManagerHelperTest.java | 6 +- .../ResourceManagerImplTest.java | 4 +- .../java/com/google/gcloud/storage/Blob.java | 4 +- .../gcloud/storage/BlobReadChannel.java | 4 +- .../gcloud/storage/BlobWriteChannel.java | 2 +- .../com/google/gcloud/storage/Bucket.java | 2 +- .../com/google/gcloud/storage/CopyWriter.java | 6 +- .../com/google/gcloud/storage/Option.java | 2 +- .../com/google/gcloud/storage/Storage.java | 4 +- .../google/gcloud/storage/StorageImpl.java | 24 ++-- .../google/gcloud/storage/StorageOptions.java | 6 +- .../{ => storage}/spi/DefaultStorageRpc.java | 134 ++++++++---------- .../gcloud/{ => storage}/spi/StorageRpc.java | 2 +- .../{ => storage}/spi/StorageRpcFactory.java | 3 +- .../gcloud/storage/BlobReadChannelTest.java | 4 +- .../gcloud/storage/BlobWriteChannelTest.java | 4 +- .../google/gcloud/storage/CopyWriterTest.java | 8 +- .../com/google/gcloud/storage/OptionTest.java | 2 +- .../gcloud/storage/SerializationTest.java | 2 +- .../gcloud/storage/StorageImplTest.java | 6 +- 46 files changed, 159 insertions(+), 175 deletions(-) rename gcloud-java-bigquery/src/main/java/com/google/gcloud/{ => bigquery}/spi/BigQueryRpc.java (99%) rename gcloud-java-bigquery/src/main/java/com/google/gcloud/{ => bigquery}/spi/BigQueryRpcFactory.java (90%) rename gcloud-java-bigquery/src/main/java/com/google/gcloud/{ => bigquery}/spi/DefaultBigQueryRpc.java (97%) rename gcloud-java-datastore/src/main/java/com/google/gcloud/{ => datastore}/spi/DatastoreRpc.java (98%) rename gcloud-java-datastore/src/main/java/com/google/gcloud/{ => datastore}/spi/DatastoreRpcFactory.java (90%) rename gcloud-java-datastore/src/main/java/com/google/gcloud/{ => datastore}/spi/DefaultDatastoreRpc.java (99%) rename gcloud-java-resourcemanager/src/main/java/com/google/gcloud/{ => resourcemanager}/spi/DefaultResourceManagerRpc.java (84%) rename gcloud-java-resourcemanager/src/main/java/com/google/gcloud/{ => resourcemanager}/spi/ResourceManagerRpc.java (98%) rename gcloud-java-resourcemanager/src/main/java/com/google/gcloud/{ => resourcemanager}/spi/ResourceManagerRpcFactory.java (90%) rename gcloud-java-storage/src/main/java/com/google/gcloud/{ => storage}/spi/DefaultStorageRpc.java (79%) rename gcloud-java-storage/src/main/java/com/google/gcloud/{ => storage}/spi/StorageRpc.java (99%) rename gcloud-java-storage/src/main/java/com/google/gcloud/{ => storage}/spi/StorageRpcFactory.java (91%) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java index 986c595e350d..3acaacaf42e5 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java @@ -25,7 +25,7 @@ import com.google.common.collect.Sets; import com.google.gcloud.Page; import com.google.gcloud.Service; -import com.google.gcloud.spi.BigQueryRpc; +import com.google.gcloud.bigquery.spi.BigQueryRpc; import java.util.List; import java.util.Set; diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java index ce881c6ea079..27f4af5d5007 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java @@ -35,7 +35,7 @@ import com.google.gcloud.PageImpl.NextPageFetcher; import com.google.gcloud.RetryHelper; import com.google.gcloud.bigquery.InsertAllRequest.RowToInsert; -import com.google.gcloud.spi.BigQueryRpc; +import com.google.gcloud.bigquery.spi.BigQueryRpc; import java.util.List; import java.util.Map; diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryOptions.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryOptions.java index 71d43cfbe565..d48cf646f349 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryOptions.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryOptions.java @@ -18,9 +18,9 @@ import com.google.common.collect.ImmutableSet; import com.google.gcloud.ServiceOptions; -import com.google.gcloud.spi.BigQueryRpc; -import com.google.gcloud.spi.BigQueryRpcFactory; -import com.google.gcloud.spi.DefaultBigQueryRpc; +import com.google.gcloud.bigquery.spi.BigQueryRpc; +import com.google.gcloud.bigquery.spi.BigQueryRpcFactory; +import com.google.gcloud.bigquery.spi.DefaultBigQueryRpc; import java.util.Set; diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Option.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Option.java index d88820fe5a29..3fdc27ecab99 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Option.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Option.java @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.MoreObjects; -import com.google.gcloud.spi.BigQueryRpc; +import com.google.gcloud.bigquery.spi.BigQueryRpc; import java.io.Serializable; import java.util.Objects; diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/BigQueryRpc.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/BigQueryRpc.java similarity index 99% rename from gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/BigQueryRpc.java rename to gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/BigQueryRpc.java index a1935e5ab136..d0b740e9e390 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/BigQueryRpc.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/BigQueryRpc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.bigquery.spi; import com.google.api.services.bigquery.model.Dataset; import com.google.api.services.bigquery.model.GetQueryResultsResponse; diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/BigQueryRpcFactory.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/BigQueryRpcFactory.java similarity index 90% rename from gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/BigQueryRpcFactory.java rename to gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/BigQueryRpcFactory.java index 2706868756a5..1323ec0624f4 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/BigQueryRpcFactory.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/BigQueryRpcFactory.java @@ -14,9 +14,10 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.bigquery.spi; import com.google.gcloud.bigquery.BigQueryOptions; +import com.google.gcloud.spi.ServiceRpcFactory; /** * An interface for BigQuery RPC factory. diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/DefaultBigQueryRpc.java similarity index 97% rename from gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java rename to gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/DefaultBigQueryRpc.java index a5c44129955a..f73517086a02 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/DefaultBigQueryRpc.java @@ -12,14 +12,14 @@ * the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.bigquery.spi; -import static com.google.gcloud.spi.BigQueryRpc.Option.DELETE_CONTENTS; -import static com.google.gcloud.spi.BigQueryRpc.Option.FIELDS; -import static com.google.gcloud.spi.BigQueryRpc.Option.MAX_RESULTS; -import static com.google.gcloud.spi.BigQueryRpc.Option.PAGE_TOKEN; -import static com.google.gcloud.spi.BigQueryRpc.Option.START_INDEX; -import static com.google.gcloud.spi.BigQueryRpc.Option.TIMEOUT; +import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.DELETE_CONTENTS; +import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.FIELDS; +import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.MAX_RESULTS; +import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.PAGE_TOKEN; +import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.START_INDEX; +import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.TIMEOUT; import static java.net.HttpURLConnection.HTTP_CREATED; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; import static java.net.HttpURLConnection.HTTP_OK; diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java index 385ee6dcc8bd..305745e72da9 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java @@ -40,9 +40,9 @@ import com.google.gcloud.RetryParams; import com.google.gcloud.WriteChannel; import com.google.gcloud.bigquery.InsertAllRequest.RowToInsert; -import com.google.gcloud.spi.BigQueryRpc; -import com.google.gcloud.spi.BigQueryRpc.Tuple; -import com.google.gcloud.spi.BigQueryRpcFactory; +import com.google.gcloud.bigquery.spi.BigQueryRpc; +import com.google.gcloud.bigquery.spi.BigQueryRpc.Tuple; +import com.google.gcloud.bigquery.spi.BigQueryRpcFactory; import org.easymock.Capture; import org.easymock.EasyMock; diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/OptionTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/OptionTest.java index 225fc284b203..2c89ececedb8 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/OptionTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/OptionTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; -import com.google.gcloud.spi.BigQueryRpc; +import com.google.gcloud.bigquery.spi.BigQueryRpc; import org.junit.Test; diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableDataWriteChannelTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableDataWriteChannelTest.java index 6b7edcd76db1..4c1be470ff57 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableDataWriteChannelTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableDataWriteChannelTest.java @@ -32,8 +32,8 @@ import com.google.gcloud.RestorableState; import com.google.gcloud.WriteChannel; -import com.google.gcloud.spi.BigQueryRpc; -import com.google.gcloud.spi.BigQueryRpcFactory; +import com.google.gcloud.bigquery.spi.BigQueryRpc; +import com.google.gcloud.bigquery.spi.BigQueryRpcFactory; import org.easymock.Capture; import org.easymock.CaptureType; diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreImpl.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreImpl.java index 92d18ed4787c..49a5728a4da9 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreImpl.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreImpl.java @@ -26,7 +26,7 @@ import com.google.gcloud.RetryHelper; import com.google.gcloud.RetryHelper.RetryHelperException; import com.google.gcloud.RetryParams; -import com.google.gcloud.spi.DatastoreRpc; +import com.google.gcloud.datastore.spi.DatastoreRpc; import com.google.protobuf.ByteString; import java.util.Arrays; diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreOptions.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreOptions.java index 2ec0f2be8f2b..db1a5f800ce8 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreOptions.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DatastoreOptions.java @@ -24,9 +24,9 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.gcloud.ServiceOptions; -import com.google.gcloud.spi.DatastoreRpc; -import com.google.gcloud.spi.DatastoreRpcFactory; -import com.google.gcloud.spi.DefaultDatastoreRpc; +import com.google.gcloud.datastore.spi.DatastoreRpc; +import com.google.gcloud.datastore.spi.DatastoreRpcFactory; +import com.google.gcloud.datastore.spi.DefaultDatastoreRpc; import java.lang.reflect.Method; import java.util.Iterator; diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpc.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/spi/DatastoreRpc.java similarity index 98% rename from gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpc.java rename to gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/spi/DatastoreRpc.java index 4d4540c70196..002078550d1f 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpc.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/spi/DatastoreRpc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.datastore.spi; import com.google.api.services.datastore.DatastoreV1.AllocateIdsRequest; import com.google.api.services.datastore.DatastoreV1.AllocateIdsResponse; diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpcFactory.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/spi/DatastoreRpcFactory.java similarity index 90% rename from gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpcFactory.java rename to gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/spi/DatastoreRpcFactory.java index 1815dda30f5d..0979b2203037 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DatastoreRpcFactory.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/spi/DatastoreRpcFactory.java @@ -14,9 +14,10 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.datastore.spi; import com.google.gcloud.datastore.DatastoreOptions; +import com.google.gcloud.spi.ServiceRpcFactory; /** * An interface for Datastore RPC factory. diff --git a/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DefaultDatastoreRpc.java b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/spi/DefaultDatastoreRpc.java similarity index 99% rename from gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DefaultDatastoreRpc.java rename to gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/spi/DefaultDatastoreRpc.java index f679cc0d5826..093322fa4117 100644 --- a/gcloud-java-datastore/src/main/java/com/google/gcloud/spi/DefaultDatastoreRpc.java +++ b/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/spi/DefaultDatastoreRpc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.datastore.spi; import com.google.api.services.datastore.DatastoreV1.AllocateIdsRequest; import com.google.api.services.datastore.DatastoreV1.AllocateIdsResponse; diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java index 284a9d322793..b0d6e8d7800b 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java @@ -23,8 +23,8 @@ import static org.junit.Assert.assertTrue; import com.google.gcloud.datastore.testing.LocalGcdHelper; -import com.google.gcloud.spi.DatastoreRpc; -import com.google.gcloud.spi.DatastoreRpcFactory; +import com.google.gcloud.datastore.spi.DatastoreRpc; +import com.google.gcloud.datastore.spi.DatastoreRpcFactory; import org.easymock.EasyMock; import org.junit.Before; diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java index 5d106fc7d31d..1886c67e22a8 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java @@ -39,8 +39,8 @@ import com.google.gcloud.datastore.StructuredQuery.Projection; import com.google.gcloud.datastore.StructuredQuery.PropertyFilter; import com.google.gcloud.datastore.testing.LocalGcdHelper; -import com.google.gcloud.spi.DatastoreRpc; -import com.google.gcloud.spi.DatastoreRpcFactory; +import com.google.gcloud.datastore.spi.DatastoreRpc; +import com.google.gcloud.datastore.spi.DatastoreRpcFactory; import com.google.protobuf.ByteString; import org.easymock.EasyMock; diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/BigQueryExample.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/BigQueryExample.java index c8fbe7289f9c..fe27ee3cf63b 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/BigQueryExample.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/BigQueryExample.java @@ -43,7 +43,7 @@ import com.google.gcloud.bigquery.TableInfo; import com.google.gcloud.bigquery.ViewDefinition; import com.google.gcloud.bigquery.WriteChannelConfiguration; -import com.google.gcloud.spi.BigQueryRpc.Tuple; +import com.google.gcloud.bigquery.spi.BigQueryRpc.Tuple; import java.nio.channels.FileChannel; import java.nio.file.Paths; diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java index e73cfc427129..a10b5ef71817 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java @@ -20,7 +20,7 @@ import com.google.gcloud.AuthCredentials.ServiceAccountAuthCredentials; import com.google.gcloud.ReadChannel; import com.google.gcloud.WriteChannel; -import com.google.gcloud.spi.StorageRpc.Tuple; +import com.google.gcloud.storage.spi.StorageRpc.Tuple; import com.google.gcloud.storage.Blob; import com.google.gcloud.storage.BlobId; import com.google.gcloud.storage.BlobInfo; diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Option.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Option.java index f48c057ba049..72d62d7fc224 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Option.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Option.java @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.MoreObjects; -import com.google.gcloud.spi.ResourceManagerRpc; +import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; import java.io.Serializable; import java.util.Objects; diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java index f9ddf6872414..a463937f875c 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java @@ -20,7 +20,7 @@ import com.google.common.collect.Sets; import com.google.gcloud.Page; import com.google.gcloud.Service; -import com.google.gcloud.spi.ResourceManagerRpc; +import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; import java.util.Set; diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java index 4176b4e610ba..fb699dcb06f0 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java @@ -29,8 +29,8 @@ import com.google.gcloud.PageImpl; import com.google.gcloud.PageImpl.NextPageFetcher; import com.google.gcloud.RetryHelper.RetryHelperException; -import com.google.gcloud.spi.ResourceManagerRpc; -import com.google.gcloud.spi.ResourceManagerRpc.Tuple; +import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; +import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Tuple; import java.util.Map; import java.util.concurrent.Callable; diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerOptions.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerOptions.java index 5c0c4baf1ecb..c744864147c2 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerOptions.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerOptions.java @@ -18,9 +18,9 @@ import com.google.common.collect.ImmutableSet; import com.google.gcloud.ServiceOptions; -import com.google.gcloud.spi.DefaultResourceManagerRpc; -import com.google.gcloud.spi.ResourceManagerRpc; -import com.google.gcloud.spi.ResourceManagerRpcFactory; +import com.google.gcloud.resourcemanager.spi.DefaultResourceManagerRpc; +import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; +import com.google.gcloud.resourcemanager.spi.ResourceManagerRpcFactory; import java.util.Set; diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java similarity index 84% rename from gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java rename to gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java index d30cd2df3627..19e40698a847 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/DefaultResourceManagerRpc.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java @@ -1,9 +1,5 @@ -package com.google.gcloud.spi; +package com.google.gcloud.resourcemanager.spi; -import static com.google.gcloud.spi.ResourceManagerRpc.Option.FIELDS; -import static com.google.gcloud.spi.ResourceManagerRpc.Option.FILTER; -import static com.google.gcloud.spi.ResourceManagerRpc.Option.PAGE_SIZE; -import static com.google.gcloud.spi.ResourceManagerRpc.Option.PAGE_TOKEN; import static java.net.HttpURLConnection.HTTP_FORBIDDEN; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; @@ -60,7 +56,7 @@ public Project get(String projectId, Map options) { try { return resourceManager.projects() .get(projectId) - .setFields(FIELDS.getString(options)) + .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { ResourceManagerException translated = translate(ex); @@ -78,10 +74,10 @@ public Tuple> list(Map options) { try { ListProjectsResponse response = resourceManager.projects() .list() - .setFields(FIELDS.getString(options)) - .setFilter(FILTER.getString(options)) - .setPageSize(PAGE_SIZE.getInt(options)) - .setPageToken(PAGE_TOKEN.getString(options)) + .setFields(Option.FIELDS.getString(options)) + .setFilter(Option.FILTER.getString(options)) + .setPageSize(Option.PAGE_SIZE.getInt(options)) + .setPageToken(Option.PAGE_TOKEN.getString(options)) .execute(); return Tuple.>of( response.getNextPageToken(), response.getProjects()); diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/ResourceManagerRpc.java similarity index 98% rename from gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java rename to gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/ResourceManagerRpc.java index e1d72a6a373e..54531edd5ed5 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpc.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/ResourceManagerRpc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.resourcemanager.spi; import com.google.api.services.cloudresourcemanager.model.Project; import com.google.gcloud.resourcemanager.ResourceManagerException; diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpcFactory.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/ResourceManagerRpcFactory.java similarity index 90% rename from gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpcFactory.java rename to gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/ResourceManagerRpcFactory.java index c2c607c0c205..4dbd1a00d4c7 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/spi/ResourceManagerRpcFactory.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/ResourceManagerRpcFactory.java @@ -14,9 +14,10 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.resourcemanager.spi; import com.google.gcloud.resourcemanager.ResourceManagerOptions; +import com.google.gcloud.spi.ServiceRpcFactory; /** * An interface for Resource Manager RPC factory. diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java index a3418fff98ab..328db315e414 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java @@ -9,9 +9,9 @@ import com.google.common.collect.ImmutableMap; import com.google.gcloud.resourcemanager.testing.LocalResourceManagerHelper; -import com.google.gcloud.spi.DefaultResourceManagerRpc; -import com.google.gcloud.spi.ResourceManagerRpc; -import com.google.gcloud.spi.ResourceManagerRpc.Tuple; +import com.google.gcloud.resourcemanager.spi.DefaultResourceManagerRpc; +import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; +import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Tuple; import org.junit.AfterClass; import org.junit.Before; diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java index 1bc233311a4d..92f5d2a18a0f 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java @@ -31,8 +31,8 @@ import com.google.gcloud.resourcemanager.ResourceManager.ProjectGetOption; import com.google.gcloud.resourcemanager.ResourceManager.ProjectListOption; import com.google.gcloud.resourcemanager.testing.LocalResourceManagerHelper; -import com.google.gcloud.spi.ResourceManagerRpc; -import com.google.gcloud.spi.ResourceManagerRpcFactory; +import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; +import com.google.gcloud.resourcemanager.spi.ResourceManagerRpcFactory; import org.easymock.EasyMock; import org.junit.AfterClass; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java index 79ad3804faf0..2cd81af5793d 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java @@ -24,8 +24,8 @@ import com.google.common.base.Function; import com.google.gcloud.ReadChannel; import com.google.gcloud.WriteChannel; -import com.google.gcloud.spi.StorageRpc; -import com.google.gcloud.spi.StorageRpc.Tuple; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc.Tuple; import com.google.gcloud.storage.Storage.BlobTargetOption; import com.google.gcloud.storage.Storage.BlobWriteOption; import com.google.gcloud.storage.Storage.CopyRequest; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java index 52b8c39321da..f9c6f912563d 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannel.java @@ -23,8 +23,8 @@ import com.google.gcloud.ReadChannel; import com.google.gcloud.RestorableState; import com.google.gcloud.RetryHelper; -import com.google.gcloud.spi.StorageRpc; -import com.google.gcloud.spi.StorageRpc.Tuple; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc.Tuple; import java.io.IOException; import java.io.Serializable; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobWriteChannel.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobWriteChannel.java index d1d12ec77638..30b0ec870f51 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobWriteChannel.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobWriteChannel.java @@ -23,7 +23,7 @@ import com.google.gcloud.RestorableState; import com.google.gcloud.RetryHelper; import com.google.gcloud.WriteChannel; -import com.google.gcloud.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc; import java.util.Map; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java index d318626f4207..3cb8af4ef044 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java @@ -26,7 +26,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gcloud.Page; -import com.google.gcloud.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc; import com.google.gcloud.storage.Storage.BlobGetOption; import com.google.gcloud.storage.Storage.BucketTargetOption; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java index 7eb91d0910a2..62b39e005369 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java @@ -22,9 +22,9 @@ import com.google.gcloud.Restorable; import com.google.gcloud.RestorableState; import com.google.gcloud.RetryHelper; -import com.google.gcloud.spi.StorageRpc; -import com.google.gcloud.spi.StorageRpc.RewriteRequest; -import com.google.gcloud.spi.StorageRpc.RewriteResponse; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc.RewriteRequest; +import com.google.gcloud.storage.spi.StorageRpc.RewriteResponse; import java.io.Serializable; import java.util.Map; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Option.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Option.java index 2ec8426bfa9f..65c55da7efc8 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Option.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Option.java @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.MoreObjects; -import com.google.gcloud.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc; import java.io.Serializable; import java.util.Objects; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 0ee18f541284..6b2e9266f24b 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -29,8 +29,8 @@ import com.google.gcloud.ReadChannel; import com.google.gcloud.Service; import com.google.gcloud.WriteChannel; -import com.google.gcloud.spi.StorageRpc; -import com.google.gcloud.spi.StorageRpc.Tuple; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc.Tuple; import java.io.InputStream; import java.io.Serializable; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java index 788072905871..d58c9e43aea9 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java @@ -19,15 +19,15 @@ import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.common.base.Preconditions.checkArgument; import static com.google.gcloud.RetryHelper.runWithRetries; -import static com.google.gcloud.spi.StorageRpc.Option.DELIMITER; -import static com.google.gcloud.spi.StorageRpc.Option.IF_GENERATION_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_GENERATION_NOT_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_METAGENERATION_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_METAGENERATION_NOT_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_SOURCE_GENERATION_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_SOURCE_GENERATION_NOT_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_SOURCE_METAGENERATION_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_SOURCE_METAGENERATION_NOT_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.DELIMITER; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_GENERATION_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_GENERATION_NOT_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_METAGENERATION_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_METAGENERATION_NOT_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_SOURCE_GENERATION_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_SOURCE_GENERATION_NOT_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_SOURCE_METAGENERATION_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_SOURCE_METAGENERATION_NOT_MATCH; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.api.services.storage.model.StorageObject; @@ -48,9 +48,9 @@ import com.google.gcloud.PageImpl.NextPageFetcher; import com.google.gcloud.ReadChannel; import com.google.gcloud.RetryHelper.RetryHelperException; -import com.google.gcloud.spi.StorageRpc; -import com.google.gcloud.spi.StorageRpc.RewriteResponse; -import com.google.gcloud.spi.StorageRpc.Tuple; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc.RewriteResponse; +import com.google.gcloud.storage.spi.StorageRpc.Tuple; import java.io.ByteArrayInputStream; import java.io.InputStream; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java index 86ce18eb71ec..e7e1c2778fa9 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java @@ -18,9 +18,9 @@ import com.google.common.collect.ImmutableSet; import com.google.gcloud.ServiceOptions; -import com.google.gcloud.spi.DefaultStorageRpc; -import com.google.gcloud.spi.StorageRpc; -import com.google.gcloud.spi.StorageRpcFactory; +import com.google.gcloud.storage.spi.DefaultStorageRpc; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpcFactory; import java.util.Set; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java similarity index 79% rename from gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java rename to gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java index ec4447d406cb..71cd51da1e38 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java @@ -12,25 +12,9 @@ * the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.storage.spi; import static com.google.common.base.MoreObjects.firstNonNull; -import static com.google.gcloud.spi.StorageRpc.Option.DELIMITER; -import static com.google.gcloud.spi.StorageRpc.Option.FIELDS; -import static com.google.gcloud.spi.StorageRpc.Option.IF_GENERATION_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_GENERATION_NOT_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_METAGENERATION_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_METAGENERATION_NOT_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_SOURCE_GENERATION_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_SOURCE_GENERATION_NOT_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_SOURCE_METAGENERATION_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.IF_SOURCE_METAGENERATION_NOT_MATCH; -import static com.google.gcloud.spi.StorageRpc.Option.MAX_RESULTS; -import static com.google.gcloud.spi.StorageRpc.Option.PAGE_TOKEN; -import static com.google.gcloud.spi.StorageRpc.Option.PREDEFINED_ACL; -import static com.google.gcloud.spi.StorageRpc.Option.PREDEFINED_DEFAULT_OBJECT_ACL; -import static com.google.gcloud.spi.StorageRpc.Option.PREFIX; -import static com.google.gcloud.spi.StorageRpc.Option.VERSIONS; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; import static javax.servlet.http.HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE; @@ -108,8 +92,8 @@ public Bucket create(Bucket bucket, Map options) { return storage.buckets() .insert(this.options.projectId(), bucket) .setProjection(DEFAULT_PROJECTION) - .setPredefinedAcl(PREDEFINED_ACL.getString(options)) - .setPredefinedDefaultObjectAcl(PREDEFINED_DEFAULT_OBJECT_ACL.getString(options)) + .setPredefinedAcl(Option.PREDEFINED_ACL.getString(options)) + .setPredefinedDefaultObjectAcl(Option.PREDEFINED_DEFAULT_OBJECT_ACL.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); @@ -125,11 +109,11 @@ public StorageObject create(StorageObject storageObject, final InputStream conte new InputStreamContent(storageObject.getContentType(), content)); insert.getMediaHttpUploader().setDirectUploadEnabled(true); return insert.setProjection(DEFAULT_PROJECTION) - .setPredefinedAcl(PREDEFINED_ACL.getString(options)) - .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)) + .setPredefinedAcl(Option.PREDEFINED_ACL.getString(options)) + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)) .execute(); } catch (IOException ex) { throw translate(ex); @@ -142,10 +126,10 @@ public Tuple> list(Map options) { Buckets buckets = storage.buckets() .list(this.options.projectId()) .setProjection(DEFAULT_PROJECTION) - .setPrefix(PREFIX.getString(options)) - .setMaxResults(MAX_RESULTS.getLong(options)) - .setPageToken(PAGE_TOKEN.getString(options)) - .setFields(FIELDS.getString(options)) + .setPrefix(Option.PREFIX.getString(options)) + .setMaxResults(Option.MAX_RESULTS.getLong(options)) + .setPageToken(Option.PAGE_TOKEN.getString(options)) + .setFields(Option.FIELDS.getString(options)) .execute(); return Tuple.>of(buckets.getNextPageToken(), buckets.getItems()); } catch (IOException ex) { @@ -159,12 +143,12 @@ public Tuple> list(final String bucket, Map storageObjects = Iterables.concat( firstNonNull(objects.getItems(), ImmutableList.of()), @@ -196,9 +180,9 @@ public Bucket get(Bucket bucket, Map options) { return storage.buckets() .get(bucket.getName()) .setProjection(DEFAULT_PROJECTION) - .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setFields(FIELDS.getString(options)) + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { StorageException serviceException = translate(ex); @@ -228,11 +212,11 @@ private Storage.Objects.Get getRequest(StorageObject object, Map opti .get(object.getBucket(), object.getName()) .setGeneration(object.getGeneration()) .setProjection(DEFAULT_PROJECTION) - .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)) - .setFields(FIELDS.getString(options)); + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)) + .setFields(Option.FIELDS.getString(options)); } @Override @@ -241,10 +225,10 @@ public Bucket patch(Bucket bucket, Map options) { return storage.buckets() .patch(bucket.getName(), bucket) .setProjection(DEFAULT_PROJECTION) - .setPredefinedAcl(PREDEFINED_ACL.getString(options)) - .setPredefinedDefaultObjectAcl(PREDEFINED_DEFAULT_OBJECT_ACL.getString(options)) - .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setPredefinedAcl(Option.PREDEFINED_ACL.getString(options)) + .setPredefinedDefaultObjectAcl(Option.PREDEFINED_DEFAULT_OBJECT_ACL.getString(options)) + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) .execute(); } catch (IOException ex) { throw translate(ex); @@ -265,11 +249,11 @@ private Storage.Objects.Patch patchRequest(StorageObject storageObject, Map options) { try { storage.buckets() .delete(bucket.getName()) - .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) .execute(); return true; } catch (IOException ex) { @@ -309,10 +293,10 @@ private Storage.Objects.Delete deleteRequest(StorageObject blob, Map return storage.objects() .delete(blob.getBucket(), blob.getName()) .setGeneration(blob.getGeneration()) - .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)); + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)); } @Override @@ -339,8 +323,8 @@ public StorageObject compose(Iterable sources, StorageObject targ try { return storage.objects() .compose(target.getBucket(), target.getName(), request) - .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(targetOptions)) - .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(targetOptions)) + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(targetOptions)) + .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(targetOptions)) .execute(); } catch (IOException ex) { throw translate(ex); @@ -353,10 +337,10 @@ public byte[] load(StorageObject from, Map options) { Storage.Objects.Get getRequest = storage.objects() .get(from.getBucket(), from.getName()) .setGeneration(from.getGeneration()) - .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)); + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)); ByteArrayOutputStream out = new ByteArrayOutputStream(); getRequest.getMediaHttpDownloader().setDirectDownloadEnabled(true); getRequest.executeMediaAndDownloadTo(out); @@ -462,10 +446,10 @@ public Tuple read(StorageObject from, Map options, lo Get req = storage.objects() .get(from.getBucket(), from.getName()) .setGeneration(from.getGeneration()) - .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)); + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)); StringBuilder range = new StringBuilder(); range.append("bytes=").append(position).append("-").append(position + bytes - 1); req.getRequestHeaders().setRange(range.toString()); @@ -589,15 +573,15 @@ private RewriteResponse rewrite(RewriteRequest req, String token) { .setRewriteToken(token) .setMaxBytesRewrittenPerCall(maxBytesRewrittenPerCall) .setProjection(DEFAULT_PROJECTION) - .setIfSourceMetagenerationMatch(IF_SOURCE_METAGENERATION_MATCH.getLong(req.sourceOptions)) + .setIfSourceMetagenerationMatch(Option.IF_SOURCE_METAGENERATION_MATCH.getLong(req.sourceOptions)) .setIfSourceMetagenerationNotMatch( - IF_SOURCE_METAGENERATION_NOT_MATCH.getLong(req.sourceOptions)) - .setIfSourceGenerationMatch(IF_SOURCE_GENERATION_MATCH.getLong(req.sourceOptions)) - .setIfSourceGenerationNotMatch(IF_SOURCE_GENERATION_NOT_MATCH.getLong(req.sourceOptions)) - .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(req.targetOptions)) - .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(req.targetOptions)) - .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(req.targetOptions)) - .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(req.targetOptions)) + Option.IF_SOURCE_METAGENERATION_NOT_MATCH.getLong(req.sourceOptions)) + .setIfSourceGenerationMatch(Option.IF_SOURCE_GENERATION_MATCH.getLong(req.sourceOptions)) + .setIfSourceGenerationNotMatch(Option.IF_SOURCE_GENERATION_NOT_MATCH.getLong(req.sourceOptions)) + .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(req.targetOptions)) + .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(req.targetOptions)) + .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(req.targetOptions)) + .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(req.targetOptions)) .execute(); return new RewriteResponse( req, diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java similarity index 99% rename from gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java rename to gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java index ab4a7a9d0acb..d239a475a6dd 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.storage.spi; import static com.google.common.base.MoreObjects.firstNonNull; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpcFactory.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpcFactory.java similarity index 91% rename from gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpcFactory.java rename to gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpcFactory.java index f4959d617d17..19b98e6273db 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/spi/StorageRpcFactory.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpcFactory.java @@ -14,8 +14,9 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.storage.spi; +import com.google.gcloud.spi.ServiceRpcFactory; import com.google.gcloud.storage.StorageOptions; /** diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobReadChannelTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobReadChannelTest.java index 5dc947df51f8..1b0f36a864a2 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobReadChannelTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobReadChannelTest.java @@ -30,8 +30,8 @@ import com.google.gcloud.ReadChannel; import com.google.gcloud.RestorableState; import com.google.gcloud.RetryParams; -import com.google.gcloud.spi.StorageRpc; -import com.google.gcloud.spi.StorageRpcFactory; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpcFactory; import org.junit.After; import org.junit.Before; diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobWriteChannelTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobWriteChannelTest.java index e499f6b9de52..18ec64a9575f 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobWriteChannelTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobWriteChannelTest.java @@ -34,8 +34,8 @@ import com.google.gcloud.RestorableState; import com.google.gcloud.RetryParams; import com.google.gcloud.WriteChannel; -import com.google.gcloud.spi.StorageRpc; -import com.google.gcloud.spi.StorageRpcFactory; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpcFactory; import org.easymock.Capture; import org.easymock.CaptureType; diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java index 1b1ffd987de6..ad4a04c34127 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java @@ -27,10 +27,10 @@ import com.google.common.collect.ImmutableMap; import com.google.gcloud.RestorableState; import com.google.gcloud.RetryParams; -import com.google.gcloud.spi.StorageRpc; -import com.google.gcloud.spi.StorageRpc.RewriteRequest; -import com.google.gcloud.spi.StorageRpc.RewriteResponse; -import com.google.gcloud.spi.StorageRpcFactory; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc.RewriteRequest; +import com.google.gcloud.storage.spi.StorageRpc.RewriteResponse; +import com.google.gcloud.storage.spi.StorageRpcFactory; import org.easymock.EasyMock; import org.junit.After; diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/OptionTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/OptionTest.java index 2703ddb401c5..5924174ab138 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/OptionTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/OptionTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertEquals; -import com.google.gcloud.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc; import org.junit.Test; diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java index ac096375b120..7894f8fdee3c 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java @@ -26,7 +26,7 @@ import com.google.gcloud.RestorableState; import com.google.gcloud.RetryParams; import com.google.gcloud.WriteChannel; -import com.google.gcloud.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc; import com.google.gcloud.storage.Acl.Project.ProjectRole; import org.junit.Test; diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java index 4050e7d6267b..428f770ae381 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java @@ -37,9 +37,9 @@ import com.google.gcloud.RetryParams; import com.google.gcloud.ServiceOptions; import com.google.gcloud.WriteChannel; -import com.google.gcloud.spi.StorageRpc; -import com.google.gcloud.spi.StorageRpc.Tuple; -import com.google.gcloud.spi.StorageRpcFactory; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc.Tuple; +import com.google.gcloud.storage.spi.StorageRpcFactory; import com.google.gcloud.storage.Storage.CopyRequest; import org.easymock.Capture; From fd7d84d59c7dbff375268d07570dd46a45d4b2a0 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 10 Mar 2016 23:02:32 +0100 Subject: [PATCH 128/203] Reorder and add imports --- .../bigquery/spi/DefaultBigQueryRpc.java | 12 +- .../datastore/DatastoreOptionsTest.java | 2 +- .../gcloud/datastore/DatastoreTest.java | 2 +- .../examples/storage/StorageExample.java | 2 +- .../spi/DefaultResourceManagerRpc.java | 14 +- .../LocalResourceManagerHelperTest.java | 2 +- .../ResourceManagerImplTest.java | 2 +- .../java/com/google/gcloud/storage/Blob.java | 4 +- .../com/google/gcloud/storage/Bucket.java | 2 +- .../gcloud/storage/spi/DefaultStorageRpc.java | 132 ++++++++++-------- .../gcloud/storage/SerializationTest.java | 2 +- .../gcloud/storage/StorageImplTest.java | 2 +- 12 files changed, 101 insertions(+), 77 deletions(-) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/DefaultBigQueryRpc.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/DefaultBigQueryRpc.java index f73517086a02..71712bda7806 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/DefaultBigQueryRpc.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/spi/DefaultBigQueryRpc.java @@ -14,11 +14,14 @@ package com.google.gcloud.bigquery.spi; +import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.ALL_DATASETS; +import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.ALL_USERS; import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.DELETE_CONTENTS; import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.FIELDS; import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.MAX_RESULTS; import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.PAGE_TOKEN; import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.START_INDEX; +import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.STATE_FILTER; import static com.google.gcloud.bigquery.spi.BigQueryRpc.Option.TIMEOUT; import static java.net.HttpURLConnection.HTTP_CREATED; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; @@ -110,9 +113,10 @@ public Tuple> listDatasets(Map options) { try { DatasetList datasetsList = bigquery.datasets() .list(this.options.projectId()) - .setAll(Option.ALL_DATASETS.getBoolean(options)) + .setAll(ALL_DATASETS.getBoolean(options)) .setMaxResults(MAX_RESULTS.getLong(options)) .setPageToken(PAGE_TOKEN.getString(options)) + .setPageToken(PAGE_TOKEN.getString(options)) .execute(); Iterable datasets = datasetsList.getDatasets(); return Tuple.of(datasetsList.getNextPageToken(), @@ -322,9 +326,9 @@ public Tuple> listJobs(Map options) { try { JobList jobsList = bigquery.jobs() .list(this.options.projectId()) - .setAllUsers(Option.ALL_USERS.getBoolean(options)) - .setFields(Option.FIELDS.getString(options)) - .setStateFilter(Option.STATE_FILTER.>get(options)) + .setAllUsers(ALL_USERS.getBoolean(options)) + .setFields(FIELDS.getString(options)) + .setStateFilter(STATE_FILTER.>get(options)) .setMaxResults(MAX_RESULTS.getLong(options)) .setPageToken(PAGE_TOKEN.getString(options)) .setProjection(DEFAULT_PROJECTION) diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java index b0d6e8d7800b..1d188c7f4e94 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreOptionsTest.java @@ -22,9 +22,9 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import com.google.gcloud.datastore.testing.LocalGcdHelper; import com.google.gcloud.datastore.spi.DatastoreRpc; import com.google.gcloud.datastore.spi.DatastoreRpcFactory; +import com.google.gcloud.datastore.testing.LocalGcdHelper; import org.easymock.EasyMock; import org.junit.Before; diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java index 1886c67e22a8..e3829a2e71ce 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/DatastoreTest.java @@ -38,9 +38,9 @@ import com.google.gcloud.datastore.StructuredQuery.OrderBy; import com.google.gcloud.datastore.StructuredQuery.Projection; import com.google.gcloud.datastore.StructuredQuery.PropertyFilter; -import com.google.gcloud.datastore.testing.LocalGcdHelper; import com.google.gcloud.datastore.spi.DatastoreRpc; import com.google.gcloud.datastore.spi.DatastoreRpcFactory; +import com.google.gcloud.datastore.testing.LocalGcdHelper; import com.google.protobuf.ByteString; import org.easymock.EasyMock; diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java index a10b5ef71817..a7260134202d 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/storage/StorageExample.java @@ -20,7 +20,6 @@ import com.google.gcloud.AuthCredentials.ServiceAccountAuthCredentials; import com.google.gcloud.ReadChannel; import com.google.gcloud.WriteChannel; -import com.google.gcloud.storage.spi.StorageRpc.Tuple; import com.google.gcloud.storage.Blob; import com.google.gcloud.storage.BlobId; import com.google.gcloud.storage.BlobInfo; @@ -31,6 +30,7 @@ import com.google.gcloud.storage.Storage.CopyRequest; import com.google.gcloud.storage.Storage.SignUrlOption; import com.google.gcloud.storage.StorageOptions; +import com.google.gcloud.storage.spi.StorageRpc.Tuple; import java.io.FileOutputStream; import java.io.IOException; diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java index 19e40698a847..2ef0d8c65ff2 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java @@ -1,5 +1,9 @@ package com.google.gcloud.resourcemanager.spi; +import static com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Option.FIELDS; +import static com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Option.FILTER; +import static com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Option.PAGE_SIZE; +import static com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Option.PAGE_TOKEN; import static java.net.HttpURLConnection.HTTP_FORBIDDEN; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; @@ -56,7 +60,7 @@ public Project get(String projectId, Map options) { try { return resourceManager.projects() .get(projectId) - .setFields(Option.FIELDS.getString(options)) + .setFields(FIELDS.getString(options)) .execute(); } catch (IOException ex) { ResourceManagerException translated = translate(ex); @@ -74,10 +78,10 @@ public Tuple> list(Map options) { try { ListProjectsResponse response = resourceManager.projects() .list() - .setFields(Option.FIELDS.getString(options)) - .setFilter(Option.FILTER.getString(options)) - .setPageSize(Option.PAGE_SIZE.getInt(options)) - .setPageToken(Option.PAGE_TOKEN.getString(options)) + .setFields(FIELDS.getString(options)) + .setFilter(FILTER.getString(options)) + .setPageSize(PAGE_SIZE.getInt(options)) + .setPageToken(PAGE_TOKEN.getString(options)) .execute(); return Tuple.>of( response.getNextPageToken(), response.getProjects()); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java index 328db315e414..c9b2970a4efa 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java @@ -8,10 +8,10 @@ import static org.junit.Assert.fail; import com.google.common.collect.ImmutableMap; -import com.google.gcloud.resourcemanager.testing.LocalResourceManagerHelper; import com.google.gcloud.resourcemanager.spi.DefaultResourceManagerRpc; import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Tuple; +import com.google.gcloud.resourcemanager.testing.LocalResourceManagerHelper; import org.junit.AfterClass; import org.junit.Before; diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java index 92f5d2a18a0f..5b172d6a070e 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java @@ -30,9 +30,9 @@ import com.google.gcloud.resourcemanager.ResourceManager.ProjectField; import com.google.gcloud.resourcemanager.ResourceManager.ProjectGetOption; import com.google.gcloud.resourcemanager.ResourceManager.ProjectListOption; -import com.google.gcloud.resourcemanager.testing.LocalResourceManagerHelper; import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; import com.google.gcloud.resourcemanager.spi.ResourceManagerRpcFactory; +import com.google.gcloud.resourcemanager.testing.LocalResourceManagerHelper; import org.easymock.EasyMock; import org.junit.AfterClass; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java index 2cd81af5793d..4c8e935f7071 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java @@ -24,12 +24,12 @@ import com.google.common.base.Function; import com.google.gcloud.ReadChannel; import com.google.gcloud.WriteChannel; -import com.google.gcloud.storage.spi.StorageRpc; -import com.google.gcloud.storage.spi.StorageRpc.Tuple; import com.google.gcloud.storage.Storage.BlobTargetOption; import com.google.gcloud.storage.Storage.BlobWriteOption; import com.google.gcloud.storage.Storage.CopyRequest; import com.google.gcloud.storage.Storage.SignUrlOption; +import com.google.gcloud.storage.spi.StorageRpc; +import com.google.gcloud.storage.spi.StorageRpc.Tuple; import java.io.IOException; import java.io.ObjectInputStream; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java index 3cb8af4ef044..5df305ff371c 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java @@ -26,9 +26,9 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gcloud.Page; -import com.google.gcloud.storage.spi.StorageRpc; import com.google.gcloud.storage.Storage.BlobGetOption; import com.google.gcloud.storage.Storage.BucketTargetOption; +import com.google.gcloud.storage.spi.StorageRpc; import java.io.IOException; import java.io.InputStream; diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java index 71cd51da1e38..aa6085e161ed 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java @@ -15,6 +15,22 @@ package com.google.gcloud.storage.spi; import static com.google.common.base.MoreObjects.firstNonNull; +import static com.google.gcloud.storage.spi.StorageRpc.Option.DELIMITER; +import static com.google.gcloud.storage.spi.StorageRpc.Option.FIELDS; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_GENERATION_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_GENERATION_NOT_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_METAGENERATION_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_METAGENERATION_NOT_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_SOURCE_GENERATION_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_SOURCE_GENERATION_NOT_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_SOURCE_METAGENERATION_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.IF_SOURCE_METAGENERATION_NOT_MATCH; +import static com.google.gcloud.storage.spi.StorageRpc.Option.MAX_RESULTS; +import static com.google.gcloud.storage.spi.StorageRpc.Option.PAGE_TOKEN; +import static com.google.gcloud.storage.spi.StorageRpc.Option.PREDEFINED_ACL; +import static com.google.gcloud.storage.spi.StorageRpc.Option.PREDEFINED_DEFAULT_OBJECT_ACL; +import static com.google.gcloud.storage.spi.StorageRpc.Option.PREFIX; +import static com.google.gcloud.storage.spi.StorageRpc.Option.VERSIONS; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; import static javax.servlet.http.HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE; @@ -92,8 +108,8 @@ public Bucket create(Bucket bucket, Map options) { return storage.buckets() .insert(this.options.projectId(), bucket) .setProjection(DEFAULT_PROJECTION) - .setPredefinedAcl(Option.PREDEFINED_ACL.getString(options)) - .setPredefinedDefaultObjectAcl(Option.PREDEFINED_DEFAULT_OBJECT_ACL.getString(options)) + .setPredefinedAcl(PREDEFINED_ACL.getString(options)) + .setPredefinedDefaultObjectAcl(PREDEFINED_DEFAULT_OBJECT_ACL.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); @@ -109,11 +125,11 @@ public StorageObject create(StorageObject storageObject, final InputStream conte new InputStreamContent(storageObject.getContentType(), content)); insert.getMediaHttpUploader().setDirectUploadEnabled(true); return insert.setProjection(DEFAULT_PROJECTION) - .setPredefinedAcl(Option.PREDEFINED_ACL.getString(options)) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)) + .setPredefinedAcl(PREDEFINED_ACL.getString(options)) + .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)) .execute(); } catch (IOException ex) { throw translate(ex); @@ -126,10 +142,10 @@ public Tuple> list(Map options) { Buckets buckets = storage.buckets() .list(this.options.projectId()) .setProjection(DEFAULT_PROJECTION) - .setPrefix(Option.PREFIX.getString(options)) - .setMaxResults(Option.MAX_RESULTS.getLong(options)) - .setPageToken(Option.PAGE_TOKEN.getString(options)) - .setFields(Option.FIELDS.getString(options)) + .setPrefix(PREFIX.getString(options)) + .setMaxResults(MAX_RESULTS.getLong(options)) + .setPageToken(PAGE_TOKEN.getString(options)) + .setFields(FIELDS.getString(options)) .execute(); return Tuple.>of(buckets.getNextPageToken(), buckets.getItems()); } catch (IOException ex) { @@ -143,12 +159,12 @@ public Tuple> list(final String bucket, Map storageObjects = Iterables.concat( firstNonNull(objects.getItems(), ImmutableList.of()), @@ -180,9 +196,9 @@ public Bucket get(Bucket bucket, Map options) { return storage.buckets() .get(bucket.getName()) .setProjection(DEFAULT_PROJECTION) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setFields(Option.FIELDS.getString(options)) + .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setFields(FIELDS.getString(options)) .execute(); } catch (IOException ex) { StorageException serviceException = translate(ex); @@ -212,11 +228,11 @@ private Storage.Objects.Get getRequest(StorageObject object, Map opti .get(object.getBucket(), object.getName()) .setGeneration(object.getGeneration()) .setProjection(DEFAULT_PROJECTION) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)) - .setFields(Option.FIELDS.getString(options)); + .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)) + .setFields(FIELDS.getString(options)); } @Override @@ -225,10 +241,10 @@ public Bucket patch(Bucket bucket, Map options) { return storage.buckets() .patch(bucket.getName(), bucket) .setProjection(DEFAULT_PROJECTION) - .setPredefinedAcl(Option.PREDEFINED_ACL.getString(options)) - .setPredefinedDefaultObjectAcl(Option.PREDEFINED_DEFAULT_OBJECT_ACL.getString(options)) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setPredefinedAcl(PREDEFINED_ACL.getString(options)) + .setPredefinedDefaultObjectAcl(PREDEFINED_DEFAULT_OBJECT_ACL.getString(options)) + .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) .execute(); } catch (IOException ex) { throw translate(ex); @@ -249,11 +265,11 @@ private Storage.Objects.Patch patchRequest(StorageObject storageObject, Map options) { try { storage.buckets() .delete(bucket.getName()) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) .execute(); return true; } catch (IOException ex) { @@ -293,10 +309,10 @@ private Storage.Objects.Delete deleteRequest(StorageObject blob, Map return storage.objects() .delete(blob.getBucket(), blob.getName()) .setGeneration(blob.getGeneration()) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)); + .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)); } @Override @@ -323,8 +339,8 @@ public StorageObject compose(Iterable sources, StorageObject targ try { return storage.objects() .compose(target.getBucket(), target.getName(), request) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(targetOptions)) - .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(targetOptions)) + .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(targetOptions)) + .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(targetOptions)) .execute(); } catch (IOException ex) { throw translate(ex); @@ -337,10 +353,10 @@ public byte[] load(StorageObject from, Map options) { Storage.Objects.Get getRequest = storage.objects() .get(from.getBucket(), from.getName()) .setGeneration(from.getGeneration()) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)); + .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)); ByteArrayOutputStream out = new ByteArrayOutputStream(); getRequest.getMediaHttpDownloader().setDirectDownloadEnabled(true); getRequest.executeMediaAndDownloadTo(out); @@ -446,10 +462,10 @@ public Tuple read(StorageObject from, Map options, lo Get req = storage.objects() .get(from.getBucket(), from.getName()) .setGeneration(from.getGeneration()) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) - .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) - .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) - .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)); + .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) + .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) + .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) + .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)); StringBuilder range = new StringBuilder(); range.append("bytes=").append(position).append("-").append(position + bytes - 1); req.getRequestHeaders().setRange(range.toString()); @@ -573,15 +589,15 @@ private RewriteResponse rewrite(RewriteRequest req, String token) { .setRewriteToken(token) .setMaxBytesRewrittenPerCall(maxBytesRewrittenPerCall) .setProjection(DEFAULT_PROJECTION) - .setIfSourceMetagenerationMatch(Option.IF_SOURCE_METAGENERATION_MATCH.getLong(req.sourceOptions)) + .setIfSourceMetagenerationMatch(IF_SOURCE_METAGENERATION_MATCH.getLong(req.sourceOptions)) .setIfSourceMetagenerationNotMatch( - Option.IF_SOURCE_METAGENERATION_NOT_MATCH.getLong(req.sourceOptions)) - .setIfSourceGenerationMatch(Option.IF_SOURCE_GENERATION_MATCH.getLong(req.sourceOptions)) - .setIfSourceGenerationNotMatch(Option.IF_SOURCE_GENERATION_NOT_MATCH.getLong(req.sourceOptions)) - .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(req.targetOptions)) - .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(req.targetOptions)) - .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(req.targetOptions)) - .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(req.targetOptions)) + IF_SOURCE_METAGENERATION_NOT_MATCH.getLong(req.sourceOptions)) + .setIfSourceGenerationMatch(IF_SOURCE_GENERATION_MATCH.getLong(req.sourceOptions)) + .setIfSourceGenerationNotMatch(IF_SOURCE_GENERATION_NOT_MATCH.getLong(req.sourceOptions)) + .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(req.targetOptions)) + .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(req.targetOptions)) + .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(req.targetOptions)) + .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(req.targetOptions)) .execute(); return new RewriteResponse( req, diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java index 7894f8fdee3c..ad13b14ae4e2 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java @@ -26,8 +26,8 @@ import com.google.gcloud.RestorableState; import com.google.gcloud.RetryParams; import com.google.gcloud.WriteChannel; -import com.google.gcloud.storage.spi.StorageRpc; import com.google.gcloud.storage.Acl.Project.ProjectRole; +import com.google.gcloud.storage.spi.StorageRpc; import org.junit.Test; diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java index 428f770ae381..9a306b2b03c6 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java @@ -37,10 +37,10 @@ import com.google.gcloud.RetryParams; import com.google.gcloud.ServiceOptions; import com.google.gcloud.WriteChannel; +import com.google.gcloud.storage.Storage.CopyRequest; import com.google.gcloud.storage.spi.StorageRpc; import com.google.gcloud.storage.spi.StorageRpc.Tuple; import com.google.gcloud.storage.spi.StorageRpcFactory; -import com.google.gcloud.storage.Storage.CopyRequest; import org.easymock.Capture; import org.easymock.EasyMock; From a595f6a0db96e2c9d146a594021ba4d7eda43aff Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 10 Mar 2016 16:36:26 +0100 Subject: [PATCH 129/203] Use groups to separate packages in javadoc's index --- .../java/com/google/gcloud/package-info.java | 20 +++++++++++++++++++ pom.xml | 14 +++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 gcloud-java-core/src/main/java/com/google/gcloud/package-info.java diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/package-info.java b/gcloud-java-core/src/main/java/com/google/gcloud/package-info.java new file mode 100644 index 000000000000..215264675dc2 --- /dev/null +++ b/gcloud-java-core/src/main/java/com/google/gcloud/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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. + */ + +/** + * Core classes for the {@code gcloud-java} library. + */ +package com.google.gcloud; \ No newline at end of file diff --git a/pom.xml b/pom.xml index b9d979c4d467..b6e8d3470edb 100644 --- a/pom.xml +++ b/pom.xml @@ -389,6 +389,20 @@ protected true ${project.build.directory}/javadoc + + + Main packages + com.google.gcloud* + + + SPI packages + com.google.gcloud.spi + + + Example packages + com.google.gcloud.examples* + + From 90d0917dde9acea5e85781b45b9d8bf210b90645 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 10 Mar 2016 18:50:34 +0100 Subject: [PATCH 130/203] Add group for testing packages --- .../src/main/java/com/google/gcloud/package-info.java | 2 +- pom.xml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/package-info.java b/gcloud-java-core/src/main/java/com/google/gcloud/package-info.java index 215264675dc2..d527640c99f9 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/package-info.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/package-info.java @@ -17,4 +17,4 @@ /** * Core classes for the {@code gcloud-java} library. */ -package com.google.gcloud; \ No newline at end of file +package com.google.gcloud; diff --git a/pom.xml b/pom.xml index b6e8d3470edb..c0a0e9bfcffe 100644 --- a/pom.xml +++ b/pom.xml @@ -394,6 +394,10 @@ Main packages com.google.gcloud* + + Test helpers packages + com.google.gcloud.bigquery.testing:com.google.gcloud.datastore.testing:com.google.gcloud.resourcemanager.testing:com.google.gcloud.storage.testing + SPI packages com.google.gcloud.spi From 24a712ae2972b428987b8d1d6b74b7968e35dfc8 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 10 Mar 2016 20:14:00 +0100 Subject: [PATCH 131/203] Rename Main packages to API packages, reorder groups, add service's SPIs --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index c0a0e9bfcffe..b7766ac0e5c6 100644 --- a/pom.xml +++ b/pom.xml @@ -391,21 +391,21 @@ ${project.build.directory}/javadoc - Main packages + API packages com.google.gcloud* Test helpers packages com.google.gcloud.bigquery.testing:com.google.gcloud.datastore.testing:com.google.gcloud.resourcemanager.testing:com.google.gcloud.storage.testing - - SPI packages - com.google.gcloud.spi - Example packages com.google.gcloud.examples* + + SPI packages + com.google.gcloud.spi:com.google.gcloud.bigquery.spi:com.google.gcloud.datastore.spi:com.google.gcloud.resourcemanager.spi:com.google.gcloud.storage.spi + From ac1ba668cb933093235407d4eb04f4138e7fbf9c Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 11 Mar 2016 18:51:15 +0100 Subject: [PATCH 132/203] Add more detailed javadoc to Blob and Storage signUrl --- .../java/com/google/gcloud/storage/Blob.java | 30 ++++++++++++++++- .../com/google/gcloud/storage/Storage.java | 33 +++++++++++++++---- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java index 4c8e935f7071..cb8b35a2ce88 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java @@ -22,6 +22,7 @@ import com.google.api.services.storage.model.StorageObject; import com.google.common.base.Function; +import com.google.gcloud.AuthCredentials; import com.google.gcloud.ReadChannel; import com.google.gcloud.WriteChannel; import com.google.gcloud.storage.Storage.BlobTargetOption; @@ -456,13 +457,40 @@ public WriteChannel writer(BlobWriteOption... options) { * Generates a signed URL for this blob. If you want to allow access to for a fixed amount of time * for this blob, you can use this method to generate a URL that is only valid within a certain * time period. This is particularly useful if you don't want publicly accessible blobs, but don't - * want to require users to explicitly log in. + * want to require users to explicitly log in. Signing a URL requires a service account + * and its associated key. If a {@link AuthCredentials.ServiceAccountAuthCredentials} was passed + * to {@link StorageOptions.Builder#authCredentials(AuthCredentials)} or the default credentials + * are being used and the environment variable {@code GOOGLE_APPLICATION_CREDENTIALS} is set, then + * {@code signUrl} will use that service account and associated key to sign the URL. If this + * is not the case, a service account with associated key can be passed to {@code signUrl} using + * the {@link SignUrlOption#serviceAccount(AuthCredentials.ServiceAccountAuthCredentials)} option. + * + *

    Example usage of creating a signed URL that is valid for 2 weeks: + *

     {@code
    +   * blob.signUrl(14, TimeUnit.DAYS);
    +   * }
    + * + *

    Example usage of creating a signed URL passing the {@code SignUrlOption.serviceAccount()} + * option: + *

     {@code
    +   * blob.signUrl(14, TimeUnit.DAYS, SignUrlOption.serviceAccount(
    +   *     AuthCredentials.createForJson(new FileInputStream("/path/to/key.json"))));
    +   * }
    * * @param duration time until the signed URL expires, expressed in {@code unit}. The finer * granularity supported is 1 second, finer granularities will be truncated * @param unit time unit of the {@code duration} parameter * @param options optional URL signing options * @return a signed URL for this bucket and the specified options + * @throws IllegalArgumentException if + * {@link SignUrlOption#serviceAccount(AuthCredentials.ServiceAccountAuthCredentials)} was not + * used and no service account was provided to {@link StorageOptions} + * @throws IllegalArgumentException if the key associated to the provided service account is + * invalid + * @throws IllegalArgumentException if {@link SignUrlOption#withMd5()} option is used and + * {@link #md5()} is {@code null} + * @throws IllegalArgumentException if {@link SignUrlOption#withContentType()} option is used and + * {@link #contentType()} is {@code null} * @see Signed-URLs */ public URL signUrl(long duration, TimeUnit unit, SignUrlOption... options) { diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 6b2e9266f24b..f673a3ac5902 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -24,6 +24,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import com.google.gcloud.AuthCredentials; import com.google.gcloud.AuthCredentials.ServiceAccountAuthCredentials; import com.google.gcloud.Page; import com.google.gcloud.ReadChannel; @@ -1476,23 +1477,43 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx WriteChannel writer(BlobInfo blobInfo, BlobWriteOption... options); /** - * Generates a signed URL for a blob. - * If you have a blob that you want to allow access to for a fixed - * amount of time, you can use this method to generate a URL that - * is only valid within a certain time period. - * This is particularly useful if you don't want publicly - * accessible blobs, but don't want to require users to explicitly log in. + * Generates a signed URL for a blob. If you have a blob that you want to allow access to for a + * fixed amount of time, you can use this method to generate a URL that is only valid within a + * certain time period. This is particularly useful if you don't want publicly accessible blobs, + * but don't want to require users to explicitly log in. Signing a URL requires a service account + * and its associated key. If a {@link ServiceAccountAuthCredentials} was passed to + * {@link StorageOptions.Builder#authCredentials(AuthCredentials)} or the default credentials are + * being used and the environment variable {@code GOOGLE_APPLICATION_CREDENTIALS} is set, then + * {@code signUrl} will use that service account and associated key to sign the URL. If this + * is not the case, a service account with associated key can be passed to {@code signUrl} using + * the {@code SignUrlOption.serviceAccount()} option. * *

    Example usage of creating a signed URL that is valid for 2 weeks: *

     {@code
        * service.signUrl(BlobInfo.builder("bucket", "name").build(), 14, TimeUnit.DAYS);
        * }
    * + *

    Example usage of creating a signed URL passing the {@code SignUrlOption.serviceAccount()} + * option: + *

     {@code
    +   * service.signUrl(BlobInfo.builder("bucket", "name").build(), 14, TimeUnit.DAYS,
    +   *     SignUrlOption.serviceAccount(
    +   *         AuthCredentials.createForJson(new FileInputStream("/path/to/key.json"))));
    +   * }
    + * * @param blobInfo the blob associated with the signed URL * @param duration time until the signed URL expires, expressed in {@code unit}. The finest * granularity supported is 1 second, finer granularities will be truncated * @param unit time unit of the {@code duration} parameter * @param options optional URL signing options + * @throws IllegalArgumentException if {@code SignUrlOption.serviceAccount()} was not used and no + * service account was provided to {@link StorageOptions} + * @throws IllegalArgumentException if the key associated to the provided service account is + * invalid + * @throws IllegalArgumentException if {@code SignUrlOption.withMd5()} option is used and + * {@code blobInfo.md5()} is {@code null} + * @throws IllegalArgumentException if {@code SignUrlOption.withContentType()} option is used and + * {@code blobInfo.contentType()} is {@code null} * @see Signed-URLs */ URL signUrl(BlobInfo blobInfo, long duration, TimeUnit unit, SignUrlOption... options); From 8a3b4f2194c6c3789e6dc4212beade7457382677 Mon Sep 17 00:00:00 2001 From: JP Martin Date: Fri, 11 Mar 2016 10:31:29 -0800 Subject: [PATCH 133/203] Remove final from Blob So we can mock it in test classes. Also make equals and hashCode final. --- .../src/main/java/com/google/gcloud/storage/Blob.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java index 4c8e935f7071..0c92a1f50594 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java @@ -49,7 +49,7 @@ * {@link BlobInfo}. *

    */ -public final class Blob extends BlobInfo { +public class Blob extends BlobInfo { private static final long serialVersionUID = -6806832496717441434L; @@ -482,13 +482,13 @@ public Builder toBuilder() { } @Override - public boolean equals(Object obj) { + public final boolean equals(Object obj) { return obj instanceof Blob && Objects.equals(toPb(), ((Blob) obj).toPb()) && Objects.equals(options, ((Blob) obj).options); } @Override - public int hashCode() { + public final int hashCode() { return Objects.hash(super.hashCode(), options); } From ddb1adee1e560b4001d335e3d7804f5723140854 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Sun, 13 Mar 2016 12:13:43 +0100 Subject: [PATCH 134/203] Rephrase signUrl javadoc for better clarity --- .../java/com/google/gcloud/storage/Blob.java | 25 +++++++++++-------- .../com/google/gcloud/storage/Storage.java | 12 ++++++--- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java index cb8b35a2ce88..c60a703eda91 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java @@ -454,16 +454,21 @@ public WriteChannel writer(BlobWriteOption... options) { } /** - * Generates a signed URL for this blob. If you want to allow access to for a fixed amount of time - * for this blob, you can use this method to generate a URL that is only valid within a certain - * time period. This is particularly useful if you don't want publicly accessible blobs, but don't - * want to require users to explicitly log in. Signing a URL requires a service account - * and its associated key. If a {@link AuthCredentials.ServiceAccountAuthCredentials} was passed - * to {@link StorageOptions.Builder#authCredentials(AuthCredentials)} or the default credentials - * are being used and the environment variable {@code GOOGLE_APPLICATION_CREDENTIALS} is set, then - * {@code signUrl} will use that service account and associated key to sign the URL. If this - * is not the case, a service account with associated key can be passed to {@code signUrl} using - * the {@link SignUrlOption#serviceAccount(AuthCredentials.ServiceAccountAuthCredentials)} option. + * Generates a signed URL for this blob. If you want to allow access for a fixed amount of time to + * this blob, you can use this method to generate a URL that is only valid within a certain time + * period. This is particularly useful if you don't want publicly accessible blobs, but don't want + * to require users to explicitly log in. Signing a URL requires a service account + * and its associated private key. If a {@link AuthCredentials.ServiceAccountAuthCredentials} was + * passed to {@link StorageOptions.Builder#authCredentials(AuthCredentials)} or the default + * credentials are being used and the environment variable {@code GOOGLE_APPLICATION_CREDENTIALS} + * is set, then {@code signUrl} will use that service account and associated key to sign the URL. + * If the credentials passed to {@link StorageOptions} do not expose a private key (this is the + * case for App Engine credentials, Compute Engine credentials and Google Cloud SDK credentials) + * then {@code signUrl} will throw an {@link IllegalArgumentException} unless a service account + * with associated key is passed using the {@code SignUrlOption.serviceAccount()} option. The + * service account and private key passed with {@code SignUrlOption.serviceAccount()} have + * priority over any credentials set with + * {@link StorageOptions.Builder#authCredentials(AuthCredentials)}. * *

    Example usage of creating a signed URL that is valid for 2 weeks: *

     {@code
    diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java
    index f673a3ac5902..91f7578d7f89 100644
    --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java
    +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java
    @@ -1481,12 +1481,16 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx
        * fixed amount of time, you can use this method to generate a URL that is only valid within a
        * certain time period. This is particularly useful if you don't want publicly accessible blobs,
        * but don't want to require users to explicitly log in. Signing a URL requires a service account
    -   * and its associated key. If a {@link ServiceAccountAuthCredentials} was passed to
    +   * and its associated private key. If a {@link ServiceAccountAuthCredentials} was passed to
        * {@link StorageOptions.Builder#authCredentials(AuthCredentials)} or the default credentials are
        * being used and the environment variable {@code GOOGLE_APPLICATION_CREDENTIALS} is set, then
    -   * {@code signUrl} will use that service account and associated key to sign the URL. If this
    -   * is not the case, a service account with associated key can be passed to {@code signUrl} using
    -   * the {@code SignUrlOption.serviceAccount()} option.
    +   * {@code signUrl} will use that service account and associated key to sign the URL. If the
    +   * credentials passed to {@link StorageOptions} do not expose a private key (this is the case for
    +   * App Engine credentials, Compute Engine credentials and Google Cloud SDK credentials) then
    +   * {@code signUrl} will throw an {@link IllegalArgumentException} unless a service account with
    +   * associated key is passed using the {@code SignUrlOption.serviceAccount()} option. The service
    +   * account and private key passed with {@code SignUrlOption.serviceAccount()} have priority over
    +   * any credentials set with {@link StorageOptions.Builder#authCredentials(AuthCredentials)}.
        *
        * 

    Example usage of creating a signed URL that is valid for 2 weeks: *

     {@code
    
    From d97c1887f4e24d1b9e03a3743d8481594041cede Mon Sep 17 00:00:00 2001
    From: Marco Ziccardi 
    Date: Mon, 14 Mar 2016 17:23:52 +0100
    Subject: [PATCH 135/203] Rename maxResults to pageSize
    
    ---
     gcloud-java-bigquery/README.md                |  2 +-
     .../com/google/gcloud/bigquery/BigQuery.java  | 38 +++++++++----------
     .../google/gcloud/bigquery/QueryRequest.java  | 28 +++++++-------
     .../gcloud/bigquery/BigQueryImplTest.java     | 34 ++++++++---------
     .../google/gcloud/bigquery/DatasetTest.java   |  4 +-
     .../gcloud/bigquery/QueryRequestTest.java     | 10 ++---
     .../gcloud/bigquery/SerializationTest.java    |  4 +-
     .../com/google/gcloud/bigquery/TableTest.java |  4 +-
     .../gcloud/bigquery/it/ITBigQueryTest.java    |  6 +--
     .../snippets/InsertDataAndQueryTable.java     |  2 +-
     .../com/google/gcloud/storage/Storage.java    | 12 +++---
     .../gcloud/storage/SerializationTest.java     |  2 +-
     .../gcloud/storage/StorageImplTest.java       | 28 +++++++-------
     13 files changed, 87 insertions(+), 87 deletions(-)
    
    diff --git a/gcloud-java-bigquery/README.md b/gcloud-java-bigquery/README.md
    index 3387cd8c4f41..81b5db71bcac 100644
    --- a/gcloud-java-bigquery/README.md
    +++ b/gcloud-java-bigquery/README.md
    @@ -185,7 +185,7 @@ Then add the following code to run the query and wait for the result:
     QueryRequest queryRequest =
         QueryRequest.builder("SELECT * FROM my_dataset_id.my_table_id")
             .maxWaitTime(60000L)
    -        .maxResults(1000L)
    +        .pageSize(1000L)
             .build();
     // Request query to be executed and wait for results
     QueryResponse queryResponse = bigquery.query(queryRequest);
    diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java
    index 3acaacaf42e5..e06c8d86ee5f 100644
    --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java
    +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java
    @@ -171,10 +171,10 @@ private DatasetListOption(BigQueryRpc.Option option, Object value) {
         }
     
         /**
    -     * Returns an option to specify the maximum number of datasets to be returned.
    +     * Returns an option to specify the maximum number of datasets returned per page.
          */
    -    public static DatasetListOption maxResults(long maxResults) {
    -      return new DatasetListOption(BigQueryRpc.Option.MAX_RESULTS, maxResults);
    +    public static DatasetListOption pageSize(long pageSize) {
    +      return new DatasetListOption(BigQueryRpc.Option.MAX_RESULTS, pageSize);
         }
     
         /**
    @@ -246,11 +246,11 @@ private TableListOption(BigQueryRpc.Option option, Object value) {
         }
     
         /**
    -     * Returns an option to specify the maximum number of tables to be returned.
    +     * Returns an option to specify the maximum number of tables returned per page.
          */
    -    public static TableListOption maxResults(long maxResults) {
    -      checkArgument(maxResults >= 0);
    -      return new TableListOption(BigQueryRpc.Option.MAX_RESULTS, maxResults);
    +    public static TableListOption pageSize(long pageSize) {
    +      checkArgument(pageSize >= 0);
    +      return new TableListOption(BigQueryRpc.Option.MAX_RESULTS, pageSize);
         }
     
         /**
    @@ -295,11 +295,11 @@ private TableDataListOption(BigQueryRpc.Option option, Object value) {
         }
     
         /**
    -     * Returns an option to specify the maximum number of rows to be returned.
    +     * Returns an option to specify the maximum number of rows returned per page.
          */
    -    public static TableDataListOption maxResults(long maxResults) {
    -      checkArgument(maxResults >= 0);
    -      return new TableDataListOption(BigQueryRpc.Option.MAX_RESULTS, maxResults);
    +    public static TableDataListOption pageSize(long pageSize) {
    +      checkArgument(pageSize >= 0);
    +      return new TableDataListOption(BigQueryRpc.Option.MAX_RESULTS, pageSize);
         }
     
         /**
    @@ -352,11 +352,11 @@ public String apply(JobStatus.State state) {
         }
     
         /**
    -     * Returns an option to specify the maximum number of jobs to be returned.
    +     * Returns an option to specify the maximum number of jobs returned per page.
          */
    -    public static JobListOption maxResults(long maxResults) {
    -      checkArgument(maxResults >= 0);
    -      return new JobListOption(BigQueryRpc.Option.MAX_RESULTS, maxResults);
    +    public static JobListOption pageSize(long pageSize) {
    +      checkArgument(pageSize >= 0);
    +      return new JobListOption(BigQueryRpc.Option.MAX_RESULTS, pageSize);
         }
     
         /**
    @@ -418,11 +418,11 @@ private QueryResultsOption(BigQueryRpc.Option option, Object value) {
         }
     
         /**
    -     * Returns an option to specify the maximum number of rows to be returned.
    +     * Returns an option to specify the maximum number of rows returned per page.
          */
    -    public static QueryResultsOption maxResults(long maxResults) {
    -      checkArgument(maxResults >= 0);
    -      return new QueryResultsOption(BigQueryRpc.Option.MAX_RESULTS, maxResults);
    +    public static QueryResultsOption pageSize(long pageSize) {
    +      checkArgument(pageSize >= 0);
    +      return new QueryResultsOption(BigQueryRpc.Option.MAX_RESULTS, pageSize);
         }
     
         /**
    diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java
    index 5f99f3c5b4ee..b3522a2a6ba3 100644
    --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java
    +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java
    @@ -40,7 +40,7 @@
      * QueryRequest request = QueryRequest.builder("SELECT field FROM table")
      *     .defaultDataset(DatasetId.of("dataset"))
      *     .maxWaitTime(60000L)
    - *     .maxResults(1000L)
    + *     .pageSize(1000L)
      *     .build();
      * QueryResponse response = bigquery.query(request);
      * while (!response.jobCompleted()) {
    @@ -65,7 +65,7 @@ public class QueryRequest implements Serializable {
       private static final long serialVersionUID = -8727328332415880852L;
     
       private final String query;
    -  private final Long maxResults;
    +  private final Long pageSize;
       private final DatasetId defaultDataset;
       private final Long maxWaitTime;
       private final Boolean dryRun;
    @@ -74,7 +74,7 @@ public class QueryRequest implements Serializable {
       public static final class Builder {
     
         private String query;
    -    private Long maxResults;
    +    private Long pageSize;
         private DatasetId defaultDataset;
         private Long maxWaitTime;
         private Boolean dryRun;
    @@ -96,8 +96,8 @@ public Builder query(String query) {
          * query result set is large. In addition to this limit, responses are also limited to 10 MB.
          * By default, there is no maximum row count, and only the byte limit applies.
          */
    -    public Builder maxResults(Long maxResults) {
    -      this.maxResults = maxResults;
    +    public Builder pageSize(Long pageSize) {
    +      this.pageSize = pageSize;
           return this;
         }
     
    @@ -157,7 +157,7 @@ public QueryRequest build() {
     
       private QueryRequest(Builder builder) {
         query = builder.query;
    -    maxResults = builder.maxResults;
    +    pageSize = builder.pageSize;
         defaultDataset = builder.defaultDataset;
         maxWaitTime = builder.maxWaitTime;
         dryRun = builder.dryRun;
    @@ -174,8 +174,8 @@ public String query() {
       /**
        * Returns the maximum number of rows of data to return per page of results.
        */
    -  public Long maxResults() {
    -    return maxResults;
    +  public Long pageSize() {
    +    return pageSize;
       }
     
       /**
    @@ -224,7 +224,7 @@ public Boolean useQueryCache() {
       public Builder toBuilder() {
         return new Builder()
             .query(query)
    -        .maxResults(maxResults)
    +        .pageSize(pageSize)
             .defaultDataset(defaultDataset)
             .maxWaitTime(maxWaitTime)
             .dryRun(dryRun)
    @@ -235,7 +235,7 @@ public Builder toBuilder() {
       public String toString() {
         return MoreObjects.toStringHelper(this)
             .add("query", query)
    -        .add("maxResults", maxResults)
    +        .add("pageSize", pageSize)
             .add("defaultDataset", defaultDataset)
             .add("maxWaitTime", maxWaitTime)
             .add("dryRun", dryRun)
    @@ -245,7 +245,7 @@ public String toString() {
     
       @Override
       public int hashCode() {
    -    return Objects.hash(query, maxResults, defaultDataset, maxWaitTime, dryRun, useQueryCache);
    +    return Objects.hash(query, pageSize, defaultDataset, maxWaitTime, dryRun, useQueryCache);
       }
     
       @Override
    @@ -264,8 +264,8 @@ QueryRequest setProjectId(String projectId) {
       com.google.api.services.bigquery.model.QueryRequest toPb() {
         com.google.api.services.bigquery.model.QueryRequest queryRequestPb =
             new com.google.api.services.bigquery.model.QueryRequest().setQuery(query);
    -    if (maxResults != null) {
    -      queryRequestPb.setMaxResults(maxResults);
    +    if (pageSize != null) {
    +      queryRequestPb.setMaxResults(pageSize);
         }
         if (defaultDataset != null) {
           queryRequestPb.setDefaultDataset(defaultDataset.toPb());
    @@ -299,7 +299,7 @@ public static QueryRequest of(String query) {
       static QueryRequest fromPb(com.google.api.services.bigquery.model.QueryRequest queryRequestPb) {
         Builder builder = builder(queryRequestPb.getQuery());
         if (queryRequestPb.getMaxResults() != null) {
    -      builder.maxResults(queryRequestPb.getMaxResults());
    +      builder.pageSize(queryRequestPb.getMaxResults());
         }
         if (queryRequestPb.getDefaultDataset() != null) {
           builder.defaultDataset(DatasetId.fromPb(queryRequestPb.getDefaultDataset()));
    diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java
    index 305745e72da9..b398f238386a 100644
    --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java
    +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java
    @@ -148,12 +148,12 @@ public class BigQueryImplTest {
       private static final TableRow TABLE_ROW =
           new TableRow().setF(ImmutableList.of(BOOLEAN_FIELD, INTEGER_FIELD));
       private static final QueryRequest QUERY_REQUEST = QueryRequest.builder("SQL")
    -      .maxResults(42L)
    +      .pageSize(42L)
           .useQueryCache(false)
           .defaultDataset(DatasetId.of(DATASET))
           .build();
       private static final QueryRequest QUERY_REQUEST_WITH_PROJECT = QueryRequest.builder("SQL")
    -      .maxResults(42L)
    +      .pageSize(42L)
           .useQueryCache(false)
           .defaultDataset(DatasetId.of(PROJECT, DATASET))
           .build();
    @@ -170,8 +170,8 @@ public class BigQueryImplTest {
           BigQuery.DatasetListOption.all();
       private static final BigQuery.DatasetListOption DATASET_LIST_PAGE_TOKEN =
           BigQuery.DatasetListOption.startPageToken("cursor");
    -  private static final BigQuery.DatasetListOption DATASET_LIST_MAX_RESULTS =
    -      BigQuery.DatasetListOption.maxResults(42L);
    +  private static final BigQuery.DatasetListOption DATASET_LIST_PAGE_SIZE =
    +      BigQuery.DatasetListOption.pageSize(42L);
       private static final Map DATASET_LIST_OPTIONS = ImmutableMap.of(
           BigQueryRpc.Option.ALL_DATASETS, true,
           BigQueryRpc.Option.PAGE_TOKEN, "cursor",
    @@ -188,8 +188,8 @@ public class BigQueryImplTest {
           BigQuery.TableOption.fields(BigQuery.TableField.SCHEMA, BigQuery.TableField.ETAG);
     
       // Table list options
    -  private static final BigQuery.TableListOption TABLE_LIST_MAX_RESULTS =
    -      BigQuery.TableListOption.maxResults(42L);
    +  private static final BigQuery.TableListOption TABLE_LIST_PAGE_SIZE =
    +      BigQuery.TableListOption.pageSize(42L);
       private static final BigQuery.TableListOption TABLE_LIST_PAGE_TOKEN =
           BigQuery.TableListOption.startPageToken("cursor");
       private static final Map TABLE_LIST_OPTIONS = ImmutableMap.of(
    @@ -197,8 +197,8 @@ public class BigQueryImplTest {
           BigQueryRpc.Option.PAGE_TOKEN, "cursor");
     
       // TableData list options
    -  private static final BigQuery.TableDataListOption TABLE_DATA_LIST_MAX_RESULTS =
    -      BigQuery.TableDataListOption.maxResults(42L);
    +  private static final BigQuery.TableDataListOption TABLE_DATA_LIST_PAGE_SIZE =
    +      BigQuery.TableDataListOption.pageSize(42L);
       private static final BigQuery.TableDataListOption TABLE_DATA_LIST_PAGE_TOKEN =
           BigQuery.TableDataListOption.startPageToken("cursor");
       private static final BigQuery.TableDataListOption TABLE_DATA_LIST_START_INDEX =
    @@ -221,8 +221,8 @@ public class BigQueryImplTest {
           BigQuery.JobListOption.stateFilter(JobStatus.State.DONE, JobStatus.State.PENDING);
       private static final BigQuery.JobListOption JOB_LIST_PAGE_TOKEN =
           BigQuery.JobListOption.startPageToken("cursor");
    -  private static final BigQuery.JobListOption JOB_LIST_MAX_RESULTS =
    -      BigQuery.JobListOption.maxResults(42L);
    +  private static final BigQuery.JobListOption JOB_LIST_PAGE_SIZE =
    +      BigQuery.JobListOption.pageSize(42L);
       private static final Map JOB_LIST_OPTIONS = ImmutableMap.of(
           BigQueryRpc.Option.ALL_USERS, true,
           BigQueryRpc.Option.STATE_FILTER, ImmutableList.of("done", "pending"),
    @@ -236,8 +236,8 @@ public class BigQueryImplTest {
           BigQuery.QueryResultsOption.startIndex(1024L);
       private static final BigQuery.QueryResultsOption QUERY_RESULTS_OPTION_PAGE_TOKEN =
           BigQuery.QueryResultsOption.startPageToken("cursor");
    -  private static final BigQuery.QueryResultsOption QUERY_RESULTS_OPTION_MAX_RESULTS =
    -      BigQuery.QueryResultsOption.maxResults(0L);
    +  private static final BigQuery.QueryResultsOption QUERY_RESULTS_OPTION_PAGE_SIZE =
    +      BigQuery.QueryResultsOption.pageSize(0L);
       private static final Map QUERY_RESULTS_OPTIONS = ImmutableMap.of(
           BigQueryRpc.Option.TIMEOUT, 42L,
           BigQueryRpc.Option.START_INDEX, 1024L,
    @@ -388,7 +388,7 @@ public void testListDatasetsWithOptions() {
         EasyMock.expect(bigqueryRpcMock.listDatasets(DATASET_LIST_OPTIONS)).andReturn(result);
         EasyMock.replay(bigqueryRpcMock);
         Page page = bigquery.listDatasets(DATASET_LIST_ALL, DATASET_LIST_PAGE_TOKEN,
    -        DATASET_LIST_MAX_RESULTS);
    +        DATASET_LIST_PAGE_SIZE);
         assertEquals(cursor, page.nextPageCursor());
         assertArrayEquals(datasetList.toArray(), Iterables.toArray(page.values(), DatasetInfo.class));
       }
    @@ -560,7 +560,7 @@ public void testListTablesWithOptions() {
             Tuple.of(cursor, Iterables.transform(tableList, TableInfo.TO_PB_FUNCTION));
         EasyMock.expect(bigqueryRpcMock.listTables(DATASET, TABLE_LIST_OPTIONS)).andReturn(result);
         EasyMock.replay(bigqueryRpcMock);
    -    Page
    page = bigquery.listTables(DATASET, TABLE_LIST_MAX_RESULTS, TABLE_LIST_PAGE_TOKEN); + Page
    page = bigquery.listTables(DATASET, TABLE_LIST_PAGE_SIZE, TABLE_LIST_PAGE_TOKEN); assertEquals(cursor, page.nextPageCursor()); assertArrayEquals(tableList.toArray(), Iterables.toArray(page.values(), Table.class)); } @@ -733,7 +733,7 @@ public void testListTableDataWithOptions() { EasyMock.replay(bigqueryRpcMock); bigquery = options.service(); Page> page = bigquery.listTableData(DATASET, TABLE, - TABLE_DATA_LIST_MAX_RESULTS, TABLE_DATA_LIST_PAGE_TOKEN, TABLE_DATA_LIST_START_INDEX); + TABLE_DATA_LIST_PAGE_SIZE, TABLE_DATA_LIST_PAGE_TOKEN, TABLE_DATA_LIST_START_INDEX); assertEquals(cursor, page.nextPageCursor()); assertArrayEquals(tableData.toArray(), Iterables.toArray(page.values(), List.class)); } @@ -859,7 +859,7 @@ public com.google.api.services.bigquery.model.Job apply(Job job) { EasyMock.expect(bigqueryRpcMock.listJobs(JOB_LIST_OPTIONS)).andReturn(result); EasyMock.replay(bigqueryRpcMock); Page page = bigquery.listJobs(JOB_LIST_ALL_USERS, JOB_LIST_STATE_FILTER, - JOB_LIST_PAGE_TOKEN, JOB_LIST_MAX_RESULTS); + JOB_LIST_PAGE_TOKEN, JOB_LIST_PAGE_SIZE); assertEquals(cursor, page.nextPageCursor()); assertArrayEquals(jobList.toArray(), Iterables.toArray(page.values(), Job.class)); } @@ -1012,7 +1012,7 @@ public void testGetQueryResultsWithOptions() { EasyMock.replay(bigqueryRpcMock); bigquery = options.service(); QueryResponse response = bigquery.getQueryResults(queryJob, QUERY_RESULTS_OPTION_TIME, - QUERY_RESULTS_OPTION_INDEX, QUERY_RESULTS_OPTION_MAX_RESULTS, + QUERY_RESULTS_OPTION_INDEX, QUERY_RESULTS_OPTION_PAGE_SIZE, QUERY_RESULTS_OPTION_PAGE_TOKEN); assertEquals(queryJob, response.jobId()); assertEquals(true, response.jobCompleted()); diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/DatasetTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/DatasetTest.java index 373291021b23..dd03b7899ebc 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/DatasetTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/DatasetTest.java @@ -260,11 +260,11 @@ public void testListWithOptions() throws Exception { new Table(serviceMockReturnsOptions, new Table.BuilderImpl(TABLE_INFO3))); PageImpl
    expectedPage = new PageImpl<>(null, "c", tableResults); expect(bigquery.options()).andReturn(mockOptions); - expect(bigquery.listTables(DATASET_INFO.datasetId(), BigQuery.TableListOption.maxResults(10L))) + expect(bigquery.listTables(DATASET_INFO.datasetId(), BigQuery.TableListOption.pageSize(10L))) .andReturn(expectedPage); replay(bigquery); initializeDataset(); - Page
    tablePage = dataset.list(BigQuery.TableListOption.maxResults(10L)); + Page
    tablePage = dataset.list(BigQuery.TableListOption.pageSize(10L)); assertArrayEquals(tableResults.toArray(), Iterables.toArray(tablePage.values(), Table.class)); assertEquals(expectedPage.nextPageCursor(), tablePage.nextPageCursor()); } diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/QueryRequestTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/QueryRequestTest.java index 370b4d614cbf..7875dee9e315 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/QueryRequestTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/QueryRequestTest.java @@ -29,13 +29,13 @@ public class QueryRequestTest { private static final DatasetId DATASET_ID = DatasetId.of("dataset"); private static final Boolean USE_QUERY_CACHE = true; private static final Boolean DRY_RUN = false; - private static final Long MAX_RESULTS = 42L; + private static final Long PAGE_SIZE = 42L; private static final Long MAX_WAIT_TIME = 42000L; private static final QueryRequest QUERY_REQUEST = QueryRequest.builder(QUERY) .useQueryCache(USE_QUERY_CACHE) .defaultDataset(DATASET_ID) .dryRun(DRY_RUN) - .maxResults(MAX_RESULTS) + .pageSize(PAGE_SIZE) .maxWaitTime(MAX_WAIT_TIME) .build(); @@ -65,7 +65,7 @@ public void testBuilder() { assertEquals(USE_QUERY_CACHE, QUERY_REQUEST.useQueryCache()); assertEquals(DATASET_ID, QUERY_REQUEST.defaultDataset()); assertEquals(DRY_RUN, QUERY_REQUEST.dryRun()); - assertEquals(MAX_RESULTS, QUERY_REQUEST.maxResults()); + assertEquals(PAGE_SIZE, QUERY_REQUEST.pageSize()); assertEquals(MAX_WAIT_TIME, QUERY_REQUEST.maxWaitTime()); thrown.expect(NullPointerException.class); QueryRequest.builder(null); @@ -78,7 +78,7 @@ public void testOf() { assertNull(request.useQueryCache()); assertNull(request.defaultDataset()); assertNull(request.dryRun()); - assertNull(request.maxResults()); + assertNull(request.pageSize()); assertNull(request.maxWaitTime()); thrown.expect(NullPointerException.class); QueryRequest.of(null); @@ -102,7 +102,7 @@ private void compareQueryRequest(QueryRequest expected, QueryRequest value) { assertEquals(expected.useQueryCache(), value.useQueryCache()); assertEquals(expected.defaultDataset(), value.defaultDataset()); assertEquals(expected.dryRun(), value.dryRun()); - assertEquals(expected.maxResults(), value.maxResults()); + assertEquals(expected.pageSize(), value.pageSize()); assertEquals(expected.maxWaitTime(), value.maxWaitTime()); } } diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java index d877bff2138c..254c8954bf30 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java @@ -207,7 +207,7 @@ public class SerializationTest { .useQueryCache(true) .defaultDataset(DATASET_ID) .dryRun(false) - .maxResults(42L) + .pageSize(42L) .maxWaitTime(10L) .build(); private static final QueryResult QUERY_RESULT = QueryResult.builder() @@ -261,7 +261,7 @@ public void testModelAndRequests() throws Exception { INSERT_ALL_RESPONSE, FIELD_VALUE, QUERY_REQUEST, QUERY_RESPONSE, BigQuery.DatasetOption.fields(), BigQuery.DatasetDeleteOption.deleteContents(), BigQuery.DatasetListOption.all(), BigQuery.TableOption.fields(), - BigQuery.TableListOption.maxResults(42L), BigQuery.JobOption.fields(), + BigQuery.TableListOption.pageSize(42L), BigQuery.JobOption.fields(), BigQuery.JobListOption.allUsers(), DATASET, TABLE, JOB}; for (Serializable obj : objects) { Object copy = serializeAndDeserialize(obj); diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableTest.java index 4866ee9ab8ec..c7828ebeadf4 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableTest.java @@ -286,11 +286,11 @@ public void testListWithOptions() throws Exception { initializeExpectedTable(1); expect(bigquery.options()).andReturn(mockOptions); PageImpl> tableDataPage = new PageImpl<>(null, "c", ROWS); - expect(bigquery.listTableData(TABLE_ID1, BigQuery.TableDataListOption.maxResults(10L))) + expect(bigquery.listTableData(TABLE_ID1, BigQuery.TableDataListOption.pageSize(10L))) .andReturn(tableDataPage); replay(bigquery); initializeTable(); - Page> dataPage = table.list(BigQuery.TableDataListOption.maxResults(10L)); + Page> dataPage = table.list(BigQuery.TableDataListOption.pageSize(10L)); Iterator> tableDataIterator = tableDataPage.values().iterator(); Iterator> dataIterator = dataPage.values().iterator(); assertTrue(Iterators.elementsEqual(tableDataIterator, dataIterator)); diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java index 63a0551ece33..50780b4fc9a9 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/it/ITBigQueryTest.java @@ -348,7 +348,7 @@ public void testCreateExternalTable() throws InterruptedException { + tableName) .defaultDataset(DatasetId.of(DATASET)) .maxWaitTime(60000L) - .maxResults(1000L) + .pageSize(1000L) .build(); QueryResponse response = bigquery.query(request); while (!response.jobCompleted()) { @@ -411,7 +411,7 @@ public void testCreateViewTable() throws InterruptedException { QueryRequest request = QueryRequest.builder("SELECT * FROM " + tableName) .defaultDataset(DatasetId.of(DATASET)) .maxWaitTime(60000L) - .maxResults(1000L) + .pageSize(1000L) .build(); QueryResponse response = bigquery.query(request); while (!response.jobCompleted()) { @@ -662,7 +662,7 @@ public void testQuery() throws InterruptedException { QueryRequest request = QueryRequest.builder(query) .defaultDataset(DatasetId.of(DATASET)) .maxWaitTime(60000L) - .maxResults(1000L) + .pageSize(1000L) .build(); QueryResponse response = bigquery.query(request); while (!response.jobCompleted()) { diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/snippets/InsertDataAndQueryTable.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/snippets/InsertDataAndQueryTable.java index f421bc832441..ba2d1291b229 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/snippets/InsertDataAndQueryTable.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/bigquery/snippets/InsertDataAndQueryTable.java @@ -84,7 +84,7 @@ public static void main(String... args) throws InterruptedException { // Create a query request QueryRequest queryRequest = QueryRequest.builder("SELECT * FROM my_dataset_id.my_table_id") .maxWaitTime(60000L) - .maxResults(1000L) + .pageSize(1000L) .build(); // Request query to be executed and wait for results QueryResponse queryResponse = bigquery.query(queryRequest); diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 6b2e9266f24b..c098c7ddc5d3 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -626,10 +626,10 @@ private BucketListOption(StorageRpc.Option option, Object value) { } /** - * Returns an option to specify the maximum number of buckets to be returned. + * Returns an option to specify the maximum number of buckets returned per page. */ - public static BucketListOption maxResults(long maxResults) { - return new BucketListOption(StorageRpc.Option.MAX_RESULTS, maxResults); + public static BucketListOption pageSize(long pageSize) { + return new BucketListOption(StorageRpc.Option.MAX_RESULTS, pageSize); } /** @@ -672,10 +672,10 @@ private BlobListOption(StorageRpc.Option option, Object value) { } /** - * Returns an option to specify the maximum number of blobs to be returned. + * Returns an option to specify the maximum number of blobs returned per page. */ - public static BlobListOption maxResults(long maxResults) { - return new BlobListOption(StorageRpc.Option.MAX_RESULTS, maxResults); + public static BlobListOption pageSize(long pageSize) { + return new BlobListOption(StorageRpc.Option.MAX_RESULTS, pageSize); } /** diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java index ad13b14ae4e2..efa56d9e39b2 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java @@ -64,7 +64,7 @@ public class SerializationTest { private static final PageImpl PAGE_RESULT = new PageImpl<>(null, "c", Collections.singletonList(BLOB)); private static final Storage.BlobListOption BLOB_LIST_OPTIONS = - Storage.BlobListOption.maxResults(100); + Storage.BlobListOption.pageSize(100); private static final Storage.BlobSourceOption BLOB_SOURCE_OPTIONS = Storage.BlobSourceOption.generationMatch(1); private static final Storage.BlobTargetOption BLOB_TARGET_OPTIONS = diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java index 9a306b2b03c6..38b4bb58e77f 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java @@ -181,8 +181,8 @@ public class StorageImplTest { StorageRpc.Option.IF_SOURCE_GENERATION_MATCH, BLOB_SOURCE_GENERATION.value()); // Bucket list options - private static final Storage.BucketListOption BUCKET_LIST_MAX_RESULT = - Storage.BucketListOption.maxResults(42L); + private static final Storage.BucketListOption BUCKET_LIST_PAGE_SIZE = + Storage.BucketListOption.pageSize(42L); private static final Storage.BucketListOption BUCKET_LIST_PREFIX = Storage.BucketListOption.prefix("prefix"); private static final Storage.BucketListOption BUCKET_LIST_FIELDS = @@ -190,12 +190,12 @@ public class StorageImplTest { private static final Storage.BucketListOption BUCKET_LIST_EMPTY_FIELDS = Storage.BucketListOption.fields(); private static final Map BUCKET_LIST_OPTIONS = ImmutableMap.of( - StorageRpc.Option.MAX_RESULTS, BUCKET_LIST_MAX_RESULT.value(), + StorageRpc.Option.MAX_RESULTS, BUCKET_LIST_PAGE_SIZE.value(), StorageRpc.Option.PREFIX, BUCKET_LIST_PREFIX.value()); // Blob list options - private static final Storage.BlobListOption BLOB_LIST_MAX_RESULT = - Storage.BlobListOption.maxResults(42L); + private static final Storage.BlobListOption BLOB_LIST_PAGE_SIZE = + Storage.BlobListOption.pageSize(42L); private static final Storage.BlobListOption BLOB_LIST_PREFIX = Storage.BlobListOption.prefix("prefix"); private static final Storage.BlobListOption BLOB_LIST_FIELDS = @@ -205,7 +205,7 @@ public class StorageImplTest { private static final Storage.BlobListOption BLOB_LIST_EMPTY_FIELDS = Storage.BlobListOption.fields(); private static final Map BLOB_LIST_OPTIONS = ImmutableMap.of( - StorageRpc.Option.MAX_RESULTS, BLOB_LIST_MAX_RESULT.value(), + StorageRpc.Option.MAX_RESULTS, BLOB_LIST_PAGE_SIZE.value(), StorageRpc.Option.PREFIX, BLOB_LIST_PREFIX.value(), StorageRpc.Option.VERSIONS, BLOB_LIST_VERSIONS.value()); @@ -567,7 +567,7 @@ public void testListBucketsWithOptions() { EasyMock.replay(storageRpcMock); initializeService(); ImmutableList bucketList = ImmutableList.of(expectedBucket1, expectedBucket2); - Page page = storage.list(BUCKET_LIST_MAX_RESULT, BUCKET_LIST_PREFIX); + Page page = storage.list(BUCKET_LIST_PAGE_SIZE, BUCKET_LIST_PREFIX); assertEquals(cursor, page.nextPageCursor()); assertArrayEquals(bucketList.toArray(), Iterables.toArray(page.values(), Bucket.class)); } @@ -654,7 +654,7 @@ public void testListBlobsWithOptions() { initializeService(); ImmutableList blobList = ImmutableList.of(expectedBlob1, expectedBlob2); Page page = - storage.list(BUCKET_NAME1, BLOB_LIST_MAX_RESULT, BLOB_LIST_PREFIX, BLOB_LIST_VERSIONS); + storage.list(BUCKET_NAME1, BLOB_LIST_PAGE_SIZE, BLOB_LIST_PREFIX, BLOB_LIST_VERSIONS); assertEquals(cursor, page.nextPageCursor()); assertArrayEquals(blobList.toArray(), Iterables.toArray(page.values(), Blob.class)); } @@ -673,9 +673,9 @@ public void testListBlobsWithSelectedFields() { initializeService(); ImmutableList blobList = ImmutableList.of(expectedBlob1, expectedBlob2); Page page = - storage.list(BUCKET_NAME1, BLOB_LIST_MAX_RESULT, BLOB_LIST_PREFIX, BLOB_LIST_FIELDS); - assertEquals(BLOB_LIST_MAX_RESULT.value(), - capturedOptions.getValue().get(BLOB_LIST_MAX_RESULT.rpcOption())); + storage.list(BUCKET_NAME1, BLOB_LIST_PAGE_SIZE, BLOB_LIST_PREFIX, BLOB_LIST_FIELDS); + assertEquals(BLOB_LIST_PAGE_SIZE.value(), + capturedOptions.getValue().get(BLOB_LIST_PAGE_SIZE.rpcOption())); assertEquals(BLOB_LIST_PREFIX.value(), capturedOptions.getValue().get(BLOB_LIST_PREFIX.rpcOption())); String selector = (String) capturedOptions.getValue().get(BLOB_LIST_FIELDS.rpcOption()); @@ -704,9 +704,9 @@ public void testListBlobsWithEmptyFields() { initializeService(); ImmutableList blobList = ImmutableList.of(expectedBlob1, expectedBlob2); Page page = - storage.list(BUCKET_NAME1, BLOB_LIST_MAX_RESULT, BLOB_LIST_PREFIX, BLOB_LIST_EMPTY_FIELDS); - assertEquals(BLOB_LIST_MAX_RESULT.value(), - capturedOptions.getValue().get(BLOB_LIST_MAX_RESULT.rpcOption())); + storage.list(BUCKET_NAME1, BLOB_LIST_PAGE_SIZE, BLOB_LIST_PREFIX, BLOB_LIST_EMPTY_FIELDS); + assertEquals(BLOB_LIST_PAGE_SIZE.value(), + capturedOptions.getValue().get(BLOB_LIST_PAGE_SIZE.rpcOption())); assertEquals(BLOB_LIST_PREFIX.value(), capturedOptions.getValue().get(BLOB_LIST_PREFIX.rpcOption())); String selector = (String) capturedOptions.getValue().get(BLOB_LIST_EMPTY_FIELDS.rpcOption()); From 767be657b14e8f6e86167389e9af8d65a7fff19d Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 14 Mar 2016 09:53:34 -0700 Subject: [PATCH 136/203] LocalDnsHelper adds the default change upon creating a zone. This now matches the behaviour of the service. Fixes #672. --- .../gcloud/dns/testing/LocalDnsHelper.java | 17 +++++++++++++---- .../gcloud/dns/testing/LocalDnsHelperTest.java | 8 ++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java index f9cd1a11281e..3b18ec5ce55b 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java @@ -680,7 +680,15 @@ Response createZone(String projectId, ManagedZone zone, String... fields) { completeZone.setId(BigInteger.valueOf(Math.abs(ID_GENERATOR.nextLong() % Long.MAX_VALUE))); completeZone.setNameServers(randomNameservers()); ZoneContainer zoneContainer = new ZoneContainer(completeZone); - zoneContainer.dnsRecords().set(defaultRecords(completeZone)); + ImmutableSortedMap defaultsRecords = defaultRecords(completeZone); + zoneContainer.dnsRecords().set(defaultsRecords); + Change change = new Change(); + change.setAdditions(ImmutableList.copyOf(defaultsRecords.values())); + change.setStatus("done"); + change.setId("0"); + change.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC() + .print(System.currentTimeMillis())); + zoneContainer.changes().add(change); ProjectContainer projectContainer = findProject(projectId); ZoneContainer oldValue = projectContainer.zones().putIfAbsent( completeZone.getName(), zoneContainer); @@ -718,8 +726,9 @@ Response createChange(String projectId, String zoneName, Change change, String.. completeChange.setDeletions(ImmutableList.copyOf(change.getDeletions())); } /* We need to set ID for the change. We are working in concurrent environment. We know that the - element fell on an index between 0 and maxId, so we will reset all IDs in this range (all of - them are valid for the respective objects). */ + element fell on an index between 1 and maxId (index 0 is the default change which creates SOA + and NS), so we will reset all IDs between 0 and maxId (all of them are valid for the respective + objects). */ ConcurrentLinkedQueue changeSequence = zoneContainer.changes(); changeSequence.add(completeChange); int maxId = changeSequence.size(); @@ -728,7 +737,7 @@ Response createChange(String projectId, String zoneName, Change change, String.. if (index == maxId) { break; } - c.setId(String.valueOf(++index)); + c.setId(String.valueOf(index++)); } completeChange.setStatus("pending"); completeChange.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC() diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java index 2d049e4ffeea..15fa437eb631 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java @@ -850,14 +850,14 @@ public void testListChanges() { RPC.create(ZONE1, EMPTY_RPC_OPTIONS); Iterable results = RPC.listChangeRequests(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); ImmutableList changes = ImmutableList.copyOf(results); - assertEquals(0, changes.size()); + assertEquals(1, changes.size()); // zone has changes RPC.applyChangeRequest(ZONE1.getName(), CHANGE1, EMPTY_RPC_OPTIONS); RPC.applyChangeRequest(ZONE1.getName(), CHANGE2, EMPTY_RPC_OPTIONS); RPC.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); results = RPC.listChangeRequests(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); changes = ImmutableList.copyOf(results); - assertEquals(3, changes.size()); + assertEquals(4, changes.size()); // error in options Map options = new HashMap<>(); options.put(DnsRpc.Option.PAGE_SIZE, 0); @@ -881,14 +881,14 @@ public void testListChanges() { options.put(DnsRpc.Option.PAGE_SIZE, 15); results = RPC.listChangeRequests(ZONE1.getName(), options).results(); changes = ImmutableList.copyOf(results); - assertEquals(3, changes.size()); + assertEquals(4, changes.size()); options = new HashMap<>(); options.put(DnsRpc.Option.SORTING_ORDER, "descending"); results = RPC.listChangeRequests(ZONE1.getName(), options).results(); ImmutableList descending = ImmutableList.copyOf(results); results = RPC.listChangeRequests(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); ImmutableList ascending = ImmutableList.copyOf(results); - int size = 3; + int size = 4; assertEquals(size, descending.size()); for (int i = 0; i < size; i++) { assertEquals(descending.get(i), ascending.get(size - i - 1)); From 86e23d55bc9cec8a2bd626d143882a998d1a165a Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Mon, 14 Mar 2016 17:59:18 +0100 Subject: [PATCH 137/203] Fix flaky RemoteGcsHelperTest.testForceDeleteTimeout --- .../java/com/google/gcloud/storage/RemoteGcsHelperTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelperTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelperTest.java index 154554a029fe..146922a9dae9 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelperTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/RemoteGcsHelperTest.java @@ -132,7 +132,8 @@ public void testForceDelete() throws InterruptedException, ExecutionException { @Test public void testForceDeleteTimeout() throws InterruptedException, ExecutionException { Storage storageMock = EasyMock.createMock(Storage.class); - EasyMock.expect(storageMock.list(BUCKET_NAME)).andReturn(blobPage).anyTimes(); + EasyMock.expect(storageMock.list(BUCKET_NAME, BlobListOption.versions(true))) + .andReturn(blobPage).anyTimes(); for (BlobInfo info : blobList) { EasyMock.expect(storageMock.delete(info.blobId())).andReturn(true).anyTimes(); } From 96e380c182aa89f8c4f7dbdcb7df2d4c188c8343 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 14 Mar 2016 14:45:15 -0700 Subject: [PATCH 138/203] Moved spi package to dns.spi as per #742 --- .../com/google/gcloud/dns/AbstractOption.java | 2 +- .../main/java/com/google/gcloud/dns/Dns.java | 2 +- .../java/com/google/gcloud/dns/DnsImpl.java | 2 +- .../com/google/gcloud/dns/DnsOptions.java | 6 ++--- .../gcloud/{ => dns}/spi/DefaultDnsRpc.java | 22 +++++++++---------- .../google/gcloud/{ => dns}/spi/DnsRpc.java | 2 +- .../gcloud/{ => dns}/spi/DnsRpcFactory.java | 3 ++- .../google/gcloud/dns/AbstractOptionTest.java | 2 +- .../com/google/gcloud/dns/DnsImplTest.java | 4 ++-- .../java/com/google/gcloud/dns/DnsTest.java | 2 +- .../dns/testing/LocalDnsHelperTest.java | 4 ++-- 11 files changed, 26 insertions(+), 25 deletions(-) rename gcloud-java-dns/src/main/java/com/google/gcloud/{ => dns}/spi/DefaultDnsRpc.java (91%) rename gcloud-java-dns/src/main/java/com/google/gcloud/{ => dns}/spi/DnsRpc.java (99%) rename gcloud-java-dns/src/main/java/com/google/gcloud/{ => dns}/spi/DnsRpcFactory.java (91%) diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java index a148468d14b5..e12f7412e687 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.MoreObjects; -import com.google.gcloud.spi.DnsRpc; +import com.google.gcloud.dns.spi.DnsRpc; import java.io.Serializable; import java.util.Objects; diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index b2cb9fbad371..6ce6b4c19994 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -20,7 +20,7 @@ import com.google.common.collect.Sets; import com.google.gcloud.Page; import com.google.gcloud.Service; -import com.google.gcloud.spi.DnsRpc; +import com.google.gcloud.dns.spi.DnsRpc; import java.io.Serializable; import java.util.Set; diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java index 17521c13c625..a60cfd9151da 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java @@ -33,7 +33,7 @@ import com.google.gcloud.Page; import com.google.gcloud.PageImpl; import com.google.gcloud.RetryHelper; -import com.google.gcloud.spi.DnsRpc; +import com.google.gcloud.dns.spi.DnsRpc; import java.util.Map; import java.util.concurrent.Callable; diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java index d9317546cea0..db922b42a3cb 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java @@ -18,9 +18,9 @@ import com.google.common.collect.ImmutableSet; import com.google.gcloud.ServiceOptions; -import com.google.gcloud.spi.DefaultDnsRpc; -import com.google.gcloud.spi.DnsRpc; -import com.google.gcloud.spi.DnsRpcFactory; +import com.google.gcloud.dns.spi.DefaultDnsRpc; +import com.google.gcloud.dns.spi.DnsRpc; +import com.google.gcloud.dns.spi.DnsRpcFactory; import java.util.Set; diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DefaultDnsRpc.java similarity index 91% rename from gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DefaultDnsRpc.java index 1df0a8a2f831..f8b8adb87ada 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DefaultDnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DefaultDnsRpc.java @@ -1,13 +1,13 @@ -package com.google.gcloud.spi; - -import static com.google.gcloud.spi.DnsRpc.ListResult.of; -import static com.google.gcloud.spi.DnsRpc.Option.DNS_NAME; -import static com.google.gcloud.spi.DnsRpc.Option.DNS_TYPE; -import static com.google.gcloud.spi.DnsRpc.Option.FIELDS; -import static com.google.gcloud.spi.DnsRpc.Option.NAME; -import static com.google.gcloud.spi.DnsRpc.Option.PAGE_SIZE; -import static com.google.gcloud.spi.DnsRpc.Option.PAGE_TOKEN; -import static com.google.gcloud.spi.DnsRpc.Option.SORTING_ORDER; +package com.google.gcloud.dns.spi; + +import static com.google.gcloud.dns.spi.DnsRpc.ListResult.of; +import static com.google.gcloud.dns.spi.DnsRpc.Option.DNS_NAME; +import static com.google.gcloud.dns.spi.DnsRpc.Option.DNS_TYPE; +import static com.google.gcloud.dns.spi.DnsRpc.Option.FIELDS; +import static com.google.gcloud.dns.spi.DnsRpc.Option.NAME; +import static com.google.gcloud.dns.spi.DnsRpc.Option.PAGE_SIZE; +import static com.google.gcloud.dns.spi.DnsRpc.Option.PAGE_TOKEN; +import static com.google.gcloud.dns.spi.DnsRpc.Option.SORTING_ORDER; import static java.net.HttpURLConnection.HTTP_NOT_FOUND; import com.google.api.client.http.HttpRequestInitializer; @@ -188,7 +188,7 @@ public ListResult listChangeRequests(String zoneName, Map opt request = request.setSortBy(SORT_BY).setSortOrder(SORTING_ORDER.getString(options)); } ChangesListResponse response = request.execute(); - return ListResult.of(response.getNextPageToken(), response.getChanges()); + return of(response.getNextPageToken(), response.getChanges()); } catch (IOException ex) { throw translate(ex); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DnsRpc.java similarity index 99% rename from gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DnsRpc.java index addb69d24b40..bde93b99bfdd 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DnsRpc.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.dns.spi; import com.google.api.services.dns.model.Change; import com.google.api.services.dns.model.ManagedZone; diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpcFactory.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DnsRpcFactory.java similarity index 91% rename from gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpcFactory.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DnsRpcFactory.java index 3d25f09bb1e5..ca1b1a0dd018 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpcFactory.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DnsRpcFactory.java @@ -14,9 +14,10 @@ * limitations under the License. */ -package com.google.gcloud.spi; +package com.google.gcloud.dns.spi; import com.google.gcloud.dns.DnsOptions; +import com.google.gcloud.spi.ServiceRpcFactory; /** * An interface for DnsRpc factory. Implementation will be loaded via {@link diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java index 09e35527879b..d88ea85c5846 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/AbstractOptionTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.fail; -import com.google.gcloud.spi.DnsRpc; +import com.google.gcloud.dns.spi.DnsRpc; import org.junit.Test; diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java index 9205de8d99dd..a97c9c408036 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java @@ -28,8 +28,8 @@ import com.google.gcloud.Page; import com.google.gcloud.RetryParams; import com.google.gcloud.ServiceOptions; -import com.google.gcloud.spi.DnsRpc; -import com.google.gcloud.spi.DnsRpcFactory; +import com.google.gcloud.dns.spi.DnsRpc; +import com.google.gcloud.dns.spi.DnsRpcFactory; import org.easymock.Capture; import org.easymock.EasyMock; diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java index c9f4df4f5bdd..2e233e2df62a 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import com.google.gcloud.spi.DnsRpc; +import com.google.gcloud.dns.spi.DnsRpc; import org.junit.Test; diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java index 15fa437eb631..59002131cc9d 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java @@ -32,8 +32,8 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.gcloud.dns.DnsException; -import com.google.gcloud.spi.DefaultDnsRpc; -import com.google.gcloud.spi.DnsRpc; +import com.google.gcloud.dns.spi.DefaultDnsRpc; +import com.google.gcloud.dns.spi.DnsRpc; import org.junit.AfterClass; import org.junit.Before; From 4e0248f951ddc61ae2a5cdb82d1f953f3bba17cb Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Tue, 15 Mar 2016 14:33:27 +0100 Subject: [PATCH 139/203] Add better javadoc for signUrl examples --- .../java/com/google/gcloud/storage/Blob.java | 30 +++++++++---------- .../com/google/gcloud/storage/Storage.java | 13 ++++---- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java index c60a703eda91..b4fc892d3df5 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java @@ -456,27 +456,27 @@ public WriteChannel writer(BlobWriteOption... options) { /** * Generates a signed URL for this blob. If you want to allow access for a fixed amount of time to * this blob, you can use this method to generate a URL that is only valid within a certain time - * period. This is particularly useful if you don't want publicly accessible blobs, but don't want - * to require users to explicitly log in. Signing a URL requires a service account - * and its associated private key. If a {@link AuthCredentials.ServiceAccountAuthCredentials} was - * passed to {@link StorageOptions.Builder#authCredentials(AuthCredentials)} or the default - * credentials are being used and the environment variable {@code GOOGLE_APPLICATION_CREDENTIALS} - * is set, then {@code signUrl} will use that service account and associated key to sign the URL. - * If the credentials passed to {@link StorageOptions} do not expose a private key (this is the - * case for App Engine credentials, Compute Engine credentials and Google Cloud SDK credentials) - * then {@code signUrl} will throw an {@link IllegalArgumentException} unless a service account - * with associated key is passed using the {@code SignUrlOption.serviceAccount()} option. The - * service account and private key passed with {@code SignUrlOption.serviceAccount()} have - * priority over any credentials set with - * {@link StorageOptions.Builder#authCredentials(AuthCredentials)}. + * period. This is particularly useful if you don't want publicly accessible blobs, but also don't + * want to require users to explicitly log in. Signing a URL requires a service account and its + * associated private key. If a {@link AuthCredentials.ServiceAccountAuthCredentials} was passed + * to {@link StorageOptions.Builder#authCredentials(AuthCredentials)} or the default credentials + * are being used and the environment variable {@code GOOGLE_APPLICATION_CREDENTIALS} is set, then + * {@code signUrl} will use that service account and associated key to sign the URL. If the + * credentials passed to {@link StorageOptions} do not expose a private key (this is the case for + * App Engine credentials, Compute Engine credentials and Google Cloud SDK credentials) then + * {@code signUrl} will throw an {@link IllegalArgumentException} unless a service account with + * associated key is passed using the {@code SignUrlOption.serviceAccount()} option. The service + * account and private key passed with {@code SignUrlOption.serviceAccount()} have priority over + * any credentials set with {@link StorageOptions.Builder#authCredentials(AuthCredentials)}. * - *

    Example usage of creating a signed URL that is valid for 2 weeks: + *

    Example usage of creating a signed URL that is valid for 2 weeks, using the default + * credentials for signing the URL: *

     {@code
        * blob.signUrl(14, TimeUnit.DAYS);
        * }
    * *

    Example usage of creating a signed URL passing the {@code SignUrlOption.serviceAccount()} - * option: + * option, that will be used for signing the URL: *

     {@code
        * blob.signUrl(14, TimeUnit.DAYS, SignUrlOption.serviceAccount(
        *     AuthCredentials.createForJson(new FileInputStream("/path/to/key.json"))));
    diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java
    index 91f7578d7f89..7a58878469f1 100644
    --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java
    +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java
    @@ -1480,10 +1480,10 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx
        * Generates a signed URL for a blob. If you have a blob that you want to allow access to for a
        * fixed amount of time, you can use this method to generate a URL that is only valid within a
        * certain time period. This is particularly useful if you don't want publicly accessible blobs,
    -   * but don't want to require users to explicitly log in. Signing a URL requires a service account
    -   * and its associated private key. If a {@link ServiceAccountAuthCredentials} was passed to
    -   * {@link StorageOptions.Builder#authCredentials(AuthCredentials)} or the default credentials are
    -   * being used and the environment variable {@code GOOGLE_APPLICATION_CREDENTIALS} is set, then
    +   * but also don't want to require users to explicitly log in. Signing a URL requires a service
    +   * account and its associated private key. If a {@link ServiceAccountAuthCredentials} was passed
    +   * to {@link StorageOptions.Builder#authCredentials(AuthCredentials)} or the default credentials
    +   * are being used and the environment variable {@code GOOGLE_APPLICATION_CREDENTIALS} is set, then
        * {@code signUrl} will use that service account and associated key to sign the URL. If the
        * credentials passed to {@link StorageOptions} do not expose a private key (this is the case for
        * App Engine credentials, Compute Engine credentials and Google Cloud SDK credentials) then
    @@ -1492,13 +1492,14 @@ private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentEx
        * account and private key passed with {@code SignUrlOption.serviceAccount()} have priority over
        * any credentials set with {@link StorageOptions.Builder#authCredentials(AuthCredentials)}.
        *
    -   * 

    Example usage of creating a signed URL that is valid for 2 weeks: + *

    Example usage of creating a signed URL that is valid for 2 weeks, using the default + * credentials for signing the URL: *

     {@code
        * service.signUrl(BlobInfo.builder("bucket", "name").build(), 14, TimeUnit.DAYS);
        * }
    * *

    Example usage of creating a signed URL passing the {@code SignUrlOption.serviceAccount()} - * option: + * option, that will be used for signing the URL: *

     {@code
        * service.signUrl(BlobInfo.builder("bucket", "name").build(), 14, TimeUnit.DAYS,
        *     SignUrlOption.serviceAccount(
    
    From 886a8bdf0885edcaf971bd6aca9de715727ae11c Mon Sep 17 00:00:00 2001
    From: Martin Derka 
    Date: Wed, 2 Mar 2016 10:13:20 -0800
    Subject: [PATCH 140/203]  Added a DNS example and documentation.
    
    ---
     gcloud-java-examples/README.md                |  19 +-
     .../google/gcloud/examples/DnsExample.java    | 516 ++++++++++++++++++
     gcloud-java/pom.xml                           |   5 +
     3 files changed, 539 insertions(+), 1 deletion(-)
     create mode 100644 gcloud-java-examples/src/main/java/com/google/gcloud/examples/DnsExample.java
    
    diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md
    index 59fbca11e219..3807813b3df0 100644
    --- a/gcloud-java-examples/README.md
    +++ b/gcloud-java-examples/README.md
    @@ -63,7 +63,7 @@ To run examples from your command line:
         ```
     
       * Here's an example run of `DatastoreExample`.
    -  
    +
         Be sure to change the placeholder project ID "your-project-id" with your own project ID. Also note that you have to enable the Google Cloud Datastore API on the [Google Developers Console][developers-console] before running the following commands.
         ```
         mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.datastore.DatastoreExample" -Dexec.args="your-project-id my_name add my\ comment"
    @@ -71,6 +71,23 @@ To run examples from your command line:
         mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.datastore.DatastoreExample" -Dexec.args="your-project-id my_name delete"
         ```
     
    +  * Here's an example run of `DnsExample`.
    +
    +    Note that you have to enable the Google Cloud DNS API on the [Google Developers Console][developers-console] before running the following commands.
    +    Note that the example creates and deletes dns records of type A only. Operations with other record types are not implemented in the example.
    +    ```
    +    $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="create some-sample-zone elaborateexample.com. description"
    +    $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="get some-sample-zone"
    +    $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="list"
    +    $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="list some-sample-zone records"
    +    $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="add-record some-sample-zone www.elaborateexample.com. 12.13.14.15 69"
    +    $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="get some-sample-zone"
    +    $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="delete-record some-sample-zone www.elaborateexample.com. 12.13.14.15 69"
    +    $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="list some-sample-zone changes ascending"
    +    $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="delete some-sample-zone"
    +    $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="quota"
    +    ```
    +
       * Here's an example run of `ResourceManagerExample`.
     
         Be sure to change the placeholder project ID "your-project-id" with your own globally unique project ID.
    diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DnsExample.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DnsExample.java
    new file mode 100644
    index 000000000000..071ba59e0f7e
    --- /dev/null
    +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DnsExample.java
    @@ -0,0 +1,516 @@
    +/*
    + * Copyright 2016 Google Inc. All Rights Reserved.
    + *
    + * 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.gcloud.examples;
    +
    +import com.google.common.base.Joiner;
    +import com.google.common.collect.ImmutableList;
    +import com.google.gcloud.dns.ChangeRequest;
    +import com.google.gcloud.dns.Dns;
    +import com.google.gcloud.dns.DnsOptions;
    +import com.google.gcloud.dns.DnsRecord;
    +import com.google.gcloud.dns.ProjectInfo;
    +import com.google.gcloud.dns.Zone;
    +import com.google.gcloud.dns.ZoneInfo;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Iterator;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +/**
    + * An example of using Google Cloud DNS.
    + *
    + * 

    This example creates, deletes, gets, and lists zones, and creates and deletes DNS records of + * type A. + * + *

    Steps needed for running the example:

      + *
    1. login using gcloud SDK - {@code gcloud auth login}.
    2. + *
    3. compile using maven - {@code mvn compile}
    4. + *
    5. run using maven - {@code mvn exec:java + * -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" + * -Dexec.args="[] + * create | + * get | + * delete | + * list [ [changes [descending | ascending] | records]] | + * add-record | + * delete-record [] | + * quota
    6. + *
    + * + *

    The first parameter is an optional {@code project_id} (logged-in project will be used if not + * supplied). Second parameter is a DNS operation (list, delete, create,...) and can be used to + * demonstrate the usage. The remaining arguments are specific to the operation. See each action's + * run method for the specific interaction. + */ +public class DnsExample { + + private static final Map ACTIONS = new HashMap<>(); + + private interface DnsAction { + void run(Dns dns, String... args); + + String params(); + + boolean check(String... args); + } + + private static class CreateZoneAction implements DnsAction { + + /** + * Creates a zone with the provided name, dns name and description (in this order). + */ + @Override + public void run(Dns dns, String... args) { + String zoneName = args[0]; + String dnsName = args[1]; + String description = args[2]; + ZoneInfo zoneInfo = ZoneInfo.builder(zoneName) + .dnsName(dnsName) + .description(description) + .build(); + Zone zone = dns.create(zoneInfo); + System.out.printf("Successfully created zone with name %s which was assigned ID %s.%n", + zone.name(), zone.id()); + } + + @Override + public String params() { + return " "; + } + + @Override + public boolean check(String... args) { + return args.length == 3; + } + } + + private static class ListZonesAction implements DnsAction { + + /** + * Lists all zones within the project. + */ + @Override + public void run(Dns dns, String... args) { + Iterator zoneIterator = dns.listZones().iterateAll(); + if (zoneIterator.hasNext()) { + System.out.println("The project contains the following zones:"); + System.out.println("Name\tID\tDNS Name\tCreated\tDesription"); + while (zoneIterator.hasNext()) { + Zone zone = zoneIterator.next(); + System.out.printf("%s\t%s\t%s\t%s\t%s%n", zone.name(), zone.id(), zone.dnsName(), + zone.creationTimeMillis(), zone.description()); + } + } else { + System.out.println("Project contains no zones."); + } + } + + @Override + public String params() { + return ""; + } + + @Override + public boolean check(String... args) { + return args.length == 0; + } + } + + private static class GetZoneAction implements DnsAction { + + /** + * Gets details about a zone with the given name. + */ + @Override + public void run(Dns dns, String... args) { + String zoneName = args[0]; + Zone zone = dns.getZone(zoneName); + if (zone == null) { + System.out.printf("No zone with name '%s' exists.%n", zoneName); + } else { + System.out.printf("Name: %s%n", zone.name()); + System.out.printf("ID: %s%n", zone.id()); + System.out.printf("Description: %s%n", zone.description()); + System.out.printf("Created: %s%n", zone.creationTimeMillis()); + System.out.printf("Name servers: %s%n", Joiner.on(",").join(zone.nameServers())); + } + } + + @Override + public String params() { + return ""; + } + + @Override + public boolean check(String... args) { + return args.length == 1; + } + } + + private static class DeleteZoneAction implements DnsAction { + + /** + * Deletes a zone with the given name. + */ + @Override + public void run(Dns dns, String... args) { + String zoneName = args[0]; + boolean deleted = dns.delete(zoneName); + if (deleted) { + System.out.printf("Zone %s was deleted.%n", zoneName); + } else { + System.out.printf("Zone %s was NOT deleted. It probably does not exist.%n", zoneName); + } + } + + @Override + public String params() { + return ""; + } + + @Override + public boolean check(String... args) { + return args.length == 1; + } + + } + + private static class DeleteDnsRecordAction implements DnsAction { + + /** + * Deletes a DNS record of type A from the given zone. The last parameter is ttl and it is not + * required. + */ + @Override + public void run(Dns dns, String... args) { + String zoneName = args[0]; + String recordName = args[1]; + String ip = args[2]; + DnsRecord record = DnsRecord.builder(recordName, DnsRecord.Type.A) + .records(ImmutableList.of(ip)) + .build(); + if (args.length > 3) { + Integer ttl = Integer.valueOf(args[3]); + record = record.toBuilder().ttl(ttl, TimeUnit.SECONDS).build(); + } + ChangeRequest changeRequest = ChangeRequest.builder() + .delete(record) + .build(); + changeRequest = dns.applyChangeRequest(zoneName, changeRequest); + System.out.printf("The request for deleting A record %s for zone %s was successfully " + + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); + while (changeRequest.status().equals(ChangeRequest.Status.PENDING)) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + System.err.println("Thread was interrupted while waiting."); + } + changeRequest = dns.getChangeRequest(zoneName, changeRequest.id()); + } + System.out.printf("The deletion has been completed.%n"); + } + + @Override + public String params() { + return " []"; + } + + @Override + public boolean check(String... args) { + if (args.length == 4) { + try { + Integer.valueOf(args[3]); + } catch (Exception ex) { + throw new IllegalArgumentException(ex); + } + return true; + } else { + return args.length == 3; + } + } + } + + private static class AddDnsRecordAction implements DnsAction { + + /** + * Adds a DNS record of type A. The last parameter is ttl and is not required. + */ + @Override + public void run(Dns dns, String... args) { + String zoneName = args[0]; + String recordName = args[1]; + String ip = args[2]; + DnsRecord record = DnsRecord.builder(recordName, DnsRecord.Type.A) + .records(ImmutableList.of(ip)) + .build(); + if (args.length > 3) { + Integer ttl = Integer.valueOf(args[3]); + record = record.toBuilder().ttl(ttl, TimeUnit.SECONDS).build(); + } + ChangeRequest changeRequest = ChangeRequest.builder() + .add(record) + .build(); + changeRequest = dns.applyChangeRequest(zoneName, changeRequest); + System.out.printf("The request for adding A record %s for zone %s was successfully " + + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); + while (changeRequest.status().equals(ChangeRequest.Status.PENDING)) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + System.err.println("Thread was interrupted while waiting."); + } + changeRequest = dns.getChangeRequest(zoneName, changeRequest.id()); + } + System.out.printf("The addition has been completed.%n"); + } + + @Override + public String params() { + return " []"; + } + + @Override + public boolean check(String... args) { + if (args.length == 4) { + try { + Integer.valueOf(args[3]); + } catch (Exception ex) { + throw new IllegalArgumentException(ex); + } + return true; + } else { + return args.length == 3; + } + } + } + + private static class ListDnsRecordsAction implements DnsAction { + + /** + * Lists all the DNS records in the given zone. + */ + @Override + public void run(Dns dns, String... args) { + String zoneName = args[0]; + Iterator iterator = dns.listDnsRecords(zoneName).iterateAll(); + if (iterator.hasNext()) { + System.out.printf("DNS records for zone %s:%n", zoneName); + System.out.printf("Record name\tTTL\tRecords%n"); + while (iterator.hasNext()) { + DnsRecord record = iterator.next(); + System.out.printf("%s\t%s\t%s%n", record.name(), record.ttl(), + Joiner.on(",").join(record.records())); + } + } else { + System.out.printf("Zone %s has no DNS records.%n", zoneName); + } + } + + @Override + public String params() { + return " records"; + } + + @Override + public boolean check(String... args) { + return args.length == 2; + } + } + + private static class ListChangesAction implements DnsAction { + + /** + * Lists all the changes for a given zone. Optionally, an order, "descending" or "ascending" can + * be specified using the last parameter. + */ + @Override + public void run(Dns dns, String... args) { + String zoneName = args[0]; + Iterator iterator; + if (args.length > 2) { + Dns.SortingOrder sortOrder = Dns.SortingOrder.valueOf(args[2].toUpperCase()); + iterator = dns.listChangeRequests(zoneName, + Dns.ChangeRequestListOption.sortOrder(sortOrder)).iterateAll(); + } else { + iterator = dns.listChangeRequests(zoneName).iterateAll(); + } + if (iterator.hasNext()) { + System.out.printf("Change requests for zone %s:%n", zoneName); + System.out.printf("ID\tStatus\tTimestamp%n"); + while (iterator.hasNext()) { + ChangeRequest change = iterator.next(); + System.out.printf("%s\t%s\t%s%n", change.id(), change.status(), change.startTimeMillis()); + System.out.printf("\tDeletions: %s%n", Joiner.on(",").join(change.deletions())); + System.out.printf("\tAdditions: %s%n", Joiner.on(",").join(change.additions())); + } + } else { + System.out.printf("Zone %s has no change requests.%n", zoneName); + } + } + + @Override + public String params() { + return " changes [descending | ascending]"; + } + + @Override + public boolean check(String... args) { + System.err.println(Arrays.asList(args)); + return args.length == 2 + || (args.length == 3 && ImmutableList.of("descending", "ascending").contains(args[2])); + } + } + + private static class ListAction implements DnsAction { + + /** + * Invokes a list action. If no parameter is provided, lists all zones. If zone name is the only + * parameter provided, lists both DNS records and changes. Otherwise, invokes listing changes or + * zones based on the parameter provided. + */ + @Override + public void run(Dns dns, String... args) { + if (args.length == 0) { + new ListZonesAction().run(dns); + } else { + if (args.length == 1 || "records".equals(args[1])) { + new ListDnsRecordsAction().run(dns, args); + } + if (args.length == 1 || "changes".equals(args[1])) { + new ListChangesAction().run(dns, args); + } + } + } + + @Override + public boolean check(String... args) { + if (args.length == 0 || args.length == 1) { + return true; + } + if ("records".equals(args[1])) { + return new ListDnsRecordsAction().check(args); + } + if ("changes".equals(args[1])) { + return new ListChangesAction().check(args); + } + return false; + } + + @Override + public String params() { + return "[ [changes [descending | ascending] | records]]"; + } + } + + private static class GetProjectAction implements DnsAction { + + @Override + public void run(Dns dns, String... args) { + ProjectInfo project = dns.getProject(); + System.out.printf("Project id: %s%nQuota:%n", dns.options().projectId()); + System.out.printf("\tZones: %d%n", project.quota().zones()); + System.out.printf("\tDNS records per zone: %d%n", project.quota().rrsetsPerZone()); + System.out.printf("\tRecord sets per DNS record: %d%n", + project.quota().resourceRecordsPerRrset()); + System.out.printf("\tAdditions per change: %d%n", project.quota().rrsetAdditionsPerChange()); + System.out.printf("\tDeletions per change: %d%n", project.quota().rrsetDeletionsPerChange()); + System.out.printf("\tTotal data size per change: %d%n", + project.quota().totalRrdataSizePerChange()); + } + + @Override + public String params() { + return ""; + } + + @Override + public boolean check(String... args) { + return args.length == 0; + } + } + + static { + ACTIONS.put("create", new CreateZoneAction()); + ACTIONS.put("delete", new DeleteZoneAction()); + ACTIONS.put("get", new GetZoneAction()); + ACTIONS.put("list", new ListAction()); + ACTIONS.put("add-record", new AddDnsRecordAction()); + ACTIONS.put("delete-record", new DeleteDnsRecordAction()); + ACTIONS.put("quota", new GetProjectAction()); + } + + private static void printUsage() { + StringBuilder actionAndParams = new StringBuilder(); + for (Map.Entry entry : ACTIONS.entrySet()) { + actionAndParams.append('\t').append(System.lineSeparator()).append(entry.getKey()); + String param = entry.getValue().params(); + if (param != null && !param.isEmpty()) { + actionAndParams.append(' ').append(param); + } + } + System.out.printf("Usage: %s [] operation *%s%n", + DnsExample.class.getSimpleName(), actionAndParams); + } + + public static void main(String... args) throws Exception { + if (args.length < 1) { + System.out.println("Missing required action"); + printUsage(); + return; + } + DnsOptions.Builder optionsBuilder = DnsOptions.builder(); + DnsAction action; + String actionName; + if (args.length >= 2 && !ACTIONS.containsKey(args[0])) { + actionName = args[1]; + optionsBuilder.projectId(args[0]); + action = ACTIONS.get(args[1]); + args = Arrays.copyOfRange(args, 2, args.length); + } else { + actionName = args[0]; + action = ACTIONS.get(args[0]); + args = Arrays.copyOfRange(args, 1, args.length); + } + if (action == null) { + System.out.println("Unrecognized action."); + printUsage(); + return; + } + Dns dns = optionsBuilder.build().service(); + boolean valid = false; + try { + valid = action.check(args); + } catch (NumberFormatException ex) { + System.out.println("Invalid input for action '" + actionName + "'."); + System.out.println("Ttl must be an integer."); + System.out.println("Expected: " + action.params()); + return; + } catch (Exception ex) { + System.out.println("Failed to parse request."); + ex.printStackTrace(); + return; + } + if (valid) { + action.run(dns, args); + } else { + System.out.println("Invalid input for action '" + actionName + "'"); + System.out.println("Expected: " + action.params()); + } + } +} diff --git a/gcloud-java/pom.xml b/gcloud-java/pom.xml index adfa716fe27b..b7dfd3f12e8f 100644 --- a/gcloud-java/pom.xml +++ b/gcloud-java/pom.xml @@ -38,5 +38,10 @@ gcloud-java-storage ${project.version} + + ${project.groupId} + gcloud-java-dns + ${project.version} + From 8e82f351520d9e8768a2818545f99a6f41c7bf2b Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 9 Mar 2016 16:40:56 -0800 Subject: [PATCH 141/203] Fixed based on first round of comments: - moved to correct package - added printouts while waiting for changes - removed tab-based formatting - removed NumberFormatException hiding - some minor code refactoring - extended documentation - switched builder() to of() construct in DNS example --- gcloud-java-examples/README.md | 21 ++- .../gcloud/examples/{ => dns}/DnsExample.java | 132 ++++++++++-------- gcloud-java/pom.xml | 6 +- 3 files changed, 85 insertions(+), 74 deletions(-) rename gcloud-java-examples/src/main/java/com/google/gcloud/examples/{ => dns}/DnsExample.java (78%) diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md index 3807813b3df0..73d613c94e27 100644 --- a/gcloud-java-examples/README.md +++ b/gcloud-java-examples/README.md @@ -74,18 +74,17 @@ To run examples from your command line: * Here's an example run of `DnsExample`. Note that you have to enable the Google Cloud DNS API on the [Google Developers Console][developers-console] before running the following commands. - Note that the example creates and deletes dns records of type A only. Operations with other record types are not implemented in the example. + You will need to replace the domain name `elaborateexample.com` with your own domain name with verified ownership. + Also, note that the example creates and deletes DNS records of type A only. Operations with other record types are not implemented in the example. ``` - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="create some-sample-zone elaborateexample.com. description" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="get some-sample-zone" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="list" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="list some-sample-zone records" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="add-record some-sample-zone www.elaborateexample.com. 12.13.14.15 69" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="get some-sample-zone" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="delete-record some-sample-zone www.elaborateexample.com. 12.13.14.15 69" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="list some-sample-zone changes ascending" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="delete some-sample-zone" - $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.DnsExample" -Dexec.args="quota" + mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="create some-sample-zone elaborateexample.com. description" + mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="list" + mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="list some-sample-zone records" + mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="add-record some-sample-zone www.elaborateexample.com. 12.13.14.15 69" + mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="get some-sample-zone" + mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="delete-record some-sample-zone www.elaborateexample.com. 12.13.14.15 69" + mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="list some-sample-zone changes ascending" + mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="delete some-sample-zone" ``` * Here's an example run of `ResourceManagerExample`. diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DnsExample.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java similarity index 78% rename from gcloud-java-examples/src/main/java/com/google/gcloud/examples/DnsExample.java rename to gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java index 071ba59e0f7e..2061f4931cab 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DnsExample.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.gcloud.examples; +package com.google.gcloud.examples.dns; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; @@ -26,7 +26,10 @@ import com.google.gcloud.dns.Zone; import com.google.gcloud.dns.ZoneInfo; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -38,7 +41,8 @@ *

    This example creates, deletes, gets, and lists zones, and creates and deletes DNS records of * type A. * - *

    Steps needed for running the example:

      + *

      Steps needed for running the example: + *

        *
      1. login using gcloud SDK - {@code gcloud auth login}.
      2. *
      3. compile using maven - {@code mvn compile}
      4. *
      5. run using maven - {@code mvn exec:java @@ -50,13 +54,13 @@ * list [ [changes [descending | ascending] | records]] | * add-record | * delete-record [] | - * quota
      6. + * quota} *
      * *

      The first parameter is an optional {@code project_id} (logged-in project will be used if not - * supplied). Second parameter is a DNS operation (list, delete, create,...) and can be used to - * demonstrate the usage. The remaining arguments are specific to the operation. See each action's - * run method for the specific interaction. + * supplied). Second parameter is a DNS operation (list, delete, create,...). The remaining + * arguments are specific to the operation. See each action's run method for the specific + * interaction. */ public class DnsExample { @@ -80,10 +84,7 @@ public void run(Dns dns, String... args) { String zoneName = args[0]; String dnsName = args[1]; String description = args[2]; - ZoneInfo zoneInfo = ZoneInfo.builder(zoneName) - .dnsName(dnsName) - .description(description) - .build(); + ZoneInfo zoneInfo = ZoneInfo.of(zoneName, dnsName, description); Zone zone = dns.create(zoneInfo); System.out.printf("Successfully created zone with name %s which was assigned ID %s.%n", zone.name(), zone.id()); @@ -110,11 +111,14 @@ public void run(Dns dns, String... args) { Iterator zoneIterator = dns.listZones().iterateAll(); if (zoneIterator.hasNext()) { System.out.println("The project contains the following zones:"); - System.out.println("Name\tID\tDNS Name\tCreated\tDesription"); + DateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); while (zoneIterator.hasNext()) { Zone zone = zoneIterator.next(); - System.out.printf("%s\t%s\t%s\t%s\t%s%n", zone.name(), zone.id(), zone.dnsName(), - zone.creationTimeMillis(), zone.description()); + System.out.printf("%nName: %s%n", zone.name()); + System.out.printf("ID: %s%n", zone.id()); + System.out.printf("Description: %s%n", zone.description()); + System.out.printf("Created: %s%n", formatter.format(new Date(zone.creationTimeMillis()))); + System.out.printf("Name servers: %s%n", Joiner.on(", ").join(zone.nameServers())); } } else { System.out.println("Project contains no zones."); @@ -147,8 +151,9 @@ public void run(Dns dns, String... args) { System.out.printf("Name: %s%n", zone.name()); System.out.printf("ID: %s%n", zone.id()); System.out.printf("Description: %s%n", zone.description()); - System.out.printf("Created: %s%n", zone.creationTimeMillis()); - System.out.printf("Name servers: %s%n", Joiner.on(",").join(zone.nameServers())); + DateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); + System.out.printf("Created: %s%n", formatter.format(new Date(zone.creationTimeMillis()))); + System.out.printf("Name servers: %s%n", Joiner.on(", ").join(zone.nameServers())); } } @@ -175,7 +180,7 @@ public void run(Dns dns, String... args) { if (deleted) { System.out.printf("Zone %s was deleted.%n", zoneName); } else { - System.out.printf("Zone %s was NOT deleted. It probably does not exist.%n", zoneName); + System.out.printf("Zone %s was NOT deleted. It does not exist.%n", zoneName); } } @@ -195,27 +200,31 @@ private static class DeleteDnsRecordAction implements DnsAction { /** * Deletes a DNS record of type A from the given zone. The last parameter is ttl and it is not - * required. + * required. If ttl is not provided, a default value of 0 is used. The service requires a + * precise match (including ttl) for deleting a record. */ @Override public void run(Dns dns, String... args) { String zoneName = args[0]; String recordName = args[1]; String ip = args[2]; + int ttl = 0; + if (args.length > 3) { + ttl = Integer.valueOf(args[3]); + } DnsRecord record = DnsRecord.builder(recordName, DnsRecord.Type.A) .records(ImmutableList.of(ip)) + .ttl(ttl, TimeUnit.SECONDS) .build(); - if (args.length > 3) { - Integer ttl = Integer.valueOf(args[3]); - record = record.toBuilder().ttl(ttl, TimeUnit.SECONDS).build(); - } ChangeRequest changeRequest = ChangeRequest.builder() .delete(record) .build(); changeRequest = dns.applyChangeRequest(zoneName, changeRequest); System.out.printf("The request for deleting A record %s for zone %s was successfully " + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); + System.out.print("Waiting for deletion to happen..."); while (changeRequest.status().equals(ChangeRequest.Status.PENDING)) { + System.out.print("."); try { Thread.sleep(500); } catch (InterruptedException e) { @@ -223,7 +232,7 @@ record = record.toBuilder().ttl(ttl, TimeUnit.SECONDS).build(); } changeRequest = dns.getChangeRequest(zoneName, changeRequest.id()); } - System.out.printf("The deletion has been completed.%n"); + System.out.printf("%nThe deletion has been completed.%n"); } @Override @@ -234,11 +243,8 @@ public String params() { @Override public boolean check(String... args) { if (args.length == 4) { - try { - Integer.valueOf(args[3]); - } catch (Exception ex) { - throw new IllegalArgumentException(ex); - } + // to check that it can be parsed + Integer.valueOf(args[3]); return true; } else { return args.length == 3; @@ -249,27 +255,31 @@ public boolean check(String... args) { private static class AddDnsRecordAction implements DnsAction { /** - * Adds a DNS record of type A. The last parameter is ttl and is not required. + * Adds a DNS record of type A. The last parameter is ttl and is not required. If ttl is not + * provided, a default value of 0 will be used. */ @Override public void run(Dns dns, String... args) { String zoneName = args[0]; String recordName = args[1]; String ip = args[2]; + int ttl = 0; + if (args.length > 3) { + ttl = Integer.valueOf(args[3]); + } DnsRecord record = DnsRecord.builder(recordName, DnsRecord.Type.A) .records(ImmutableList.of(ip)) + .ttl(ttl, TimeUnit.SECONDS) .build(); - if (args.length > 3) { - Integer ttl = Integer.valueOf(args[3]); - record = record.toBuilder().ttl(ttl, TimeUnit.SECONDS).build(); - } ChangeRequest changeRequest = ChangeRequest.builder() .add(record) .build(); changeRequest = dns.applyChangeRequest(zoneName, changeRequest); System.out.printf("The request for adding A record %s for zone %s was successfully " + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); + System.out.print("Waiting for deletion to happen..."); while (changeRequest.status().equals(ChangeRequest.Status.PENDING)) { + System.out.print("."); try { Thread.sleep(500); } catch (InterruptedException e) { @@ -288,11 +298,8 @@ public String params() { @Override public boolean check(String... args) { if (args.length == 4) { - try { - Integer.valueOf(args[3]); - } catch (Exception ex) { - throw new IllegalArgumentException(ex); - } + // to check that it can be parsed + Integer.valueOf(args[3]); return true; } else { return args.length == 3; @@ -311,11 +318,10 @@ public void run(Dns dns, String... args) { Iterator iterator = dns.listDnsRecords(zoneName).iterateAll(); if (iterator.hasNext()) { System.out.printf("DNS records for zone %s:%n", zoneName); - System.out.printf("Record name\tTTL\tRecords%n"); while (iterator.hasNext()) { DnsRecord record = iterator.next(); - System.out.printf("%s\t%s\t%s%n", record.name(), record.ttl(), - Joiner.on(",").join(record.records())); + System.out.printf("%nRecord name: %s%nTTL: %s%nRecords: %s%n", record.name(), + record.ttl(), Joiner.on(", ").join(record.records())); } } else { System.out.printf("Zone %s has no DNS records.%n", zoneName); @@ -352,12 +358,14 @@ public void run(Dns dns, String... args) { } if (iterator.hasNext()) { System.out.printf("Change requests for zone %s:%n", zoneName); - System.out.printf("ID\tStatus\tTimestamp%n"); + DateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); while (iterator.hasNext()) { ChangeRequest change = iterator.next(); - System.out.printf("%s\t%s\t%s%n", change.id(), change.status(), change.startTimeMillis()); - System.out.printf("\tDeletions: %s%n", Joiner.on(",").join(change.deletions())); - System.out.printf("\tAdditions: %s%n", Joiner.on(",").join(change.additions())); + System.out.printf("%nID: %s%n", change.id()); + System.out.printf("Status: %s%n", change.status()); + System.out.printf("Started: %s%n", formatter.format(change.startTimeMillis())); + System.out.printf("Deletions: %s%n", Joiner.on(", ").join(change.deletions())); + System.out.printf("Additions: %s%n", Joiner.on(", ").join(change.additions())); } } else { System.out.printf("Zone %s has no change requests.%n", zoneName); @@ -371,9 +379,9 @@ public String params() { @Override public boolean check(String... args) { - System.err.println(Arrays.asList(args)); return args.length == 2 - || (args.length == 3 && ImmutableList.of("descending", "ascending").contains(args[2])); + || (args.length == 3 + && ImmutableList.of("descending", "ascending").contains(args[2].toLowerCase())); } } @@ -400,7 +408,7 @@ public void run(Dns dns, String... args) { @Override public boolean check(String... args) { - if (args.length == 0 || args.length == 1) { + if (args.length == 0) { return true; } if ("records".equals(args[1])) { @@ -423,15 +431,16 @@ private static class GetProjectAction implements DnsAction { @Override public void run(Dns dns, String... args) { ProjectInfo project = dns.getProject(); + ProjectInfo.Quota quota = project.quota(); System.out.printf("Project id: %s%nQuota:%n", dns.options().projectId()); - System.out.printf("\tZones: %d%n", project.quota().zones()); - System.out.printf("\tDNS records per zone: %d%n", project.quota().rrsetsPerZone()); + System.out.printf("\tZones: %d%n", quota.zones()); + System.out.printf("\tDNS records per zone: %d%n", quota.rrsetsPerZone()); System.out.printf("\tRecord sets per DNS record: %d%n", - project.quota().resourceRecordsPerRrset()); - System.out.printf("\tAdditions per change: %d%n", project.quota().rrsetAdditionsPerChange()); - System.out.printf("\tDeletions per change: %d%n", project.quota().rrsetDeletionsPerChange()); + quota.resourceRecordsPerRrset()); + System.out.printf("\tAdditions per change: %d%n", quota.rrsetAdditionsPerChange()); + System.out.printf("\tDeletions per change: %d%n", quota.rrsetDeletionsPerChange()); System.out.printf("\tTotal data size per change: %d%n", - project.quota().totalRrdataSizePerChange()); + quota.totalRrdataSizePerChange()); } @Override @@ -458,7 +467,7 @@ public boolean check(String... args) { private static void printUsage() { StringBuilder actionAndParams = new StringBuilder(); for (Map.Entry entry : ACTIONS.entrySet()) { - actionAndParams.append('\t').append(System.lineSeparator()).append(entry.getKey()); + actionAndParams.append(System.lineSeparator()).append('\t').append(entry.getKey()); String param = entry.getValue().params(); if (param != null && !param.isEmpty()) { actionAndParams.append(' ').append(param); @@ -474,25 +483,23 @@ public static void main(String... args) throws Exception { printUsage(); return; } - DnsOptions.Builder optionsBuilder = DnsOptions.builder(); + String projectId = null; DnsAction action; String actionName; if (args.length >= 2 && !ACTIONS.containsKey(args[0])) { actionName = args[1]; - optionsBuilder.projectId(args[0]); - action = ACTIONS.get(args[1]); + projectId = args[0]; args = Arrays.copyOfRange(args, 2, args.length); } else { actionName = args[0]; - action = ACTIONS.get(args[0]); args = Arrays.copyOfRange(args, 1, args.length); } + action = ACTIONS.get(actionName); if (action == null) { - System.out.println("Unrecognized action."); + System.out.printf("Unrecognized action %s.%n", actionName); printUsage(); return; } - Dns dns = optionsBuilder.build().service(); boolean valid = false; try { valid = action.check(args); @@ -507,6 +514,11 @@ public static void main(String... args) throws Exception { return; } if (valid) { + DnsOptions.Builder optionsBuilder = DnsOptions.builder(); + if(projectId != null) { + optionsBuilder.projectId(projectId); + } + Dns dns = optionsBuilder.build().service(); action.run(dns, args); } else { System.out.println("Invalid input for action '" + actionName + "'"); diff --git a/gcloud-java/pom.xml b/gcloud-java/pom.xml index b7dfd3f12e8f..03d2b6600ba3 100644 --- a/gcloud-java/pom.xml +++ b/gcloud-java/pom.xml @@ -30,17 +30,17 @@ ${project.groupId} - gcloud-java-resourcemanager + gcloud-java-dns ${project.version} ${project.groupId} - gcloud-java-storage + gcloud-java-resourcemanager ${project.version} ${project.groupId} - gcloud-java-dns + gcloud-java-storage ${project.version} From da877d86f55a46b93ee2cb5295e38707b65e93c2 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 10 Mar 2016 09:40:03 -0800 Subject: [PATCH 142/203] Added code snippets for DNS. Also extended example doc and added links. Refactored zone print. --- .../com/google/gcloud/dns/DnsOptions.java | 8 ++ gcloud-java-examples/README.md | 2 +- .../gcloud/examples/dns/DnsExample.java | 108 +++++++++--------- .../dns/snippets/CreateAndListDnsRecords.java | 73 ++++++++++++ .../dns/snippets/CreateAndListZones.java | 62 ++++++++++ .../examples/dns/snippets/DeleteZone.java | 88 ++++++++++++++ 6 files changed, 284 insertions(+), 57 deletions(-) create mode 100644 gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListDnsRecords.java create mode 100644 gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListZones.java create mode 100644 gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java index db922b42a3cb..541e7a6c6ea7 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsOptions.java @@ -96,6 +96,14 @@ public static Builder builder() { return new Builder(); } + /** + * Creates a default instance of {@code DnsOptions} with the project ID and credentials inferred + * from the environment. + */ + public static DnsOptions defaultInstance() { + return builder().build(); + } + @Override public boolean equals(Object obj) { return obj instanceof DnsOptions && baseEquals((DnsOptions) obj); diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md index 73d613c94e27..5e11fd2b0cb7 100644 --- a/gcloud-java-examples/README.md +++ b/gcloud-java-examples/README.md @@ -74,7 +74,7 @@ To run examples from your command line: * Here's an example run of `DnsExample`. Note that you have to enable the Google Cloud DNS API on the [Google Developers Console][developers-console] before running the following commands. - You will need to replace the domain name `elaborateexample.com` with your own domain name with verified ownership. + You will need to replace the domain name `elaborateexample.com` with your own domain name with [verified ownership] (https://www.google.com/webmasters/verification/home). Also, note that the example creates and deletes DNS records of type A only. Operations with other record types are not implemented in the example. ``` mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="create some-sample-zone elaborateexample.com. description" diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java index 2061f4931cab..1b6ba8f179da 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java @@ -38,8 +38,8 @@ /** * An example of using Google Cloud DNS. * - *

      This example creates, deletes, gets, and lists zones, and creates and deletes DNS records of - * type A. + *

      This example creates, deletes, gets, and lists zones. It also creates and deletes DNS records + * of type A, and lists DNS records. * *

      Steps needed for running the example: *

        @@ -57,14 +57,16 @@ * quota} *
      * - *

      The first parameter is an optional {@code project_id} (logged-in project will be used if not - * supplied). Second parameter is a DNS operation (list, delete, create,...). The remaining - * arguments are specific to the operation. See each action's run method for the specific - * interaction. + *

      The first parameter is an optional {@code project_id}. The project specified in the Google + * Cloud SDK configuration (see {@code gcloud config list}) will be used if the project ID is not + * supplied. The second parameter is a DNS operation (list, delete, create, ...). The remaining + * arguments are specific to the operation. See each action's {@code run} method for the specific + * arguments. */ public class DnsExample { private static final Map ACTIONS = new HashMap<>(); + private static final DateFormat FORMATTER = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); private interface DnsAction { void run(Dns dns, String... args); @@ -77,7 +79,7 @@ private interface DnsAction { private static class CreateZoneAction implements DnsAction { /** - * Creates a zone with the provided name, dns name and description (in this order). + * Creates a zone with the provided name, DNS name and description (in this order). */ @Override public void run(Dns dns, String... args) { @@ -111,14 +113,8 @@ public void run(Dns dns, String... args) { Iterator zoneIterator = dns.listZones().iterateAll(); if (zoneIterator.hasNext()) { System.out.println("The project contains the following zones:"); - DateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); while (zoneIterator.hasNext()) { - Zone zone = zoneIterator.next(); - System.out.printf("%nName: %s%n", zone.name()); - System.out.printf("ID: %s%n", zone.id()); - System.out.printf("Description: %s%n", zone.description()); - System.out.printf("Created: %s%n", formatter.format(new Date(zone.creationTimeMillis()))); - System.out.printf("Name servers: %s%n", Joiner.on(", ").join(zone.nameServers())); + printZone(zoneIterator.next()); } } else { System.out.println("Project contains no zones."); @@ -148,12 +144,7 @@ public void run(Dns dns, String... args) { if (zone == null) { System.out.printf("No zone with name '%s' exists.%n", zoneName); } else { - System.out.printf("Name: %s%n", zone.name()); - System.out.printf("ID: %s%n", zone.id()); - System.out.printf("Description: %s%n", zone.description()); - DateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); - System.out.printf("Created: %s%n", formatter.format(new Date(zone.creationTimeMillis()))); - System.out.printf("Name servers: %s%n", Joiner.on(", ").join(zone.nameServers())); + printZone(zone); } } @@ -210,7 +201,7 @@ public void run(Dns dns, String... args) { String ip = args[2]; int ttl = 0; if (args.length > 3) { - ttl = Integer.valueOf(args[3]); + ttl = Integer.parseInt(args[3]); } DnsRecord record = DnsRecord.builder(recordName, DnsRecord.Type.A) .records(ImmutableList.of(ip)) @@ -220,18 +211,10 @@ public void run(Dns dns, String... args) { .delete(record) .build(); changeRequest = dns.applyChangeRequest(zoneName, changeRequest); - System.out.printf("The request for deleting A record %s for zone %s was successfully " + - "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); + System.out.printf("The request for deleting A record %s for zone %s was successfully " + + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); System.out.print("Waiting for deletion to happen..."); - while (changeRequest.status().equals(ChangeRequest.Status.PENDING)) { - System.out.print("."); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - System.err.println("Thread was interrupted while waiting."); - } - changeRequest = dns.getChangeRequest(zoneName, changeRequest.id()); - } + waitForChangeToFinish(dns, zoneName, changeRequest); System.out.printf("%nThe deletion has been completed.%n"); } @@ -244,7 +227,7 @@ public String params() { public boolean check(String... args) { if (args.length == 4) { // to check that it can be parsed - Integer.valueOf(args[3]); + Integer.parseInt(args[3]); return true; } else { return args.length == 3; @@ -265,28 +248,18 @@ public void run(Dns dns, String... args) { String ip = args[2]; int ttl = 0; if (args.length > 3) { - ttl = Integer.valueOf(args[3]); + ttl = Integer.parseInt(args[3]); } DnsRecord record = DnsRecord.builder(recordName, DnsRecord.Type.A) .records(ImmutableList.of(ip)) .ttl(ttl, TimeUnit.SECONDS) .build(); - ChangeRequest changeRequest = ChangeRequest.builder() - .add(record) - .build(); + ChangeRequest changeRequest = ChangeRequest.builder().add(record).build(); changeRequest = dns.applyChangeRequest(zoneName, changeRequest); - System.out.printf("The request for adding A record %s for zone %s was successfully " + - "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); - System.out.print("Waiting for deletion to happen..."); - while (changeRequest.status().equals(ChangeRequest.Status.PENDING)) { - System.out.print("."); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - System.err.println("Thread was interrupted while waiting."); - } - changeRequest = dns.getChangeRequest(zoneName, changeRequest.id()); - } + System.out.printf("The request for adding A record %s for zone %s was successfully " + + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); + System.out.print("Waiting for addition to happen..."); + waitForChangeToFinish(dns, zoneName, changeRequest); System.out.printf("The addition has been completed.%n"); } @@ -299,7 +272,7 @@ public String params() { public boolean check(String... args) { if (args.length == 4) { // to check that it can be parsed - Integer.valueOf(args[3]); + Integer.parseInt(args[3]); return true; } else { return args.length == 3; @@ -342,8 +315,8 @@ public boolean check(String... args) { private static class ListChangesAction implements DnsAction { /** - * Lists all the changes for a given zone. Optionally, an order, "descending" or "ascending" can - * be specified using the last parameter. + * Lists all the changes for a given zone. Optionally, an order ("descending" or "ascending") + * can be specified using the last parameter. */ @Override public void run(Dns dns, String... args) { @@ -358,12 +331,11 @@ public void run(Dns dns, String... args) { } if (iterator.hasNext()) { System.out.printf("Change requests for zone %s:%n", zoneName); - DateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); while (iterator.hasNext()) { ChangeRequest change = iterator.next(); System.out.printf("%nID: %s%n", change.id()); System.out.printf("Status: %s%n", change.status()); - System.out.printf("Started: %s%n", formatter.format(change.startTimeMillis())); + System.out.printf("Started: %s%n", FORMATTER.format(change.startTimeMillis())); System.out.printf("Deletions: %s%n", Joiner.on(", ").join(change.deletions())); System.out.printf("Additions: %s%n", Joiner.on(", ").join(change.additions())); } @@ -408,7 +380,7 @@ public void run(Dns dns, String... args) { @Override public boolean check(String... args) { - if (args.length == 0) { + if (args.length == 0 || args.length == 1) { return true; } if ("records".equals(args[1])) { @@ -464,6 +436,29 @@ public boolean check(String... args) { ACTIONS.put("quota", new GetProjectAction()); } + private static void printZone(Zone zone) { + System.out.printf("%nName: %s%n", zone.name()); + System.out.printf("ID: %s%n", zone.id()); + System.out.printf("Description: %s%n", zone.description()); + System.out.printf("Created: %s%n", FORMATTER.format(new Date(zone.creationTimeMillis()))); + System.out.printf("Name servers: %s%n", Joiner.on(", ").join(zone.nameServers())); + } + + private static ChangeRequest waitForChangeToFinish(Dns dns, String zoneName, + ChangeRequest request) { + ChangeRequest current = request; + while (current.status().equals(ChangeRequest.Status.PENDING)) { + System.out.print("."); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + System.err.println("Thread was interrupted while waiting."); + } + current = dns.getChangeRequest(zoneName, current.id()); + } + return current; + } + private static void printUsage() { StringBuilder actionAndParams = new StringBuilder(); for (Map.Entry entry : ACTIONS.entrySet()) { @@ -510,12 +505,13 @@ public static void main(String... args) throws Exception { return; } catch (Exception ex) { System.out.println("Failed to parse request."); + System.out.println("Expected: " + action.params()); ex.printStackTrace(); return; } if (valid) { DnsOptions.Builder optionsBuilder = DnsOptions.builder(); - if(projectId != null) { + if (projectId != null) { optionsBuilder.projectId(projectId); } Dns dns = optionsBuilder.build().service(); diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListDnsRecords.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListDnsRecords.java new file mode 100644 index 000000000000..1e47a12fed02 --- /dev/null +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListDnsRecords.java @@ -0,0 +1,73 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file is referenced in README's and javadoc. Any change to this file should be reflected in + * the project's README's and package-info.java. + */ + +package com.google.gcloud.examples.dns.snippets; + +import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.Dns; +import com.google.gcloud.dns.DnsOptions; +import com.google.gcloud.dns.DnsRecord; +import com.google.gcloud.dns.Zone; + +import java.util.Iterator; +import java.util.concurrent.TimeUnit; + +/** + * A snippet for Google Cloud DNS showing how to create a DNS records. + */ +public class CreateAndListDnsRecords { + + public static void main(String... args) { + // Create a service object. + // The project ID and credentials will be inferred from the environment. + Dns dns = DnsOptions.defaultInstance().service(); + + // Change this to a zone name that exists within your project + String zoneName = "some-sample-zone"; + + // Get zone from the service + Zone zone = dns.getZone(zoneName); + + // Prepare a www.. type A record with ttl of 24 hours + String ip = "12.13.14.15"; + DnsRecord toCreate = DnsRecord.builder("www." + zone.dnsName(), DnsRecord.Type.A) + .ttl(24, TimeUnit.HOURS) + .addRecord(ip) + .build(); + + // Make a change + ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate); + + // Verify a www.. type A record does not exist yet. + // If it does exist, we will overwrite it with our prepared record. + Iterator recordIterator = zone.listDnsRecords().iterateAll(); + while (recordIterator.hasNext()) { + DnsRecord current = recordIterator.next(); + if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) { + changeBuilder.delete(current); + } + } + + // Build and apply the change request to our zone + zone.applyChangeRequest(changeBuilder.build()); + } +} diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListZones.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListZones.java new file mode 100644 index 000000000000..21fdba2b7449 --- /dev/null +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListZones.java @@ -0,0 +1,62 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file is referenced in README's and javadoc. Any change to this file should be reflected in + * the project's README's and package-info.java. + */ + +package com.google.gcloud.examples.dns.snippets; + +import com.google.gcloud.dns.Dns; +import com.google.gcloud.dns.DnsOptions; +import com.google.gcloud.dns.Zone; +import com.google.gcloud.dns.ZoneInfo; + +import java.util.Iterator; + +/** + * A snippet for Google Cloud DNS showing how to create a zone and list all zones in the project. + * You will need to change the {@code domainName} to a domain name, the ownership of which you + * should verify with Google. + */ +public class CreateAndListZones { + + public static void main(String... args) { + // Create a service object + // The project ID and credentials will be inferred from the environment. + Dns dns = DnsOptions.defaultInstance().service(); + + // Create a zone metadata object + String zoneName = "my_unique_zone"; // Change this zone name which is unique within your project + String domainName = "someexampledomain.com."; // Change this to a domain which you own + String description = "This is a gcloud-java-dns sample zone."; + ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description); + + // Create zone in Google Cloud DNS + Zone createdZone = dns.create(zoneInfo); + System.out.printf("Zone was created and assigned ID %s.%n", createdZone.id()); + + // Now list all the zones within this project + Iterator zoneIterator = dns.listZones().iterateAll(); + int counter = 1; + while (zoneIterator.hasNext()) { + System.out.printf("#%d.: %s%n%n", counter, zoneIterator.next().toString()); + counter++; + } + } +} diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java new file mode 100644 index 000000000000..667a0d89e6ab --- /dev/null +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java @@ -0,0 +1,88 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file is referenced in README's and javadoc. Any change to this file should be reflected in + * the project's README's and package-info.java. + */ + +package com.google.gcloud.examples.dns.snippets; + +import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.Dns; +import com.google.gcloud.dns.DnsOptions; +import com.google.gcloud.dns.DnsRecord; + +import java.util.Iterator; + +/** + * A snippet for Google Cloud DNS showing how to delete a zone. It also shows how to list and delete + * DNS records. + */ +public class DeleteZone { + + public static void main(String... args) { + // Create a service object. + // The project ID and credentials will be inferred from the environment. + Dns dns = DnsOptions.defaultInstance().service(); + + // Change this to a zone name that exists within your project and that you want to delete. + String zoneName = "some-sample-zone"; + + // Get iterator for the existing records which have to be deleted before deleting the zone + Iterator recordIterator = dns.listDnsRecords(zoneName).iterateAll(); + + // Make a change for deleting the records + ChangeRequest.Builder changeBuilder = ChangeRequest.builder(); + while (recordIterator.hasNext()) { + DnsRecord current = recordIterator.next(); + // SOA and NS records cannot be deleted + if (!DnsRecord.Type.SOA.equals(current.type()) && !DnsRecord.Type.NS.equals(current.type())) { + changeBuilder.delete(current); + } + } + + // Build and apply the change request to our zone if it contains records to delete + ChangeRequest changeRequest = changeBuilder.build(); + if (!changeRequest.deletions().isEmpty()) { + changeRequest = dns.applyChangeRequest(zoneName, changeRequest); + + // Wait for change to finish, but save data traffic by transferring only ID and status + Dns.ChangeRequestOption option = + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS); + while (ChangeRequest.Status.PENDING.equals(changeRequest.status())) { + System.out.println("Waiting for change to complete. Going to sleep for 500ms..."); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + System.err.println("The thread was interrupted while waiting for change request to be " + + "processed."); + } + // Update the change, but fetch only change ID and status + changeRequest = dns.getChangeRequest(zoneName, changeRequest.id(), option); + } + } + + // Delete the zone + boolean result = dns.delete(zoneName); + if (result) { + System.out.println("Zone was deleted."); + } else { + System.out.println("Zone was not deleted because it does not exist."); + } + } +} From baee7d70fd9aa93d6f95b9ce8850ada77e2ccc7f Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Mon, 14 Mar 2016 15:37:03 -0700 Subject: [PATCH 143/203] Added integration test for invalid change request. Also added checks for the exceptions being non-retryable. Closes #673. --- .../com/google/gcloud/dns/it/ITDnsTest.java | 92 ++++++++++++++++--- 1 file changed, 79 insertions(+), 13 deletions(-) diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java index 4ad17fa8b217..e1a7c218c1b4 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java @@ -48,8 +48,6 @@ public class ITDnsTest { - // todo(mderka) Implement test for creating invalid change when DnsException is finished. #673 - private static final String PREFIX = "gcldjvit-"; private static final Dns DNS = DnsOptions.builder().build().service(); private static final String ZONE_NAME1 = (PREFIX + UUID.randomUUID()).substring(0, 32); @@ -201,14 +199,14 @@ public void testCreateZoneWithErrors() { fail("Zone name is missing a period. The service returns an error."); } catch (DnsException ex) { // expected - // todo(mderka) test non-retryable when implemented within #593 + assertFalse(ex.retryable()); } try { DNS.create(ZONE_DNS_NO_PERIOD); fail("Zone name is missing a period. The service returns an error."); } catch (DnsException ex) { // expected - // todo(mderka) test non-retryable when implemented within #593 + assertFalse(ex.retryable()); } } finally { DNS.delete(ZONE_NAME_ERROR.name()); @@ -393,7 +391,7 @@ public void testListZones() { } catch (DnsException ex) { // expected assertEquals(400, ex.code()); - // todo(mderka) test not-retryable + assertFalse(ex.retryable()); } try { DNS.listZones(Dns.ZoneListOption.pageSize(-1)); @@ -401,7 +399,7 @@ public void testListZones() { } catch (DnsException ex) { // expected assertEquals(400, ex.code()); - // todo(mderka) test not-retryable + assertFalse(ex.retryable()); } // ok size zones = filter(DNS.listZones(Dns.ZoneListOption.pageSize(1000)).iterateAll()); @@ -413,7 +411,7 @@ public void testListZones() { } catch (DnsException ex) { // expected assertEquals(400, ex.code()); - // todo(mderka) test not-retryable + assertFalse(ex.retryable()); } // ok name zones = filter(DNS.listZones(Dns.ZoneListOption.dnsName(ZONE1.dnsName())).iterateAll()); @@ -586,6 +584,74 @@ public void testCreateChange() { } } + @Test + public void testInvalidChangeRequest() { + Zone zone = DNS.create(ZONE1); + DnsRecord validA = DnsRecord.builder("subdomain." + zone.dnsName(), DnsRecord.Type.A) + .records(ImmutableList.of("0.255.1.5")) + .build(); + try { + ChangeRequest validChange = ChangeRequest.builder().add(validA).build(); + zone.applyChangeRequest(validChange); + try { + zone.applyChangeRequest(validChange); + fail("Created a record which already exists."); + } catch (DnsException ex) { + // expected + assertFalse(ex.retryable()); + assertEquals(409, ex.code()); + } + // delete with field mismatch + DnsRecord mismatch = validA.toBuilder().ttl(20, TimeUnit.SECONDS).build(); + ChangeRequest deletion = ChangeRequest.builder().delete(mismatch).build(); + try { + zone.applyChangeRequest(deletion); + fail("Deleted a record without a complete match."); + } catch (DnsException ex) { + // expected + assertEquals(412, ex.code()); + assertFalse(ex.retryable()); + } + // delete and add SOA + Iterator recordIterator = zone.listDnsRecords().iterateAll(); + LinkedList deletions = new LinkedList<>(); + LinkedList additions = new LinkedList<>(); + while (recordIterator.hasNext()) { + DnsRecord record = recordIterator.next(); + if (record.type() == DnsRecord.Type.SOA) { + deletions.add(record); + // the subdomain is necessary to get 400 instead of 412 + DnsRecord copy = record.toBuilder().name("x." + record.name()).build(); + additions.add(copy); + break; + } + } + deletion = deletion.toBuilder().deletions(deletions).build(); + ChangeRequest addition = ChangeRequest.builder().additions(additions).build(); + try { + zone.applyChangeRequest(deletion); + fail("Deleted SOA."); + } catch (DnsException ex) { + // expected + assertFalse(ex.retryable()); + assertEquals(400, ex.code()); + } + try { + zone.applyChangeRequest(addition); + fail("Added second SOA."); + } catch (DnsException ex) { + // expected + assertFalse(ex.retryable()); + assertEquals(400, ex.code()); + } + } finally { + ChangeRequest deletion = ChangeRequest.builder().delete(validA).build(); + ChangeRequest request = zone.applyChangeRequest(deletion); + waitForChangeToComplete(zone.name(), request.id()); + zone.delete(); + } + } + @Test public void testListChanges() { try { @@ -596,7 +662,7 @@ public void testListChanges() { } catch (DnsException ex) { // expected assertEquals(404, ex.code()); - // todo(mderka) test retry functionality + assertFalse(ex.retryable()); } // zone exists but has no changes DNS.create(ZONE1); @@ -621,7 +687,7 @@ public void testListChanges() { } catch (DnsException ex) { // expected assertEquals(400, ex.code()); - // todo(mderka) test retry functionality + assertFalse(ex.retryable()); } try { DNS.listChangeRequests(ZONE1.name(), Dns.ChangeRequestListOption.pageSize(-1)); @@ -629,7 +695,7 @@ public void testListChanges() { } catch (DnsException ex) { // expected assertEquals(400, ex.code()); - // todo(mderka) test retry functionality + assertFalse(ex.retryable()); } // sorting order ImmutableList ascending = ImmutableList.copyOf(DNS.listChangeRequests( @@ -863,7 +929,7 @@ public void testListDnsRecords() { } catch (DnsException ex) { // expected assertEquals(400, ex.code()); - // todo(mderka) test retry functionality when available + assertFalse(ex.retryable()); } try { DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.pageSize(0)); @@ -871,7 +937,7 @@ public void testListDnsRecords() { } catch (DnsException ex) { // expected assertEquals(400, ex.code()); - // todo(mderka) test retry functionality when available + assertFalse(ex.retryable()); } try { DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.pageSize(-1)); @@ -879,7 +945,7 @@ public void testListDnsRecords() { } catch (DnsException ex) { // expected assertEquals(400, ex.code()); - // todo(mderka) test retry functionality when available + assertFalse(ex.retryable()); } waitForChangeToComplete(ZONE1.name(), change.id()); } finally { From c2c662843263d53d702f88eb045bffa380697293 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Tue, 1 Mar 2016 10:02:57 -0800 Subject: [PATCH 144/203] Add get, replace, and test for IAM --- .../main/java/com/google/gcloud/Identity.java | 24 +-- .../java/com/google/gcloud/IdentityTest.java | 14 +- .../google/gcloud/resourcemanager/Policy.java | 102 +++++++++--- .../gcloud/resourcemanager/Project.java | 18 +- .../resourcemanager/ResourceManager.java | 157 ++++++++++++++++-- .../resourcemanager/ResourceManagerImpl.java | 84 ++++++++-- .../spi/DefaultResourceManagerRpc.java | 58 ++++++- .../spi/ResourceManagerRpc.java | 24 +++ .../testing/LocalResourceManagerHelper.java | 131 +++++++++++++-- .../LocalResourceManagerHelperTest.java | 82 ++++++++- .../gcloud/resourcemanager/PolicyTest.java | 30 +++- .../gcloud/resourcemanager/ProjectTest.java | 26 ++- .../ResourceManagerImplTest.java | 64 +++++++ .../resourcemanager/SerializationTest.java | 2 +- 14 files changed, 718 insertions(+), 98 deletions(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java b/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java index d1644198f759..687a76ffc42c 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/Identity.java @@ -44,7 +44,7 @@ public final class Identity implements Serializable { private static final long serialVersionUID = -8181841964597657446L; private final Type type; - private final String id; + private final String value; /** * The types of IAM identities. @@ -82,9 +82,9 @@ public enum Type { DOMAIN } - private Identity(Type type, String id) { + private Identity(Type type, String value) { this.type = type; - this.id = id; + this.value = value; } public Type type() { @@ -92,7 +92,7 @@ public Type type() { } /** - * Returns the string identifier for this identity. The id corresponds to: + * Returns the string identifier for this identity. The value corresponds to: *

        *
      • email address (for identities of type {@code USER}, {@code SERVICE_ACCOUNT}, and * {@code GROUP}) @@ -101,8 +101,8 @@ public Type type() { * {@code ALL_AUTHENTICATED_USERS}) *
      */ - public String id() { - return id; + public String value() { + return value; } /** @@ -163,7 +163,7 @@ public static Identity domain(String domain) { @Override public int hashCode() { - return Objects.hash(id, type); + return Objects.hash(value, type); } @Override @@ -172,7 +172,7 @@ public boolean equals(Object obj) { return false; } Identity other = (Identity) obj; - return Objects.equals(id, other.id()) && Objects.equals(type, other.type()); + return Objects.equals(value, other.value()) && Objects.equals(type, other.type()); } /** @@ -186,13 +186,13 @@ public String strValue() { case ALL_AUTHENTICATED_USERS: return "allAuthenticatedUsers"; case USER: - return "user:" + id; + return "user:" + value; case SERVICE_ACCOUNT: - return "serviceAccount:" + id; + return "serviceAccount:" + value; case GROUP: - return "group:" + id; + return "group:" + value; case DOMAIN: - return "domain:" + id; + return "domain:" + value; default: throw new IllegalStateException("Unexpected identity type: " + type); } diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java index 828f1c839431..a42bc9db7abd 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/IdentityTest.java @@ -34,19 +34,19 @@ public class IdentityTest { @Test public void testAllUsers() { assertEquals(Identity.Type.ALL_USERS, ALL_USERS.type()); - assertNull(ALL_USERS.id()); + assertNull(ALL_USERS.value()); } @Test public void testAllAuthenticatedUsers() { assertEquals(Identity.Type.ALL_AUTHENTICATED_USERS, ALL_AUTH_USERS.type()); - assertNull(ALL_AUTH_USERS.id()); + assertNull(ALL_AUTH_USERS.value()); } @Test public void testUser() { assertEquals(Identity.Type.USER, USER.type()); - assertEquals("abc@gmail.com", USER.id()); + assertEquals("abc@gmail.com", USER.value()); } @Test(expected = NullPointerException.class) @@ -57,7 +57,7 @@ public void testUserNullEmail() { @Test public void testServiceAccount() { assertEquals(Identity.Type.SERVICE_ACCOUNT, SERVICE_ACCOUNT.type()); - assertEquals("service-account@gmail.com", SERVICE_ACCOUNT.id()); + assertEquals("service-account@gmail.com", SERVICE_ACCOUNT.value()); } @Test(expected = NullPointerException.class) @@ -68,7 +68,7 @@ public void testServiceAccountNullEmail() { @Test public void testGroup() { assertEquals(Identity.Type.GROUP, GROUP.type()); - assertEquals("group@gmail.com", GROUP.id()); + assertEquals("group@gmail.com", GROUP.value()); } @Test(expected = NullPointerException.class) @@ -79,7 +79,7 @@ public void testGroupNullEmail() { @Test public void testDomain() { assertEquals(Identity.Type.DOMAIN, DOMAIN.type()); - assertEquals("google.com", DOMAIN.id()); + assertEquals("google.com", DOMAIN.value()); } @Test(expected = NullPointerException.class) @@ -100,6 +100,6 @@ public void testIdentityToAndFromPb() { private void compareIdentities(Identity expected, Identity actual) { assertEquals(expected, actual); assertEquals(expected.type(), actual.type()); - assertEquals(expected.id(), actual.id()); + assertEquals(expected.value(), actual.value()); } } diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java index 0d7118dcbbd7..46330e19fa59 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java @@ -17,18 +17,19 @@ package com.google.gcloud.resourcemanager; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.CaseFormat; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.gcloud.IamPolicy; import com.google.gcloud.Identity; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; /** @@ -48,40 +49,101 @@ public class Policy extends IamPolicy { /** * Represents legacy roles in an IAM Policy. */ - public enum Role { + public static class Role implements Serializable { /** - * Permissions for read-only actions that preserve state. + * The recognized roles in a Project's IAM policy. */ - VIEWER("roles/viewer"), + public enum Type { + + /** + * Permissions for read-only actions that preserve state. + */ + VIEWER, + + /** + * All viewer permissions and permissions for actions that modify state. + */ + EDITOR, + + /** + * All editor permissions and permissions for the following actions: + *
        + *
      • Manage access control for a resource. + *
      • Set up billing (for a project). + *
      + */ + OWNER + } + + private static final long serialVersionUID = 2421978909244287488L; + + private final String value; + private final Type type; + + private Role(String value, Type type) { + this.value = value; + this.type = type; + } + + String value() { + return value; + } /** - * All viewer permissions and permissions for actions that modify state. + * Returns the type of role (editor, owner, or viewer). Returns {@code null} if the role type + * is unrecognized. */ - EDITOR("roles/editor"), + public Type type() { + return type; + } /** - * All editor permissions and permissions for the following actions: - *
        - *
      • Manage access control for a resource. - *
      • Set up billing (for a project). - *
      + * Returns a {@code Role} of type {@link Type#VIEWER VIEWER}. */ - OWNER("roles/owner"); + public static Role viewer() { + return new Role("roles/viewer", Type.VIEWER); + } - private String strValue; + /** + * Returns a {@code Role} of type {@link Type#EDITOR EDITOR}. + */ + public static Role editor() { + return new Role("roles/editor", Type.EDITOR); + } - private Role(String strValue) { - this.strValue = strValue; + /** + * Returns a {@code Role} of type {@link Type#OWNER OWNER}. + */ + public static Role owner() { + return new Role("roles/owner", Type.OWNER); } - String strValue() { - return strValue; + static Role rawRole(String roleStr) { + return new Role(roleStr, null); } static Role fromStr(String roleStr) { - return Role.valueOf(CaseFormat.LOWER_CAMEL.to( - CaseFormat.UPPER_UNDERSCORE, roleStr.substring("roles/".length()))); + try { + Type type = Type.valueOf(roleStr.split("/")[1].toUpperCase()); + return new Role(roleStr, type); + } catch (Exception ex) { + return new Role(roleStr, null); + } + } + + @Override + public final int hashCode() { + return Objects.hash(value, type); + } + + @Override + public final boolean equals(Object obj) { + if (!(obj instanceof Role)) { + return false; + } + Role other = (Role) obj; + return Objects.equals(value, other.value()) && Objects.equals(type, other.type()); } } @@ -124,7 +186,7 @@ com.google.api.services.cloudresourcemanager.model.Policy toPb() { for (Map.Entry> binding : bindings().entrySet()) { com.google.api.services.cloudresourcemanager.model.Binding bindingPb = new com.google.api.services.cloudresourcemanager.model.Binding(); - bindingPb.setRole(binding.getKey().strValue()); + bindingPb.setRole(binding.getKey().value()); bindingPb.setMembers( Lists.transform( new ArrayList<>(binding.getValue()), diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java index 4d12a31274c0..46b142c5aa53 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java @@ -157,10 +157,10 @@ public Project reload() { * completes, the project is not retrievable by the {@link ResourceManager#get} and * {@link ResourceManager#list} methods. The caller must have modify permissions for this project. * - * @see Cloud - * Resource Manager delete * @throws ResourceManagerException upon failure + * @see Cloud + * Resource Manager delete */ public void delete() { resourceManager.delete(projectId()); @@ -174,10 +174,10 @@ public void delete() { * state of {@link ProjectInfo.State#DELETE_IN_PROGRESS}, the project cannot be restored. The * caller must have modify permissions for this project. * - * @see Cloud - * Resource Manager undelete * @throws ResourceManagerException upon failure (including when the project can't be restored) + * @see Cloud + * Resource Manager undelete */ public void undelete() { resourceManager.undelete(projectId()); @@ -188,11 +188,11 @@ public void undelete() { * *

      The caller must have modify permissions for this project. * - * @see Cloud - * Resource Manager update * @return the Project representing the new project metadata * @throws ResourceManagerException upon failure + * @see Cloud + * Resource Manager update */ public Project replace() { return resourceManager.replace(this); diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java index a463937f875c..f14d47f2a676 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java @@ -18,10 +18,12 @@ import com.google.common.base.Joiner; import com.google.common.collect.Sets; +import com.google.gcloud.IamPolicy; import com.google.gcloud.Page; import com.google.gcloud.Service; import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; +import java.util.List; import java.util.Set; /** @@ -167,6 +169,38 @@ public static ProjectListOption fields(ProjectField... fields) { } } + /** + * The permissions associated with a Google Cloud project. These values can be used when calling + * {@link #testPermissions}. + * + * @see + * Project-level roles + */ + enum Permission { + DELETE("delete"), + GET("get"), + GET_POLICY("getIamPolicy"), + REPLACE("update"), + REPLACE_POLICY("setIamPolicy"), + UNDELETE("undelete"); + + private static final String PREFIX = "resourcemanager.projects."; + + private final String value; + + Permission(String suffix) { + this.value = PREFIX + suffix; + } + + /** + * Returns the string representation of the permission. + */ + public String value() { + return value; + } + } + /** * Creates a new project. * @@ -174,13 +208,13 @@ public static ProjectListOption fields(ProjectField... fields) { * grant permission to others to read or update the project. Several APIs are activated * automatically for the project, including Google Cloud Storage. * - * @see Cloud - * Resource Manager create * @return Project object representing the new project's metadata. The returned object will * include the following read-only fields supplied by the server: project number, lifecycle * state, and creation time. * @throws ResourceManagerException upon failure + * @see Cloud + * Resource Manager create */ Project create(ProjectInfo project); @@ -201,10 +235,10 @@ public static ProjectListOption fields(ProjectField... fields) { * completes, the project is not retrievable by the {@link ResourceManager#get} and * {@link ResourceManager#list} methods. The caller must have modify permissions for this project. * - * @see Cloud - * Resource Manager delete * @throws ResourceManagerException upon failure + * @see Cloud + * Resource Manager delete */ void delete(String projectId); @@ -214,10 +248,9 @@ public static ProjectListOption fields(ProjectField... fields) { *

      Returns {@code null} if the project is not found or if the user doesn't have read * permissions for the project. * - * @see Cloud - * Resource Manager get * @throws ResourceManagerException upon failure + * @see + * Cloud Resource Manager get */ Project get(String projectId, ProjectGetOption... options); @@ -228,11 +261,11 @@ public static ProjectListOption fields(ProjectField... fields) { * at the end of the list. Use {@link ProjectListOption} to filter this list, set page size, and * set page tokens. * - * @see Cloud - * Resource Manager list * @return {@code Page}, a page of projects * @throws ResourceManagerException upon failure + * @see Cloud + * Resource Manager list */ Page list(ProjectListOption... options); @@ -241,11 +274,11 @@ public static ProjectListOption fields(ProjectField... fields) { * *

      The caller must have modify permissions for this project. * - * @see Cloud - * Resource Manager update * @return the Project representing the new project metadata * @throws ResourceManagerException upon failure + * @see Cloud + * Resource Manager update */ Project replace(ProjectInfo newProject); @@ -257,10 +290,98 @@ public static ProjectListOption fields(ProjectField... fields) { * state of {@link ProjectInfo.State#DELETE_IN_PROGRESS}, the project cannot be restored. The * caller must have modify permissions for this project. * - * @see Cloud - * Resource Manager undelete * @throws ResourceManagerException upon failure + * @see Cloud + * Resource Manager undelete */ void undelete(String projectId); + + /** + * Returns the IAM access control policy for the specified project. Returns {@code null} if the + * resource does not exist or if you do not have adequate permission to view the project or get + * the policy. + * + * @throws ResourceManagerException upon failure + * @see + * Resource Manager getIamPolicy + */ + Policy getPolicy(String projectId); + + /** + * Sets the IAM access control policy for the specified project. Replaces any existing policy. The + * following constraints apply: + *

        + *
      • Projects currently support only user:{emailid} and serviceAccount:{emailid} + * members in a binding of a policy. + *
      • To be added as an owner, a user must be invited via Cloud Platform console and must accept + * the invitation. + *
      • Members cannot be added to more than one role in the same policy. + *
      • There must be at least one owner who has accepted the Terms of Service (ToS) agreement in + * the policy. An attempt to set a policy that removes the last ToS-accepted owner from the + * policy will fail. + *
      • Calling this method requires enabling the App Engine Admin API. + *
      + * Note: Removing service accounts from policies or changing their roles can render services + * completely inoperable. It is important to understand how the service account is being used + * before removing or updating its roles. + * + *

      It is recommended that you use the read-modify-write pattern. This pattern entails reading + * the project's current policy, updating it locally, and then sending the modified policy for + * writing. Cloud IAM solves the problem of conflicting processes simultaneously attempting to + * modify a policy by using the {@link IamPolicy#etag etag} property. This property is used to + * verify whether the policy has changed since the last request. When you make a request to Cloud + * IAM with an etag value, Cloud IAM compares the etag value in the request with the existing etag + * value associated with the policy. It writes the policy only if the etag values match. If the + * etags don't match, a {@code ResourceManagerException} is thrown, denoting that the server + * aborted update. If an etag is not provided, the policy is overwritten blindly. + * + *

      An example of using the read-write-modify pattern is as follows: + *

       {@code
      +   * Policy currentPolicy = resourceManager.getPolicy("my-project-id");
      +   * Policy modifiedPolicy =
      +   *     current.toBuilder().removeIdentity(Role.VIEWER, Identity.user("user@gmail.com"));
      +   * Policy newPolicy = resourceManager.replacePolicy("my-project-id", modified);
      +   * }
      +   * 
      + * + * @throws ResourceManagerException upon failure + * @see + * Resource Manager setIamPolicy + */ + Policy replacePolicy(String projectId, Policy newPolicy); + + /** + * Returns the permissions that a caller has on the specified project. You typically don't call + * this method if you're using Google Cloud Platform directly to manage permissions. This method + * is intended for integration with your proprietary software, such as a customized graphical user + * interface. For example, the Cloud Platform Console tests IAM permissions internally to + * determine which UI should be available to the logged-in user. + * + * @return A list of booleans representing whether the caller has the permissions specified (in + * the order of the given permissions) + * @throws ResourceManagerException upon failure + * @see + * Resource Manager testIamPermissions + */ + List testPermissions(String projectId, List permissions); + + /** + * Returns the permissions that a caller has on the specified project. You typically don't call + * this method if you're using Google Cloud Platform directly to manage permissions. This method + * is intended for integration with your proprietary software, such as a customized graphical user + * interface. For example, the Cloud Platform Console tests IAM permissions internally to + * determine which UI should be available to the logged-in user. + * + * @return A list of booleans representing whether the caller has the permissions specified (in + * the order of the given permissions) + * @throws ResourceManagerException upon failure + * @see + * Resource Manager testIamPermissions + */ + List testPermissions(String projectId, Permission first, Permission... others); } diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java index fb699dcb06f0..d9911b911f0b 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gcloud.BaseService; import com.google.gcloud.Page; @@ -32,6 +33,7 @@ import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Tuple; +import java.util.List; import java.util.Map; import java.util.concurrent.Callable; @@ -55,8 +57,8 @@ public com.google.api.services.cloudresourcemanager.model.Project call() { return resourceManagerRpc.create(project.toPb()); } }, options().retryParams(), EXCEPTION_HANDLER)); - } catch (RetryHelperException e) { - throw ResourceManagerException.translateAndThrow(e); + } catch (RetryHelperException ex) { + throw ResourceManagerException.translateAndThrow(ex); } } @@ -70,8 +72,8 @@ public Void call() { return null; } }, options().retryParams(), EXCEPTION_HANDLER); - } catch (RetryHelperException e) { - throw ResourceManagerException.translateAndThrow(e); + } catch (RetryHelperException ex) { + throw ResourceManagerException.translateAndThrow(ex); } } @@ -87,8 +89,8 @@ public com.google.api.services.cloudresourcemanager.model.Project call() { } }, options().retryParams(), EXCEPTION_HANDLER); return answer == null ? null : Project.fromPb(this, answer); - } catch (RetryHelperException e) { - throw ResourceManagerException.translateAndThrow(e); + } catch (RetryHelperException ex) { + throw ResourceManagerException.translateAndThrow(ex); } } @@ -146,8 +148,8 @@ public Project apply( }); return new PageImpl<>( new ProjectPageFetcher(serviceOptions, cursor, optionsMap), cursor, projects); - } catch (RetryHelperException e) { - throw ResourceManagerException.translateAndThrow(e); + } catch (RetryHelperException ex) { + throw ResourceManagerException.translateAndThrow(ex); } } @@ -161,8 +163,8 @@ public com.google.api.services.cloudresourcemanager.model.Project call() { return resourceManagerRpc.replace(newProject.toPb()); } }, options().retryParams(), EXCEPTION_HANDLER)); - } catch (RetryHelperException e) { - throw ResourceManagerException.translateAndThrow(e); + } catch (RetryHelperException ex) { + throw ResourceManagerException.translateAndThrow(ex); } } @@ -176,11 +178,69 @@ public Void call() { return null; } }, options().retryParams(), EXCEPTION_HANDLER); - } catch (RetryHelperException e) { - throw ResourceManagerException.translateAndThrow(e); + } catch (RetryHelperException ex) { + throw ResourceManagerException.translateAndThrow(ex); } } + @Override + public Policy getPolicy(final String projectId) { + try { + com.google.api.services.cloudresourcemanager.model.Policy answer = + runWithRetries( + new Callable() { + @Override + public com.google.api.services.cloudresourcemanager.model.Policy call() { + return resourceManagerRpc.getPolicy(projectId); + } + }, options().retryParams(), EXCEPTION_HANDLER); + return answer == null ? null : Policy.fromPb(answer); + } catch (RetryHelperException ex) { + throw ResourceManagerException.translateAndThrow(ex); + } + } + + @Override + public Policy replacePolicy(final String projectId, final Policy newPolicy) { + try { + return Policy.fromPb(runWithRetries( + new Callable() { + @Override + public com.google.api.services.cloudresourcemanager.model.Policy call() { + return resourceManagerRpc.replacePolicy(projectId, newPolicy.toPb()); + } + }, options().retryParams(), EXCEPTION_HANDLER)); + } catch (RetryHelperException ex) { + throw ResourceManagerException.translateAndThrow(ex); + } + } + + @Override + public List testPermissions(final String projectId, final List permissions) { + try { + return runWithRetries( + new Callable>() { + @Override + public List call() { + return resourceManagerRpc.testPermissions(projectId, + Lists.transform(permissions, new Function() { + @Override + public String apply(Permission permission) { + return permission.value(); + } + })); + } + }, options().retryParams(), EXCEPTION_HANDLER); + } catch (RetryHelperException ex) { + throw ResourceManagerException.translateAndThrow(ex); + } + } + + @Override + public List testPermissions(String projectId, Permission first, Permission... others) { + return testPermissions(projectId, Lists.asList(first, others)); + } + private Map optionMap(Option... options) { Map temp = Maps.newEnumMap(ResourceManagerRpc.Option.class); for (Option option : options) { diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java index 2ef0d8c65ff2..9f92ff545874 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/DefaultResourceManagerRpc.java @@ -1,5 +1,6 @@ package com.google.gcloud.resourcemanager.spi; +import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Option.FIELDS; import static com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Option.FILTER; import static com.google.gcloud.resourcemanager.spi.ResourceManagerRpc.Option.PAGE_SIZE; @@ -11,13 +12,22 @@ import com.google.api.client.http.HttpTransport; import com.google.api.client.json.jackson.JacksonFactory; import com.google.api.services.cloudresourcemanager.Cloudresourcemanager; +import com.google.api.services.cloudresourcemanager.model.GetIamPolicyRequest; import com.google.api.services.cloudresourcemanager.model.ListProjectsResponse; +import com.google.api.services.cloudresourcemanager.model.Policy; import com.google.api.services.cloudresourcemanager.model.Project; +import com.google.api.services.cloudresourcemanager.model.SetIamPolicyRequest; +import com.google.api.services.cloudresourcemanager.model.TestIamPermissionsRequest; +import com.google.api.services.cloudresourcemanager.model.TestIamPermissionsResponse; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import com.google.gcloud.resourcemanager.ResourceManagerException; import com.google.gcloud.resourcemanager.ResourceManagerOptions; import java.io.IOException; +import java.util.List; import java.util.Map; +import java.util.Set; public class DefaultResourceManagerRpc implements ResourceManagerRpc { @@ -107,5 +117,51 @@ public Project replace(Project project) { throw translate(ex); } } -} + @Override + public Policy getPolicy(String projectId) throws ResourceManagerException { + try { + return resourceManager.projects() + .getIamPolicy(projectId, new GetIamPolicyRequest()) + .execute(); + } catch (IOException ex) { + ResourceManagerException translated = translate(ex); + if (translated.code() == HTTP_FORBIDDEN) { + // Service returns permission denied if policy doesn't exist. + return null; + } else { + throw translated; + } + } + } + + @Override + public Policy replacePolicy(String projectId, Policy newPolicy) throws ResourceManagerException { + try { + return resourceManager.projects() + .setIamPolicy(projectId, new SetIamPolicyRequest().setPolicy(newPolicy)).execute(); + } catch (IOException ex) { + throw translate(ex); + } + } + + @Override + public List testPermissions(String projectId, List permissions) + throws ResourceManagerException { + try { + TestIamPermissionsResponse response = resourceManager.projects() + .testIamPermissions( + projectId, new TestIamPermissionsRequest().setPermissions(permissions)) + .execute(); + Set permissionsOwned = + ImmutableSet.copyOf(firstNonNull(response.getPermissions(), ImmutableList.of())); + ImmutableList.Builder answer = ImmutableList.builder(); + for (String p : permissions) { + answer.add(permissionsOwned.contains(p)); + } + return answer.build(); + } catch (IOException ex) { + throw translate(ex); + } + } +} diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/ResourceManagerRpc.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/ResourceManagerRpc.java index 54531edd5ed5..d6ec068a92a3 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/ResourceManagerRpc.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/spi/ResourceManagerRpc.java @@ -16,9 +16,11 @@ package com.google.gcloud.resourcemanager.spi; +import com.google.api.services.cloudresourcemanager.model.Policy; import com.google.api.services.cloudresourcemanager.model.Project; import com.google.gcloud.resourcemanager.ResourceManagerException; +import java.util.List; import java.util.Map; public interface ResourceManagerRpc { @@ -121,5 +123,27 @@ public Y y() { */ Project replace(Project project); + /** + * Returns the IAM policy associated with a project. + * + * @throws ResourceManagerException upon failure + */ + Policy getPolicy(String projectId); + + /** + * Replaces the IAM policy associated with the given project. + * + * @throws ResourceManagerException upon failure + */ + Policy replacePolicy(String projectId, Policy newPolicy); + + /** + * Tests whether the caller has the given permissions. Returns a list of booleans corresponding to + * whether or not the user has the permission in the same position of input list. + * + * @throws ResourceManagerException upon failure + */ + List testPermissions(String projectId, List permissions); + // TODO(ajaykannan): implement "Organization" functionality when available (issue #319) } diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java index cda2dd1e00ea..8ddca18b6261 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -5,7 +5,12 @@ import static java.net.HttpURLConnection.HTTP_OK; import com.google.api.client.json.JsonFactory; +import com.google.api.services.cloudresourcemanager.model.Binding; +import com.google.api.services.cloudresourcemanager.model.Policy; import com.google.api.services.cloudresourcemanager.model.Project; +import com.google.api.services.cloudresourcemanager.model.SetIamPolicyRequest; +import com.google.api.services.cloudresourcemanager.model.TestIamPermissionsRequest; +import com.google.api.services.cloudresourcemanager.model.TestIamPermissionsResponse; import com.google.common.base.Joiner; import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; @@ -13,6 +18,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.io.ByteStreams; import com.google.gcloud.AuthCredentials; +import com.google.gcloud.resourcemanager.ResourceManager.Permission; import com.google.gcloud.resourcemanager.ResourceManagerOptions; import com.sun.net.httpserver.Headers; @@ -30,11 +36,14 @@ import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; +import java.util.UUID; import java.util.concurrent.ConcurrentSkipListMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -46,7 +55,25 @@ * Utility to create a local Resource Manager mock for testing. * *

      The mock runs in a separate thread, listening for HTTP requests on the local machine at an - * ephemeral port. + * ephemeral port. While this mock attempts to simulate the Cloud Resource Manager, there are some + * divergences in behavior. The following is a non-exhaustive list of some of those behavioral + * differences: + * + *

        + *
      • This mock assumes you have adequate permissions for any action. Related to this, + * testIamPermissions always indicates that the caller has all permissions listed in the + * request. + *
      • IAM policies are set to an empty policy with version 0 (only legacy roles supported) upon + * project creation. The actual service will not have an empty list of bindings and may also + * set your version to 1. + *
      • There is no input validation for the policy provided when replacing a policy. + *
      • In this mock, projects never move from the DELETE_REQUESTED lifecycle state to + * DELETE_IN_PROGRESS without an explicit call to the utility method + * {@link #changeLifecycleState}. Similarly, a project is never completely removed without an + * explicit call to the utility method {@link #removeProject}. + *
      • The messages in the error responses given by this mock do not necessarily match the messages + * given by the actual service. + *
      */ @SuppressWarnings("restriction") public class LocalResourceManagerHelper { @@ -62,8 +89,12 @@ public class LocalResourceManagerHelper { private static final Pattern LIST_FIELDS_PATTERN = Pattern.compile("(.*?)projects\\((.*?)\\)(.*?)"); private static final String[] NO_FIELDS = {}; + private static final Set PERMISSIONS = new HashSet<>(); static { + for (Permission permission : Permission.values()) { + PERMISSIONS.add(permission.value()); + } try { BASE_CONTEXT = new URI(CONTEXT); } catch (URISyntaxException e) { @@ -78,6 +109,7 @@ public class LocalResourceManagerHelper { private final HttpServer server; private final ConcurrentSkipListMap projects = new ConcurrentSkipListMap<>(); + private final Map policies = new HashMap<>(); private final int port; private static class Response { @@ -99,6 +131,7 @@ String body() { } private enum Error { + ABORTED(409, "global", "aborted", "ABORTED"), ALREADY_EXISTS(409, "global", "alreadyExists", "ALREADY_EXISTS"), PERMISSION_DENIED(403, "global", "forbidden", "PERMISSION_DENIED"), FAILED_PRECONDITION(400, "global", "failedPrecondition", "FAILED_PRECONDITION"), @@ -150,13 +183,7 @@ public void handle(HttpExchange exchange) { try { switch (requestMethod) { case "POST": - if (path.endsWith(":undelete")) { - response = undelete(projectIdFromUri(path)); - } else { - String requestBody = - decodeContent(exchange.getRequestHeaders(), exchange.getRequestBody()); - response = create(jsonFactory.fromString(requestBody, Project.class)); - } + response = handlePost(exchange, path); break; case "DELETE": response = delete(projectIdFromUri(path)); @@ -187,6 +214,30 @@ public void handle(HttpExchange exchange) { } } + private Response handlePost(HttpExchange exchange, String path) throws IOException { + String requestBody = decodeContent(exchange.getRequestHeaders(), exchange.getRequestBody()); + if (!path.contains(":")) { + return create(jsonFactory.fromString(requestBody, Project.class)); + } else { + switch (path.split(":", 2)[1]) { + case "undelete": + return undelete(projectIdFromUri(path)); + case "getIamPolicy": + return getPolicy(projectIdFromUri(path)); + case "setIamPolicy": + return replacePolicy(projectIdFromUri(path), + jsonFactory.fromString(requestBody, SetIamPolicyRequest.class).getPolicy()); + case "testIamPermissions": + return testPermissions(projectIdFromUri(path), + jsonFactory.fromString(requestBody, TestIamPermissionsRequest.class) + .getPermissions()); + default: + return Error.BAD_REQUEST.response( + "The server could not understand the following request URI: POST " + path); + } + } + } + private static void writeResponse(HttpExchange exchange, Response response) { exchange.getResponseHeaders().set("Content-type", "application/json; charset=UTF-8"); OutputStream outputStream = exchange.getResponseBody(); @@ -259,7 +310,7 @@ private static Map parseListOptions(String query) throws IOExcep options.put("pageToken", argEntry[1]); break; case "pageSize": - int pageSize = Integer.valueOf(argEntry[1]); + int pageSize = Integer.parseInt(argEntry[1]); if (pageSize < 1) { throw new IOException("Page size must be greater than 0."); } @@ -317,7 +368,7 @@ private static boolean isValidIdOrLabel(String value, int minLength, int maxLeng return value.length() >= minLength && value.length() <= maxLength; } - Response create(Project project) { + synchronized Response create(Project project) { String customErrorMessage = checkForProjectErrors(project); if (customErrorMessage != null) { return Error.INVALID_ARGUMENT.response(customErrorMessage); @@ -329,6 +380,11 @@ Response create(Project project) { return Error.ALREADY_EXISTS.response( "A project with the same project ID (" + project.getProjectId() + ") already exists."); } + Policy emptyPolicy = new Policy() + .setBindings(Collections.emptyList()) + .setEtag(UUID.randomUUID().toString()) + .setVersion(0); + policies.put(project.getProjectId(), emptyPolicy); try { String createdProjectStr = jsonFactory.toString(project); return new Response(HTTP_OK, createdProjectStr); @@ -540,6 +596,58 @@ synchronized Response undelete(String projectId) { return response; } + synchronized Response getPolicy(String projectId) { + Policy policy = policies.get(projectId); + if (policy == null) { + return Error.PERMISSION_DENIED.response("Project " + projectId + " not found."); + } + try { + return new Response(HTTP_OK, jsonFactory.toString(policy)); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response( + "Error when serializing the IAM policy for " + projectId); + } + } + + synchronized Response replacePolicy(String projectId, Policy policy) { + Policy originalPolicy = policies.get(projectId); + if (originalPolicy == null) { + return Error.PERMISSION_DENIED.response("Error when replacing the policy for " + projectId + + " because the project was not found."); + } + String etag = policy.getEtag(); + if (etag != null && !originalPolicy.getEtag().equals(etag)) { + return Error.ABORTED.response("Policy etag mismatch when replacing the policy for project " + + projectId + ", please retry the read."); + } + policy.setEtag(UUID.randomUUID().toString()); + policy.setVersion(originalPolicy.getVersion()); + policies.put(projectId, policy); + try { + return new Response(HTTP_OK, jsonFactory.toString(policy)); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response( + "Error when serializing the policy for project " + projectId); + } + } + + synchronized Response testPermissions(String projectId, List permissions) { + if (!projects.containsKey(projectId)) { + return Error.PERMISSION_DENIED.response("Project " + projectId + " not found."); + } + for (String p : permissions) { + if (!PERMISSIONS.contains(p)) { + return Error.INVALID_ARGUMENT.response("Invalid permission: " + p); + } + } + try { + return new Response(HTTP_OK, + jsonFactory.toString(new TestIamPermissionsResponse().setPermissions(permissions))); + } catch (IOException e) { + return Error.INTERNAL_ERROR.response("Error when serializing permissions " + permissions); + } + } + private LocalResourceManagerHelper() { try { server = HttpServer.create(new InetSocketAddress(0), 0); @@ -611,6 +719,7 @@ public synchronized boolean changeLifecycleState(String projectId, String lifecy public synchronized boolean removeProject(String projectId) { // Because this method is synchronized, any code that relies on non-atomic read/write operations // should not fail if that code is also synchronized. - return projects.remove(checkNotNull(projectId)) != null; + policies.remove(checkNotNull(projectId)); + return projects.remove(projectId) != null; } } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java index c9b2970a4efa..829094816664 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java @@ -2,11 +2,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import com.google.api.services.cloudresourcemanager.model.Binding; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gcloud.resourcemanager.spi.DefaultResourceManagerRpc; import com.google.gcloud.resourcemanager.spi.ResourceManagerRpc; @@ -18,8 +21,10 @@ import org.junit.BeforeClass; import org.junit.Test; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; public class LocalResourceManagerHelperTest { @@ -45,7 +50,12 @@ public class LocalResourceManagerHelperTest { .setLabels(ImmutableMap.of("k1", "v1", "k2", "v2")); private static final com.google.api.services.cloudresourcemanager.model.Project PROJECT_WITH_PARENT = - copyFrom(COMPLETE_PROJECT).setProjectId("project-with-parent-id").setParent(PARENT); + copyFrom(COMPLETE_PROJECT).setProjectId("project-with-parent-id").setParent(PARENT); + private static final List BINDINGS = ImmutableList.of( + new Binding().setRole("roles/owner").setMembers(ImmutableList.of("user:me@gmail.com")), + new Binding().setRole("roles/viewer").setMembers(ImmutableList.of("group:group@gmail.com"))); + private static final com.google.api.services.cloudresourcemanager.model.Policy POLICY = + new com.google.api.services.cloudresourcemanager.model.Policy().setBindings(BINDINGS); @BeforeClass public static void beforeClass() { @@ -92,6 +102,13 @@ public void testCreate() { assertNull(returnedProject.getParent()); assertNotNull(returnedProject.getProjectNumber()); assertNotNull(returnedProject.getCreateTime()); + com.google.api.services.cloudresourcemanager.model.Policy policy = + rpc.getPolicy(PARTIAL_PROJECT.getProjectId()); + assertEquals(Collections.emptyList(), policy.getBindings()); + assertNotNull(policy.getEtag()); + assertEquals(0, policy.getVersion().intValue()); + rpc.replacePolicy(PARTIAL_PROJECT.getProjectId(), POLICY); + assertEquals(POLICY.getBindings(), rpc.getPolicy(PARTIAL_PROJECT.getProjectId()).getBindings()); try { rpc.create(PARTIAL_PROJECT); fail("Should fail, project already exists."); @@ -99,6 +116,8 @@ public void testCreate() { assertEquals(409, e.code()); assertTrue(e.getMessage().startsWith("A project with the same project ID") && e.getMessage().endsWith("already exists.")); + assertEquals( + POLICY.getBindings(), rpc.getPolicy(PARTIAL_PROJECT.getProjectId()).getBindings()); } returnedProject = rpc.create(PROJECT_WITH_PARENT); compareReadWriteFields(PROJECT_WITH_PARENT, returnedProject); @@ -609,6 +628,65 @@ public void testUndeleteWhenDeleteInProgress() { } } + @Test + public void testGetPolicy() { + assertNull(rpc.getPolicy("nonexistent-project")); + rpc.create(PARTIAL_PROJECT); + com.google.api.services.cloudresourcemanager.model.Policy policy = + rpc.getPolicy(PARTIAL_PROJECT.getProjectId()); + assertEquals(Collections.emptyList(), policy.getBindings()); + assertNotNull(policy.getEtag()); + } + + @Test + public void testReplacePolicy() { + try { + rpc.replacePolicy("nonexistent-project", POLICY); + fail("Project doesn't exist."); + } catch (ResourceManagerException e) { + assertEquals(403, e.code()); + assertTrue(e.getMessage().contains("project was not found")); + } + rpc.create(PARTIAL_PROJECT); + com.google.api.services.cloudresourcemanager.model.Policy invalidPolicy = + new com.google.api.services.cloudresourcemanager.model.Policy().setEtag("wrong-etag"); + try { + rpc.replacePolicy(PARTIAL_PROJECT.getProjectId(), invalidPolicy); + fail("Invalid etag."); + } catch (ResourceManagerException e) { + assertEquals(409, e.code()); + assertTrue(e.getMessage().startsWith("Policy etag mismatch")); + } + String originalEtag = rpc.getPolicy(PARTIAL_PROJECT.getProjectId()).getEtag(); + com.google.api.services.cloudresourcemanager.model.Policy newPolicy = + rpc.replacePolicy(PARTIAL_PROJECT.getProjectId(), POLICY); + assertEquals(POLICY.getBindings(), newPolicy.getBindings()); + assertNotNull(newPolicy.getEtag()); + assertNotEquals(originalEtag, newPolicy.getEtag()); + } + + @Test + public void testTestPermissions() { + List permissions = ImmutableList.of("resourcemanager.projects.get"); + try { + rpc.testPermissions("nonexistent-project", permissions); + fail("Nonexistent project."); + } catch (ResourceManagerException e) { + assertEquals(403, e.code()); + assertEquals("Project nonexistent-project not found.", e.getMessage()); + } + rpc.create(PARTIAL_PROJECT); + try { + rpc.testPermissions(PARTIAL_PROJECT.getProjectId(), ImmutableList.of("get")); + fail("Invalid permission."); + } catch (ResourceManagerException e) { + assertEquals(400, e.code()); + assertEquals("Invalid permission: get", e.getMessage()); + } + assertEquals(ImmutableList.of(true), + rpc.testPermissions(PARTIAL_PROJECT.getProjectId(), permissions)); + } + @Test public void testChangeLifecycleStatus() { assertFalse(RESOURCE_MANAGER_HELPER.changeLifecycleState( @@ -632,8 +710,10 @@ public void testChangeLifecycleStatus() { public void testRemoveProject() { assertFalse(RESOURCE_MANAGER_HELPER.removeProject(COMPLETE_PROJECT.getProjectId())); rpc.create(COMPLETE_PROJECT); + assertNotNull(rpc.getPolicy(COMPLETE_PROJECT.getProjectId())); assertTrue(RESOURCE_MANAGER_HELPER.removeProject(COMPLETE_PROJECT.getProjectId())); assertNull(rpc.get(COMPLETE_PROJECT.getProjectId(), EMPTY_RPC_OPTIONS)); + assertNull(rpc.getPolicy(COMPLETE_PROJECT.getProjectId())); } private void compareReadWriteFields( diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java index 05d1b85bdbed..e6d0105838b7 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java @@ -17,9 +17,13 @@ package com.google.gcloud.resourcemanager; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNull; import com.google.common.collect.ImmutableSet; import com.google.gcloud.Identity; +import com.google.gcloud.resourcemanager.Policy.Role; +import com.google.gcloud.resourcemanager.Policy.Role.Type; import org.junit.Test; @@ -33,8 +37,10 @@ public class PolicyTest { private static final Identity GROUP = Identity.group("group@gmail.com"); private static final Identity DOMAIN = Identity.domain("google.com"); private static final Policy SIMPLE_POLICY = Policy.builder() - .addBinding(Policy.Role.VIEWER, ImmutableSet.of(USER, SERVICE_ACCOUNT, ALL_USERS)) - .addBinding(Policy.Role.EDITOR, ImmutableSet.of(ALL_AUTH_USERS, GROUP, DOMAIN)) + .addBinding(Role.owner(), ImmutableSet.of(USER)) + .addBinding(Role.viewer(), ImmutableSet.of(ALL_USERS)) + .addBinding(Role.editor(), ImmutableSet.of(ALL_AUTH_USERS, DOMAIN)) + .addBinding(Role.rawRole("some-role"), ImmutableSet.of(SERVICE_ACCOUNT, GROUP)) .build(); private static final Policy FULL_POLICY = new Policy.Builder(SIMPLE_POLICY.bindings(), "etag", 1).build(); @@ -50,4 +56,24 @@ public void testPolicyToAndFromPb() { assertEquals(FULL_POLICY, Policy.fromPb(FULL_POLICY.toPb())); assertEquals(SIMPLE_POLICY, Policy.fromPb(SIMPLE_POLICY.toPb())); } + + @Test + public void testRoleType() { + assertEquals(Type.OWNER, Role.owner().type()); + assertEquals(Type.EDITOR, Role.editor().type()); + assertEquals(Type.VIEWER, Role.viewer().type()); + assertNull(Role.rawRole("raw-role").type()); + } + + @Test + public void testEquals() { + Policy copy = Policy.builder() + .addBinding(Role.owner(), ImmutableSet.of(USER)) + .addBinding(Role.viewer(), ImmutableSet.of(ALL_USERS)) + .addBinding(Role.editor(), ImmutableSet.of(ALL_AUTH_USERS, DOMAIN)) + .addBinding(Role.rawRole("some-role"), ImmutableSet.of(SERVICE_ACCOUNT, GROUP)) + .build(); + assertEquals(SIMPLE_POLICY, copy); + assertNotEquals(SIMPLE_POLICY, FULL_POLICY); + } } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java index 4e239acc45ef..882ec77197f3 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java @@ -26,6 +26,7 @@ import static org.junit.Assert.assertNull; import com.google.common.collect.ImmutableMap; +import com.google.gcloud.resourcemanager.ProjectInfo.ResourceId; import org.junit.After; import org.junit.Before; @@ -84,12 +85,12 @@ public void testToBuilder() { @Test public void testBuilder() { - initializeExpectedProject(4); - expect(resourceManager.options()).andReturn(mockOptions).times(4); + expect(resourceManager.options()).andReturn(mockOptions).times(7); replay(resourceManager); Project.Builder builder = - new Project.Builder(new Project(resourceManager, new ProjectInfo.BuilderImpl(PROJECT_ID))); - Project project = builder.name(NAME) + new Project.Builder(new Project(resourceManager, new ProjectInfo.BuilderImpl("wrong-id"))); + Project project = builder.projectId(PROJECT_ID) + .name(NAME) .labels(LABELS) .projectNumber(PROJECT_NUMBER) .createTimeMillis(CREATE_TIME_MILLIS) @@ -102,6 +103,23 @@ public void testBuilder() { assertEquals(CREATE_TIME_MILLIS, project.createTimeMillis()); assertEquals(STATE, project.state()); assertEquals(resourceManager.options(), project.resourceManager().options()); + assertNull(project.parent()); + ResourceId parent = new ResourceId("id", "type"); + project = project.toBuilder() + .clearLabels() + .addLabel("k3", "v3") + .addLabel("k4", "v4") + .removeLabel("k4") + .parent(parent) + .build(); + assertEquals(PROJECT_ID, project.projectId()); + assertEquals(NAME, project.name()); + assertEquals(ImmutableMap.of("k3", "v3"), project.labels()); + assertEquals(PROJECT_NUMBER, project.projectNumber()); + assertEquals(CREATE_TIME_MILLIS, project.createTimeMillis()); + assertEquals(STATE, project.state()); + assertEquals(resourceManager.options(), project.resourceManager().options()); + assertEquals(parent, project.parent()); } @Test diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java index 5b172d6a070e..a69880c5d064 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java @@ -18,15 +18,20 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.gcloud.Identity; import com.google.gcloud.Page; +import com.google.gcloud.resourcemanager.Policy.Role; import com.google.gcloud.resourcemanager.ProjectInfo.ResourceId; +import com.google.gcloud.resourcemanager.ResourceManager.Permission; import com.google.gcloud.resourcemanager.ResourceManager.ProjectField; import com.google.gcloud.resourcemanager.ResourceManager.ProjectGetOption; import com.google.gcloud.resourcemanager.ResourceManager.ProjectListOption; @@ -43,6 +48,7 @@ import org.junit.rules.ExpectedException; import java.util.Iterator; +import java.util.List; import java.util.Map; public class ResourceManagerImplTest { @@ -65,6 +71,10 @@ public class ResourceManagerImplTest { .parent(PARENT) .build(); private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); + private static final Policy POLICY = Policy.builder() + .addBinding(Role.owner(), Identity.user("me@gmail.com")) + .addBinding(Role.editor(), Identity.serviceAccount("serviceaccount@gmail.com")) + .build(); @Rule public ExpectedException thrown = ExpectedException.none(); @@ -320,6 +330,60 @@ public void testUndelete() { } } + @Test + public void testGetPolicy() { + assertNull(RESOURCE_MANAGER.getPolicy(COMPLETE_PROJECT.projectId())); + RESOURCE_MANAGER.create(COMPLETE_PROJECT); + RESOURCE_MANAGER.replacePolicy(COMPLETE_PROJECT.projectId(), POLICY); + Policy retrieved = RESOURCE_MANAGER.getPolicy(COMPLETE_PROJECT.projectId()); + assertEquals(POLICY.bindings(), retrieved.bindings()); + assertNotNull(retrieved.etag()); + assertEquals(0, retrieved.version().intValue()); + } + + @Test + public void testReplacePolicy() { + try { + RESOURCE_MANAGER.replacePolicy("nonexistent-project", POLICY); + fail("Project doesn't exist."); + } catch (ResourceManagerException e) { + assertEquals(403, e.code()); + assertTrue(e.getMessage().endsWith("project was not found.")); + } + RESOURCE_MANAGER.create(PARTIAL_PROJECT); + Policy oldPolicy = RESOURCE_MANAGER.getPolicy(PARTIAL_PROJECT.projectId()); + RESOURCE_MANAGER.replacePolicy(PARTIAL_PROJECT.projectId(), POLICY); + try { + RESOURCE_MANAGER.replacePolicy(PARTIAL_PROJECT.projectId(), oldPolicy); + fail("Policy with an invalid etag didn't cause error."); + } catch (ResourceManagerException e) { + assertEquals(409, e.code()); + assertTrue(e.getMessage().contains("Policy etag mismatch")); + } + String originalEtag = RESOURCE_MANAGER.getPolicy(PARTIAL_PROJECT.projectId()).etag(); + Policy newPolicy = RESOURCE_MANAGER.replacePolicy(PARTIAL_PROJECT.projectId(), POLICY); + assertEquals(POLICY.bindings(), newPolicy.bindings()); + assertNotNull(newPolicy.etag()); + assertNotEquals(originalEtag, newPolicy.etag()); + } + + @Test + public void testTestPermissions() { + List permissions = ImmutableList.of(Permission.GET); + try { + RESOURCE_MANAGER.testPermissions("nonexistent-project", permissions); + fail("Nonexistent project"); + } catch (ResourceManagerException e) { + assertEquals(403, e.code()); + assertEquals("Project nonexistent-project not found.", e.getMessage()); + } + RESOURCE_MANAGER.create(PARTIAL_PROJECT); + assertEquals(ImmutableList.of(true), + RESOURCE_MANAGER.testPermissions(PARTIAL_PROJECT.projectId(), permissions)); + assertEquals(ImmutableList.of(true, true), RESOURCE_MANAGER.testPermissions( + PARTIAL_PROJECT.projectId(), Permission.DELETE, Permission.GET)); + } + @Test public void testRetryableException() { ResourceManagerRpcFactory rpcFactoryMock = EasyMock.createMock(ResourceManagerRpcFactory.class); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index 35b72ae1713f..f71f5d7989d6 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -56,7 +56,7 @@ public class SerializationTest { private static final ResourceManager.ProjectListOption PROJECT_LIST_OPTION = ResourceManager.ProjectListOption.filter("name:*"); private static final Policy POLICY = Policy.builder() - .addBinding(Policy.Role.VIEWER, ImmutableSet.of(Identity.user("abc@gmail.com"))) + .addBinding(Policy.Role.viewer(), ImmutableSet.of(Identity.user("abc@gmail.com"))) .build(); @Test From 8ae8a1b160bbbd1e18bedf2a35d014449397ec3e Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Wed, 16 Mar 2016 09:35:09 +0100 Subject: [PATCH 145/203] Create base class for serialization tests --- gcloud-java-bigquery/pom.xml | 7 ++ .../gcloud/bigquery/SerializationTest.java | 47 ++-------- .../google/gcloud/BaseSerializationTest.java | 64 +++++++++++++ .../com/google/gcloud/SerializationTest.java | 33 +++++++ gcloud-java-datastore/pom.xml | 7 ++ .../gcloud/datastore/SerializationTest.java | 90 +++---------------- gcloud-java-resourcemanager/pom.xml | 7 ++ .../resourcemanager/SerializationTest.java | 50 ++--------- gcloud-java-storage/pom.xml | 7 ++ .../gcloud/storage/SerializationTest.java | 47 ++-------- pom.xml | 7 ++ 11 files changed, 163 insertions(+), 203 deletions(-) create mode 100644 gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java create mode 100644 gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java diff --git a/gcloud-java-bigquery/pom.xml b/gcloud-java-bigquery/pom.xml index 9a2137cb987d..5c79f150c722 100644 --- a/gcloud-java-bigquery/pom.xml +++ b/gcloud-java-bigquery/pom.xml @@ -39,6 +39,13 @@ + + ${project.groupId} + gcloud-java-core + ${project.version} + test-jar + test + junit junit diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java index 254c8954bf30..f64946e062d7 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java @@ -17,11 +17,11 @@ package com.google.gcloud.bigquery; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gcloud.AuthCredentials; +import com.google.gcloud.BaseSerializationTest; import com.google.gcloud.RestorableState; import com.google.gcloud.RetryParams; import com.google.gcloud.WriteChannel; @@ -29,17 +29,13 @@ import org.junit.Test; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.io.Serializable; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; -public class SerializationTest { +public class SerializationTest extends BaseSerializationTest { private static final Acl DOMAIN_ACCESS = Acl.of(new Acl.Domain("domain"), Acl.Role.WRITER); @@ -231,27 +227,18 @@ public class SerializationTest { private static final Table TABLE = new Table(BIGQUERY, new TableInfo.BuilderImpl(TABLE_INFO)); private static final Job JOB = new Job(BIGQUERY, new JobInfo.BuilderImpl(JOB_INFO)); - @Test - public void testServiceOptions() throws Exception { + @Override + public Serializable[] serializableObjects() { BigQueryOptions options = BigQueryOptions.builder() .projectId("p1") .authCredentials(AuthCredentials.createForAppEngine()) .build(); - BigQueryOptions serializedCopy = serializeAndDeserialize(options); - assertEquals(options, serializedCopy); - - options = options.toBuilder() + BigQueryOptions otherOptions = options.toBuilder() .projectId("p2") .retryParams(RetryParams.defaultInstance()) .authCredentials(null) .build(); - serializedCopy = serializeAndDeserialize(options); - assertEquals(options, serializedCopy); - } - - @Test - public void testModelAndRequests() throws Exception { - Serializable[] objects = {DOMAIN_ACCESS, GROUP_ACCESS, USER_ACCESS, VIEW_ACCESS, DATASET_ID, + return new Serializable[]{DOMAIN_ACCESS, GROUP_ACCESS, USER_ACCESS, VIEW_ACCESS, DATASET_ID, DATASET_INFO, TABLE_ID, CSV_OPTIONS, STREAMING_BUFFER, TABLE_DEFINITION, EXTERNAL_TABLE_DEFINITION, VIEW_DEFINITION, TABLE_SCHEMA, TABLE_INFO, VIEW_INFO, EXTERNAL_TABLE_INFO, INLINE_FUNCTION, URI_FUNCTION, JOB_STATISTICS, EXTRACT_STATISTICS, @@ -262,14 +249,7 @@ public void testModelAndRequests() throws Exception { BigQuery.DatasetOption.fields(), BigQuery.DatasetDeleteOption.deleteContents(), BigQuery.DatasetListOption.all(), BigQuery.TableOption.fields(), BigQuery.TableListOption.pageSize(42L), BigQuery.JobOption.fields(), - BigQuery.JobListOption.allUsers(), DATASET, TABLE, JOB}; - for (Serializable obj : objects) { - Object copy = serializeAndDeserialize(obj); - assertEquals(obj, obj); - assertEquals(obj, copy); - assertNotSame(obj, copy); - assertEquals(copy, copy); - } + BigQuery.JobListOption.allUsers(), DATASET, TABLE, JOB, options, otherOptions}; } @Test @@ -288,17 +268,4 @@ public void testWriteChannelState() throws IOException, ClassNotFoundException { assertEquals(state.hashCode(), deserializedState.hashCode()); assertEquals(state.toString(), deserializedState.toString()); } - - @SuppressWarnings("unchecked") - private T serializeAndDeserialize(T obj) - throws IOException, ClassNotFoundException { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { - output.writeObject(obj); - } - try (ObjectInputStream input = - new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) { - return (T) input.readObject(); - } - } } diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java new file mode 100644 index 000000000000..533dfcde6ad8 --- /dev/null +++ b/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java @@ -0,0 +1,64 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; + +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +/** + * Base class for serialization tests. To use this class in your tests override the + * {@code serializableObjects()} method to return all objects that must be serializable. + */ +public abstract class BaseSerializationTest { + + public abstract Serializable[] serializableObjects(); + + @Test + public void testSerializableObjects() throws Exception { + for (Serializable obj : serializableObjects()) { + Object copy = serializeAndDeserialize(obj); + assertEquals(obj, obj); + assertEquals(obj, copy); + assertEquals(obj.hashCode(), copy.hashCode()); + assertEquals(obj.toString(), copy.toString()); + assertNotSame(obj, copy); + assertEquals(copy, copy); + } + } + + @SuppressWarnings("unchecked") + public T serializeAndDeserialize(T obj) + throws IOException, ClassNotFoundException { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { + output.writeObject(obj); + } + try (ObjectInputStream input = + new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) { + return (T) input.readObject(); + } + } +} diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java new file mode 100644 index 000000000000..aec9158e1ee0 --- /dev/null +++ b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud; + +import com.google.common.collect.ImmutableList; + +import java.io.Serializable; + +public class SerializationTest extends BaseSerializationTest { + + private static final PageImpl PAGE = + new PageImpl<>(null, "cursor", ImmutableList.of("string1", "string2")); + private static final RetryParams RETRY_PARAMS = RetryParams.defaultInstance(); + + @Override + public Serializable[] serializableObjects() { + return new Serializable[]{PAGE, RETRY_PARAMS}; + } +} diff --git a/gcloud-java-datastore/pom.xml b/gcloud-java-datastore/pom.xml index 977b6db22b14..f3b46e22b3c8 100644 --- a/gcloud-java-datastore/pom.xml +++ b/gcloud-java-datastore/pom.xml @@ -33,6 +33,13 @@ + + ${project.groupId} + gcloud-java-core + ${project.version} + test-jar + test + junit junit diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java index 3976be2cc383..7a6f065d6ca6 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java @@ -17,28 +17,17 @@ package com.google.gcloud.datastore; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; import com.google.api.services.datastore.DatastoreV1; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; import com.google.gcloud.AuthCredentials; +import com.google.gcloud.BaseSerializationTest; import com.google.gcloud.RetryParams; import com.google.gcloud.datastore.StructuredQuery.CompositeFilter; import com.google.gcloud.datastore.StructuredQuery.OrderBy; import com.google.gcloud.datastore.StructuredQuery.Projection; import com.google.gcloud.datastore.StructuredQuery.PropertyFilter; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; - -public class SerializationTest { +public class SerializationTest extends BaseSerializationTest { private static final IncompleteKey INCOMPLETE_KEY1 = IncompleteKey.builder("ds", "k").ancestors(PathElement.of("p", 1)).build(); @@ -114,82 +103,23 @@ public class SerializationTest { .build(); private static final ProjectionEntity PROJECTION_ENTITY = ProjectionEntity.fromPb(ENTITY1.toPb()); - @SuppressWarnings("rawtypes") - private static final Multimap TYPE_TO_VALUES = - ImmutableMultimap.builder() - .put(ValueType.NULL, NULL_VALUE) - .put(ValueType.KEY, KEY_VALUE) - .put(ValueType.STRING, STRING_VALUE) - .putAll(ValueType.ENTITY, EMBEDDED_ENTITY_VALUE1, EMBEDDED_ENTITY_VALUE2, - EMBEDDED_ENTITY_VALUE3) - .put(ValueType.LIST, LIST_VALUE) - .put(ValueType.LONG, LONG_VALUE) - .put(ValueType.DOUBLE, DOUBLE_VALUE) - .put(ValueType.BOOLEAN, BOOLEAN_VALUE) - .put(ValueType.DATE_TIME, DATE_AND_TIME_VALUE) - .put(ValueType.BLOB, BLOB_VALUE) - .put(ValueType.RAW_VALUE, RAW_VALUE) - .build(); - - @Test - public void testServiceOptions() throws Exception { + @Override + public java.io.Serializable[] serializableObjects() { DatastoreOptions options = DatastoreOptions.builder() .authCredentials(AuthCredentials.createForAppEngine()) .normalizeDataset(false) .projectId("ds1") .build(); - DatastoreOptions serializedCopy = serializeAndDeserialize(options); - assertEquals(options, serializedCopy); - - options = options.toBuilder() + DatastoreOptions otherOptions = options.toBuilder() .namespace("ns1") .retryParams(RetryParams.defaultInstance()) .authCredentials(null) .force(true) .build(); - serializedCopy = serializeAndDeserialize(options); - assertEquals(options, serializedCopy); - } - - @Test - public void testValues() throws Exception { - for (ValueType valueType : ValueType.values()) { - for (Value value : TYPE_TO_VALUES.get(valueType)) { - Value copy = serializeAndDeserialize(value); - assertEquals(value, value); - assertEquals(value, copy); - assertNotSame(value, copy); - assertEquals(copy, copy); - assertEquals(value.get(), copy.get()); - } - } - } - - @Test - public void testTypes() throws Exception { - Serializable[] types = { KEY1, KEY2, INCOMPLETE_KEY1, INCOMPLETE_KEY2, ENTITY1, ENTITY2, - ENTITY3, EMBEDDED_ENTITY, PROJECTION_ENTITY, DATE_TIME1, BLOB1, CURSOR1, GQL1, GQL2, - QUERY1, QUERY2, QUERY3}; - for (Serializable obj : types) { - Object copy = serializeAndDeserialize(obj); - assertEquals(obj, obj); - assertEquals(obj, copy); - assertNotSame(obj, copy); - assertEquals(copy, copy); - } - } - - private T serializeAndDeserialize(T obj) - throws IOException, ClassNotFoundException { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { - output.writeObject(obj); - } - try (ObjectInputStream input = - new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) { - @SuppressWarnings("unchecked") - T result = (T) input.readObject(); - return result; - } + return new java.io.Serializable[]{KEY1, KEY2, INCOMPLETE_KEY1, INCOMPLETE_KEY2, ENTITY1, + ENTITY2, ENTITY3, EMBEDDED_ENTITY, PROJECTION_ENTITY, DATE_TIME1, BLOB1, CURSOR1, GQL1, + GQL2, QUERY1, QUERY2, QUERY3, NULL_VALUE, KEY_VALUE, STRING_VALUE, EMBEDDED_ENTITY_VALUE1, + EMBEDDED_ENTITY_VALUE2, EMBEDDED_ENTITY_VALUE3, LIST_VALUE, LONG_VALUE, DOUBLE_VALUE, + BOOLEAN_VALUE, DATE_AND_TIME_VALUE, BLOB_VALUE, RAW_VALUE, options, otherOptions}; } } diff --git a/gcloud-java-resourcemanager/pom.xml b/gcloud-java-resourcemanager/pom.xml index c10691d3b07d..c0c48af48f1e 100644 --- a/gcloud-java-resourcemanager/pom.xml +++ b/gcloud-java-resourcemanager/pom.xml @@ -33,6 +33,13 @@ + + ${project.groupId} + gcloud-java-core + ${project.version} + test-jar + test + junit junit diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index f71f5d7989d6..2dcd3f9d3e7b 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -16,26 +16,17 @@ package com.google.gcloud.resourcemanager; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; - import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.gcloud.Identity; +import com.google.gcloud.BaseSerializationTest; import com.google.gcloud.PageImpl; import com.google.gcloud.RetryParams; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Collections; -public class SerializationTest { +public class SerializationTest extends BaseSerializationTest { private static final ResourceManager RESOURCE_MANAGER = ResourceManagerOptions.defaultInstance().service(); @@ -59,41 +50,14 @@ public class SerializationTest { .addBinding(Policy.Role.viewer(), ImmutableSet.of(Identity.user("abc@gmail.com"))) .build(); - @Test - public void testServiceOptions() throws Exception { + @Override + public Serializable[] serializableObjects() { ResourceManagerOptions options = ResourceManagerOptions.builder().build(); - ResourceManagerOptions serializedCopy = serializeAndDeserialize(options); - assertEquals(options, serializedCopy); - options = options.toBuilder() + ResourceManagerOptions otherOptions = options.toBuilder() .projectId("some-unnecessary-project-ID") .retryParams(RetryParams.defaultInstance()) .build(); - serializedCopy = serializeAndDeserialize(options); - assertEquals(options, serializedCopy); - } - - @Test - public void testModelAndRequests() throws Exception { - Serializable[] objects = {PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PROJECT, PAGE_RESULT, - PROJECT_GET_OPTION, PROJECT_LIST_OPTION, POLICY}; - for (Serializable obj : objects) { - Object copy = serializeAndDeserialize(obj); - assertEquals(obj, obj); - assertEquals(obj, copy); - assertNotSame(obj, copy); - assertEquals(copy, copy); - } - } - - @SuppressWarnings("unchecked") - private T serializeAndDeserialize(T obj) throws IOException, ClassNotFoundException { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { - output.writeObject(obj); - } - try (ObjectInputStream input = - new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) { - return (T) input.readObject(); - } + return new Serializable[]{PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PROJECT, PAGE_RESULT, + PROJECT_GET_OPTION, PROJECT_LIST_OPTION, POLICY, options, otherOptions}; } } diff --git a/gcloud-java-storage/pom.xml b/gcloud-java-storage/pom.xml index d5f0f6d98660..16427d50de3a 100644 --- a/gcloud-java-storage/pom.xml +++ b/gcloud-java-storage/pom.xml @@ -37,6 +37,13 @@ + + ${project.groupId} + gcloud-java-core + ${project.version} + test-jar + test + junit junit diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java index efa56d9e39b2..ee3d7c946312 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java @@ -17,10 +17,10 @@ package com.google.gcloud.storage; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; import com.google.common.collect.ImmutableMap; import com.google.gcloud.AuthCredentials; +import com.google.gcloud.BaseSerializationTest; import com.google.gcloud.PageImpl; import com.google.gcloud.ReadChannel; import com.google.gcloud.RestorableState; @@ -31,16 +31,12 @@ import org.junit.Test; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Collections; import java.util.Map; -public class SerializationTest { +public class SerializationTest extends BaseSerializationTest { private static final Storage STORAGE = StorageOptions.builder().projectId("p").build().service(); private static final Acl.Domain ACL_DOMAIN = new Acl.Domain("domain"); @@ -77,37 +73,21 @@ public class SerializationTest { Storage.BucketTargetOption.metagenerationNotMatch(); private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); - @Test - public void testServiceOptions() throws Exception { + @Override + public Serializable[] serializableObjects() { StorageOptions options = StorageOptions.builder() .projectId("p1") .authCredentials(AuthCredentials.createForAppEngine()) .build(); - StorageOptions serializedCopy = serializeAndDeserialize(options); - assertEquals(options, serializedCopy); - - options = options.toBuilder() + StorageOptions otherOptions = options.toBuilder() .projectId("p2") .retryParams(RetryParams.defaultInstance()) .authCredentials(null) .build(); - serializedCopy = serializeAndDeserialize(options); - assertEquals(options, serializedCopy); - } - - @Test - public void testModelAndRequests() throws Exception { - Serializable[] objects = {ACL_DOMAIN, ACL_GROUP, ACL_PROJECT_, ACL_USER, ACL_RAW, ACL, + return new Serializable[]{ACL_DOMAIN, ACL_GROUP, ACL_PROJECT_, ACL_USER, ACL_RAW, ACL, BLOB_INFO, BLOB, BUCKET_INFO, BUCKET, ORIGIN, CORS, BATCH_REQUEST, BATCH_RESPONSE, PAGE_RESULT, BLOB_LIST_OPTIONS, BLOB_SOURCE_OPTIONS, BLOB_TARGET_OPTIONS, - BUCKET_LIST_OPTIONS, BUCKET_SOURCE_OPTIONS, BUCKET_TARGET_OPTIONS}; - for (Serializable obj : objects) { - Object copy = serializeAndDeserialize(obj); - assertEquals(obj, obj); - assertEquals(obj, copy); - assertNotSame(obj, copy); - assertEquals(copy, copy); - } + BUCKET_LIST_OPTIONS, BUCKET_SOURCE_OPTIONS, BUCKET_TARGET_OPTIONS, options, otherOptions}; } @Test @@ -142,17 +122,4 @@ public void testWriteChannelState() throws IOException, ClassNotFoundException { assertEquals(state.hashCode(), deserializedState.hashCode()); assertEquals(state.toString(), deserializedState.toString()); } - - @SuppressWarnings("unchecked") - private T serializeAndDeserialize(T obj) - throws IOException, ClassNotFoundException { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { - output.writeObject(obj); - } - try (ObjectInputStream input = - new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) { - return (T) input.readObject(); - } - } } diff --git a/pom.xml b/pom.xml index b7766ac0e5c6..1abfb094ffb8 100644 --- a/pom.xml +++ b/pom.xml @@ -215,6 +215,13 @@ + + + + test-jar + + + maven-compiler-plugin From f7f4de852874b04e92cff4233dfa0f635c0792c2 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 1 Mar 2016 12:58:25 -0800 Subject: [PATCH 146/203] Added READMEs. This includes: - Package README - Adjusted global gcloud-java README - Package description - Reorganizing snippets to be consistent with readme --- README.md | 74 +++- gcloud-java-dns/README.md | 385 ++++++++++++++++++ .../com/google/gcloud/dns/package-info.java | 60 +++ .../com/google/gcloud/dns/it/ITDnsTest.java | 2 +- ...rds.java => CreateOrUpdateDnsRecords.java} | 9 +- ...reateAndListZones.java => CreateZone.java} | 23 +- .../examples/dns/snippets/DeleteZone.java | 2 +- .../snippets/ManipulateZonesAndRecords.java | 157 +++++++ 8 files changed, 688 insertions(+), 24 deletions(-) create mode 100644 gcloud-java-dns/README.md create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java rename gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/{CreateAndListDnsRecords.java => CreateOrUpdateDnsRecords.java} (89%) rename gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/{CreateAndListZones.java => CreateZone.java} (70%) create mode 100644 gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecords.java diff --git a/README.md b/README.md index 32a0f539425e..a908cef0bf35 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ This client supports the following Google Cloud Platform services: - [Google Cloud BigQuery] (#google-cloud-bigquery-alpha) (Alpha) - [Google Cloud Datastore] (#google-cloud-datastore) +- [Google Cloud DNS] (#google-cloud-dns-alpha) (Alpha) - [Google Cloud Resource Manager] (#google-cloud-resource-manager-alpha) (Alpha) - [Google Cloud Storage] (#google-cloud-storage) @@ -48,8 +49,10 @@ Example Applications - Read more about using this application on the [`BigQueryExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/bigquery/BigQueryExample.html). - [`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/bookshelf) - An App Engine app that manages a virtual bookshelf. - This app uses `gcloud-java` to interface with Cloud Datastore and Cloud Storage. It also uses Cloud SQL, another Google Cloud Platform service. -- [`DatastoreExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) - A simple command line interface for the Cloud Datastore +- [`DatastoreExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/datastore/DatastoreExample.java) - A simple command line interface for Cloud Datastore - Read more about using this application on the [`DatastoreExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/datastore/DatastoreExample.html). +- [`DnsExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java) - A simple command line interface for Cloud DNS + - Read more about using this application on the [`DnsExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/dns/DnsExample.html). - [`ResourceManagerExample`](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/ResourceManagerExample.java) - A simple command line interface providing some of Cloud Resource Manager's functionality - Read more about using this application on the [`ResourceManagerExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/resourcemanager/ResourceManagerExample.html). - [`SparkDemo`](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/managed_vms/sparkjava) - An example of using gcloud-java-datastore from within the SparkJava and App Engine Managed VM frameworks. @@ -218,6 +221,71 @@ if (entity != null) { } ``` +Google Cloud DNS (Alpha) +---------------------- +- [API Documentation][dns-api] +- [Official Documentation][cloud-dns-docs] + +*Follow the [activation instructions][cloud-dns-activation] to use the Google Cloud DNS API with your project.* + +#### Preview + +Here are two code snippets showing simple usage examples from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere. + +The first snippet shows how to create a zone resource. Complete source code can be found on +[CreateZone.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateZone.java). + +```java +import com.google.gcloud.dns.Dns; +import com.google.gcloud.dns.DnsOptions; +import com.google.gcloud.dns.Zone; +import com.google.gcloud.dns.ZoneInfo; + +Dns dns = DnsOptions.defaultInstance().service(); +String zoneName = "my-unique-zone"; +String domainName = "someexampledomain.com."; +String description = "This is a gcloud-java-dns sample zone."; +ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description); +Zone zone = dns.create(zoneInfo); +``` + +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). + +```java +import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.Dns; +import com.google.gcloud.dns.DnsOptions; +import com.google.gcloud.dns.DnsRecord; +import com.google.gcloud.dns.Zone; + +import java.util.Iterator; +import java.util.concurrent.TimeUnit; + +Dns dns = DnsOptions.defaultInstance().service(); +String zoneName = "my-unique-zone"; +Zone zone = dns.getZone(zoneName); +String ip = "12.13.14.15"; +DnsRecord toCreate = DnsRecord.builder("www.someexampledomain.com.", DnsRecord.Type.A) + .ttl(24, TimeUnit.HOURS) + .addRecord(ip) + .build(); +ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate); + +// Verify that the record does not exist yet. +// If it does exist, we will overwrite it with our prepared record. +Iterator recordIterator = zone.listDnsRecords().iterateAll(); +while (recordIterator.hasNext()) { + DnsRecord current = recordIterator.next(); + if (toCreate.name().equals(current.name()) && + toCreate.type().equals(current.type())) { + changeBuilder.delete(current); + } +} + +ChangeRequest changeRequest = changeBuilder.build(); +zone.applyChangeRequest(changeRequest); +``` + Google Cloud Resource Manager (Alpha) ---------------------- @@ -359,6 +427,10 @@ Apache 2.0 - See [LICENSE] for more information. [cloud-datastore-activation]: https://cloud.google.com/datastore/docs/activate [datastore-api]: http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/datastore/package-summary.html +[dns-api]: http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/dns/package-summary.html +[cloud-dns-docs]: https://cloud.google.com/dns/docs +[cloud-dns-activation]: https://console.cloud.google.com/start/api?id=dns + [cloud-pubsub]: https://cloud.google.com/pubsub/ [cloud-pubsub-docs]: https://cloud.google.com/pubsub/docs diff --git a/gcloud-java-dns/README.md b/gcloud-java-dns/README.md new file mode 100644 index 000000000000..4f65d8e3b814 --- /dev/null +++ b/gcloud-java-dns/README.md @@ -0,0 +1,385 @@ +Google Cloud Java Client for DNS +================================ + +Java idiomatic client for [Google Cloud DNS] (https://cloud.google.com/dns/). + +[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) +[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) +[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-dns.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-dns.svg) +[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/gcloud-java) +[![Dependency Status](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969/badge.svg?style=flat)](https://www.versioneye.com/user/projects/56bd8ee72a29ed002d2b0969) + +- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) +- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/dns/package-summary.html) + +> Note: This client is a work-in-progress, and may occasionally +> make backwards-incompatible changes. + +Quickstart +---------- +If you are using Maven, add this to your pom.xml file +```xml + + com.google.gcloud + gcloud-java-dns + 0.1.5 + +``` +If you are using Gradle, add this to your dependencies +```Groovy +compile 'com.google.gcloud:gcloud-java-dns:0.1.5' +``` +If you are using SBT, add this to your dependencies +```Scala +libraryDependencies += "com.google.gcloud" % "gcloud-java-dns" % "0.1.5" +``` + +Example Application +------------------- + +[`DnsExample`](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java) +is a simple command line interface that provides some of Google Cloud DNS's functionality. Read +more about using the application on the +[`DnsExample` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/dns/DnsExample.html). + +Authentication +-------------- + +See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section +in the base directory's README. + +About Google Cloud DNS +-------------------------- + +[Google Cloud DNS][cloud-dns] is a scalable, reliable and managed authoritative Domain Name System +(DNS) service running on the same infrastructure as Google. It has low latency, high availability +and is a cost-effective way to make your applications and services available to your users. + +See the [Google Cloud DNS docs][dns-activate] for more details on how to activate +Cloud DNS for your project. + +See the [``gcloud-java-dns`` API documentation][dns-api] to learn how to interact +with the Cloud DNS using this client Library. + +Getting Started +--------------- +#### Prerequisites +For this tutorial, you will need a [Google Developers Console](https://console.developers.google.com/) +project with the DNS API enabled. You will need to [enable billing](https://support.google.com/cloud/answer/6158867?hl=en) +to use Google Cloud DNS. [Follow these instructions](https://cloud.google.com/docs/authentication#preparation) +to get your project set up. You will also need to set up the local development environment by +[installing the Google Cloud SDK](https://cloud.google.com/sdk/) and running the following commands +in command line: `gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`. + +#### Installation and setup +You'll need to obtain the `gcloud-java-dns` library. See the [Quickstart](#quickstart) section to +add `gcloud-java-dns` as a dependency in your code. + +#### Creating an authorized service object +To make authenticated requests to Google Cloud DNS, you must create a service object with +credentials. You can then make API calls by calling methods on the DNS service object. The simplest +way to authenticate is to use [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials). +These credentials are automatically inferred from your environment, so you only need the following +code to create your service object: + +```java +import com.google.gcloud.dns.Dns; +import com.google.gcloud.dns.DnsOptions; + +Dns dns = DnsOptions.defaultInstance().service(); +``` + +For other authentication options, see the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) page. + +#### Managing Zones +DNS records in `gcloud-java-dns` are managed inside containers called "zones". `ZoneInfo` is a class +which encapsulates metadata that describe a zone in Google Cloud DNS. `Zone`, a subclass of `ZoneInfo`, adds service-related +functionality over `ZoneInfo`. + +*Important: Zone names must be unique to the project. If you choose a zone name that already +exists within your project, you'll get a helpful error message telling you to choose another name. In the code below, +replace "my-unique-zone" with a unique zone name. See more about naming rules [here](https://cloud.google.com/dns/api/v1/managedZones#name).* + +In this code snippet, we create a new zone to manage DNS records for domain `someexampledomain.com.` + +*Important: The service may require that you verify ownership of the domain for which you are creating a zone. +Hence, we recommend that you do so beforehand. You can verify ownership of +a domain name [here](https://www.google.com/webmasters/verification/home). Note that Cloud DNS +requires fully qualified domain names which must end with a period.* + +Add the following imports at the top of your file: + +```java +import com.google.gcloud.dns.Zone; +import com.google.gcloud.dns.ZoneInfo; +``` + +Then add the following code to create a zone. + +```java +// Create a zone metadata object +String zoneName = "my-unique-zone"; // Change this zone name which is unique within your project +String domainName = "someexampledomain.com."; // Change this to a domain which you own +String description = "This is a gcloud-java-dns sample zone."; +ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description); + +// Create zone in Google Cloud DNS +Zone zone = dns.create(zoneInfo); +System.out.printf("Zone was created and assigned ID %s.%n", zone.id()); +``` + +You now have an empty zone hosted in Google Cloud DNS which is ready to be populated with DNS +records for domain name `someexampledomain.com.` Upon creating the zone, the cloud service +assigned a set of DNS servers to host records for this zone and +created the required SOA and NS records for the domain. The following snippet prints the list of servers +assigned to the zone created above. First, import + +```java +import java.util.List; +``` + +and then add + +```java +// Print assigned name servers +List nameServers = zone.nameServers(); +for(String nameServer : nameServers) { + System.out.println(nameServer); +} +``` + +You can now instruct your domain registrar to [update your domain name servers] (https://cloud.google.com/dns/update-name-servers). +As soon as this happens and the change propagates through cached values in DNS resolvers, +all the DNS queries will be directed to and answered by the Google Cloud DNS service. + +#### Creating DNS Records +Now that we have a zone, we can add some DNS records. The DNS records held within zones are +modified by "change requests". In this example, we create and apply a change request to +our zone that creates a DNS record of type A and points URL www.someexampledomain.com to +IP address 12.13.14.15. Start by adding + +```java +import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.DnsRecord; + +import java.util.concurrent.TimeUnit; +``` + +and proceed with: + +```java +// Prepare a www.someexampledomain.com. type A record with ttl of 24 hours +String ip = "12.13.14.15"; +DnsRecord toCreate = DnsRecord.builder("www.someexampledomain.com.", DnsRecord.Type.A) + .ttl(24, TimeUnit.HOURS) + .addRecord(ip) + .build(); + +// Make a change +ChangeRequest changeRequest = ChangeRequest.builder().add(toCreate).build(); + +// Build and apply the change request to our zone +changeRequest = zone.applyChangeRequest(changeRequest); +``` + +The `addRecord` method of `DnsRecord.Builder` accepts records in the form of +strings. The format of the strings depends on the type of the DNS record to be added. +More information on the supported DNS record types and record formats can be found [here](https://cloud.google.com/dns/what-is-cloud-dns#supported_record_types). + +If you already have a DNS record, Cloud DNS will return an error upon an attempt to create a duplicate of it. +You can modify the code above to create a DNS record or update it if it already exists by making the +following adjustment in your imports + +```java +import java.util.Iterator; +``` + +and in the code + +```java +// Make a change +ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate); + +// Verify the type A record does not exist yet. +// If it does exist, we will overwrite it with our prepared record. +Iterator recordIterator = zone.listDnsRecords().iterateAll(); +while (recordIterator.hasNext()) { + DnsRecord current = recordIterator.next(); + if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) { + changeBuilder.delete(current); + } +} + +// Build and apply the change request to our zone +ChangeRequest changeRequest = changeBuilder.build(); +zone.applyChangeRequest(changeRequest); +``` +You can find more information about changes in the [Cloud DNS documentation] (https://cloud.google.com/dns/what-is-cloud-dns#cloud_dns_api_concepts). + +When the change request is applied, it is registered with the Cloud DNS service for processing. We +can wait for its completion as follows: + +```java +while (ChangeRequest.Status.PENDING.equals(changeRequest.status())) { + try { + Thread.sleep(500L); + } catch (InterruptedException e) { + System.err.println("The thread was interrupted while waiting..."); + } + changeRequest = dns.getChangeRequest(zone.name(), changeRequest.id()); +} +System.out.println("The change request has been applied."); +``` + +Change requests are applied atomically to all the assigned DNS servers at once. Note that when this +happens, it may still take a while for the change to be registered by the DNS cache resolvers. +See more on this topic [here](https://cloud.google.com/dns/monitoring). + +#### Listing Zones and DNS Records +Suppose that you have added more zones and DNS records, and now you want to list them. +First, import the following (unless you have done so in the previous section): + +```java +import java.util.Iterator; +``` + +Then add the following code to list all your zones and DNS records. + +```java +// List all your zones +Iterator zoneIterator = dns.listZones().iterateAll(); +int counter = 1; +while (zoneIterator.hasNext()) { + System.out.printf("#%d.: %s%n%n", counter, zoneIterator.next()); + counter++; +} + +// List the DNS records in a particular zone +Iterator recordIterator = zone.listDnsRecords().iterateAll(); +System.out.println(String.format("DNS records inside %s:", zone.name())); +while (recordIterator.hasNext()) { + System.out.println(recordIterator.next()); +} +``` + +You can also list the history of change requests that were applied to a zone: + +```java +// List the change requests applied to a particular zone +Iterator changeIterator = zone.listChangeRequests().iterateAll(); +System.out.println(String.format("The history of changes in %s:", zone.name())); +while (changeIterator.hasNext()) { + System.out.println(changeIterator.next()); +} +``` + +#### Deleting Zones + +If you no longer want to host a zone in Cloud DNS, you can delete it. +First, you need to empty the zone by deleting all its records except for the default SOA and NS records. + +```java +// Make a change for deleting the records +ChangeRequest.Builder changeBuilder = ChangeRequest.builder(); +while (recordIterator.hasNext()) { + DnsRecord current = recordIterator.next(); + // SOA and NS records cannot be deleted + if (!DnsRecord.Type.SOA.equals(current.type()) && !DnsRecord.Type.NS.equals(current.type())) { + changeBuilder.delete(current); + } +} + +// Build and apply the change request to our zone if it contains records to delete +ChangeRequest changeRequest = changeBuilder.build(); +if (!changeRequest.deletions().isEmpty()) { + changeRequest = dns.applyChangeRequest(zoneName, changeRequest); + + // Wait for change to finish, but save data traffic by transferring only ID and status + Dns.ChangeRequestOption option = + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS); + while (ChangeRequest.Status.PENDING.equals(changeRequest.status())) { + System.out.println("Waiting for change to complete. Going to sleep for 500ms..."); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + System.err.println("The thread was interrupted while waiting for change request to be " + + "processed."); + } + + // Update the change, but fetch only change ID and status + changeRequest = dns.getChangeRequest(zoneName, changeRequest.id(), option); + } +} + +// Delete the zone +boolean result = dns.delete(zoneName); +if (result) { + System.out.println("Zone was deleted."); +} else { + System.out.println("Zone was not deleted because it does not exist."); +} +``` + +#### Complete Source Code + +We composed some of the aforementioned snippets into complete executable code samples. In +[CreateZones.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateZone.java) +we create a zone. In [CreateOrUpdateDnsRecords.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateDnsRecords.java) +we create a type A record for a zone, or update an existing type A record to a new IP address. We +demonstrate how to delete a zone in [DeleteZone.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java). +Finally, in [ManipulateZonesAndRecords.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecords.java) +we assemble all the code snippets together and create zone, create or update a DNS record, list zones, list DNS records, list changes, and +delete a zone. The applications assume that they are running on Compute Engine or from your own desktop. To run any of these examples on App +Engine, simply move the code from the main method to your application's servlet class and change the +print statements to display on your webpage. + +Troubleshooting +--------------- + +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). + +Java Versions +------------- + +Java 7 or above is required for using this client. + +Testing +------- + +This library has tools to help make tests for code using Cloud DNS. + +See [TESTING] to read more about testing. + +Versioning +---------- + +This library follows [Semantic Versioning] (http://semver.org/). + +It is currently in major version zero (``0.y.z``), which means that anything +may change at any time and the public API should not be considered +stable. + +Contributing +------------ + +Contributions to this library are always welcome and highly encouraged. + +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. + +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. + +License +------- + +Apache 2.0 - See [LICENSE] for more information. + + +[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md +[code-of-conduct]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct +[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE +[TESTING]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/TESTING.md#testing-code-that-uses-storage +[cloud-platform]: https://cloud.google.com/ + +[cloud-dns]: https://cloud.google.com/dns/ +[dns-api]: http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/dns/package-summary.html +[dns-activate]:https://cloud.google.com/dns/getting-started#prerequisites diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java new file mode 100644 index 000000000000..8a137285c357 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java @@ -0,0 +1,60 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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. + */ + +/** + * A client to the Google Cloud DNS. + * + *

      Here are two simple usage examples from within Compute/App Engine. + * + * The first snippet shows how to create a zone resource. The complete source code can be found on + * + * CreateAndListZones.java. Note that you need to replace the {@code domainName} with a domain + * name that you own and the ownership of which you verified with Google. + * + *

       {@code
      + * Dns dns = DnsOptions.defaultInstance().service();
      + * String zoneName = "my-unique-zone";
      + * String domainName = "someexampledomain.com.";
      + * String description = "This is a gcloud-java-dns sample zone.";
      + * ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description);
      + * Zone createdZone = dns.create(zoneInfo);
      + * } 
      + * + *

      The second example shows how to create records inside a zone. The complete code can be found + * on + * CreateAndListDnsRecords.java. + * + *

       {@code
      + * Dns dns = DnsOptions.defaultInstance().service();
      + * String zoneName = "my-unique-zone";
      + * Zone zone = dns.getZone(zoneName);
      + * String ip = "12.13.14.15";
      + * DnsRecord toCreate = DnsRecord.builder("www.someexampledomain.com.", DnsRecord.Type.A)
      + *   .ttl(24, TimeUnit.HOURS)
      + *   .addRecord(ip)
      + *   .build();
      + * ChangeRequest changeRequest = ChangeRequest.builder().add(toCreate).build();
      + * zone.applyChangeRequest(changeRequest);
      + * } 
      + * + *

      When using gcloud-java from outside of App/Compute Engine, you have to specify a + * project ID and provide + * credentials. + * + * @see Google Cloud DNS + */ +package com.google.gcloud.dns; diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java index e1a7c218c1b4..bfea46dfe039 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java @@ -49,7 +49,7 @@ public class ITDnsTest { private static final String PREFIX = "gcldjvit-"; - private static final Dns DNS = DnsOptions.builder().build().service(); + private static final Dns DNS = DnsOptions.defaultInstance().service(); private static final String ZONE_NAME1 = (PREFIX + UUID.randomUUID()).substring(0, 32); private static final String ZONE_NAME_EMPTY_DESCRIPTION = (PREFIX + UUID.randomUUID()).substring(0, 32); diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListDnsRecords.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateDnsRecords.java similarity index 89% rename from gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListDnsRecords.java rename to gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateDnsRecords.java index 1e47a12fed02..71327ba98a96 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListDnsRecords.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateDnsRecords.java @@ -32,9 +32,9 @@ import java.util.concurrent.TimeUnit; /** - * A snippet for Google Cloud DNS showing how to create a DNS records. + * A snippet for Google Cloud DNS showing how to create and update a DNS record. */ -public class CreateAndListDnsRecords { +public class CreateOrUpdateDnsRecords { public static void main(String... args) { // Create a service object. @@ -42,7 +42,7 @@ public static void main(String... args) { Dns dns = DnsOptions.defaultInstance().service(); // Change this to a zone name that exists within your project - String zoneName = "some-sample-zone"; + String zoneName = "my-unique-zone"; // Get zone from the service Zone zone = dns.getZone(zoneName); @@ -68,6 +68,7 @@ public static void main(String... args) { } // Build and apply the change request to our zone - zone.applyChangeRequest(changeBuilder.build()); + ChangeRequest changeRequest = changeBuilder.build(); + zone.applyChangeRequest(changeRequest); } } diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListZones.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateZone.java similarity index 70% rename from gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListZones.java rename to gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateZone.java index 21fdba2b7449..2c2ba211bd86 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateAndListZones.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateZone.java @@ -27,14 +27,11 @@ import com.google.gcloud.dns.Zone; import com.google.gcloud.dns.ZoneInfo; -import java.util.Iterator; - /** - * A snippet for Google Cloud DNS showing how to create a zone and list all zones in the project. - * You will need to change the {@code domainName} to a domain name, the ownership of which you - * should verify with Google. + * A snippet for Google Cloud DNS showing how to create a zone. You will need to change the {@code + * domainName} to a domain name, the ownership of which you should verify with Google. */ -public class CreateAndListZones { +public class CreateZone { public static void main(String... args) { // Create a service object @@ -42,21 +39,13 @@ public static void main(String... args) { Dns dns = DnsOptions.defaultInstance().service(); // Create a zone metadata object - String zoneName = "my_unique_zone"; // Change this zone name which is unique within your project + String zoneName = "my-unique-zone"; // Change this zone name which is unique within your project String domainName = "someexampledomain.com."; // Change this to a domain which you own String description = "This is a gcloud-java-dns sample zone."; ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description); // Create zone in Google Cloud DNS - Zone createdZone = dns.create(zoneInfo); - System.out.printf("Zone was created and assigned ID %s.%n", createdZone.id()); - - // Now list all the zones within this project - Iterator zoneIterator = dns.listZones().iterateAll(); - int counter = 1; - while (zoneIterator.hasNext()) { - System.out.printf("#%d.: %s%n%n", counter, zoneIterator.next().toString()); - counter++; - } + Zone zone = dns.create(zoneInfo); + System.out.printf("Zone was created and assigned ID %s.%n", zone.id()); } } diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java index 667a0d89e6ab..e841a4cd54ed 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java @@ -41,7 +41,7 @@ public static void main(String... args) { Dns dns = DnsOptions.defaultInstance().service(); // Change this to a zone name that exists within your project and that you want to delete. - String zoneName = "some-sample-zone"; + String zoneName = "my-unique-zone"; // Get iterator for the existing records which have to be deleted before deleting the zone Iterator recordIterator = dns.listDnsRecords(zoneName).iterateAll(); diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecords.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecords.java new file mode 100644 index 000000000000..4de262386d53 --- /dev/null +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecords.java @@ -0,0 +1,157 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file is referenced in README's and javadoc. Any change to this file should be reflected in + * the project's README's and package-info.java. + */ + +package com.google.gcloud.examples.dns.snippets; + +import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.Dns; +import com.google.gcloud.dns.DnsOptions; +import com.google.gcloud.dns.DnsRecord; +import com.google.gcloud.dns.Zone; +import com.google.gcloud.dns.ZoneInfo; + +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * A complete snippet for Google Cloud DNS showing how to create and delete a zone. It also shows + * how to create, list and delete DNS records, and how to list changes. + */ +public class ManipulateZonesAndRecords { + + public static void main(String... args) { + Dns dns = DnsOptions.defaultInstance().service(); + + // Create a zone metadata object + String zoneName = "my-unique-zone"; // Change this zone name which is unique within your project + String domainName = "someexampledomain.com."; // Change this to a domain which you own + String description = "This is a gcloud-java-dns sample zone."; + ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description); + + // Create zone in Google Cloud DNS + Zone zone = dns.create(zoneInfo); + System.out.printf("Zone was created and assigned ID %s.%n", zone.id()); + + // Print assigned name servers + List nameServers = zone.nameServers(); + for (String nameServer : nameServers) { + System.out.println(nameServer); + } + + // Prepare a www.someexampledomain.com. type A record with ttl of 24 hours + String ip = "12.13.14.15"; + DnsRecord toCreate = DnsRecord.builder("www.someexampledomain.com.", DnsRecord.Type.A) + .ttl(24, TimeUnit.HOURS) + .addRecord(ip) + .build(); + + // Make a change + ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate); + + // Verify the type A record does not exist yet. + // If it does exist, we will overwrite it with our prepared record. + Iterator recordIterator = zone.listDnsRecords().iterateAll(); + while (recordIterator.hasNext()) { + DnsRecord current = recordIterator.next(); + if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) { + changeBuilder.delete(current); + } + } + + // Build and apply the change request to our zone + ChangeRequest changeRequest = changeBuilder.build(); + zone.applyChangeRequest(changeRequest); + + while (ChangeRequest.Status.PENDING.equals(changeRequest.status())) { + try { + Thread.sleep(500L); + } catch (InterruptedException e) { + System.err.println("The thread was interrupted while waiting..."); + } + changeRequest = dns.getChangeRequest(zone.name(), changeRequest.id()); + } + System.out.println("The change request has been applied."); + + // List all your zones + Iterator zoneIterator = dns.listZones().iterateAll(); + int counter = 1; + while (zoneIterator.hasNext()) { + System.out.printf("#%d.: %s%n%n", counter, zoneIterator.next()); + counter++; + } + + // List the DNS records in a particular zone + recordIterator = zone.listDnsRecords().iterateAll(); + System.out.println(String.format("DNS records inside %s:", zone.name())); + while (recordIterator.hasNext()) { + System.out.println(recordIterator.next()); + } + + // List the change requests applied to a particular zone + Iterator changeIterator = zone.listChangeRequests().iterateAll(); + System.out.println(String.format("The history of changes in %s:", zone.name())); + while (changeIterator.hasNext()) { + System.out.println(changeIterator.next()); + } + + // Make a change for deleting the records + changeBuilder = ChangeRequest.builder(); + while (recordIterator.hasNext()) { + DnsRecord current = recordIterator.next(); + // SOA and NS records cannot be deleted + if (!DnsRecord.Type.SOA.equals(current.type()) && !DnsRecord.Type.NS.equals(current.type())) { + changeBuilder.delete(current); + } + } + + // Build and apply the change request to our zone if it contains records to delete + changeRequest = changeBuilder.build(); + if (!changeRequest.deletions().isEmpty()) { + changeRequest = dns.applyChangeRequest(zoneName, changeRequest); + + // Wait for change to finish, but save data traffic by transferring only ID and status + Dns.ChangeRequestOption option = + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS); + while (ChangeRequest.Status.PENDING.equals(changeRequest.status())) { + System.out.println("Waiting for change to complete. Going to sleep for 500ms..."); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + System.err.println("The thread was interrupted while waiting for change request to be " + + "processed."); + } + + // Update the change, but fetch only change ID and status + changeRequest = dns.getChangeRequest(zoneName, changeRequest.id(), option); + } + } + + // Delete the zone + boolean result = dns.delete(zoneName); + if (result) { + System.out.println("Zone was deleted."); + } else { + System.out.println("Zone was not deleted because it does not exist."); + } + } +} From 967c5c5a20f39ce232e415b371e7b3a038e453fa Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 17 Mar 2016 09:54:13 +0100 Subject: [PATCH 147/203] Add tests for restorable classes. Fix serialization issues --- .../gcloud/bigquery/SerializationTest.java | 17 +------ .../com/google/gcloud/AuthCredentials.java | 10 ++++ .../com/google/gcloud/ExceptionHandler.java | 22 +++++++++ .../google/gcloud/BaseSerializationTest.java | 19 +++++++- .../com/google/gcloud/SerializationTest.java | 46 ++++++++++++++++++- .../gcloud/datastore/SerializationTest.java | 2 - .../resourcemanager/SerializationTest.java | 4 +- .../gcloud/storage/SerializationTest.java | 29 ++---------- 8 files changed, 101 insertions(+), 48 deletions(-) diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java index f64946e062d7..087d263b0fa4 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java @@ -16,15 +16,10 @@ package com.google.gcloud.bigquery; -import static org.junit.Assert.assertEquals; - import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gcloud.AuthCredentials; import com.google.gcloud.BaseSerializationTest; -import com.google.gcloud.RestorableState; -import com.google.gcloud.RetryParams; -import com.google.gcloud.WriteChannel; import com.google.gcloud.bigquery.StandardTableDefinition.StreamingBuffer; import org.junit.Test; @@ -235,7 +230,6 @@ public Serializable[] serializableObjects() { .build(); BigQueryOptions otherOptions = options.toBuilder() .projectId("p2") - .retryParams(RetryParams.defaultInstance()) .authCredentials(null) .build(); return new Serializable[]{DOMAIN_ACCESS, GROUP_ACCESS, USER_ACCESS, VIEW_ACCESS, DATASET_ID, @@ -254,18 +248,11 @@ public Serializable[] serializableObjects() { @Test public void testWriteChannelState() throws IOException, ClassNotFoundException { - BigQueryOptions options = BigQueryOptions.builder() - .projectId("p2") - .retryParams(RetryParams.defaultInstance()) - .build(); + BigQueryOptions options = BigQueryOptions.builder().projectId("p2").build(); // avoid closing when you don't want partial writes upon failure @SuppressWarnings("resource") TableDataWriteChannel writer = new TableDataWriteChannel(options, LOAD_CONFIGURATION, "upload-id"); - RestorableState state = writer.capture(); - RestorableState deserializedState = serializeAndDeserialize(state); - assertEquals(state, deserializedState); - assertEquals(state.hashCode(), deserializedState.hashCode()); - assertEquals(state.toString(), deserializedState.toString()); + assertRestorable(writer); } } diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java b/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java index 6f9e09ca04bc..38265a26be2e 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java @@ -276,6 +276,16 @@ private static class NoAuthCredentialsState public AuthCredentials restore() { return INSTANCE; } + + @Override + public int hashCode() { + return getClass().getName().hashCode(); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof NoAuthCredentialsState; + } } @Override diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/ExceptionHandler.java b/gcloud-java-core/src/main/java/com/google/gcloud/ExceptionHandler.java index 39d4c4e75a1a..0dbcbeb65378 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/ExceptionHandler.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/ExceptionHandler.java @@ -26,6 +26,7 @@ import java.io.Serializable; import java.lang.reflect.Method; +import java.util.Objects; import java.util.Set; import java.util.concurrent.Callable; @@ -259,6 +260,27 @@ boolean shouldRetry(Exception ex) { return retryResult == Interceptor.RetryResult.RETRY; } + @Override + public int hashCode() { + return Objects.hash(interceptors, retriableExceptions, nonRetriableExceptions, retryInfo); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ExceptionHandler)) { + return false; + } + ExceptionHandler other = (ExceptionHandler) obj; + return Objects.equals(interceptors, other.interceptors) + && Objects.equals(retriableExceptions, other.retriableExceptions) + && Objects.equals(nonRetriableExceptions, other.nonRetriableExceptions) + && Objects.equals(retryInfo, other.retryInfo); + + } + /** * Returns an instance which retry any checked exception and abort on any runtime exception. */ diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java index 533dfcde6ad8..a8136bfbf0cc 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java @@ -34,6 +34,9 @@ */ public abstract class BaseSerializationTest { + /** + * Returns all objects for which correct serialization must be tested. + */ public abstract Serializable[] serializableObjects(); @Test @@ -50,8 +53,7 @@ public void testSerializableObjects() throws Exception { } @SuppressWarnings("unchecked") - public T serializeAndDeserialize(T obj) - throws IOException, ClassNotFoundException { + public T serializeAndDeserialize(T obj) throws IOException, ClassNotFoundException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { output.writeObject(obj); @@ -61,4 +63,17 @@ public T serializeAndDeserialize(T obj) return (T) input.readObject(); } } + + /** + * Checks whether the state of a restorable object can correctly be captured, serialized and + * restored. + */ + public void assertRestorable(Restorable restorable) throws IOException, + ClassNotFoundException { + RestorableState state = restorable.capture(); + RestorableState deserializedState = serializeAndDeserialize(state); + assertEquals(state, deserializedState); + assertEquals(state.hashCode(), deserializedState.hashCode()); + assertEquals(state.toString(), deserializedState.toString()); + } } diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java index aec9158e1ee0..46f1f73563f7 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java @@ -18,16 +18,60 @@ import com.google.common.collect.ImmutableList; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.Serializable; public class SerializationTest extends BaseSerializationTest { + private static final ExceptionHandler EXCEPTION_HANDLER = ExceptionHandler.defaultInstance(); + private static final Identity IDENTITY = Identity.allAuthenticatedUsers(); private static final PageImpl PAGE = new PageImpl<>(null, "cursor", ImmutableList.of("string1", "string2")); private static final RetryParams RETRY_PARAMS = RetryParams.defaultInstance(); + private static final String JSON_KEY = "{\n" + + " \"private_key_id\": \"somekeyid\",\n" + + " \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS" + + "kAgEAAoIBAQC+K2hSuFpAdrJI\\nnCgcDz2M7t7bjdlsadsasad+fvRSW6TjNQZ3p5LLQY1kSZRqBqylRkzteMOyHg" + + "aR\\n0Pmxh3ILCND5men43j3h4eDbrhQBuxfEMalkG92sL+PNQSETY2tnvXryOvmBRwa/\\nQP/9dJfIkIDJ9Fw9N4" + + "Bhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nknddadwkwewcVxHFhcZJO+XWf6ofLUXpRwiTZakGMn8EE1uVa2" + + "LgczOjwWHGi99MFjxSer5m9\\n1tCa3/KEGKiS/YL71JvjwX3mb+cewlkcmweBKZHM2JPTk0ZednFSpVZMtycjkbLa" + + "\\ndYOS8V85AgMBewECggEBAKksaldajfDZDV6nGqbFjMiizAKJolr/M3OQw16K6o3/\\n0S31xIe3sSlgW0+UbYlF" + + "4U8KifhManD1apVSC3csafaspP4RZUHFhtBywLO9pR5c\\nr6S5aLp+gPWFyIp1pfXbWGvc5VY/v9x7ya1VEa6rXvL" + + "sKupSeWAW4tMj3eo/64ge\\nsdaceaLYw52KeBYiT6+vpsnYrEkAHO1fF/LavbLLOFJmFTMxmsNaG0tuiJHgjshB\\" + + "n82DpMCbXG9YcCgI/DbzuIjsdj2JC1cascSP//3PmefWysucBQe7Jryb6NQtASmnv\\nCdDw/0jmZTEjpe4S1lxfHp" + + "lAhHFtdgYTvyYtaLZiVVkCgYEA8eVpof2rceecw/I6\\n5ng1q3Hl2usdWV/4mZMvR0fOemacLLfocX6IYxT1zA1FF" + + "JlbXSRsJMf/Qq39mOR2\\nSpW+hr4jCoHeRVYLgsbggtrevGmILAlNoqCMpGZ6vDmJpq6ECV9olliDvpPgWOP+\\nm" + + "YPDreFBGxWvQrADNbRt2dmGsrsCgYEAyUHqB2wvJHFqdmeBsaacewzV8x9WgmeX\\ngUIi9REwXlGDW0Mz50dxpxcK" + + "CAYn65+7TCnY5O/jmL0VRxU1J2mSWyWTo1C+17L0\\n3fUqjxL1pkefwecxwecvC+gFFYdJ4CQ/MHHXU81Lwl1iWdF" + + "Cd2UoGddYaOF+KNeM\\nHC7cmqra+JsCgYEAlUNywzq8nUg7282E+uICfCB0LfwejuymR93CtsFgb7cRd6ak\\nECR" + + "8FGfCpH8ruWJINllbQfcHVCX47ndLZwqv3oVFKh6pAS/vVI4dpOepP8++7y1u\\ncoOvtreXCX6XqfrWDtKIvv0vjl" + + "HBhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nkndj5uNl5SiuVxHFhcZJO+XWf6ofLUregtevZakGMn8EE1uVa" + + "2AY7eafmoU/nZPT\\n00YB0TBATdCbn/nBSuKDESkhSg9s2GEKQZG5hBmL5uCMfo09z3SfxZIhJdlerreP\\nJ7gSi" + + "dI12N+EZxYd4xIJh/HFDgp7RRO87f+WJkofMQKBgGTnClK1VMaCRbJZPriw\\nEfeFCoOX75MxKwXs6xgrw4W//AYG" + + "GUjDt83lD6AZP6tws7gJ2IwY/qP7+lyhjEqN\\nHtfPZRGFkGZsdaksdlaksd323423d+15/UvrlRSFPNj1tWQmNKk" + + "XyRDW4IG1Oa2p\\nrALStNBx5Y9t0/LQnFI4w3aG\\n-----END PRIVATE KEY-----\\n\",\n" + + " \"client_email\": \"someclientid@developer.gserviceaccount.com\",\n" + + " \"client_id\": \"someclientid.apps.googleusercontent.com\",\n" + + " \"type\": \"service_account\"\n" + + "}"; @Override public Serializable[] serializableObjects() { - return new Serializable[]{PAGE, RETRY_PARAMS}; + return new Serializable[]{EXCEPTION_HANDLER, IDENTITY, PAGE, RETRY_PARAMS}; + } + + @Test + public void testAuthCredentialState() throws IOException, ClassNotFoundException { + AuthCredentials credentials = AuthCredentials.createApplicationDefaults(); + assertRestorable(credentials); + credentials = AuthCredentials.createForAppEngine(); + assertRestorable(credentials); + credentials = AuthCredentials.noAuth(); + assertRestorable(credentials); + credentials = AuthCredentials.createForJson(new ByteArrayInputStream(JSON_KEY.getBytes())); + assertRestorable(credentials); } } diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java index 7a6f065d6ca6..5cbf63b9624d 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java @@ -21,7 +21,6 @@ import com.google.api.services.datastore.DatastoreV1; import com.google.gcloud.AuthCredentials; import com.google.gcloud.BaseSerializationTest; -import com.google.gcloud.RetryParams; import com.google.gcloud.datastore.StructuredQuery.CompositeFilter; import com.google.gcloud.datastore.StructuredQuery.OrderBy; import com.google.gcloud.datastore.StructuredQuery.Projection; @@ -112,7 +111,6 @@ public java.io.Serializable[] serializableObjects() { .build(); DatastoreOptions otherOptions = options.toBuilder() .namespace("ns1") - .retryParams(RetryParams.defaultInstance()) .authCredentials(null) .force(true) .build(); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index 2dcd3f9d3e7b..786865e0f872 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -18,10 +18,9 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.gcloud.Identity; import com.google.gcloud.BaseSerializationTest; +import com.google.gcloud.Identity; import com.google.gcloud.PageImpl; -import com.google.gcloud.RetryParams; import java.io.Serializable; import java.util.Collections; @@ -55,7 +54,6 @@ public Serializable[] serializableObjects() { ResourceManagerOptions options = ResourceManagerOptions.builder().build(); ResourceManagerOptions otherOptions = options.toBuilder() .projectId("some-unnecessary-project-ID") - .retryParams(RetryParams.defaultInstance()) .build(); return new Serializable[]{PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PROJECT, PAGE_RESULT, PROJECT_GET_OPTION, PROJECT_LIST_OPTION, POLICY, options, otherOptions}; diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java index ee3d7c946312..392636ccd100 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java @@ -16,16 +16,11 @@ package com.google.gcloud.storage; -import static org.junit.Assert.assertEquals; - import com.google.common.collect.ImmutableMap; import com.google.gcloud.AuthCredentials; import com.google.gcloud.BaseSerializationTest; import com.google.gcloud.PageImpl; import com.google.gcloud.ReadChannel; -import com.google.gcloud.RestorableState; -import com.google.gcloud.RetryParams; -import com.google.gcloud.WriteChannel; import com.google.gcloud.storage.Acl.Project.ProjectRole; import com.google.gcloud.storage.spi.StorageRpc; @@ -81,7 +76,6 @@ public Serializable[] serializableObjects() { .build(); StorageOptions otherOptions = options.toBuilder() .projectId("p2") - .retryParams(RetryParams.defaultInstance()) .authCredentials(null) .build(); return new Serializable[]{ACL_DOMAIN, ACL_GROUP, ACL_PROJECT_, ACL_USER, ACL_RAW, ACL, @@ -92,34 +86,19 @@ public Serializable[] serializableObjects() { @Test public void testReadChannelState() throws IOException, ClassNotFoundException { - StorageOptions options = StorageOptions.builder() - .projectId("p2") - .retryParams(RetryParams.defaultInstance()) - .build(); + StorageOptions options = StorageOptions.builder().projectId("p2").build(); ReadChannel reader = new BlobReadChannel(options, BlobId.of("b", "n"), EMPTY_RPC_OPTIONS); - RestorableState state = reader.capture(); - RestorableState deserializedState = serializeAndDeserialize(state); - assertEquals(state, deserializedState); - assertEquals(state.hashCode(), deserializedState.hashCode()); - assertEquals(state.toString(), deserializedState.toString()); - reader.close(); + assertRestorable(reader); } @Test public void testWriteChannelState() throws IOException, ClassNotFoundException { - StorageOptions options = StorageOptions.builder() - .projectId("p2") - .retryParams(RetryParams.defaultInstance()) - .build(); + StorageOptions options = StorageOptions.builder().projectId("p2").build(); // avoid closing when you don't want partial writes to GCS upon failure @SuppressWarnings("resource") BlobWriteChannel writer = new BlobWriteChannel(options, BlobInfo.builder(BlobId.of("b", "n")).build(), "upload-id"); - RestorableState state = writer.capture(); - RestorableState deserializedState = serializeAndDeserialize(state); - assertEquals(state, deserializedState); - assertEquals(state.hashCode(), deserializedState.hashCode()); - assertEquals(state.toString(), deserializedState.toString()); + assertRestorable(writer); } } From 034432a4915439f8323cc898e38c47f5cd4f1788 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 17 Mar 2016 17:28:55 +0100 Subject: [PATCH 148/203] Remove serialization test for ApplicationDefaultAuthCredentials --- .../src/test/java/com/google/gcloud/SerializationTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java index 46f1f73563f7..a9526a42d7d7 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java @@ -65,9 +65,7 @@ public Serializable[] serializableObjects() { @Test public void testAuthCredentialState() throws IOException, ClassNotFoundException { - AuthCredentials credentials = AuthCredentials.createApplicationDefaults(); - assertRestorable(credentials); - credentials = AuthCredentials.createForAppEngine(); + AuthCredentials credentials = AuthCredentials.createForAppEngine(); assertRestorable(credentials); credentials = AuthCredentials.noAuth(); assertRestorable(credentials); From ce597930debaa6ab8ffc16af25547e1bfa7283a6 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 17 Mar 2016 18:59:46 +0100 Subject: [PATCH 149/203] Add restorableObjects method to BaseSerializationTest --- .../gcloud/bigquery/SerializationTest.java | 12 +++--- .../com/google/gcloud/ExceptionHandler.java | 1 - .../google/gcloud/BaseSerializationTest.java | 39 +++++++++++-------- .../com/google/gcloud/SerializationTest.java | 21 +++++----- .../gcloud/datastore/SerializationTest.java | 8 +++- .../resourcemanager/SerializationTest.java | 8 +++- .../gcloud/storage/SerializationTest.java | 18 +++------ 7 files changed, 57 insertions(+), 50 deletions(-) diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java index 087d263b0fa4..74644216c109 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java @@ -20,11 +20,9 @@ import com.google.common.collect.ImmutableMap; import com.google.gcloud.AuthCredentials; import com.google.gcloud.BaseSerializationTest; +import com.google.gcloud.Restorable; import com.google.gcloud.bigquery.StandardTableDefinition.StreamingBuffer; -import org.junit.Test; - -import java.io.IOException; import java.io.Serializable; import java.nio.charset.StandardCharsets; import java.util.List; @@ -223,7 +221,7 @@ public class SerializationTest extends BaseSerializationTest { private static final Job JOB = new Job(BIGQUERY, new JobInfo.BuilderImpl(JOB_INFO)); @Override - public Serializable[] serializableObjects() { + protected Serializable[] serializableObjects() { BigQueryOptions options = BigQueryOptions.builder() .projectId("p1") .authCredentials(AuthCredentials.createForAppEngine()) @@ -246,13 +244,13 @@ public Serializable[] serializableObjects() { BigQuery.JobListOption.allUsers(), DATASET, TABLE, JOB, options, otherOptions}; } - @Test - public void testWriteChannelState() throws IOException, ClassNotFoundException { + @Override + protected Restorable[] restorableObjects() { BigQueryOptions options = BigQueryOptions.builder().projectId("p2").build(); // avoid closing when you don't want partial writes upon failure @SuppressWarnings("resource") TableDataWriteChannel writer = new TableDataWriteChannel(options, LOAD_CONFIGURATION, "upload-id"); - assertRestorable(writer); + return new Restorable[]{writer}; } } diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/ExceptionHandler.java b/gcloud-java-core/src/main/java/com/google/gcloud/ExceptionHandler.java index 0dbcbeb65378..0b3c923d1eb9 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/ExceptionHandler.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/ExceptionHandler.java @@ -278,7 +278,6 @@ public boolean equals(Object obj) { && Objects.equals(retriableExceptions, other.retriableExceptions) && Objects.equals(nonRetriableExceptions, other.nonRetriableExceptions) && Objects.equals(retryInfo, other.retryInfo); - } /** diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java index a8136bfbf0cc..e9ab3d47984b 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/BaseSerializationTest.java @@ -16,6 +16,7 @@ package com.google.gcloud; +import static com.google.common.base.MoreObjects.firstNonNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; @@ -30,18 +31,26 @@ /** * Base class for serialization tests. To use this class in your tests override the - * {@code serializableObjects()} method to return all objects that must be serializable. + * {@code serializableObjects()} method to return all objects that must be serializable. Also + * override {@code restorableObjects()} method to return all restorable objects whose state must be + * tested for proper serialization. Both methods can return {@code null} if no such object needs to + * be tested. */ public abstract class BaseSerializationTest { /** * Returns all objects for which correct serialization must be tested. */ - public abstract Serializable[] serializableObjects(); + protected abstract Serializable[] serializableObjects(); + + /** + * Returns all restorable objects whose state must be tested for proper serialization. + */ + protected abstract Restorable[] restorableObjects(); @Test public void testSerializableObjects() throws Exception { - for (Serializable obj : serializableObjects()) { + for (Serializable obj : firstNonNull(serializableObjects(), new Serializable[0])) { Object copy = serializeAndDeserialize(obj); assertEquals(obj, obj); assertEquals(obj, copy); @@ -52,6 +61,17 @@ public void testSerializableObjects() throws Exception { } } + @Test + public void testRestorableObjects() throws Exception { + for (Restorable restorable : firstNonNull(restorableObjects(), new Restorable[0])) { + RestorableState state = restorable.capture(); + RestorableState deserializedState = serializeAndDeserialize(state); + assertEquals(state, deserializedState); + assertEquals(state.hashCode(), deserializedState.hashCode()); + assertEquals(state.toString(), deserializedState.toString()); + } + } + @SuppressWarnings("unchecked") public T serializeAndDeserialize(T obj) throws IOException, ClassNotFoundException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); @@ -63,17 +83,4 @@ public T serializeAndDeserialize(T obj) throws IOException, ClassNotFoundExc return (T) input.readObject(); } } - - /** - * Checks whether the state of a restorable object can correctly be captured, serialized and - * restored. - */ - public void assertRestorable(Restorable restorable) throws IOException, - ClassNotFoundException { - RestorableState state = restorable.capture(); - RestorableState deserializedState = serializeAndDeserialize(state); - assertEquals(state, deserializedState); - assertEquals(state.hashCode(), deserializedState.hashCode()); - assertEquals(state.toString(), deserializedState.toString()); - } } diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java index a9526a42d7d7..c4bcfcc13b1c 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java @@ -18,8 +18,6 @@ import com.google.common.collect.ImmutableList; -import org.junit.Test; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.Serializable; @@ -59,17 +57,18 @@ public class SerializationTest extends BaseSerializationTest { + "}"; @Override - public Serializable[] serializableObjects() { + protected Serializable[] serializableObjects() { return new Serializable[]{EXCEPTION_HANDLER, IDENTITY, PAGE, RETRY_PARAMS}; } - @Test - public void testAuthCredentialState() throws IOException, ClassNotFoundException { - AuthCredentials credentials = AuthCredentials.createForAppEngine(); - assertRestorable(credentials); - credentials = AuthCredentials.noAuth(); - assertRestorable(credentials); - credentials = AuthCredentials.createForJson(new ByteArrayInputStream(JSON_KEY.getBytes())); - assertRestorable(credentials); + @Override + protected Restorable[] restorableObjects() { + try { + return new Restorable[]{AuthCredentials.createForAppEngine(), AuthCredentials.noAuth(), + AuthCredentials.createForJson(new ByteArrayInputStream(JSON_KEY.getBytes()))}; + } catch (IOException ex) { + // never reached + throw new RuntimeException(ex); + } } } diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java index 5cbf63b9624d..3ea74ef7c4d6 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java @@ -21,6 +21,7 @@ import com.google.api.services.datastore.DatastoreV1; import com.google.gcloud.AuthCredentials; import com.google.gcloud.BaseSerializationTest; +import com.google.gcloud.Restorable; import com.google.gcloud.datastore.StructuredQuery.CompositeFilter; import com.google.gcloud.datastore.StructuredQuery.OrderBy; import com.google.gcloud.datastore.StructuredQuery.Projection; @@ -103,7 +104,7 @@ public class SerializationTest extends BaseSerializationTest { private static final ProjectionEntity PROJECTION_ENTITY = ProjectionEntity.fromPb(ENTITY1.toPb()); @Override - public java.io.Serializable[] serializableObjects() { + protected java.io.Serializable[] serializableObjects() { DatastoreOptions options = DatastoreOptions.builder() .authCredentials(AuthCredentials.createForAppEngine()) .normalizeDataset(false) @@ -120,4 +121,9 @@ public java.io.Serializable[] serializableObjects() { EMBEDDED_ENTITY_VALUE2, EMBEDDED_ENTITY_VALUE3, LIST_VALUE, LONG_VALUE, DOUBLE_VALUE, BOOLEAN_VALUE, DATE_AND_TIME_VALUE, BLOB_VALUE, RAW_VALUE, options, otherOptions}; } + + @Override + protected Restorable[] restorableObjects() { + return null; + } } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index 786865e0f872..5bad065003e0 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -21,6 +21,7 @@ import com.google.gcloud.BaseSerializationTest; import com.google.gcloud.Identity; import com.google.gcloud.PageImpl; +import com.google.gcloud.Restorable; import java.io.Serializable; import java.util.Collections; @@ -50,7 +51,7 @@ public class SerializationTest extends BaseSerializationTest { .build(); @Override - public Serializable[] serializableObjects() { + protected Serializable[] serializableObjects() { ResourceManagerOptions options = ResourceManagerOptions.builder().build(); ResourceManagerOptions otherOptions = options.toBuilder() .projectId("some-unnecessary-project-ID") @@ -58,4 +59,9 @@ public Serializable[] serializableObjects() { return new Serializable[]{PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PROJECT, PAGE_RESULT, PROJECT_GET_OPTION, PROJECT_LIST_OPTION, POLICY, options, otherOptions}; } + + @Override + protected Restorable[] restorableObjects() { + return null; + } } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java index 392636ccd100..6aae7b1a0cb2 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java @@ -21,12 +21,10 @@ import com.google.gcloud.BaseSerializationTest; import com.google.gcloud.PageImpl; import com.google.gcloud.ReadChannel; +import com.google.gcloud.Restorable; import com.google.gcloud.storage.Acl.Project.ProjectRole; import com.google.gcloud.storage.spi.StorageRpc; -import org.junit.Test; - -import java.io.IOException; import java.io.Serializable; import java.util.Collections; import java.util.Map; @@ -69,7 +67,7 @@ public class SerializationTest extends BaseSerializationTest { private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); @Override - public Serializable[] serializableObjects() { + protected Serializable[] serializableObjects() { StorageOptions options = StorageOptions.builder() .projectId("p1") .authCredentials(AuthCredentials.createForAppEngine()) @@ -84,21 +82,15 @@ public Serializable[] serializableObjects() { BUCKET_LIST_OPTIONS, BUCKET_SOURCE_OPTIONS, BUCKET_TARGET_OPTIONS, options, otherOptions}; } - @Test - public void testReadChannelState() throws IOException, ClassNotFoundException { + @Override + protected Restorable[] restorableObjects() { StorageOptions options = StorageOptions.builder().projectId("p2").build(); ReadChannel reader = new BlobReadChannel(options, BlobId.of("b", "n"), EMPTY_RPC_OPTIONS); - assertRestorable(reader); - } - - @Test - public void testWriteChannelState() throws IOException, ClassNotFoundException { - StorageOptions options = StorageOptions.builder().projectId("p2").build(); // avoid closing when you don't want partial writes to GCS upon failure @SuppressWarnings("resource") BlobWriteChannel writer = new BlobWriteChannel(options, BlobInfo.builder(BlobId.of("b", "n")).build(), "upload-id"); - assertRestorable(writer); + return new Restorable[]{reader, writer}; } } From 0a113cd7431722d0c10d849a2760a41eb2ce4d87 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 18 Mar 2016 14:25:25 +0100 Subject: [PATCH 150/203] Remove default contentType from Storage's compose --- .../java/com/google/gcloud/storage/spi/DefaultStorageRpc.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java index aa6085e161ed..3f465e0ab20e 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java @@ -319,9 +319,6 @@ private Storage.Objects.Delete deleteRequest(StorageObject blob, Map public StorageObject compose(Iterable sources, StorageObject target, Map targetOptions) { ComposeRequest request = new ComposeRequest(); - if (target.getContentType() == null) { - target.setContentType("application/octet-stream"); - } request.setDestination(target); List sourceObjects = new ArrayList<>(); for (StorageObject source : sources) { From 8840b33a9cfbb2ab780c846e12131716fda8e0ab Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 18 Mar 2016 14:56:46 +0100 Subject: [PATCH 151/203] Remove default contentType from Bucket's create --- .../com/google/gcloud/storage/Bucket.java | 50 +++++++++++++++---- .../com/google/gcloud/storage/Storage.java | 2 - .../com/google/gcloud/storage/BucketTest.java | 12 ++--- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java index 5df305ff371c..e44bd60d785c 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java @@ -22,7 +22,6 @@ import static com.google.gcloud.storage.Bucket.BucketSourceOption.toSourceOptions; import com.google.common.base.Function; -import com.google.common.base.MoreObjects; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gcloud.Page; @@ -633,15 +632,13 @@ public List get(String blobName1, String blobName2, String... blobNames) { * * @param blob a blob name * @param content the blob content - * @param contentType the blob content type. If {@code null} then - * {@value com.google.gcloud.storage.Storage#DEFAULT_CONTENT_TYPE} is used. + * @param contentType the blob content type * @param options options for blob creation * @return a complete blob information * @throws StorageException upon failure */ public Blob create(String blob, byte[] content, String contentType, BlobTargetOption... options) { - BlobInfo blobInfo = BlobInfo.builder(BlobId.of(name(), blob)) - .contentType(MoreObjects.firstNonNull(contentType, Storage.DEFAULT_CONTENT_TYPE)).build(); + BlobInfo blobInfo = BlobInfo.builder(BlobId.of(name(), blob)).contentType(contentType).build(); StorageRpc.Tuple target = BlobTargetOption.toTargetOptions(blobInfo, options); return storage.create(target.x(), content, target.y()); @@ -654,16 +651,51 @@ public Blob create(String blob, byte[] content, String contentType, BlobTargetOp * * @param blob a blob name * @param content the blob content as a stream - * @param contentType the blob content type. If {@code null} then - * {@value com.google.gcloud.storage.Storage#DEFAULT_CONTENT_TYPE} is used. + * @param contentType the blob content type * @param options options for blob creation * @return a complete blob information * @throws StorageException upon failure */ public Blob create(String blob, InputStream content, String contentType, BlobWriteOption... options) { - BlobInfo blobInfo = BlobInfo.builder(BlobId.of(name(), blob)) - .contentType(MoreObjects.firstNonNull(contentType, Storage.DEFAULT_CONTENT_TYPE)).build(); + BlobInfo blobInfo = BlobInfo.builder(BlobId.of(name(), blob)).contentType(contentType).build(); + StorageRpc.Tuple write = + BlobWriteOption.toWriteOptions(blobInfo, options); + return storage.create(write.x(), content, write.y()); + } + + /** + * Creates a new blob in this bucket. Direct upload is used to upload {@code content}. + * For large content, {@link Blob#writer(com.google.gcloud.storage.Storage.BlobWriteOption...)} + * is recommended as it uses resumable upload. MD5 and CRC32C hashes of {@code content} are + * computed and used for validating transferred data. + * + * @param blob a blob name + * @param content the blob content + * @param options options for blob creation + * @return a complete blob information + * @throws StorageException upon failure + */ + public Blob create(String blob, byte[] content, BlobTargetOption... options) { + BlobInfo blobInfo = BlobInfo.builder(BlobId.of(name(), blob)).build(); + StorageRpc.Tuple target = + BlobTargetOption.toTargetOptions(blobInfo, options); + return storage.create(target.x(), content, target.y()); + } + + /** + * Creates a new blob in this bucket. Direct upload is used to upload {@code content}. + * For large content, {@link Blob#writer(com.google.gcloud.storage.Storage.BlobWriteOption...)} + * is recommended as it uses resumable upload. + * + * @param blob a blob name + * @param content the blob content as a stream + * @param options options for blob creation + * @return a complete blob information + * @throws StorageException upon failure + */ + public Blob create(String blob, InputStream content, BlobWriteOption... options) { + BlobInfo blobInfo = BlobInfo.builder(BlobId.of(name(), blob)).build(); StorageRpc.Tuple write = BlobWriteOption.toWriteOptions(blobInfo, options); return storage.create(write.x(), content, write.y()); diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index c30111e50835..35fc6117cbc2 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -53,8 +53,6 @@ */ public interface Storage extends Service { - String DEFAULT_CONTENT_TYPE = "application/octet-stream"; - enum PredefinedAcl { AUTHENTICATED_READ("authenticatedRead"), ALL_AUTHENTICATED_USERS("allAuthenticatedUsers"), diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java index 236411e0c2d8..53056c39c0dc 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java @@ -293,16 +293,16 @@ public void testCreate() throws Exception { } @Test - public void testCreateNullContentType() throws Exception { + public void testCreateNoContentType() throws Exception { initializeExpectedBucket(5); - BlobInfo info = BlobInfo.builder("b", "n").contentType(Storage.DEFAULT_CONTENT_TYPE).build(); + BlobInfo info = BlobInfo.builder("b", "n").build(); Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info)); byte[] content = {0xD, 0xE, 0xA, 0xD}; expect(storage.options()).andReturn(mockOptions); expect(storage.create(info, content)).andReturn(expectedBlob); replay(storage); initializeBucket(); - Blob blob = bucket.create("n", content, null); + Blob blob = bucket.create("n", content); assertEquals(expectedBlob, blob); } @@ -388,9 +388,9 @@ public void testCreateFromStream() throws Exception { } @Test - public void testCreateFromStreamNullContentType() throws Exception { + public void testCreateFromStreamNoContentType() throws Exception { initializeExpectedBucket(5); - BlobInfo info = BlobInfo.builder("b", "n").contentType(Storage.DEFAULT_CONTENT_TYPE).build(); + BlobInfo info = BlobInfo.builder("b", "n").build(); Blob expectedBlob = new Blob(serviceMockReturnsOptions, new BlobInfo.BuilderImpl(info)); byte[] content = {0xD, 0xE, 0xA, 0xD}; InputStream streamContent = new ByteArrayInputStream(content); @@ -398,7 +398,7 @@ public void testCreateFromStreamNullContentType() throws Exception { expect(storage.create(info, streamContent)).andReturn(expectedBlob); replay(storage); initializeBucket(); - Blob blob = bucket.create("n", streamContent, null); + Blob blob = bucket.create("n", streamContent); assertEquals(expectedBlob, blob); } From 5c4e2886f8257470932341191b699e1d621c890e Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 18 Mar 2016 16:01:58 +0100 Subject: [PATCH 152/203] Make NoAuthCredentials constructor private --- .../src/main/java/com/google/gcloud/AuthCredentials.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java b/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java index 38265a26be2e..27cafc181505 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java @@ -288,6 +288,8 @@ public boolean equals(Object obj) { } } + private NoAuthCredentials() {} + @Override public GoogleCredentials credentials() { return null; From 19e0c6e9736bc13a26d6a8f811322ee97e477200 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 18 Mar 2016 16:03:46 +0100 Subject: [PATCH 153/203] Add IamPolicy to SerializationTest --- .../com/google/gcloud/SerializationTest.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java index c4bcfcc13b1c..194479ac365c 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java @@ -24,11 +24,34 @@ public class SerializationTest extends BaseSerializationTest { + private static class SomeIamPolicy extends IamPolicy { + + private static final long serialVersionUID = 271243551016958285L; + + private static class Builder extends IamPolicy.Builder { + + @Override + public SomeIamPolicy build() { + return new SomeIamPolicy(this); + } + } + + protected SomeIamPolicy(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder(); + } + } + private static final ExceptionHandler EXCEPTION_HANDLER = ExceptionHandler.defaultInstance(); private static final Identity IDENTITY = Identity.allAuthenticatedUsers(); private static final PageImpl PAGE = new PageImpl<>(null, "cursor", ImmutableList.of("string1", "string2")); private static final RetryParams RETRY_PARAMS = RetryParams.defaultInstance(); + private static final SomeIamPolicy SOME_IAM_POLICY = new SomeIamPolicy.Builder().build(); private static final String JSON_KEY = "{\n" + " \"private_key_id\": \"somekeyid\",\n" + " \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS" @@ -58,7 +81,7 @@ public class SerializationTest extends BaseSerializationTest { @Override protected Serializable[] serializableObjects() { - return new Serializable[]{EXCEPTION_HANDLER, IDENTITY, PAGE, RETRY_PARAMS}; + return new Serializable[]{EXCEPTION_HANDLER, IDENTITY, PAGE, RETRY_PARAMS, SOME_IAM_POLICY}; } @Override From 83ddb08d0e6aae40707ab8b9d071fa62854e8769 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 18 Mar 2016 16:08:37 +0100 Subject: [PATCH 154/203] Add equals and hashCode to exceptions. Add exceptions to serialization tests --- .../gcloud/bigquery/BigQueryException.java | 18 ++++++++ .../gcloud/bigquery/SerializationTest.java | 4 +- .../google/gcloud/BaseServiceException.java | 45 ++++++++++++++----- .../com/google/gcloud/SerializationTest.java | 5 ++- .../gcloud/datastore/SerializationTest.java | 5 ++- .../resourcemanager/SerializationTest.java | 5 ++- .../gcloud/storage/SerializationTest.java | 4 +- 7 files changed, 71 insertions(+), 15 deletions(-) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryException.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryException.java index a157afd25db2..e78734a2899e 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryException.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryException.java @@ -22,6 +22,7 @@ import com.google.gcloud.RetryHelper.RetryInterruptedException; import java.io.IOException; +import java.util.Objects; import java.util.Set; /** @@ -73,6 +74,23 @@ protected Set retryableErrors() { return RETRYABLE_ERRORS; } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BigQueryException)) { + return false; + } + BigQueryException other = (BigQueryException) obj; + return super.equals(other) && Objects.equals(error, other.error); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), error); + } + /** * Translate RetryHelperException to the BigQueryException that caused the error. This method will * always throw an exception. diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java index 74644216c109..111df074ffa2 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java @@ -219,6 +219,8 @@ public class SerializationTest extends BaseSerializationTest { new Dataset(BIGQUERY, new DatasetInfo.BuilderImpl(DATASET_INFO)); private static final Table TABLE = new Table(BIGQUERY, new TableInfo.BuilderImpl(TABLE_INFO)); private static final Job JOB = new Job(BIGQUERY, new JobInfo.BuilderImpl(JOB_INFO)); + private static final BigQueryException BIG_QUERY_EXCEPTION = + new BigQueryException(42, "message", BIGQUERY_ERROR); @Override protected Serializable[] serializableObjects() { @@ -237,7 +239,7 @@ protected Serializable[] serializableObjects() { LOAD_STATISTICS, QUERY_STATISTICS, BIGQUERY_ERROR, JOB_STATUS, JOB_ID, COPY_JOB_CONFIGURATION, EXTRACT_JOB_CONFIGURATION, LOAD_CONFIGURATION, LOAD_JOB_CONFIGURATION, QUERY_JOB_CONFIGURATION, JOB_INFO, INSERT_ALL_REQUEST, - INSERT_ALL_RESPONSE, FIELD_VALUE, QUERY_REQUEST, QUERY_RESPONSE, + INSERT_ALL_RESPONSE, FIELD_VALUE, QUERY_REQUEST, QUERY_RESPONSE, BIG_QUERY_EXCEPTION, BigQuery.DatasetOption.fields(), BigQuery.DatasetDeleteOption.deleteContents(), BigQuery.DatasetListOption.all(), BigQuery.TableOption.fields(), BigQuery.TableListOption.pageSize(42L), BigQuery.JobOption.fields(), diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/BaseServiceException.java b/gcloud-java-core/src/main/java/com/google/gcloud/BaseServiceException.java index 365243904436..4e0d03e0073a 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/BaseServiceException.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/BaseServiceException.java @@ -32,6 +32,16 @@ */ public class BaseServiceException extends RuntimeException { + private static final long serialVersionUID = 759921776378760835L; + public static final int UNKNOWN_CODE = 0; + + private final int code; + private final boolean retryable; + private final String reason; + private final boolean idempotent; + private final String location; + private final String debugInfo; + protected static final class Error implements Serializable { private static final long serialVersionUID = -4019600198652965721L; @@ -79,16 +89,6 @@ public int hashCode() { } } - private static final long serialVersionUID = 759921776378760835L; - public static final int UNKNOWN_CODE = 0; - - private final int code; - private final boolean retryable; - private final String reason; - private final boolean idempotent; - private final String location; - private final String debugInfo; - public BaseServiceException(IOException exception, boolean idempotent) { super(message(exception), exception); int code = UNKNOWN_CODE; @@ -198,6 +198,31 @@ protected String debugInfo() { return debugInfo; } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BaseServiceException)) { + return false; + } + BaseServiceException other = (BaseServiceException) obj; + return Objects.equals(getCause(), other.getCause()) + && Objects.equals(getMessage(), other.getMessage()) + && code == other.code + && retryable == other.retryable + && Objects.equals(reason, other.reason) + && idempotent == other.idempotent + && Objects.equals(location, other.location) + && Objects.equals(debugInfo, other.debugInfo); + } + + @Override + public int hashCode() { + return Objects.hash(getCause(), getMessage(), code, retryable, reason, idempotent, location, + debugInfo); + } + protected static String reason(GoogleJsonError error) { if (error.getErrors() != null && !error.getErrors().isEmpty()) { return error.getErrors().get(0).getReason(); diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java index 194479ac365c..3255a17333aa 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/SerializationTest.java @@ -46,6 +46,8 @@ public Builder toBuilder() { } } + private static final BaseServiceException BASE_SERVICE_EXCEPTION = + new BaseServiceException(42, "message", "reason", true); private static final ExceptionHandler EXCEPTION_HANDLER = ExceptionHandler.defaultInstance(); private static final Identity IDENTITY = Identity.allAuthenticatedUsers(); private static final PageImpl PAGE = @@ -81,7 +83,8 @@ public Builder toBuilder() { @Override protected Serializable[] serializableObjects() { - return new Serializable[]{EXCEPTION_HANDLER, IDENTITY, PAGE, RETRY_PARAMS, SOME_IAM_POLICY}; + return new Serializable[]{BASE_SERVICE_EXCEPTION, EXCEPTION_HANDLER, IDENTITY, PAGE, + RETRY_PARAMS, SOME_IAM_POLICY}; } @Override diff --git a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java index 3ea74ef7c4d6..b9e78800ffab 100644 --- a/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java +++ b/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/SerializationTest.java @@ -102,6 +102,8 @@ public class SerializationTest extends BaseSerializationTest { .addValue(new NullValue()) .build(); private static final ProjectionEntity PROJECTION_ENTITY = ProjectionEntity.fromPb(ENTITY1.toPb()); + private static final DatastoreException DATASTORE_EXCEPTION = + new DatastoreException(42, "message", "reason"); @Override protected java.io.Serializable[] serializableObjects() { @@ -119,7 +121,8 @@ protected java.io.Serializable[] serializableObjects() { ENTITY2, ENTITY3, EMBEDDED_ENTITY, PROJECTION_ENTITY, DATE_TIME1, BLOB1, CURSOR1, GQL1, GQL2, QUERY1, QUERY2, QUERY3, NULL_VALUE, KEY_VALUE, STRING_VALUE, EMBEDDED_ENTITY_VALUE1, EMBEDDED_ENTITY_VALUE2, EMBEDDED_ENTITY_VALUE3, LIST_VALUE, LONG_VALUE, DOUBLE_VALUE, - BOOLEAN_VALUE, DATE_AND_TIME_VALUE, BLOB_VALUE, RAW_VALUE, options, otherOptions}; + BOOLEAN_VALUE, DATE_AND_TIME_VALUE, BLOB_VALUE, RAW_VALUE, DATASTORE_EXCEPTION, options, + otherOptions}; } @Override diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index 5bad065003e0..c6e907da16a0 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -49,6 +49,8 @@ public class SerializationTest extends BaseSerializationTest { private static final Policy POLICY = Policy.builder() .addBinding(Policy.Role.viewer(), ImmutableSet.of(Identity.user("abc@gmail.com"))) .build(); + private static final ResourceManagerException RESOURCE_MANAGER_EXCEPTION = + new ResourceManagerException(42, "message"); @Override protected Serializable[] serializableObjects() { @@ -57,7 +59,8 @@ protected Serializable[] serializableObjects() { .projectId("some-unnecessary-project-ID") .build(); return new Serializable[]{PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, PROJECT, PAGE_RESULT, - PROJECT_GET_OPTION, PROJECT_LIST_OPTION, POLICY, options, otherOptions}; + PROJECT_GET_OPTION, PROJECT_LIST_OPTION, POLICY, RESOURCE_MANAGER_EXCEPTION, options, + otherOptions}; } @Override diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java index 6aae7b1a0cb2..613cb81c3549 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/SerializationTest.java @@ -52,6 +52,7 @@ public class SerializationTest extends BaseSerializationTest { Collections.>emptyList()); private static final PageImpl PAGE_RESULT = new PageImpl<>(null, "c", Collections.singletonList(BLOB)); + private static final StorageException STORAGE_EXCEPTION = new StorageException(42, "message"); private static final Storage.BlobListOption BLOB_LIST_OPTIONS = Storage.BlobListOption.pageSize(100); private static final Storage.BlobSourceOption BLOB_SOURCE_OPTIONS = @@ -79,7 +80,8 @@ protected Serializable[] serializableObjects() { return new Serializable[]{ACL_DOMAIN, ACL_GROUP, ACL_PROJECT_, ACL_USER, ACL_RAW, ACL, BLOB_INFO, BLOB, BUCKET_INFO, BUCKET, ORIGIN, CORS, BATCH_REQUEST, BATCH_RESPONSE, PAGE_RESULT, BLOB_LIST_OPTIONS, BLOB_SOURCE_OPTIONS, BLOB_TARGET_OPTIONS, - BUCKET_LIST_OPTIONS, BUCKET_SOURCE_OPTIONS, BUCKET_TARGET_OPTIONS, options, otherOptions}; + BUCKET_LIST_OPTIONS, BUCKET_SOURCE_OPTIONS, BUCKET_TARGET_OPTIONS, STORAGE_EXCEPTION, + options, otherOptions}; } @Override From 22636e276005b809e7bef8cc869a38cba786b162 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Fri, 18 Mar 2016 17:00:47 +0100 Subject: [PATCH 155/203] Remove checks for contentType in CopyRequest - update CopyRequest to hold both targetId and targetInfo - avoid sending storage object in StorageRpc.rewrite when only targetId is set - refactor CopyWriter and state - add integration tests --- .../com/google/gcloud/storage/CopyWriter.java | 57 +++++--- .../com/google/gcloud/storage/Storage.java | 80 ++++++------ .../google/gcloud/storage/StorageImpl.java | 15 ++- .../gcloud/storage/spi/DefaultStorageRpc.java | 4 +- .../google/gcloud/storage/spi/StorageRpc.java | 19 ++- .../com/google/gcloud/storage/BlobTest.java | 12 +- .../gcloud/storage/CopyRequestTest.java | 53 +++----- .../google/gcloud/storage/CopyWriterTest.java | 122 +++++++++++++++--- .../gcloud/storage/StorageImplTest.java | 14 +- .../gcloud/storage/it/ITStorageTest.java | 51 ++++++++ 10 files changed, 288 insertions(+), 139 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java index 62b39e005369..38d9c0d5e952 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java @@ -65,11 +65,11 @@ public class CopyWriter implements Restorable { * * @throws StorageException upon failure */ - public BlobInfo result() { + public Blob result() { while (!isDone()) { copyChunk(); } - return BlobInfo.fromPb(rewriteResponse.result); + return Blob.fromPb(serviceOptions.service(), rewriteResponse.result); } /** @@ -120,8 +120,12 @@ public RestorableState capture() { serviceOptions, BlobId.fromPb(rewriteResponse.rewriteRequest.source), rewriteResponse.rewriteRequest.sourceOptions, - BlobInfo.fromPb(rewriteResponse.rewriteRequest.target), + BlobId.of(rewriteResponse.rewriteRequest.targetBucket, + rewriteResponse.rewriteRequest.targetName), rewriteResponse.rewriteRequest.targetOptions) + .targetInfo(rewriteResponse.rewriteRequest.targetObject != null + ? BlobInfo.fromPb(rewriteResponse.rewriteRequest.targetObject) : null) + .result(rewriteResponse.result != null ? BlobInfo.fromPb(rewriteResponse.result) : null) .blobSize(blobSize()) .isDone(isDone()) .megabytesCopiedPerChunk(rewriteResponse.rewriteRequest.megabytesRewrittenPerCall) @@ -132,12 +136,13 @@ public RestorableState capture() { static class StateImpl implements RestorableState, Serializable { - private static final long serialVersionUID = 8279287678903181701L; + private static final long serialVersionUID = 1693964441435822700L; private final StorageOptions serviceOptions; private final BlobId source; private final Map sourceOptions; - private final BlobInfo target; + private final BlobId targetId; + private final BlobInfo targetInfo; private final Map targetOptions; private final BlobInfo result; private final long blobSize; @@ -150,7 +155,8 @@ static class StateImpl implements RestorableState, Serializable { this.serviceOptions = builder.serviceOptions; this.source = builder.source; this.sourceOptions = builder.sourceOptions; - this.target = builder.target; + this.targetId = builder.targetId; + this.targetInfo = builder.targetInfo; this.targetOptions = builder.targetOptions; this.result = builder.result; this.blobSize = builder.blobSize; @@ -165,8 +171,9 @@ static class Builder { private final StorageOptions serviceOptions; private final BlobId source; private final Map sourceOptions; - private final BlobInfo target; + private final BlobId targetId; private final Map targetOptions; + private BlobInfo targetInfo; private BlobInfo result; private long blobSize; private boolean isDone; @@ -176,14 +183,19 @@ static class Builder { private Builder(StorageOptions options, BlobId source, Map sourceOptions, - BlobInfo target, Map targetOptions) { + BlobId targetId, Map targetOptions) { this.serviceOptions = options; this.source = source; this.sourceOptions = sourceOptions; - this.target = target; + this.targetId = targetId; this.targetOptions = targetOptions; } + Builder targetInfo(BlobInfo targetInfo) { + this.targetInfo = targetInfo; + return this; + } + Builder result(BlobInfo result) { this.result = result; return this; @@ -220,15 +232,16 @@ RestorableState build() { } static Builder builder(StorageOptions options, BlobId source, - Map sourceOptions, BlobInfo target, + Map sourceOptions, BlobId targetId, Map targetOptions) { - return new Builder(options, source, sourceOptions, target, targetOptions); + return new Builder(options, source, sourceOptions, targetId, targetOptions); } @Override public CopyWriter restore() { - RewriteRequest rewriteRequest = new RewriteRequest( - source.toPb(), sourceOptions, target.toPb(), targetOptions, megabytesCopiedPerChunk); + RewriteRequest rewriteRequest = new RewriteRequest(source.toPb(), sourceOptions, + targetId.bucket(), targetId.name(), targetInfo != null ? targetInfo.toPb() : null, + targetOptions, megabytesCopiedPerChunk); RewriteResponse rewriteResponse = new RewriteResponse(rewriteRequest, result != null ? result.toPb() : null, blobSize, isDone, rewriteToken, totalBytesCopied); @@ -237,8 +250,9 @@ public CopyWriter restore() { @Override public int hashCode() { - return Objects.hash(serviceOptions, source, sourceOptions, target, targetOptions, result, - blobSize, isDone, megabytesCopiedPerChunk, rewriteToken, totalBytesCopied); + return Objects.hash(serviceOptions, source, sourceOptions, targetId, targetInfo, + targetOptions, result, blobSize, isDone, megabytesCopiedPerChunk, rewriteToken, + totalBytesCopied); } @Override @@ -253,7 +267,8 @@ public boolean equals(Object obj) { return Objects.equals(this.serviceOptions, other.serviceOptions) && Objects.equals(this.source, other.source) && Objects.equals(this.sourceOptions, other.sourceOptions) - && Objects.equals(this.target, other.target) + && Objects.equals(this.targetId, other.targetId) + && Objects.equals(this.targetInfo, other.targetInfo) && Objects.equals(this.targetOptions, other.targetOptions) && Objects.equals(this.result, other.result) && Objects.equals(this.rewriteToken, other.rewriteToken) @@ -267,10 +282,14 @@ public boolean equals(Object obj) { public String toString() { return MoreObjects.toStringHelper(this) .add("source", source) - .add("target", target) - .add("isDone", isDone) - .add("totalBytesRewritten", totalBytesCopied) + .add("targetId", targetId) + .add("targetInfo", targetInfo) + .add("result", result) .add("blobSize", blobSize) + .add("isDone", isDone) + .add("rewriteToken", rewriteToken) + .add("totalBytesCopied", totalBytesCopied) + .add("megabytesCopiedPerChunk", megabytesCopiedPerChunk) .toString(); } } diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 35fc6117cbc2..8204f0105e7e 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -962,7 +962,8 @@ class CopyRequest implements Serializable { private final BlobId source; private final List sourceOptions; - private final BlobInfo target; + private final BlobId targetId; + private final BlobInfo targetInfo; private final List targetOptions; private final Long megabytesCopiedPerChunk; @@ -971,7 +972,8 @@ public static class Builder { private final Set sourceOptions = new LinkedHashSet<>(); private final Set targetOptions = new LinkedHashSet<>(); private BlobId source; - private BlobInfo target; + private BlobId targetId; + private BlobInfo targetInfo; private Long megabytesCopiedPerChunk; /** @@ -1019,39 +1021,37 @@ public Builder sourceOptions(Iterable options) { * * @return the builder */ - public Builder target(BlobId target) { - this.target = BlobInfo.builder(target).build(); + public Builder target(BlobId targetId) { + this.targetId = targetId; return this; } /** * Sets the copy target and target options. {@code target} parameter is used to override - * source blob information (e.g. {@code contentType}, {@code contentLanguage}). {@code - * target.contentType} is a required field. + * source blob information (e.g. {@code contentType}, {@code contentLanguage}). Target blob + * information is set exactly to {@code target}, no information is inherited from the source + * blob. If not set, target blob information is inherited from the source blob. * * @return the builder - * @throws IllegalArgumentException if {@code target.contentType} is {@code null} */ - public Builder target(BlobInfo target, BlobTargetOption... options) - throws IllegalArgumentException { - checkContentType(target); - this.target = target; + public Builder target(BlobInfo targetInfo, BlobTargetOption... options) { + this.targetId = targetInfo.blobId(); + this.targetInfo = targetInfo; Collections.addAll(targetOptions, options); return this; } /** * Sets the copy target and target options. {@code target} parameter is used to override - * source blob information (e.g. {@code contentType}, {@code contentLanguage}). {@code - * target.contentType} is a required field. + * source blob information (e.g. {@code contentType}, {@code contentLanguage}). Target blob + * information is set exactly to {@code target}, no information is inherited from the source + * blob. If not set, target blob information is inherited from the source blob. * * @return the builder - * @throws IllegalArgumentException if {@code target.contentType} is {@code null} */ - public Builder target(BlobInfo target, Iterable options) - throws IllegalArgumentException { - checkContentType(target); - this.target = target; + public Builder target(BlobInfo targetInfo, Iterable options) { + this.targetId = targetInfo.blobId(); + this.targetInfo = targetInfo; Iterables.addAll(targetOptions, options); return this; } @@ -1072,8 +1072,6 @@ public Builder megabytesCopiedPerChunk(Long megabytesCopiedPerChunk) { * Creates a {@code CopyRequest} object. */ public CopyRequest build() { - checkNotNull(source); - checkNotNull(target); return new CopyRequest(this); } } @@ -1081,7 +1079,8 @@ public CopyRequest build() { private CopyRequest(Builder builder) { source = checkNotNull(builder.source); sourceOptions = ImmutableList.copyOf(builder.sourceOptions); - target = checkNotNull(builder.target); + targetId = checkNotNull(builder.targetId); + targetInfo = builder.targetInfo; targetOptions = ImmutableList.copyOf(builder.targetOptions); megabytesCopiedPerChunk = builder.megabytesCopiedPerChunk; } @@ -1101,10 +1100,20 @@ public List sourceOptions() { } /** - * Returns the {@link BlobInfo} for the target blob. + * Returns the {@link BlobId} for the target blob. */ - public BlobInfo target() { - return target; + public BlobId targetId() { + return targetId; + } + + /** + * Returns the {@link BlobInfo} for the target blob. If set, this value is used to replace + * source blob information (e.g. {@code contentType}, {@code contentLanguage}). Target blob + * information is set exactly to this value, no information is inherited from the source blob. + * If not set, target blob information is inherited from the source blob. + */ + public BlobInfo targetInfo() { + return targetInfo; } /** @@ -1125,34 +1134,27 @@ public Long megabytesCopiedPerChunk() { /** * Creates a copy request. {@code target} parameter is used to override source blob information - * (e.g. {@code contentType}, {@code contentLanguage}). {@code target.contentType} is a required - * field. + * (e.g. {@code contentType}, {@code contentLanguage}). * * @param sourceBucket name of the bucket containing the source blob * @param sourceBlob name of the source blob * @param target a {@code BlobInfo} object for the target blob * @return a copy request - * @throws IllegalArgumentException if {@code target.contentType} is {@code null} */ - public static CopyRequest of(String sourceBucket, String sourceBlob, BlobInfo target) - throws IllegalArgumentException { - checkContentType(target); + public static CopyRequest of(String sourceBucket, String sourceBlob, BlobInfo target) { return builder().source(sourceBucket, sourceBlob).target(target).build(); } /** - * Creates a copy request. {@code target} parameter is used to override source blob information - * (e.g. {@code contentType}, {@code contentLanguage}). {@code target.contentType} is a required - * field. + * Creates a copy request. {@code target} parameter is used to replace source blob information + * (e.g. {@code contentType}, {@code contentLanguage}). Target blob information is set exactly + * to {@code target}, no information is inherited from the source blob. * * @param sourceBlobId a {@code BlobId} object for the source blob * @param target a {@code BlobInfo} object for the target blob * @return a copy request - * @throws IllegalArgumentException if {@code target.contentType} is {@code null} */ - public static CopyRequest of(BlobId sourceBlobId, BlobInfo target) - throws IllegalArgumentException { - checkContentType(target); + public static CopyRequest of(BlobId sourceBlobId, BlobInfo target) { return builder().source(sourceBlobId).target(target).build(); } @@ -1214,10 +1216,6 @@ public static CopyRequest of(BlobId sourceBlobId, BlobId targetBlobId) { public static Builder builder() { return new Builder(); } - - private static void checkContentType(BlobInfo blobInfo) throws IllegalArgumentException { - checkArgument(blobInfo.contentType() != null, "Blob content type can not be null"); - } } /** diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java index d58c9e43aea9..30c0046b802c 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java @@ -413,15 +413,20 @@ public CopyWriter copy(final CopyRequest copyRequest) { final StorageObject source = copyRequest.source().toPb(); final Map sourceOptions = optionMap(copyRequest.source().generation(), null, copyRequest.sourceOptions(), true); - final StorageObject target = copyRequest.target().toPb(); - final Map targetOptions = optionMap(copyRequest.target().generation(), - copyRequest.target().metageneration(), copyRequest.targetOptions()); + final BlobId targetId = copyRequest.targetId(); + final StorageObject targetObject = + copyRequest.targetInfo() != null ? copyRequest.targetInfo().toPb() : null; + final Map targetOptions = optionMap( + copyRequest.targetInfo() != null ? copyRequest.targetInfo().generation() : null, + copyRequest.targetInfo() != null ? copyRequest.targetInfo().metageneration() : null, + copyRequest.targetOptions()); try { RewriteResponse rewriteResponse = runWithRetries(new Callable() { @Override public RewriteResponse call() { - return storageRpc.openRewrite(new StorageRpc.RewriteRequest(source, sourceOptions, target, - targetOptions, copyRequest.megabytesCopiedPerChunk())); + return storageRpc.openRewrite(new StorageRpc.RewriteRequest(source, sourceOptions, + targetId.bucket(), targetId.name(), targetObject, targetOptions, + copyRequest.megabytesCopiedPerChunk())); } }, options().retryParams(), EXCEPTION_HANDLER); return new CopyWriter(options(), rewriteResponse); diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java index 3f465e0ab20e..7f13212556aa 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java @@ -580,8 +580,8 @@ private RewriteResponse rewrite(RewriteRequest req, String token) { Long maxBytesRewrittenPerCall = req.megabytesRewrittenPerCall != null ? req.megabytesRewrittenPerCall * MEGABYTE : null; com.google.api.services.storage.model.RewriteResponse rewriteResponse = storage.objects() - .rewrite(req.source.getBucket(), req.source.getName(), req.target.getBucket(), - req.target.getName(), req.target.getContentType() != null ? req.target : null) + .rewrite(req.source.getBucket(), req.source.getName(), req.targetBucket, + req.targetName, req.targetObject) .setSourceGeneration(req.source.getGeneration()) .setRewriteToken(token) .setMaxBytesRewrittenPerCall(maxBytesRewrittenPerCall) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java index d239a475a6dd..7256368e189f 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java @@ -138,16 +138,20 @@ class RewriteRequest { public final StorageObject source; public final Map sourceOptions; - public final StorageObject target; + public final String targetBucket; + public final String targetName; + public final StorageObject targetObject; public final Map targetOptions; public final Long megabytesRewrittenPerCall; public RewriteRequest(StorageObject source, Map sourceOptions, - StorageObject target, Map targetOptions, - Long megabytesRewrittenPerCall) { + String targetBucket, String targetName, StorageObject targetObject, + Map targetOptions, Long megabytesRewrittenPerCall) { this.source = source; this.sourceOptions = sourceOptions; - this.target = target; + this.targetBucket = targetBucket; + this.targetName = targetName; + this.targetObject = targetObject; this.targetOptions = targetOptions; this.megabytesRewrittenPerCall = megabytesRewrittenPerCall; } @@ -163,14 +167,17 @@ public boolean equals(Object obj) { final RewriteRequest other = (RewriteRequest) obj; return Objects.equals(this.source, other.source) && Objects.equals(this.sourceOptions, other.sourceOptions) - && Objects.equals(this.target, other.target) + && Objects.equals(this.targetBucket, other.targetBucket) + && Objects.equals(this.targetName, other.targetName) + && Objects.equals(this.targetObject, other.targetObject) && Objects.equals(this.targetOptions, other.targetOptions) && Objects.equals(this.megabytesRewrittenPerCall, other.megabytesRewrittenPerCall); } @Override public int hashCode() { - return Objects.hash(source, sourceOptions, target, targetOptions, megabytesRewrittenPerCall); + return Objects.hash(source, sourceOptions, targetBucket, targetName, targetObject, + targetOptions, megabytesRewrittenPerCall); } } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java index 5a6173c08199..2d4920816c38 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java @@ -222,7 +222,6 @@ public void testDelete() throws Exception { @Test public void testCopyToBucket() throws Exception { initializeExpectedBlob(2); - BlobInfo target = BlobInfo.builder(BlobId.of("bt", "n")).build(); CopyWriter copyWriter = createMock(CopyWriter.class); Capture capturedCopyRequest = Capture.newInstance(); expect(storage.options()).andReturn(mockOptions); @@ -232,7 +231,8 @@ public void testCopyToBucket() throws Exception { CopyWriter returnedCopyWriter = blob.copyTo("bt"); assertEquals(copyWriter, returnedCopyWriter); assertEquals(capturedCopyRequest.getValue().source(), blob.blobId()); - assertEquals(capturedCopyRequest.getValue().target(), target); + assertEquals(capturedCopyRequest.getValue().targetId(), BlobId.of("bt", "n")); + assertNull(capturedCopyRequest.getValue().targetInfo()); assertTrue(capturedCopyRequest.getValue().sourceOptions().isEmpty()); assertTrue(capturedCopyRequest.getValue().targetOptions().isEmpty()); } @@ -240,7 +240,6 @@ public void testCopyToBucket() throws Exception { @Test public void testCopyTo() throws Exception { initializeExpectedBlob(2); - BlobInfo target = BlobInfo.builder(BlobId.of("bt", "nt")).build(); CopyWriter copyWriter = createMock(CopyWriter.class); Capture capturedCopyRequest = Capture.newInstance(); expect(storage.options()).andReturn(mockOptions); @@ -250,7 +249,8 @@ public void testCopyTo() throws Exception { CopyWriter returnedCopyWriter = blob.copyTo("bt", "nt"); assertEquals(copyWriter, returnedCopyWriter); assertEquals(capturedCopyRequest.getValue().source(), blob.blobId()); - assertEquals(capturedCopyRequest.getValue().target(), target); + assertEquals(capturedCopyRequest.getValue().targetId(), BlobId.of("bt", "nt")); + assertNull(capturedCopyRequest.getValue().targetInfo()); assertTrue(capturedCopyRequest.getValue().sourceOptions().isEmpty()); assertTrue(capturedCopyRequest.getValue().targetOptions().isEmpty()); } @@ -260,7 +260,6 @@ public void testCopyToBlobId() throws Exception { initializeExpectedBlob(2); BlobId targetId = BlobId.of("bt", "nt"); CopyWriter copyWriter = createMock(CopyWriter.class); - BlobInfo target = BlobInfo.builder(targetId).build(); Capture capturedCopyRequest = Capture.newInstance(); expect(storage.options()).andReturn(mockOptions); expect(storage.copy(capture(capturedCopyRequest))).andReturn(copyWriter); @@ -269,7 +268,8 @@ public void testCopyToBlobId() throws Exception { CopyWriter returnedCopyWriter = blob.copyTo(targetId); assertEquals(copyWriter, returnedCopyWriter); assertEquals(capturedCopyRequest.getValue().source(), blob.blobId()); - assertEquals(capturedCopyRequest.getValue().target(), target); + assertEquals(capturedCopyRequest.getValue().targetId(), targetId); + assertNull(capturedCopyRequest.getValue().targetInfo()); assertTrue(capturedCopyRequest.getValue().sourceOptions().isEmpty()); assertTrue(capturedCopyRequest.getValue().targetOptions().isEmpty()); } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyRequestTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyRequestTest.java index b7e8d14e53a1..5700ea804cd6 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyRequestTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyRequestTest.java @@ -18,6 +18,7 @@ import static com.google.gcloud.storage.Storage.PredefinedAcl.PUBLIC_READ; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import com.google.common.collect.ImmutableList; import com.google.gcloud.storage.Storage.BlobSourceOption; @@ -52,7 +53,8 @@ public void testCopyRequest() { assertEquals(SOURCE_BLOB_ID, copyRequest1.source()); assertEquals(1, copyRequest1.sourceOptions().size()); assertEquals(BlobSourceOption.generationMatch(1), copyRequest1.sourceOptions().get(0)); - assertEquals(TARGET_BLOB_INFO, copyRequest1.target()); + assertEquals(TARGET_BLOB_INFO.blobId(), copyRequest1.targetId()); + assertEquals(TARGET_BLOB_INFO, copyRequest1.targetInfo()); assertEquals(1, copyRequest1.targetOptions().size()); assertEquals(BlobTargetOption.predefinedAcl(PUBLIC_READ), copyRequest1.targetOptions().get(0)); @@ -61,14 +63,16 @@ public void testCopyRequest() { .target(TARGET_BLOB_ID) .build(); assertEquals(SOURCE_BLOB_ID, copyRequest2.source()); - assertEquals(BlobInfo.builder(TARGET_BLOB_ID).build(), copyRequest2.target()); + assertEquals(TARGET_BLOB_ID, copyRequest2.targetId()); + assertNull(copyRequest2.targetInfo()); Storage.CopyRequest copyRequest3 = Storage.CopyRequest.builder() .source(SOURCE_BLOB_ID) .target(TARGET_BLOB_INFO, ImmutableList.of(BlobTargetOption.predefinedAcl(PUBLIC_READ))) .build(); assertEquals(SOURCE_BLOB_ID, copyRequest3.source()); - assertEquals(TARGET_BLOB_INFO, copyRequest3.target()); + assertEquals(TARGET_BLOB_INFO.blobId(), copyRequest3.targetId()); + assertEquals(TARGET_BLOB_INFO, copyRequest3.targetInfo()); assertEquals(ImmutableList.of(BlobTargetOption.predefinedAcl(PUBLIC_READ)), copyRequest3.targetOptions()); } @@ -77,53 +81,34 @@ public void testCopyRequest() { public void testCopyRequestOf() { Storage.CopyRequest copyRequest1 = Storage.CopyRequest.of(SOURCE_BLOB_ID, TARGET_BLOB_INFO); assertEquals(SOURCE_BLOB_ID, copyRequest1.source()); - assertEquals(TARGET_BLOB_INFO, copyRequest1.target()); + assertEquals(TARGET_BLOB_INFO.blobId(), copyRequest1.targetId()); + assertEquals(TARGET_BLOB_INFO, copyRequest1.targetInfo()); Storage.CopyRequest copyRequest2 = Storage.CopyRequest.of(SOURCE_BLOB_ID, TARGET_BLOB_NAME); assertEquals(SOURCE_BLOB_ID, copyRequest2.source()); - assertEquals(BlobInfo.builder(SOURCE_BUCKET_NAME, TARGET_BLOB_NAME).build(), - copyRequest2.target()); + assertEquals(BlobId.of(SOURCE_BUCKET_NAME, TARGET_BLOB_NAME), copyRequest2.targetId()); + assertNull(copyRequest2.targetInfo()); Storage.CopyRequest copyRequest3 = Storage.CopyRequest.of(SOURCE_BUCKET_NAME, SOURCE_BLOB_NAME, TARGET_BLOB_INFO); assertEquals(SOURCE_BLOB_ID, copyRequest3.source()); - assertEquals(TARGET_BLOB_INFO, copyRequest3.target()); + assertEquals(TARGET_BLOB_INFO.blobId(), copyRequest3.targetId()); + assertEquals(TARGET_BLOB_INFO, copyRequest3.targetInfo()); Storage.CopyRequest copyRequest4 = Storage.CopyRequest.of(SOURCE_BUCKET_NAME, SOURCE_BLOB_NAME, TARGET_BLOB_NAME); assertEquals(SOURCE_BLOB_ID, copyRequest4.source()); - assertEquals(BlobInfo.builder(SOURCE_BUCKET_NAME, TARGET_BLOB_NAME).build(), - copyRequest4.target()); + assertEquals(BlobId.of(SOURCE_BUCKET_NAME, TARGET_BLOB_NAME), copyRequest4.targetId()); + assertNull(copyRequest4.targetInfo()); Storage.CopyRequest copyRequest5 = Storage.CopyRequest.of(SOURCE_BLOB_ID, TARGET_BLOB_ID); assertEquals(SOURCE_BLOB_ID, copyRequest5.source()); - assertEquals(BlobInfo.builder(TARGET_BLOB_ID).build(), copyRequest5.target()); + assertEquals(TARGET_BLOB_ID, copyRequest5.targetId()); + assertNull(copyRequest5.targetInfo()); Storage.CopyRequest copyRequest6 = Storage.CopyRequest.of(SOURCE_BUCKET_NAME, SOURCE_BLOB_NAME, TARGET_BLOB_ID); assertEquals(SOURCE_BLOB_ID, copyRequest6.source()); - assertEquals(BlobInfo.builder(TARGET_BLOB_ID).build(), copyRequest6.target()); - } - - @Test - public void testCopyRequestFail() { - thrown.expect(IllegalArgumentException.class); - Storage.CopyRequest.builder() - .source(SOURCE_BLOB_ID) - .target(BlobInfo.builder(TARGET_BLOB_ID).build()) - .build(); - } - - @Test - public void testCopyRequestOfBlobInfoFail() { - thrown.expect(IllegalArgumentException.class); - Storage.CopyRequest.of(SOURCE_BLOB_ID, BlobInfo.builder(TARGET_BLOB_ID).build()); - } - - @Test - public void testCopyRequestOfStringFail() { - thrown.expect(IllegalArgumentException.class); - Storage.CopyRequest.of( - SOURCE_BUCKET_NAME, SOURCE_BLOB_NAME, BlobInfo.builder(TARGET_BLOB_ID).build()); - } + assertEquals(TARGET_BLOB_ID, copyRequest6.targetId()); + assertNull(copyRequest6.targetInfo()); } } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java index ad4a04c34127..75b863075770 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java @@ -48,20 +48,29 @@ public class CopyWriterTest { private static final BlobId BLOB_ID = BlobId.of(SOURCE_BUCKET_NAME, SOURCE_BLOB_NAME); private static final BlobInfo BLOB_INFO = BlobInfo.builder(DESTINATION_BUCKET_NAME, DESTINATION_BLOB_NAME).build(); - private static final BlobInfo RESULT = + private static final BlobInfo RESULT_INFO = BlobInfo.builder(DESTINATION_BUCKET_NAME, DESTINATION_BLOB_NAME).contentType("type").build(); private static final Map EMPTY_OPTIONS = ImmutableMap.of(); - private static final RewriteRequest REQUEST = new StorageRpc.RewriteRequest(BLOB_ID.toPb(), - EMPTY_OPTIONS, BLOB_INFO.toPb(), EMPTY_OPTIONS, null); - private static final RewriteResponse RESPONSE = new StorageRpc.RewriteResponse(REQUEST, - null, 42L, false, "token", 21L); - private static final RewriteResponse RESPONSE_DONE = new StorageRpc.RewriteResponse(REQUEST, - RESULT.toPb(), 42L, true, "token", 42L); + private static final RewriteRequest REQUEST_WITH_OBJECT = + new StorageRpc.RewriteRequest(BLOB_ID.toPb(), EMPTY_OPTIONS, DESTINATION_BUCKET_NAME, + DESTINATION_BLOB_NAME, BLOB_INFO.toPb(), EMPTY_OPTIONS, null); + private static final RewriteRequest REQUEST_WITHOUT_OBJECT = + new StorageRpc.RewriteRequest(BLOB_ID.toPb(), EMPTY_OPTIONS, DESTINATION_BUCKET_NAME, + DESTINATION_BLOB_NAME, null, EMPTY_OPTIONS, null); + private static final RewriteResponse RESPONSE_WITH_OBJECT = new RewriteResponse( + REQUEST_WITH_OBJECT, null, 42L, false, "token", 21L); + private static final RewriteResponse RESPONSE_WITHOUT_OBJECT = new RewriteResponse( + REQUEST_WITHOUT_OBJECT, null, 42L, false, "token", 21L); + private static final RewriteResponse RESPONSE_WITH_OBJECT_DONE = + new RewriteResponse(REQUEST_WITH_OBJECT, RESULT_INFO.toPb(), 42L, true, "token", 42L); + private static final RewriteResponse RESPONSE_WITHOUT_OBJECT_DONE = + new RewriteResponse(REQUEST_WITHOUT_OBJECT, RESULT_INFO.toPb(), 42L, true, "token", 42L); private StorageOptions options; private StorageRpcFactory rpcFactoryMock; private StorageRpc storageRpcMock; private CopyWriter copyWriter; + private Blob result; @Before public void setUp() { @@ -75,6 +84,7 @@ public void setUp() { .serviceRpcFactory(rpcFactoryMock) .retryParams(RetryParams.noRetries()) .build(); + result = new Blob(options.service(), new BlobInfo.BuilderImpl(RESULT_INFO)); } @After @@ -83,41 +93,111 @@ public void tearDown() throws Exception { } @Test - public void testRewrite() { - EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE)).andReturn(RESPONSE_DONE); + public void testRewriteWithObject() { + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITH_OBJECT)) + .andReturn(RESPONSE_WITH_OBJECT_DONE); EasyMock.replay(storageRpcMock); - copyWriter = new CopyWriter(options, RESPONSE); - assertEquals(RESULT, copyWriter.result()); + copyWriter = new CopyWriter(options, RESPONSE_WITH_OBJECT); + assertEquals(result, copyWriter.result()); assertTrue(copyWriter.isDone()); assertEquals(42L, copyWriter.totalBytesCopied()); assertEquals(42L, copyWriter.blobSize()); } @Test - public void testRewriteMultipleRequests() { - EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE)).andReturn(RESPONSE); - EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE)).andReturn(RESPONSE_DONE); + public void testRewriteWithoutObject() { + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITHOUT_OBJECT)) + .andReturn(RESPONSE_WITHOUT_OBJECT_DONE); EasyMock.replay(storageRpcMock); - copyWriter = new CopyWriter(options, RESPONSE); - assertEquals(RESULT, copyWriter.result()); + copyWriter = new CopyWriter(options, RESPONSE_WITHOUT_OBJECT); + assertEquals(result, copyWriter.result()); assertTrue(copyWriter.isDone()); assertEquals(42L, copyWriter.totalBytesCopied()); assertEquals(42L, copyWriter.blobSize()); } @Test - public void testSaveAndRestore() { - EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE)).andReturn(RESPONSE); - EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE)).andReturn(RESPONSE_DONE); + public void testRewriteWithObjectMultipleRequests() { + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITH_OBJECT)) + .andReturn(RESPONSE_WITH_OBJECT); + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITH_OBJECT)) + .andReturn(RESPONSE_WITH_OBJECT_DONE); EasyMock.replay(storageRpcMock); - copyWriter = new CopyWriter(options, RESPONSE); + copyWriter = new CopyWriter(options, RESPONSE_WITH_OBJECT); + assertEquals(result, copyWriter.result()); + assertTrue(copyWriter.isDone()); + assertEquals(42L, copyWriter.totalBytesCopied()); + assertEquals(42L, copyWriter.blobSize()); + } + + @Test + public void testRewriteWithoutObjectMultipleRequests() { + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITHOUT_OBJECT)) + .andReturn(RESPONSE_WITHOUT_OBJECT); + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITHOUT_OBJECT)) + .andReturn(RESPONSE_WITHOUT_OBJECT_DONE); + EasyMock.replay(storageRpcMock); + copyWriter = new CopyWriter(options, RESPONSE_WITHOUT_OBJECT); + assertEquals(result, copyWriter.result()); + assertTrue(copyWriter.isDone()); + assertEquals(42L, copyWriter.totalBytesCopied()); + assertEquals(42L, copyWriter.blobSize()); + } + + @Test + public void testSaveAndRestoreWithObject() { + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITH_OBJECT)) + .andReturn(RESPONSE_WITH_OBJECT); + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITH_OBJECT)) + .andReturn(RESPONSE_WITH_OBJECT_DONE); + EasyMock.replay(storageRpcMock); + copyWriter = new CopyWriter(options, RESPONSE_WITH_OBJECT); + copyWriter.copyChunk(); + assertTrue(!copyWriter.isDone()); + assertEquals(21L, copyWriter.totalBytesCopied()); + assertEquals(42L, copyWriter.blobSize()); + RestorableState rewriterState = copyWriter.capture(); + CopyWriter restoredRewriter = rewriterState.restore(); + assertEquals(result, restoredRewriter.result()); + assertTrue(restoredRewriter.isDone()); + assertEquals(42L, restoredRewriter.totalBytesCopied()); + assertEquals(42L, restoredRewriter.blobSize()); + } + + @Test + public void testSaveAndRestoreWithoutObject() { + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITHOUT_OBJECT)) + .andReturn(RESPONSE_WITHOUT_OBJECT); + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITHOUT_OBJECT)) + .andReturn(RESPONSE_WITHOUT_OBJECT_DONE); + EasyMock.replay(storageRpcMock); + copyWriter = new CopyWriter(options, RESPONSE_WITHOUT_OBJECT); copyWriter.copyChunk(); assertTrue(!copyWriter.isDone()); assertEquals(21L, copyWriter.totalBytesCopied()); assertEquals(42L, copyWriter.blobSize()); RestorableState rewriterState = copyWriter.capture(); CopyWriter restoredRewriter = rewriterState.restore(); - assertEquals(RESULT, restoredRewriter.result()); + assertEquals(result, restoredRewriter.result()); + assertTrue(restoredRewriter.isDone()); + assertEquals(42L, restoredRewriter.totalBytesCopied()); + assertEquals(42L, restoredRewriter.blobSize()); + } + + @Test + public void testSaveAndRestoreWithResult() { + EasyMock.expect(storageRpcMock.continueRewrite(RESPONSE_WITH_OBJECT)) + .andReturn(RESPONSE_WITH_OBJECT_DONE); + EasyMock.replay(storageRpcMock); + copyWriter = new CopyWriter(options, RESPONSE_WITH_OBJECT); + copyWriter.copyChunk(); + assertEquals(result, copyWriter.result()); + assertTrue(copyWriter.isDone()); + assertEquals(42L, copyWriter.totalBytesCopied()); + assertEquals(42L, copyWriter.blobSize()); + RestorableState rewriterState = copyWriter.capture(); + CopyWriter restoredRewriter = rewriterState.restore(); + assertEquals(result, restoredRewriter.result()); assertTrue(restoredRewriter.isDone()); assertEquals(42L, restoredRewriter.totalBytesCopied()); assertEquals(42L, restoredRewriter.blobSize()); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java index 38b4bb58e77f..db1166598237 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java @@ -866,7 +866,8 @@ public void testComposeWithOptions() { public void testCopy() { CopyRequest request = Storage.CopyRequest.of(BLOB_INFO1.blobId(), BLOB_INFO2.blobId()); StorageRpc.RewriteRequest rpcRequest = new StorageRpc.RewriteRequest(request.source().toPb(), - EMPTY_RPC_OPTIONS, request.target().toPb(), EMPTY_RPC_OPTIONS, null); + EMPTY_RPC_OPTIONS, BLOB_INFO2.blobId().bucket(), BLOB_INFO2.blobId().name(), null, + EMPTY_RPC_OPTIONS, null); StorageRpc.RewriteResponse rpcResponse = new StorageRpc.RewriteResponse(rpcRequest, null, 42L, false, "token", 21L); EasyMock.expect(storageRpcMock.openRewrite(rpcRequest)).andReturn(rpcResponse); @@ -886,7 +887,8 @@ public void testCopyWithOptions() { .target(BLOB_INFO1, BLOB_TARGET_GENERATION, BLOB_TARGET_METAGENERATION) .build(); StorageRpc.RewriteRequest rpcRequest = new StorageRpc.RewriteRequest(request.source().toPb(), - BLOB_SOURCE_OPTIONS_COPY, request.target().toPb(), BLOB_TARGET_OPTIONS_COMPOSE, null); + BLOB_SOURCE_OPTIONS_COPY, BLOB_INFO1.blobId().bucket(), BLOB_INFO1.blobId().name(), + request.targetInfo().toPb(), BLOB_TARGET_OPTIONS_COMPOSE, null); StorageRpc.RewriteResponse rpcResponse = new StorageRpc.RewriteResponse(rpcRequest, null, 42L, false, "token", 21L); EasyMock.expect(storageRpcMock.openRewrite(rpcRequest)).andReturn(rpcResponse); @@ -906,7 +908,8 @@ public void testCopyWithOptionsFromBlobId() { .target(BLOB_INFO1, BLOB_TARGET_GENERATION, BLOB_TARGET_METAGENERATION) .build(); StorageRpc.RewriteRequest rpcRequest = new StorageRpc.RewriteRequest(request.source().toPb(), - BLOB_SOURCE_OPTIONS_COPY, request.target().toPb(), BLOB_TARGET_OPTIONS_COMPOSE, null); + BLOB_SOURCE_OPTIONS_COPY, BLOB_INFO1.blobId().bucket(), BLOB_INFO1.blobId().name(), + request.targetInfo().toPb(), BLOB_TARGET_OPTIONS_COMPOSE, null); StorageRpc.RewriteResponse rpcResponse = new StorageRpc.RewriteResponse(rpcRequest, null, 42L, false, "token", 21L); EasyMock.expect(storageRpcMock.openRewrite(rpcRequest)).andReturn(rpcResponse); @@ -922,7 +925,8 @@ public void testCopyWithOptionsFromBlobId() { public void testCopyMultipleRequests() { CopyRequest request = Storage.CopyRequest.of(BLOB_INFO1.blobId(), BLOB_INFO2.blobId()); StorageRpc.RewriteRequest rpcRequest = new StorageRpc.RewriteRequest(request.source().toPb(), - EMPTY_RPC_OPTIONS, request.target().toPb(), EMPTY_RPC_OPTIONS, null); + EMPTY_RPC_OPTIONS, BLOB_INFO2.blobId().bucket(), BLOB_INFO2.blobId().name(), null, + EMPTY_RPC_OPTIONS, null); StorageRpc.RewriteResponse rpcResponse1 = new StorageRpc.RewriteResponse(rpcRequest, null, 42L, false, "token", 21L); StorageRpc.RewriteResponse rpcResponse2 = new StorageRpc.RewriteResponse(rpcRequest, @@ -935,7 +939,7 @@ public void testCopyMultipleRequests() { assertEquals(42L, writer.blobSize()); assertEquals(21L, writer.totalBytesCopied()); assertTrue(!writer.isDone()); - assertEquals(BLOB_INFO1, writer.result()); + assertEquals(expectedBlob1, writer.result()); assertTrue(writer.isDone()); assertEquals(42L, writer.totalBytesCopied()); assertEquals(42L, writer.blobSize()); diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java index 563a621c48fb..13d768442c34 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/it/ITStorageTest.java @@ -599,6 +599,37 @@ public void testComposeBlob() { assertNotNull(remoteTargetBlob); assertEquals(targetBlob.name(), remoteTargetBlob.name()); assertEquals(targetBlob.bucket(), remoteTargetBlob.bucket()); + assertNull(remoteTargetBlob.contentType()); + byte[] readBytes = storage.readAllBytes(BUCKET, targetBlobName); + byte[] composedBytes = Arrays.copyOf(BLOB_BYTE_CONTENT, BLOB_BYTE_CONTENT.length * 2); + System.arraycopy(BLOB_BYTE_CONTENT, 0, composedBytes, BLOB_BYTE_CONTENT.length, + BLOB_BYTE_CONTENT.length); + assertArrayEquals(composedBytes, readBytes); + assertTrue(remoteSourceBlob1.delete()); + assertTrue(remoteSourceBlob2.delete()); + assertTrue(remoteTargetBlob.delete()); + } + + @Test + public void testComposeBlobWithContentType() { + String sourceBlobName1 = "test-compose-blob-with-content-type-source-1"; + String sourceBlobName2 = "test-compose-blob-with-content-type-source-2"; + BlobInfo sourceBlob1 = BlobInfo.builder(BUCKET, sourceBlobName1).build(); + BlobInfo sourceBlob2 = BlobInfo.builder(BUCKET, sourceBlobName2).build(); + Blob remoteSourceBlob1 = storage.create(sourceBlob1, BLOB_BYTE_CONTENT); + Blob remoteSourceBlob2 = storage.create(sourceBlob2, BLOB_BYTE_CONTENT); + assertNotNull(remoteSourceBlob1); + assertNotNull(remoteSourceBlob2); + String targetBlobName = "test-compose-blob-with-content-type-target"; + BlobInfo targetBlob = + BlobInfo.builder(BUCKET, targetBlobName).contentType(CONTENT_TYPE).build(); + Storage.ComposeRequest req = + Storage.ComposeRequest.of(ImmutableList.of(sourceBlobName1, sourceBlobName2), targetBlob); + Blob remoteTargetBlob = storage.compose(req); + assertNotNull(remoteTargetBlob); + assertEquals(targetBlob.name(), remoteTargetBlob.name()); + assertEquals(targetBlob.bucket(), remoteTargetBlob.bucket()); + assertEquals(CONTENT_TYPE, remoteTargetBlob.contentType()); byte[] readBytes = storage.readAllBytes(BUCKET, targetBlobName); byte[] composedBytes = Arrays.copyOf(BLOB_BYTE_CONTENT, BLOB_BYTE_CONTENT.length * 2); System.arraycopy(BLOB_BYTE_CONTENT, 0, composedBytes, BLOB_BYTE_CONTENT.length, @@ -682,6 +713,26 @@ public void testCopyBlobUpdateMetadata() { assertTrue(storage.delete(BUCKET, targetBlobName)); } + @Test + public void testCopyBlobNoContentType() { + String sourceBlobName = "test-copy-blob-no-content-type-source"; + BlobId source = BlobId.of(BUCKET, sourceBlobName); + Blob remoteSourceBlob = storage.create(BlobInfo.builder(source).build(), BLOB_BYTE_CONTENT); + assertNotNull(remoteSourceBlob); + String targetBlobName = "test-copy-blob-no-content-type-target"; + ImmutableMap metadata = ImmutableMap.of("k", "v"); + BlobInfo target = BlobInfo.builder(BUCKET, targetBlobName).metadata(metadata).build(); + Storage.CopyRequest req = Storage.CopyRequest.of(source, target); + CopyWriter copyWriter = storage.copy(req); + assertEquals(BUCKET, copyWriter.result().bucket()); + assertEquals(targetBlobName, copyWriter.result().name()); + assertNull(copyWriter.result().contentType()); + assertEquals(metadata, copyWriter.result().metadata()); + assertTrue(copyWriter.isDone()); + assertTrue(remoteSourceBlob.delete()); + assertTrue(storage.delete(BUCKET, targetBlobName)); + } + @Test public void testCopyBlobFail() { String sourceBlobName = "test-copy-blob-source-fail"; From 3e5db7a87013d677d179d6d484448fcae3cbdbc6 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Sun, 20 Mar 2016 21:05:16 +0100 Subject: [PATCH 156/203] Refactor CopyRequest: remove targetId, add boolean overrideInfo --- .../com/google/gcloud/storage/CopyWriter.java | 47 ++++++++--------- .../com/google/gcloud/storage/Storage.java | 50 ++++++++++--------- .../google/gcloud/storage/StorageImpl.java | 12 ++--- .../gcloud/storage/spi/DefaultStorageRpc.java | 4 +- .../google/gcloud/storage/spi/StorageRpc.java | 23 ++++----- .../com/google/gcloud/storage/BlobTest.java | 15 +++--- .../gcloud/storage/CopyRequestTest.java | 42 +++++++++------- .../google/gcloud/storage/CopyWriterTest.java | 8 +-- .../gcloud/storage/StorageImplTest.java | 12 ++--- 9 files changed, 102 insertions(+), 111 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java index 38d9c0d5e952..26c728942a28 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java @@ -120,11 +120,9 @@ public RestorableState capture() { serviceOptions, BlobId.fromPb(rewriteResponse.rewriteRequest.source), rewriteResponse.rewriteRequest.sourceOptions, - BlobId.of(rewriteResponse.rewriteRequest.targetBucket, - rewriteResponse.rewriteRequest.targetName), + rewriteResponse.rewriteRequest.overrideInfo, + BlobInfo.fromPb(rewriteResponse.rewriteRequest.target), rewriteResponse.rewriteRequest.targetOptions) - .targetInfo(rewriteResponse.rewriteRequest.targetObject != null - ? BlobInfo.fromPb(rewriteResponse.rewriteRequest.targetObject) : null) .result(rewriteResponse.result != null ? BlobInfo.fromPb(rewriteResponse.result) : null) .blobSize(blobSize()) .isDone(isDone()) @@ -141,8 +139,8 @@ static class StateImpl implements RestorableState, Serializable { private final StorageOptions serviceOptions; private final BlobId source; private final Map sourceOptions; - private final BlobId targetId; - private final BlobInfo targetInfo; + private final boolean overrideInfo; + private final BlobInfo target; private final Map targetOptions; private final BlobInfo result; private final long blobSize; @@ -155,8 +153,8 @@ static class StateImpl implements RestorableState, Serializable { this.serviceOptions = builder.serviceOptions; this.source = builder.source; this.sourceOptions = builder.sourceOptions; - this.targetId = builder.targetId; - this.targetInfo = builder.targetInfo; + this.overrideInfo = builder.overrideInfo; + this.target = builder.target; this.targetOptions = builder.targetOptions; this.result = builder.result; this.blobSize = builder.blobSize; @@ -171,9 +169,9 @@ static class Builder { private final StorageOptions serviceOptions; private final BlobId source; private final Map sourceOptions; - private final BlobId targetId; + private final boolean overrideInfo; + private BlobInfo target; private final Map targetOptions; - private BlobInfo targetInfo; private BlobInfo result; private long blobSize; private boolean isDone; @@ -182,20 +180,16 @@ static class Builder { private Long megabytesCopiedPerChunk; private Builder(StorageOptions options, BlobId source, - Map sourceOptions, - BlobId targetId, Map targetOptions) { + Map sourceOptions, boolean overrideInfo, BlobInfo target, + Map targetOptions) { this.serviceOptions = options; this.source = source; this.sourceOptions = sourceOptions; - this.targetId = targetId; + this.overrideInfo = overrideInfo; + this.target = target; this.targetOptions = targetOptions; } - Builder targetInfo(BlobInfo targetInfo) { - this.targetInfo = targetInfo; - return this; - } - Builder result(BlobInfo result) { this.result = result; return this; @@ -232,16 +226,15 @@ RestorableState build() { } static Builder builder(StorageOptions options, BlobId source, - Map sourceOptions, BlobId targetId, + Map sourceOptions, boolean overrideInfo, BlobInfo target, Map targetOptions) { - return new Builder(options, source, sourceOptions, targetId, targetOptions); + return new Builder(options, source, sourceOptions, overrideInfo, target, targetOptions); } @Override public CopyWriter restore() { RewriteRequest rewriteRequest = new RewriteRequest(source.toPb(), sourceOptions, - targetId.bucket(), targetId.name(), targetInfo != null ? targetInfo.toPb() : null, - targetOptions, megabytesCopiedPerChunk); + overrideInfo, target.toPb(), targetOptions, megabytesCopiedPerChunk); RewriteResponse rewriteResponse = new RewriteResponse(rewriteRequest, result != null ? result.toPb() : null, blobSize, isDone, rewriteToken, totalBytesCopied); @@ -250,7 +243,7 @@ public CopyWriter restore() { @Override public int hashCode() { - return Objects.hash(serviceOptions, source, sourceOptions, targetId, targetInfo, + return Objects.hash(serviceOptions, source, sourceOptions, overrideInfo, target, targetOptions, result, blobSize, isDone, megabytesCopiedPerChunk, rewriteToken, totalBytesCopied); } @@ -267,8 +260,8 @@ public boolean equals(Object obj) { return Objects.equals(this.serviceOptions, other.serviceOptions) && Objects.equals(this.source, other.source) && Objects.equals(this.sourceOptions, other.sourceOptions) - && Objects.equals(this.targetId, other.targetId) - && Objects.equals(this.targetInfo, other.targetInfo) + && Objects.equals(this.overrideInfo, other.overrideInfo) + && Objects.equals(this.target, other.target) && Objects.equals(this.targetOptions, other.targetOptions) && Objects.equals(this.result, other.result) && Objects.equals(this.rewriteToken, other.rewriteToken) @@ -282,8 +275,8 @@ public boolean equals(Object obj) { public String toString() { return MoreObjects.toStringHelper(this) .add("source", source) - .add("targetId", targetId) - .add("targetInfo", targetInfo) + .add("overrideInfo", overrideInfo) + .add("target", target) .add("result", result) .add("blobSize", blobSize) .add("isDone", isDone) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index 8204f0105e7e..b30d46431de0 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -962,8 +962,8 @@ class CopyRequest implements Serializable { private final BlobId source; private final List sourceOptions; - private final BlobId targetId; - private final BlobInfo targetInfo; + private final boolean overrideInfo; + private final BlobInfo target; private final List targetOptions; private final Long megabytesCopiedPerChunk; @@ -972,8 +972,8 @@ public static class Builder { private final Set sourceOptions = new LinkedHashSet<>(); private final Set targetOptions = new LinkedHashSet<>(); private BlobId source; - private BlobId targetId; - private BlobInfo targetInfo; + private boolean overrideInfo; + private BlobInfo target; private Long megabytesCopiedPerChunk; /** @@ -1022,7 +1022,8 @@ public Builder sourceOptions(Iterable options) { * @return the builder */ public Builder target(BlobId targetId) { - this.targetId = targetId; + this.overrideInfo = false; + this.target = BlobInfo.builder(targetId).build(); return this; } @@ -1030,13 +1031,13 @@ public Builder target(BlobId targetId) { * Sets the copy target and target options. {@code target} parameter is used to override * source blob information (e.g. {@code contentType}, {@code contentLanguage}). Target blob * information is set exactly to {@code target}, no information is inherited from the source - * blob. If not set, target blob information is inherited from the source blob. + * blob. * * @return the builder */ - public Builder target(BlobInfo targetInfo, BlobTargetOption... options) { - this.targetId = targetInfo.blobId(); - this.targetInfo = targetInfo; + public Builder target(BlobInfo target, BlobTargetOption... options) { + this.overrideInfo = true; + this.target = checkNotNull(target); Collections.addAll(targetOptions, options); return this; } @@ -1045,13 +1046,13 @@ public Builder target(BlobInfo targetInfo, BlobTargetOption... options) { * Sets the copy target and target options. {@code target} parameter is used to override * source blob information (e.g. {@code contentType}, {@code contentLanguage}). Target blob * information is set exactly to {@code target}, no information is inherited from the source - * blob. If not set, target blob information is inherited from the source blob. + * blob. * * @return the builder */ - public Builder target(BlobInfo targetInfo, Iterable options) { - this.targetId = targetInfo.blobId(); - this.targetInfo = targetInfo; + public Builder target(BlobInfo target, Iterable options) { + this.overrideInfo = true; + this.target = checkNotNull(target); Iterables.addAll(targetOptions, options); return this; } @@ -1079,8 +1080,8 @@ public CopyRequest build() { private CopyRequest(Builder builder) { source = checkNotNull(builder.source); sourceOptions = ImmutableList.copyOf(builder.sourceOptions); - targetId = checkNotNull(builder.targetId); - targetInfo = builder.targetInfo; + overrideInfo = builder.overrideInfo; + target = checkNotNull(builder.target); targetOptions = ImmutableList.copyOf(builder.targetOptions); megabytesCopiedPerChunk = builder.megabytesCopiedPerChunk; } @@ -1100,20 +1101,21 @@ public List sourceOptions() { } /** - * Returns the {@link BlobId} for the target blob. + * Returns the {@link BlobInfo} for the target blob. */ - public BlobId targetId() { - return targetId; + public BlobInfo target() { + return target; } /** - * Returns the {@link BlobInfo} for the target blob. If set, this value is used to replace - * source blob information (e.g. {@code contentType}, {@code contentLanguage}). Target blob - * information is set exactly to this value, no information is inherited from the source blob. - * If not set, target blob information is inherited from the source blob. + * Returns whether to override the target blob information with {@link #target()}. + * If {@code true}, the value of {@link #target()} is used to replace source blob information + * (e.g. {@code contentType}, {@code contentLanguage}). Target blob information is set exactly + * to this value, no information is inherited from the source blob. If {@code false}, target + * blob information is inherited from the source blob. */ - public BlobInfo targetInfo() { - return targetInfo; + public boolean overrideInfo() { + return overrideInfo; } /** diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java index 30c0046b802c..cf709ba5e293 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageImpl.java @@ -413,19 +413,15 @@ public CopyWriter copy(final CopyRequest copyRequest) { final StorageObject source = copyRequest.source().toPb(); final Map sourceOptions = optionMap(copyRequest.source().generation(), null, copyRequest.sourceOptions(), true); - final BlobId targetId = copyRequest.targetId(); - final StorageObject targetObject = - copyRequest.targetInfo() != null ? copyRequest.targetInfo().toPb() : null; - final Map targetOptions = optionMap( - copyRequest.targetInfo() != null ? copyRequest.targetInfo().generation() : null, - copyRequest.targetInfo() != null ? copyRequest.targetInfo().metageneration() : null, - copyRequest.targetOptions()); + final StorageObject targetObject = copyRequest.target().toPb(); + final Map targetOptions = optionMap(copyRequest.target().generation(), + copyRequest.target().metageneration(), copyRequest.targetOptions()); try { RewriteResponse rewriteResponse = runWithRetries(new Callable() { @Override public RewriteResponse call() { return storageRpc.openRewrite(new StorageRpc.RewriteRequest(source, sourceOptions, - targetId.bucket(), targetId.name(), targetObject, targetOptions, + copyRequest.overrideInfo(), targetObject, targetOptions, copyRequest.megabytesCopiedPerChunk())); } }, options().retryParams(), EXCEPTION_HANDLER); diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java index 7f13212556aa..8d06832534e2 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/DefaultStorageRpc.java @@ -580,8 +580,8 @@ private RewriteResponse rewrite(RewriteRequest req, String token) { Long maxBytesRewrittenPerCall = req.megabytesRewrittenPerCall != null ? req.megabytesRewrittenPerCall * MEGABYTE : null; com.google.api.services.storage.model.RewriteResponse rewriteResponse = storage.objects() - .rewrite(req.source.getBucket(), req.source.getName(), req.targetBucket, - req.targetName, req.targetObject) + .rewrite(req.source.getBucket(), req.source.getName(), req.target.getBucket(), + req.target.getName(), req.overrideInfo ? req.target : null) .setSourceGeneration(req.source.getGeneration()) .setRewriteToken(token) .setMaxBytesRewrittenPerCall(maxBytesRewrittenPerCall) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java index 7256368e189f..74f8171de87f 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/spi/StorageRpc.java @@ -138,20 +138,18 @@ class RewriteRequest { public final StorageObject source; public final Map sourceOptions; - public final String targetBucket; - public final String targetName; - public final StorageObject targetObject; + public final boolean overrideInfo; + public final StorageObject target; public final Map targetOptions; public final Long megabytesRewrittenPerCall; public RewriteRequest(StorageObject source, Map sourceOptions, - String targetBucket, String targetName, StorageObject targetObject, - Map targetOptions, Long megabytesRewrittenPerCall) { + boolean overrideInfo, StorageObject target, Map targetOptions, + Long megabytesRewrittenPerCall) { this.source = source; this.sourceOptions = sourceOptions; - this.targetBucket = targetBucket; - this.targetName = targetName; - this.targetObject = targetObject; + this.overrideInfo = overrideInfo; + this.target = target; this.targetOptions = targetOptions; this.megabytesRewrittenPerCall = megabytesRewrittenPerCall; } @@ -167,17 +165,16 @@ public boolean equals(Object obj) { final RewriteRequest other = (RewriteRequest) obj; return Objects.equals(this.source, other.source) && Objects.equals(this.sourceOptions, other.sourceOptions) - && Objects.equals(this.targetBucket, other.targetBucket) - && Objects.equals(this.targetName, other.targetName) - && Objects.equals(this.targetObject, other.targetObject) + && Objects.equals(this.overrideInfo, other.overrideInfo) + && Objects.equals(this.target, other.target) && Objects.equals(this.targetOptions, other.targetOptions) && Objects.equals(this.megabytesRewrittenPerCall, other.megabytesRewrittenPerCall); } @Override public int hashCode() { - return Objects.hash(source, sourceOptions, targetBucket, targetName, targetObject, - targetOptions, megabytesRewrittenPerCall); + return Objects.hash(source, sourceOptions, overrideInfo, target, targetOptions, + megabytesRewrittenPerCall); } } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java index 2d4920816c38..d6c97ca9ca03 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java @@ -222,6 +222,7 @@ public void testDelete() throws Exception { @Test public void testCopyToBucket() throws Exception { initializeExpectedBlob(2); + BlobInfo target = BlobInfo.builder(BlobId.of("bt", "n")).build(); CopyWriter copyWriter = createMock(CopyWriter.class); Capture capturedCopyRequest = Capture.newInstance(); expect(storage.options()).andReturn(mockOptions); @@ -231,8 +232,8 @@ public void testCopyToBucket() throws Exception { CopyWriter returnedCopyWriter = blob.copyTo("bt"); assertEquals(copyWriter, returnedCopyWriter); assertEquals(capturedCopyRequest.getValue().source(), blob.blobId()); - assertEquals(capturedCopyRequest.getValue().targetId(), BlobId.of("bt", "n")); - assertNull(capturedCopyRequest.getValue().targetInfo()); + assertEquals(capturedCopyRequest.getValue().target(), target); + assertFalse(capturedCopyRequest.getValue().overrideInfo()); assertTrue(capturedCopyRequest.getValue().sourceOptions().isEmpty()); assertTrue(capturedCopyRequest.getValue().targetOptions().isEmpty()); } @@ -240,6 +241,7 @@ public void testCopyToBucket() throws Exception { @Test public void testCopyTo() throws Exception { initializeExpectedBlob(2); + BlobInfo target = BlobInfo.builder(BlobId.of("bt", "nt")).build(); CopyWriter copyWriter = createMock(CopyWriter.class); Capture capturedCopyRequest = Capture.newInstance(); expect(storage.options()).andReturn(mockOptions); @@ -249,8 +251,8 @@ public void testCopyTo() throws Exception { CopyWriter returnedCopyWriter = blob.copyTo("bt", "nt"); assertEquals(copyWriter, returnedCopyWriter); assertEquals(capturedCopyRequest.getValue().source(), blob.blobId()); - assertEquals(capturedCopyRequest.getValue().targetId(), BlobId.of("bt", "nt")); - assertNull(capturedCopyRequest.getValue().targetInfo()); + assertEquals(capturedCopyRequest.getValue().target(), target); + assertFalse(capturedCopyRequest.getValue().overrideInfo()); assertTrue(capturedCopyRequest.getValue().sourceOptions().isEmpty()); assertTrue(capturedCopyRequest.getValue().targetOptions().isEmpty()); } @@ -258,6 +260,7 @@ public void testCopyTo() throws Exception { @Test public void testCopyToBlobId() throws Exception { initializeExpectedBlob(2); + BlobInfo target = BlobInfo.builder(BlobId.of("bt", "nt")).build(); BlobId targetId = BlobId.of("bt", "nt"); CopyWriter copyWriter = createMock(CopyWriter.class); Capture capturedCopyRequest = Capture.newInstance(); @@ -268,8 +271,8 @@ public void testCopyToBlobId() throws Exception { CopyWriter returnedCopyWriter = blob.copyTo(targetId); assertEquals(copyWriter, returnedCopyWriter); assertEquals(capturedCopyRequest.getValue().source(), blob.blobId()); - assertEquals(capturedCopyRequest.getValue().targetId(), targetId); - assertNull(capturedCopyRequest.getValue().targetInfo()); + assertEquals(capturedCopyRequest.getValue().target(), target); + assertFalse(capturedCopyRequest.getValue().overrideInfo()); assertTrue(capturedCopyRequest.getValue().sourceOptions().isEmpty()); assertTrue(capturedCopyRequest.getValue().targetOptions().isEmpty()); } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyRequestTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyRequestTest.java index 5700ea804cd6..9f8edfb84162 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyRequestTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyRequestTest.java @@ -18,7 +18,8 @@ import static com.google.gcloud.storage.Storage.PredefinedAcl.PUBLIC_READ; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableList; import com.google.gcloud.storage.Storage.BlobSourceOption; @@ -53,8 +54,8 @@ public void testCopyRequest() { assertEquals(SOURCE_BLOB_ID, copyRequest1.source()); assertEquals(1, copyRequest1.sourceOptions().size()); assertEquals(BlobSourceOption.generationMatch(1), copyRequest1.sourceOptions().get(0)); - assertEquals(TARGET_BLOB_INFO.blobId(), copyRequest1.targetId()); - assertEquals(TARGET_BLOB_INFO, copyRequest1.targetInfo()); + assertEquals(TARGET_BLOB_INFO, copyRequest1.target()); + assertTrue(copyRequest1.overrideInfo()); assertEquals(1, copyRequest1.targetOptions().size()); assertEquals(BlobTargetOption.predefinedAcl(PUBLIC_READ), copyRequest1.targetOptions().get(0)); @@ -63,16 +64,16 @@ public void testCopyRequest() { .target(TARGET_BLOB_ID) .build(); assertEquals(SOURCE_BLOB_ID, copyRequest2.source()); - assertEquals(TARGET_BLOB_ID, copyRequest2.targetId()); - assertNull(copyRequest2.targetInfo()); + assertEquals(BlobInfo.builder(TARGET_BLOB_ID).build(), copyRequest2.target()); + assertFalse(copyRequest2.overrideInfo()); Storage.CopyRequest copyRequest3 = Storage.CopyRequest.builder() .source(SOURCE_BLOB_ID) .target(TARGET_BLOB_INFO, ImmutableList.of(BlobTargetOption.predefinedAcl(PUBLIC_READ))) .build(); assertEquals(SOURCE_BLOB_ID, copyRequest3.source()); - assertEquals(TARGET_BLOB_INFO.blobId(), copyRequest3.targetId()); - assertEquals(TARGET_BLOB_INFO, copyRequest3.targetInfo()); + assertEquals(TARGET_BLOB_INFO, copyRequest3.target()); + assertTrue(copyRequest3.overrideInfo()); assertEquals(ImmutableList.of(BlobTargetOption.predefinedAcl(PUBLIC_READ)), copyRequest3.targetOptions()); } @@ -81,34 +82,37 @@ public void testCopyRequest() { public void testCopyRequestOf() { Storage.CopyRequest copyRequest1 = Storage.CopyRequest.of(SOURCE_BLOB_ID, TARGET_BLOB_INFO); assertEquals(SOURCE_BLOB_ID, copyRequest1.source()); - assertEquals(TARGET_BLOB_INFO.blobId(), copyRequest1.targetId()); - assertEquals(TARGET_BLOB_INFO, copyRequest1.targetInfo()); + assertEquals(TARGET_BLOB_INFO, copyRequest1.target()); + assertTrue(copyRequest1.overrideInfo()); Storage.CopyRequest copyRequest2 = Storage.CopyRequest.of(SOURCE_BLOB_ID, TARGET_BLOB_NAME); assertEquals(SOURCE_BLOB_ID, copyRequest2.source()); - assertEquals(BlobId.of(SOURCE_BUCKET_NAME, TARGET_BLOB_NAME), copyRequest2.targetId()); - assertNull(copyRequest2.targetInfo()); + assertEquals(BlobInfo.builder(BlobId.of(SOURCE_BUCKET_NAME, TARGET_BLOB_NAME)).build(), + copyRequest2.target()); + assertFalse(copyRequest2.overrideInfo()); Storage.CopyRequest copyRequest3 = Storage.CopyRequest.of(SOURCE_BUCKET_NAME, SOURCE_BLOB_NAME, TARGET_BLOB_INFO); assertEquals(SOURCE_BLOB_ID, copyRequest3.source()); - assertEquals(TARGET_BLOB_INFO.blobId(), copyRequest3.targetId()); - assertEquals(TARGET_BLOB_INFO, copyRequest3.targetInfo()); + assertEquals(TARGET_BLOB_INFO, copyRequest3.target()); + assertTrue(copyRequest3.overrideInfo()); Storage.CopyRequest copyRequest4 = Storage.CopyRequest.of(SOURCE_BUCKET_NAME, SOURCE_BLOB_NAME, TARGET_BLOB_NAME); assertEquals(SOURCE_BLOB_ID, copyRequest4.source()); - assertEquals(BlobId.of(SOURCE_BUCKET_NAME, TARGET_BLOB_NAME), copyRequest4.targetId()); - assertNull(copyRequest4.targetInfo()); + assertEquals(BlobInfo.builder(BlobId.of(SOURCE_BUCKET_NAME, TARGET_BLOB_NAME)).build(), + copyRequest4.target()); + assertFalse(copyRequest4.overrideInfo()); Storage.CopyRequest copyRequest5 = Storage.CopyRequest.of(SOURCE_BLOB_ID, TARGET_BLOB_ID); assertEquals(SOURCE_BLOB_ID, copyRequest5.source()); - assertEquals(TARGET_BLOB_ID, copyRequest5.targetId()); - assertNull(copyRequest5.targetInfo()); + assertEquals(BlobInfo.builder(TARGET_BLOB_ID).build(), copyRequest5.target()); + assertFalse(copyRequest5.overrideInfo()); Storage.CopyRequest copyRequest6 = Storage.CopyRequest.of(SOURCE_BUCKET_NAME, SOURCE_BLOB_NAME, TARGET_BLOB_ID); assertEquals(SOURCE_BLOB_ID, copyRequest6.source()); - assertEquals(TARGET_BLOB_ID, copyRequest6.targetId()); - assertNull(copyRequest6.targetInfo()); } + assertEquals(BlobInfo.builder(TARGET_BLOB_ID).build(), copyRequest6.target()); + assertFalse(copyRequest6.overrideInfo()); + } } diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java index 75b863075770..8ccb81688b65 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/CopyWriterTest.java @@ -52,11 +52,11 @@ public class CopyWriterTest { BlobInfo.builder(DESTINATION_BUCKET_NAME, DESTINATION_BLOB_NAME).contentType("type").build(); private static final Map EMPTY_OPTIONS = ImmutableMap.of(); private static final RewriteRequest REQUEST_WITH_OBJECT = - new StorageRpc.RewriteRequest(BLOB_ID.toPb(), EMPTY_OPTIONS, DESTINATION_BUCKET_NAME, - DESTINATION_BLOB_NAME, BLOB_INFO.toPb(), EMPTY_OPTIONS, null); + new StorageRpc.RewriteRequest(BLOB_ID.toPb(), EMPTY_OPTIONS, true, BLOB_INFO.toPb(), + EMPTY_OPTIONS, null); private static final RewriteRequest REQUEST_WITHOUT_OBJECT = - new StorageRpc.RewriteRequest(BLOB_ID.toPb(), EMPTY_OPTIONS, DESTINATION_BUCKET_NAME, - DESTINATION_BLOB_NAME, null, EMPTY_OPTIONS, null); + new StorageRpc.RewriteRequest(BLOB_ID.toPb(), EMPTY_OPTIONS, false, BLOB_INFO.toPb(), + EMPTY_OPTIONS, null); private static final RewriteResponse RESPONSE_WITH_OBJECT = new RewriteResponse( REQUEST_WITH_OBJECT, null, 42L, false, "token", 21L); private static final RewriteResponse RESPONSE_WITHOUT_OBJECT = new RewriteResponse( diff --git a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java index db1166598237..3cc99e3bf884 100644 --- a/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java +++ b/gcloud-java-storage/src/test/java/com/google/gcloud/storage/StorageImplTest.java @@ -866,8 +866,7 @@ public void testComposeWithOptions() { public void testCopy() { CopyRequest request = Storage.CopyRequest.of(BLOB_INFO1.blobId(), BLOB_INFO2.blobId()); StorageRpc.RewriteRequest rpcRequest = new StorageRpc.RewriteRequest(request.source().toPb(), - EMPTY_RPC_OPTIONS, BLOB_INFO2.blobId().bucket(), BLOB_INFO2.blobId().name(), null, - EMPTY_RPC_OPTIONS, null); + EMPTY_RPC_OPTIONS, false, BLOB_INFO2.toPb(), EMPTY_RPC_OPTIONS, null); StorageRpc.RewriteResponse rpcResponse = new StorageRpc.RewriteResponse(rpcRequest, null, 42L, false, "token", 21L); EasyMock.expect(storageRpcMock.openRewrite(rpcRequest)).andReturn(rpcResponse); @@ -887,8 +886,7 @@ public void testCopyWithOptions() { .target(BLOB_INFO1, BLOB_TARGET_GENERATION, BLOB_TARGET_METAGENERATION) .build(); StorageRpc.RewriteRequest rpcRequest = new StorageRpc.RewriteRequest(request.source().toPb(), - BLOB_SOURCE_OPTIONS_COPY, BLOB_INFO1.blobId().bucket(), BLOB_INFO1.blobId().name(), - request.targetInfo().toPb(), BLOB_TARGET_OPTIONS_COMPOSE, null); + BLOB_SOURCE_OPTIONS_COPY, true, request.target().toPb(), BLOB_TARGET_OPTIONS_COMPOSE, null); StorageRpc.RewriteResponse rpcResponse = new StorageRpc.RewriteResponse(rpcRequest, null, 42L, false, "token", 21L); EasyMock.expect(storageRpcMock.openRewrite(rpcRequest)).andReturn(rpcResponse); @@ -908,8 +906,7 @@ public void testCopyWithOptionsFromBlobId() { .target(BLOB_INFO1, BLOB_TARGET_GENERATION, BLOB_TARGET_METAGENERATION) .build(); StorageRpc.RewriteRequest rpcRequest = new StorageRpc.RewriteRequest(request.source().toPb(), - BLOB_SOURCE_OPTIONS_COPY, BLOB_INFO1.blobId().bucket(), BLOB_INFO1.blobId().name(), - request.targetInfo().toPb(), BLOB_TARGET_OPTIONS_COMPOSE, null); + BLOB_SOURCE_OPTIONS_COPY, true, request.target().toPb(), BLOB_TARGET_OPTIONS_COMPOSE, null); StorageRpc.RewriteResponse rpcResponse = new StorageRpc.RewriteResponse(rpcRequest, null, 42L, false, "token", 21L); EasyMock.expect(storageRpcMock.openRewrite(rpcRequest)).andReturn(rpcResponse); @@ -925,8 +922,7 @@ public void testCopyWithOptionsFromBlobId() { public void testCopyMultipleRequests() { CopyRequest request = Storage.CopyRequest.of(BLOB_INFO1.blobId(), BLOB_INFO2.blobId()); StorageRpc.RewriteRequest rpcRequest = new StorageRpc.RewriteRequest(request.source().toPb(), - EMPTY_RPC_OPTIONS, BLOB_INFO2.blobId().bucket(), BLOB_INFO2.blobId().name(), null, - EMPTY_RPC_OPTIONS, null); + EMPTY_RPC_OPTIONS, false, BLOB_INFO2.toPb(), EMPTY_RPC_OPTIONS, null); StorageRpc.RewriteResponse rpcResponse1 = new StorageRpc.RewriteResponse(rpcRequest, null, 42L, false, "token", 21L); StorageRpc.RewriteResponse rpcResponse2 = new StorageRpc.RewriteResponse(rpcRequest, From 1855ae1a86370e90bc5fae34dff58bf39cb27671 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Sun, 20 Mar 2016 21:05:49 +0100 Subject: [PATCH 157/203] Add better javadoc to Storage.copy and CopyWriter --- .../com/google/gcloud/storage/CopyWriter.java | 8 +++++++- .../java/com/google/gcloud/storage/Storage.java | 17 +++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java index 26c728942a28..2f3850d5dd03 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java @@ -32,7 +32,13 @@ import java.util.concurrent.Callable; /** - * Google Storage blob copy writer. This class holds the result of a copy request. If source and + * Google Storage blob copy writer. A {@code CopyWriter} object allows to copy both blob's data and + * information. To override source blob's information call {@link Storage#copy(Storage.CopyRequest)} + * with a {@code CopyRequest} object where the copy target is set via + * {@link Storage.CopyRequest.Builder#target(BlobInfo, Storage.BlobTargetOption...)} or + * {@link Storage.CopyRequest.Builder#target(BlobInfo, Iterable)}. + * + *

      This class holds the result of a copy request. If source and * destination blobs share the same location and storage class the copy is completed in one RPC call * otherwise one or more {@link #copyChunk} calls are necessary to complete the copy. In addition, * {@link CopyWriter#result()} can be used to automatically complete the copy and return information diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index b30d46431de0..33c1d7e7e143 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -1385,12 +1385,17 @@ public static Builder builder() { Blob compose(ComposeRequest composeRequest); /** - * Sends a copy request. Returns a {@link CopyWriter} object for the provided - * {@code CopyRequest}. If source and destination objects share the same location and storage - * class the source blob is copied with one request and {@link CopyWriter#result()} immediately - * returns, regardless of the {@link CopyRequest#megabytesCopiedPerChunk} parameter. - * If source and destination have different location or storage class {@link CopyWriter#result()} - * might issue multiple RPC calls depending on blob's size. + * Sends a copy request. This method copies both blob's data and information. To override source + * blob's information set the copy target via + * {@link CopyRequest.Builder#target(BlobInfo, BlobTargetOption...)} or + * {@link CopyRequest.Builder#target(BlobInfo, Iterable)}. + * + *

      This method returns a {@link CopyWriter} object for the provided {@code CopyRequest}. If + * source and destination objects share the same location and storage class the source blob is + * copied with one request and {@link CopyWriter#result()} immediately returns, regardless of the + * {@link CopyRequest#megabytesCopiedPerChunk} parameter. If source and destination have different + * location or storage class {@link CopyWriter#result()} might issue multiple RPC calls depending + * on blob's size. * *

      Example usage of copy: *

       {@code BlobInfo blob = service.copy(copyRequest).result();}
      
      From 5dd0292085c00ac79aed381d4192bc33b09e2b97 Mon Sep 17 00:00:00 2001
      From: Marco Ziccardi 
      Date: Sun, 20 Mar 2016 22:39:16 +0100
      Subject: [PATCH 158/203] Rephrase RewriteChannel and Storage.copy javadoc. Add
       final to CopyWriter's StateImpl.target
      
      ---
       .../main/java/com/google/gcloud/storage/CopyWriter.java    | 6 +++---
       .../src/main/java/com/google/gcloud/storage/Storage.java   | 7 ++++---
       2 files changed, 7 insertions(+), 6 deletions(-)
      
      diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java
      index 2f3850d5dd03..743630b6c4c2 100644
      --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java
      +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/CopyWriter.java
      @@ -33,8 +33,8 @@
       
       /**
        * Google Storage blob copy writer. A {@code CopyWriter} object allows to copy both blob's data and
      - * information. To override source blob's information call {@link Storage#copy(Storage.CopyRequest)}
      - * with a {@code CopyRequest} object where the copy target is set via
      + * information. To override source blob's information supply a {@code BlobInfo} to the
      + * {@code CopyRequest} using either
        * {@link Storage.CopyRequest.Builder#target(BlobInfo, Storage.BlobTargetOption...)} or
        * {@link Storage.CopyRequest.Builder#target(BlobInfo, Iterable)}.
        *
      @@ -176,7 +176,7 @@ static class Builder {
             private final BlobId source;
             private final Map sourceOptions;
             private final boolean overrideInfo;
      -      private BlobInfo target;
      +      private final BlobInfo target;
             private final Map targetOptions;
             private BlobInfo result;
             private long blobSize;
      diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java
      index 33c1d7e7e143..b4fbe45244b0 100644
      --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java
      +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java
      @@ -1386,9 +1386,10 @@ public static Builder builder() {
       
         /**
          * Sends a copy request. This method copies both blob's data and information. To override source
      -   * blob's information set the copy target via
      -   * {@link CopyRequest.Builder#target(BlobInfo, BlobTargetOption...)} or
      -   * {@link CopyRequest.Builder#target(BlobInfo, Iterable)}.
      +   * blob's information supply a {@code BlobInfo} to the
      +   * {@code CopyRequest} using either
      +   * {@link Storage.CopyRequest.Builder#target(BlobInfo, Storage.BlobTargetOption...)} or
      +   * {@link Storage.CopyRequest.Builder#target(BlobInfo, Iterable)}.
          *
          * 

      This method returns a {@link CopyWriter} object for the provided {@code CopyRequest}. If * source and destination objects share the same location and storage class the source blob is From 3e9e1a0e8e034248c090e9c9b9918d3a783412be Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Wed, 16 Mar 2016 13:48:52 -0700 Subject: [PATCH 159/203] IAM docs and functional methods for policies --- .../snippets/ModifyPolicy.java | 64 +++++++++++++++++ gcloud-java-resourcemanager/README.md | 43 +++++++++++- .../google/gcloud/resourcemanager/Policy.java | 5 ++ .../gcloud/resourcemanager/Project.java | 68 +++++++++++++++++++ .../gcloud/resourcemanager/ProjectTest.java | 46 +++++++++++++ 5 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java new file mode 100644 index 000000000000..7401f0b88bbc --- /dev/null +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java @@ -0,0 +1,64 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file is referenced in READMEs and javadoc. Any change to this file should be reflected in + * the project's READMEs and package-info.java. + */ + +package com.google.gcloud.examples.resourcemanager.snippets; + +import com.google.gcloud.Identity; +import com.google.gcloud.resourcemanager.Policy; +import com.google.gcloud.resourcemanager.Policy.Role; +import com.google.gcloud.resourcemanager.Project; +import com.google.gcloud.resourcemanager.ResourceManager; +import com.google.gcloud.resourcemanager.ResourceManagerOptions; + +/** + * A snippet for Google Cloud Resource Manager showing how to modify a project's IAM policy. + */ +public class ModifyPolicy { + + public static void main(String... args) { + // Create Resource Manager service object + // By default, credentials are inferred from the runtime environment. + ResourceManager resourceManager = ResourceManagerOptions.defaultInstance().service(); + + // Get a project from the server + String projectId = "some-project-id"; // Use an existing project's ID + Project project = resourceManager.get(projectId); + + // Get the project's policy + Policy policy = project.getPolicy(); + + // Add a viewer + Policy.Builder modifiedPolicy = policy.toBuilder(); + Identity newViewer = Identity.user(""); + if (policy.bindings().containsKey(Role.viewer())) { + modifiedPolicy.addIdentity(Role.viewer(), newViewer); + } else { + modifiedPolicy.addBinding(Role.viewer(), newViewer); + } + + // Write policy + Policy updatedPolicy = project.replacePolicy(modifiedPolicy.build()); + + // Print policy + System.out.printf("Updated policy for %s: %n%s%n", projectId, updatedPolicy); + } +} diff --git a/gcloud-java-resourcemanager/README.md b/gcloud-java-resourcemanager/README.md index 94037e27a709..a2539df7adab 100644 --- a/gcloud-java-resourcemanager/README.md +++ b/gcloud-java-resourcemanager/README.md @@ -163,9 +163,46 @@ while (projectIterator.hasNext()) { } ``` +#### Managing IAM Policies +You can edit [Google Cloud IAM](https://cloud.google.com/iam/) (Identity and Access Management) +policies on the project-level using this library as well. We recommend using the read-modify-write +pattern to make policy changes. This entails reading the project's current policy, updating it +locally, and then sending the modified policy for writing, as shown in the snippet below. First, +add these imports: + +```java +import com.google.gcloud.Identity; +import com.google.gcloud.resourcemanager.Policy; +import com.google.gcloud.resourcemanager.Policy.Role; +``` + +Assuming you have completed the steps above to create the `ResourceManager` service object and load +a project from the server, you just need to add the following code: + +```java +// Get the project's policy +Policy policy = project.getPolicy(); + +// Add a viewer +Policy.Builder modifiedPolicy = policy.toBuilder(); +Identity newViewer = Identity.user(""); +if (policy.bindings().containsKey(Role.viewer())) { + modifiedPolicy.addIdentity(Role.viewer(), newViewer); +} else { + modifiedPolicy.addBinding(Role.viewer(), newViewer); +} + +// Write policy +Policy updatedPolicy = project.replacePolicy(modifiedPolicy.build()); +``` + +Note that the policy you pass in to `replacePolicy` overwrites the original policy. For example, if +the original policy has two bindings and you call `replacePolicy` with a new policy containing only +one binding, the two original bindings are lost. + #### Complete source code -We put together all the code shown above into two programs. Both programs assume that you are +We put together all the code shown above into three programs. The programs assume that you are running from your own desktop and used the Google Cloud SDK to authenticate yourself. The first program creates a project if it does not exist. Complete source code can be found at @@ -175,6 +212,10 @@ The second program updates a project if it exists and lists all projects the use view. Complete source code can be found at [UpdateAndListProjects.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/UpdateAndListProjects.java). +The third program modifies the IAM policy associated with a project using the read-modify-write +pattern. Complete source code can be found at +[ModifyPolicy.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java) + Java Versions ------------- diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java index 46330e19fa59..6399b52b3c04 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java @@ -178,6 +178,11 @@ public Builder toBuilder() { return new Builder(bindings(), etag(), version()); } + @Override + public String toString() { + return toPb().toString(); + } + com.google.api.services.cloudresourcemanager.model.Policy toPb() { com.google.api.services.cloudresourcemanager.model.Policy policyPb = new com.google.api.services.cloudresourcemanager.model.Policy(); diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java index 46b142c5aa53..dd252155645b 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java @@ -18,8 +18,11 @@ import static com.google.common.base.Preconditions.checkNotNull; +import com.google.gcloud.resourcemanager.ResourceManager.Permission; + import java.io.IOException; import java.io.ObjectInputStream; +import java.util.List; import java.util.Map; import java.util.Objects; @@ -198,6 +201,71 @@ public Project replace() { return resourceManager.replace(this); } + /** + * Returns the IAM access control policy for the specified project. Returns {@code null} if the + * resource does not exist or if you do not have adequate permission to view the project or get + * the policy. + * + * @throws ResourceManagerException upon failure + * @see + * Resource Manager getIamPolicy + */ + public Policy getPolicy() { + return resourceManager.getPolicy(projectId()); + } + + /** + * Sets the IAM access control policy for the specified project. Replaces any existing policy. + * It is recommended that you use the read-modify-write pattern. See code samples and important + * details of replacing policies in the documentation for {@link ResourceManager#replacePolicy}. + * + * @throws ResourceManagerException upon failure + * @see ResourceManager#replacePolicy + * @see + * Resource Manager setIamPolicy + */ + public Policy replacePolicy(Policy newPolicy) { + return resourceManager.replacePolicy(projectId(), newPolicy); + } + + /** + * Returns the permissions that a caller has on this project. You typically don't call this method + * if you're using Google Cloud Platform directly to manage permissions. This method is intended + * for integration with your proprietary software, such as a customized graphical user interface. + * For example, the Cloud Platform Console tests IAM permissions internally to determine which UI + * should be available to the logged-in user. + * + * @return A list of booleans representing whether the caller has the permissions specified (in + * the order of the given permissions) + * @throws ResourceManagerException upon failure + * @see + * Resource Manager testIamPermissions + */ + List testPermissions(List permissions) { + return resourceManager.testPermissions(projectId(), permissions); + } + + /** + * Returns the permissions that a caller has on this project. You typically don't call this method + * if you're using Google Cloud Platform directly to manage permissions. This method is intended + * for integration with your proprietary software, such as a customized graphical user interface. + * For example, the Cloud Platform Console tests IAM permissions internally to determine which UI + * should be available to the logged-in user. + * + * @return A list of booleans representing whether the caller has the permissions specified (in + * the order of the given permissions) + * @throws ResourceManagerException upon failure + * @see + * Resource Manager testIamPermissions + */ + List testPermissions(Permission first, Permission... others) { + return resourceManager.testPermissions(projectId(), first, others); + } + @Override public Builder toBuilder() { return new Builder(this); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java index 882ec77197f3..816f541146d5 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java @@ -25,13 +25,19 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.gcloud.Identity; +import com.google.gcloud.resourcemanager.Policy.Role; import com.google.gcloud.resourcemanager.ProjectInfo.ResourceId; +import com.google.gcloud.resourcemanager.ResourceManager.Permission; import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.util.List; import java.util.Map; public class ProjectTest { @@ -48,6 +54,13 @@ public class ProjectTest { .createTimeMillis(CREATE_TIME_MILLIS) .state(STATE) .build(); + private static final Identity USER = Identity.user("abc@gmail.com"); + private static final Identity SERVICE_ACCOUNT = + Identity.serviceAccount("service-account@gmail.com"); + private static final Policy POLICY = Policy.builder() + .addBinding(Role.owner(), ImmutableSet.of(USER)) + .addBinding(Role.editor(), ImmutableSet.of(SERVICE_ACCOUNT)) + .build(); private ResourceManager serviceMockReturnsOptions = createStrictMock(ResourceManager.class); private ResourceManagerOptions mockOptions = createMock(ResourceManagerOptions.class); @@ -205,6 +218,39 @@ public void testReplace() { compareProjectInfos(expectedReplacedProject, actualReplacedProject); } + @Test + public void testGetPolicy() { + expect(resourceManager.options()).andReturn(mockOptions).times(1); + expect(resourceManager.getPolicy(PROJECT_ID)).andReturn(POLICY); + replay(resourceManager); + initializeProject(); + assertEquals(POLICY, project.getPolicy()); + } + + @Test + public void testReplacePolicy() { + expect(resourceManager.options()).andReturn(mockOptions).times(1); + expect(resourceManager.replacePolicy(PROJECT_ID, POLICY)).andReturn(POLICY); + replay(resourceManager); + initializeProject(); + assertEquals(POLICY, project.replacePolicy(POLICY)); + } + + @Test + public void testTestPermissions() { + List response = ImmutableList.of(true, true); + expect(resourceManager.options()).andReturn(mockOptions).times(1); + expect(resourceManager.testPermissions(PROJECT_ID, Permission.GET, Permission.DELETE)) + .andReturn(response); + expect(resourceManager.testPermissions( + PROJECT_ID, ImmutableList.of(Permission.GET, Permission.DELETE))).andReturn(response); + replay(resourceManager); + initializeProject(); + assertEquals(response, project.testPermissions(Permission.GET, Permission.DELETE)); + assertEquals( + response, project.testPermissions(ImmutableList.of(Permission.GET, Permission.DELETE))); + } + private void compareProjects(Project expected, Project value) { assertEquals(expected, value); compareProjectInfos(expected, value); From c05e738b1f17048560b781f4445ca1ccff7f0759 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 21 Mar 2016 09:36:13 -0700 Subject: [PATCH 160/203] Add binding entries as necessary in IamPolicy.Builder --- .../java/com/google/gcloud/IamPolicy.java | 63 +++++-------------- .../java/com/google/gcloud/IamPolicyTest.java | 44 +++++++++---- .../snippets/ModifyPolicy.java | 6 +- .../gcloud/resourcemanager/Project.java | 18 +++--- .../gcloud/resourcemanager/PolicyTest.java | 16 ++--- .../gcloud/resourcemanager/ProjectTest.java | 4 +- .../ResourceManagerImplTest.java | 4 +- .../resourcemanager/SerializationTest.java | 6 +- 8 files changed, 73 insertions(+), 88 deletions(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java index 748eaba2ab4c..3d7c1422e6fa 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java @@ -83,39 +83,8 @@ public final B bindings(Map> bindings) { return self(); } - /** - * Adds a binding to the policy. - * - * @throws IllegalArgumentException if the policy already contains a binding with the same role - * or if the role or any identities are null - */ - public final B addBinding(R role, Set identities) { - verifyBinding(role, identities); - checkArgument(!bindings.containsKey(role), - "The policy already contains a binding with the role " + role.toString() + "."); - bindings.put(role, new HashSet(identities)); - return self(); - } - - /** - * Adds a binding to the policy. - * - * @throws IllegalArgumentException if the policy already contains a binding with the same role - * or if the role or any identities are null - */ - public final B addBinding(R role, Identity first, Identity... others) { - HashSet identities = new HashSet<>(); - identities.add(first); - identities.addAll(Arrays.asList(others)); - return addBinding(role, identities); - } - private void verifyBinding(R role, Collection identities) { checkArgument(role != null, "The role cannot be null."); - verifyIdentities(identities); - } - - private void verifyIdentities(Collection identities) { checkArgument(identities != null, "A role cannot be assigned to a null set of identities."); checkArgument(!identities.contains(null), "Null identities are not permitted."); } @@ -129,33 +98,33 @@ public final B removeBinding(R role) { } /** - * Adds one or more identities to an existing binding. - * - * @throws IllegalArgumentException if the policy doesn't contain a binding with the specified - * role or any identities are null + * Adds one or more identities to the policy under the role specified. Creates a new role + * binding if the binding corresponding to the given role did not previously exist. */ public final B addIdentity(R role, Identity first, Identity... others) { - checkArgument(bindings.containsKey(role), - "The policy doesn't contain the role " + role.toString() + "."); List toAdd = new LinkedList<>(); toAdd.add(first); toAdd.addAll(Arrays.asList(others)); - verifyIdentities(toAdd); - bindings.get(role).addAll(toAdd); + verifyBinding(role, toAdd); + Set identities = bindings.get(role); + if (identities == null) { + identities = new HashSet(); + bindings.put(role, identities); + } + identities.addAll(toAdd); return self(); } /** - * Removes one or more identities from an existing binding. - * - * @throws IllegalArgumentException if the policy doesn't contain a binding with the specified - * role + * Removes one or more identities from an existing binding. Does nothing if the binding + * associated with the provided role doesn't exist. */ public final B removeIdentity(R role, Identity first, Identity... others) { - checkArgument(bindings.containsKey(role), - "The policy doesn't contain the role " + role.toString() + "."); - bindings.get(role).remove(first); - bindings.get(role).removeAll(Arrays.asList(others)); + Set identities = bindings.get(role); + if (identities != null) { + identities.remove(first); + identities.removeAll(Arrays.asList(others)); + } return self(); } diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java index db0935c4766d..2f40c3b76001 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java @@ -28,6 +28,7 @@ import org.junit.Test; +import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -46,8 +47,8 @@ public class IamPolicyTest { "editor", ImmutableSet.of(ALL_AUTH_USERS, GROUP, DOMAIN)); private static final PolicyImpl SIMPLE_POLICY = PolicyImpl.builder() - .addBinding("viewer", ImmutableSet.of(USER, SERVICE_ACCOUNT, ALL_USERS)) - .addBinding("editor", ImmutableSet.of(ALL_AUTH_USERS, GROUP, DOMAIN)) + .addIdentity("viewer", USER, SERVICE_ACCOUNT, ALL_USERS) + .addIdentity("editor", ALL_AUTH_USERS, GROUP, DOMAIN) .build(); private static final PolicyImpl FULL_POLICY = new PolicyImpl.Builder(SIMPLE_POLICY.bindings(), "etag", 1).build(); @@ -105,22 +106,43 @@ public void testBuilder() { policy.bindings()); assertNull(policy.etag()); assertNull(policy.version()); - policy = PolicyImpl.builder().addBinding("owner", USER, SERVICE_ACCOUNT).build(); + policy = PolicyImpl.builder() + .removeIdentity("viewer", USER) + .addIdentity("owner", USER, SERVICE_ACCOUNT) + .build(); assertEquals( ImmutableMap.of("owner", ImmutableSet.of(USER, SERVICE_ACCOUNT)), policy.bindings()); assertNull(policy.etag()); assertNull(policy.version()); + } + + @Test + public void testIllegalPolicies() { + try { + PolicyImpl.builder().addIdentity(null, USER); + fail("Null role should cause exception."); + } catch (IllegalArgumentException ex) { + assertEquals("The role cannot be null.", ex.getMessage()); + } + try { + PolicyImpl.builder().addIdentity("viewer", null, USER); + fail("Null identity should cause exception."); + } catch (IllegalArgumentException ex) { + assertEquals("Null identities are not permitted.", ex.getMessage()); + } try { - SIMPLE_POLICY.toBuilder().addBinding("viewer", USER); - fail("Should have failed due to duplicate role."); - } catch (IllegalArgumentException e) { - assertEquals("The policy already contains a binding with the role viewer.", e.getMessage()); + PolicyImpl.builder().bindings(null); + fail("Null bindings map should cause exception."); + } catch (IllegalArgumentException ex) { + assertEquals("The provided map of bindings cannot be null.", ex.getMessage()); } try { - SIMPLE_POLICY.toBuilder().addBinding("editor", ImmutableSet.of(USER)); - fail("Should have failed due to duplicate role."); - } catch (IllegalArgumentException e) { - assertEquals("The policy already contains a binding with the role editor.", e.getMessage()); + Map> bindings = new HashMap<>(); + bindings.put("viewer", null); + PolicyImpl.builder().bindings(bindings); + fail("Null set of identities should cause exception."); + } catch (IllegalArgumentException ex) { + assertEquals("A role cannot be assigned to a null set of identities.", ex.getMessage()); } } diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java index 7401f0b88bbc..478765a9ecf4 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java @@ -49,11 +49,7 @@ public static void main(String... args) { // Add a viewer Policy.Builder modifiedPolicy = policy.toBuilder(); Identity newViewer = Identity.user(""); - if (policy.bindings().containsKey(Role.viewer())) { - modifiedPolicy.addIdentity(Role.viewer(), newViewer); - } else { - modifiedPolicy.addBinding(Role.viewer(), newViewer); - } + modifiedPolicy.addIdentity(Role.viewer(), newViewer); // Write policy Policy updatedPolicy = project.replacePolicy(modifiedPolicy.build()); diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java index dd252155645b..8c6a0eacd44f 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java @@ -202,10 +202,10 @@ public Project replace() { } /** - * Returns the IAM access control policy for the specified project. Returns {@code null} if the - * resource does not exist or if you do not have adequate permission to view the project or get - * the policy. + * Returns the IAM access control policy for this project. Returns {@code null} if the resource + * does not exist or if you do not have adequate permission to view the project or get the policy. * + * @return the IAM policy for the project * @throws ResourceManagerException upon failure * @see @@ -216,12 +216,12 @@ public Policy getPolicy() { } /** - * Sets the IAM access control policy for the specified project. Replaces any existing policy. - * It is recommended that you use the read-modify-write pattern. See code samples and important - * details of replacing policies in the documentation for {@link ResourceManager#replacePolicy}. + * Sets the IAM access control policy for this project. Replaces any existing policy. It is + * recommended that you use the read-modify-write pattern. See code samples and important details + * of replacing policies in the documentation for {@link ResourceManager#replacePolicy}. * + * @return the newly set IAM policy for this project * @throws ResourceManagerException upon failure - * @see ResourceManager#replacePolicy * @see * Resource Manager setIamPolicy @@ -237,7 +237,7 @@ public Policy replacePolicy(Policy newPolicy) { * For example, the Cloud Platform Console tests IAM permissions internally to determine which UI * should be available to the logged-in user. * - * @return A list of booleans representing whether the caller has the permissions specified (in + * @return a list of booleans representing whether the caller has the permissions specified (in * the order of the given permissions) * @throws ResourceManagerException upon failure * @see testPermissions(List permissions) { * For example, the Cloud Platform Console tests IAM permissions internally to determine which UI * should be available to the logged-in user. * - * @return A list of booleans representing whether the caller has the permissions specified (in + * @return a list of booleans representing whether the caller has the permissions specified (in * the order of the given permissions) * @throws ResourceManagerException upon failure * @see EMPTY_RPC_OPTIONS = ImmutableMap.of(); private static final Policy POLICY = Policy.builder() - .addBinding(Role.owner(), Identity.user("me@gmail.com")) - .addBinding(Role.editor(), Identity.serviceAccount("serviceaccount@gmail.com")) + .addIdentity(Role.owner(), Identity.user("me@gmail.com")) + .addIdentity(Role.editor(), Identity.serviceAccount("serviceaccount@gmail.com")) .build(); @Rule diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index c6e907da16a0..1c0b9c68c86d 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -17,7 +17,6 @@ package com.google.gcloud.resourcemanager; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.gcloud.BaseSerializationTest; import com.google.gcloud.Identity; import com.google.gcloud.PageImpl; @@ -46,9 +45,8 @@ public class SerializationTest extends BaseSerializationTest { ResourceManager.ProjectGetOption.fields(ResourceManager.ProjectField.NAME); private static final ResourceManager.ProjectListOption PROJECT_LIST_OPTION = ResourceManager.ProjectListOption.filter("name:*"); - private static final Policy POLICY = Policy.builder() - .addBinding(Policy.Role.viewer(), ImmutableSet.of(Identity.user("abc@gmail.com"))) - .build(); + private static final Policy POLICY = + Policy.builder().addIdentity(Policy.Role.viewer(), Identity.user("abc@gmail.com")).build(); private static final ResourceManagerException RESOURCE_MANAGER_EXCEPTION = new ResourceManagerException(42, "message"); From 7bbe67fd3651f9294b6c3bcb3265a3872d2f1383 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 21 Mar 2016 16:29:10 -0700 Subject: [PATCH 161/203] Take care of minor changes --- .../java/com/google/gcloud/IamPolicy.java | 44 +++++++++++-------- .../java/com/google/gcloud/IamPolicyTest.java | 29 +++++++++--- 2 files changed, 49 insertions(+), 24 deletions(-) diff --git a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java index 3d7c1422e6fa..9cce4b23c864 100644 --- a/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java +++ b/gcloud-java-core/src/main/java/com/google/gcloud/IamPolicy.java @@ -17,17 +17,16 @@ package com.google.gcloud; import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import java.io.Serializable; import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; +import java.util.LinkedHashSet; import java.util.Map; import java.util.Objects; import java.util.Set; @@ -69,12 +68,16 @@ protected Builder() {} /** * Replaces the builder's map of bindings with the given map of bindings. * - * @throws IllegalArgumentException if the provided map is null or contain any null values + * @throws NullPointerException if the given map is null or contains any null keys or values + * @throws IllegalArgumentException if any identities in the given map are null */ public final B bindings(Map> bindings) { - checkArgument(bindings != null, "The provided map of bindings cannot be null."); + checkNotNull(bindings, "The provided map of bindings cannot be null."); for (Map.Entry> binding : bindings.entrySet()) { - verifyBinding(binding.getKey(), binding.getValue()); + checkNotNull(binding.getKey(), "The role cannot be null."); + Set identities = binding.getValue(); + checkNotNull(identities, "A role cannot be assigned to a null set of identities."); + checkArgument(!identities.contains(null), "Null identities are not permitted."); } this.bindings.clear(); for (Map.Entry> binding : bindings.entrySet()) { @@ -83,30 +86,30 @@ public final B bindings(Map> bindings) { return self(); } - private void verifyBinding(R role, Collection identities) { - checkArgument(role != null, "The role cannot be null."); - checkArgument(identities != null, "A role cannot be assigned to a null set of identities."); - checkArgument(!identities.contains(null), "Null identities are not permitted."); - } - /** - * Removes the binding associated with the specified role. + * Removes the role (and all identities associated with that role) from the policy. */ - public final B removeBinding(R role) { + public final B removeRole(R role) { bindings.remove(role); return self(); } /** - * Adds one or more identities to the policy under the role specified. Creates a new role - * binding if the binding corresponding to the given role did not previously exist. + * Adds one or more identities to the policy under the role specified. + * + * @throws NullPointerException if the role or any of the identities is null. */ public final B addIdentity(R role, Identity first, Identity... others) { - List toAdd = new LinkedList<>(); + String nullIdentityMessage = "Null identities are not permitted."; + checkNotNull(first, nullIdentityMessage); + checkNotNull(others, nullIdentityMessage); + for (Identity identity : others) { + checkNotNull(identity, nullIdentityMessage); + } + Set toAdd = new LinkedHashSet<>(); toAdd.add(first); toAdd.addAll(Arrays.asList(others)); - verifyBinding(role, toAdd); - Set identities = bindings.get(role); + Set identities = bindings.get(checkNotNull(role, "The role cannot be null.")); if (identities == null) { identities = new HashSet(); bindings.put(role, identities); @@ -125,6 +128,9 @@ public final B removeIdentity(R role, Identity first, Identity... others) { identities.remove(first); identities.removeAll(Arrays.asList(others)); } + if (identities != null && identities.isEmpty()) { + bindings.remove(role); + } return self(); } diff --git a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java index 2f40c3b76001..235c2c2b1c85 100644 --- a/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java +++ b/gcloud-java-core/src/test/java/com/google/gcloud/IamPolicyTest.java @@ -29,6 +29,7 @@ import org.junit.Test; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -94,7 +95,7 @@ public void testBuilder() { assertEquals(editorBinding, policy.bindings()); assertEquals("etag", policy.etag()); assertEquals(1, policy.version().intValue()); - policy = SIMPLE_POLICY.toBuilder().removeBinding("editor").build(); + policy = SIMPLE_POLICY.toBuilder().removeRole("editor").build(); assertEquals(ImmutableMap.of("viewer", BINDINGS.get("viewer")), policy.bindings()); assertNull(policy.etag()); assertNull(policy.version()); @@ -109,6 +110,8 @@ public void testBuilder() { policy = PolicyImpl.builder() .removeIdentity("viewer", USER) .addIdentity("owner", USER, SERVICE_ACCOUNT) + .addIdentity("editor", GROUP) + .removeIdentity("editor", GROUP) .build(); assertEquals( ImmutableMap.of("owner", ImmutableSet.of(USER, SERVICE_ACCOUNT)), policy.bindings()); @@ -121,19 +124,25 @@ public void testIllegalPolicies() { try { PolicyImpl.builder().addIdentity(null, USER); fail("Null role should cause exception."); - } catch (IllegalArgumentException ex) { + } catch (NullPointerException ex) { assertEquals("The role cannot be null.", ex.getMessage()); } try { PolicyImpl.builder().addIdentity("viewer", null, USER); fail("Null identity should cause exception."); - } catch (IllegalArgumentException ex) { + } catch (NullPointerException ex) { + assertEquals("Null identities are not permitted.", ex.getMessage()); + } + try { + PolicyImpl.builder().addIdentity("viewer", USER, (Identity[]) null); + fail("Null identity should cause exception."); + } catch (NullPointerException ex) { assertEquals("Null identities are not permitted.", ex.getMessage()); } try { PolicyImpl.builder().bindings(null); fail("Null bindings map should cause exception."); - } catch (IllegalArgumentException ex) { + } catch (NullPointerException ex) { assertEquals("The provided map of bindings cannot be null.", ex.getMessage()); } try { @@ -141,9 +150,19 @@ public void testIllegalPolicies() { bindings.put("viewer", null); PolicyImpl.builder().bindings(bindings); fail("Null set of identities should cause exception."); - } catch (IllegalArgumentException ex) { + } catch (NullPointerException ex) { assertEquals("A role cannot be assigned to a null set of identities.", ex.getMessage()); } + try { + Map> bindings = new HashMap<>(); + Set identities = new HashSet<>(); + identities.add(null); + bindings.put("viewer", identities); + PolicyImpl.builder().bindings(bindings); + fail("Null identity should cause exception."); + } catch (IllegalArgumentException ex) { + assertEquals("Null identities are not permitted.", ex.getMessage()); + } } @Test From 3a97ae10587c21d34cf495447a3f9c3e9b9093da Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 21 Mar 2016 17:47:54 -0700 Subject: [PATCH 162/203] Make role and permission strings to allow for service-specific values --- .../snippets/ModifyPolicy.java | 4 +- .../google/gcloud/resourcemanager/Policy.java | 123 +++++------------- .../gcloud/resourcemanager/Project.java | 22 +++- .../resourcemanager/ResourceManager.java | 51 +++----- .../resourcemanager/ResourceManagerImpl.java | 15 +-- .../testing/LocalResourceManagerHelper.java | 14 +- .../LocalResourceManagerHelperTest.java | 7 - .../gcloud/resourcemanager/PolicyTest.java | 29 ++--- .../gcloud/resourcemanager/ProjectTest.java | 19 +-- .../ResourceManagerImplTest.java | 23 ++-- .../resourcemanager/SerializationTest.java | 6 +- 11 files changed, 108 insertions(+), 205 deletions(-) diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java index 478765a9ecf4..f97adf5b0916 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/resourcemanager/snippets/ModifyPolicy.java @@ -24,7 +24,7 @@ import com.google.gcloud.Identity; import com.google.gcloud.resourcemanager.Policy; -import com.google.gcloud.resourcemanager.Policy.Role; +import com.google.gcloud.resourcemanager.Policy.ProjectRole; import com.google.gcloud.resourcemanager.Project; import com.google.gcloud.resourcemanager.ResourceManager; import com.google.gcloud.resourcemanager.ResourceManagerOptions; @@ -49,7 +49,7 @@ public static void main(String... args) { // Add a viewer Policy.Builder modifiedPolicy = policy.toBuilder(); Identity newViewer = Identity.user(""); - modifiedPolicy.addIdentity(Role.viewer(), newViewer); + modifiedPolicy.addIdentity(ProjectRole.VIEWER.value(), newViewer); // Write policy Policy updatedPolicy = project.replacePolicy(modifiedPolicy.build()); diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java index 6399b52b3c04..884f474bed59 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java @@ -23,13 +23,11 @@ import com.google.gcloud.IamPolicy; import com.google.gcloud.Identity; -import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Set; /** @@ -42,120 +40,63 @@ * * @see Policy */ -public class Policy extends IamPolicy { +public class Policy extends IamPolicy { private static final long serialVersionUID = -5573557282693961850L; /** - * Represents legacy roles in an IAM Policy. + * The project-level roles in an IAM policy. This enum is not an exhaustive list of all roles + * you can use in an IAM policy. You can also use service-specific roles (e.g. + * roles/pubsub.editor). See the Supported Cloud Platform Services page for links + * to service-specific roles. + * + * @see Supported Cloud + * Platform Services */ - public static class Role implements Serializable { + public enum ProjectRole { /** - * The recognized roles in a Project's IAM policy. + * Permissions for read-only actions that preserve state. */ - public enum Type { - - /** - * Permissions for read-only actions that preserve state. - */ - VIEWER, - - /** - * All viewer permissions and permissions for actions that modify state. - */ - EDITOR, - - /** - * All editor permissions and permissions for the following actions: - *

        - *
      • Manage access control for a resource. - *
      • Set up billing (for a project). - *
      - */ - OWNER - } - - private static final long serialVersionUID = 2421978909244287488L; - - private final String value; - private final Type type; - - private Role(String value, Type type) { - this.value = value; - this.type = type; - } - - String value() { - return value; - } + VIEWER("roles/viewer"), /** - * Returns the type of role (editor, owner, or viewer). Returns {@code null} if the role type - * is unrecognized. + * All viewer permissions and permissions for actions that modify state. */ - public Type type() { - return type; - } + EDITOR("roles/editor"), /** - * Returns a {@code Role} of type {@link Type#VIEWER VIEWER}. + * All editor permissions and permissions for the following actions: + *
        + *
      • Manage access control for a resource. + *
      • Set up billing (for a project). + *
      */ - public static Role viewer() { - return new Role("roles/viewer", Type.VIEWER); - } + OWNER("roles/owner"); - /** - * Returns a {@code Role} of type {@link Type#EDITOR EDITOR}. - */ - public static Role editor() { - return new Role("roles/editor", Type.EDITOR); + String value; + + private ProjectRole(String value) { + this.value = value; } /** - * Returns a {@code Role} of type {@link Type#OWNER OWNER}. + * Returns the string value associated with the role. */ - public static Role owner() { - return new Role("roles/owner", Type.OWNER); - } - - static Role rawRole(String roleStr) { - return new Role(roleStr, null); - } - - static Role fromStr(String roleStr) { - try { - Type type = Type.valueOf(roleStr.split("/")[1].toUpperCase()); - return new Role(roleStr, type); - } catch (Exception ex) { - return new Role(roleStr, null); - } - } - - @Override - public final int hashCode() { - return Objects.hash(value, type); - } - - @Override - public final boolean equals(Object obj) { - if (!(obj instanceof Role)) { - return false; - } - Role other = (Role) obj; - return Objects.equals(value, other.value()) && Objects.equals(type, other.type()); + public String value() { + return value; } } /** * Builder for an IAM Policy. */ - public static class Builder extends IamPolicy.Builder { + public static class Builder extends IamPolicy.Builder { private Builder() {} @VisibleForTesting - Builder(Map> bindings, String etag, Integer version) { + Builder(Map> bindings, String etag, Integer version) { bindings(bindings).etag(etag).version(version); } @@ -188,10 +129,10 @@ com.google.api.services.cloudresourcemanager.model.Policy toPb() { new com.google.api.services.cloudresourcemanager.model.Policy(); List bindingPbList = new LinkedList<>(); - for (Map.Entry> binding : bindings().entrySet()) { + for (Map.Entry> binding : bindings().entrySet()) { com.google.api.services.cloudresourcemanager.model.Binding bindingPb = new com.google.api.services.cloudresourcemanager.model.Binding(); - bindingPb.setRole(binding.getKey().value()); + bindingPb.setRole(binding.getKey()); bindingPb.setMembers( Lists.transform( new ArrayList<>(binding.getValue()), @@ -211,11 +152,11 @@ public String apply(Identity identity) { static Policy fromPb( com.google.api.services.cloudresourcemanager.model.Policy policyPb) { - Map> bindings = new HashMap<>(); + Map> bindings = new HashMap<>(); for (com.google.api.services.cloudresourcemanager.model.Binding bindingPb : policyPb.getBindings()) { bindings.put( - Role.fromStr(bindingPb.getRole()), + bindingPb.getRole(), ImmutableSet.copyOf( Lists.transform( bindingPb.getMembers(), diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java index 8c6a0eacd44f..de5e6c336af4 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java @@ -18,8 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -import com.google.gcloud.resourcemanager.ResourceManager.Permission; - import java.io.IOException; import java.io.ObjectInputStream; import java.util.List; @@ -235,7 +233,9 @@ public Policy replacePolicy(Policy newPolicy) { * if you're using Google Cloud Platform directly to manage permissions. This method is intended * for integration with your proprietary software, such as a customized graphical user interface. * For example, the Cloud Platform Console tests IAM permissions internally to determine which UI - * should be available to the logged-in user. + * should be available to the logged-in user. Each service that supports IAM lists the possible + * permissions; see the Supported Cloud Platform services page below for links to these + * lists. * * @return a list of booleans representing whether the caller has the permissions specified (in * the order of the given permissions) @@ -243,8 +243,11 @@ public Policy replacePolicy(Policy newPolicy) { * @see * Resource Manager testIamPermissions + * @see Supported Cloud Platform + * Services */ - List testPermissions(List permissions) { + List testPermissions(List permissions) { return resourceManager.testPermissions(projectId(), permissions); } @@ -253,7 +256,9 @@ List testPermissions(List permissions) { * if you're using Google Cloud Platform directly to manage permissions. This method is intended * for integration with your proprietary software, such as a customized graphical user interface. * For example, the Cloud Platform Console tests IAM permissions internally to determine which UI - * should be available to the logged-in user. + * should be available to the logged-in user. Each service that supports IAM lists the possible + * permissions; see the Supported Cloud Platform services page below for links to these + * lists. * * @return a list of booleans representing whether the caller has the permissions specified (in * the order of the given permissions) @@ -261,9 +266,12 @@ List testPermissions(List permissions) { * @see * Resource Manager testIamPermissions + * @see Supported Cloud Platform + * Services */ - List testPermissions(Permission first, Permission... others) { - return resourceManager.testPermissions(projectId(), first, others); + List testPermissions(String firstPermission, String... otherPermissions) { + return resourceManager.testPermissions(projectId(), firstPermission, otherPermissions); } @Override diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java index f14d47f2a676..708bd711b477 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java @@ -169,38 +169,6 @@ public static ProjectListOption fields(ProjectField... fields) { } } - /** - * The permissions associated with a Google Cloud project. These values can be used when calling - * {@link #testPermissions}. - * - * @see - * Project-level roles - */ - enum Permission { - DELETE("delete"), - GET("get"), - GET_POLICY("getIamPolicy"), - REPLACE("update"), - REPLACE_POLICY("setIamPolicy"), - UNDELETE("undelete"); - - private static final String PREFIX = "resourcemanager.projects."; - - private final String value; - - Permission(String suffix) { - this.value = PREFIX + suffix; - } - - /** - * Returns the string representation of the permission. - */ - public String value() { - return value; - } - } - /** * Creates a new project. * @@ -358,7 +326,9 @@ public String value() { * this method if you're using Google Cloud Platform directly to manage permissions. This method * is intended for integration with your proprietary software, such as a customized graphical user * interface. For example, the Cloud Platform Console tests IAM permissions internally to - * determine which UI should be available to the logged-in user. + * determine which UI should be available to the logged-in user. Each service that supports IAM + * lists the possible permissions; see the Supported Cloud Platform services page below for + * links to these lists. * * @return A list of booleans representing whether the caller has the permissions specified (in * the order of the given permissions) @@ -366,15 +336,20 @@ public String value() { * @see * Resource Manager testIamPermissions + * @see Supported Cloud Platform + * Services */ - List testPermissions(String projectId, List permissions); + List testPermissions(String projectId, List permissions); /** * Returns the permissions that a caller has on the specified project. You typically don't call * this method if you're using Google Cloud Platform directly to manage permissions. This method * is intended for integration with your proprietary software, such as a customized graphical user * interface. For example, the Cloud Platform Console tests IAM permissions internally to - * determine which UI should be available to the logged-in user. + * determine which UI should be available to the logged-in user. Each service that supports IAM + * lists the possible permissions; see the Supported Cloud Platform services page below for + * links to these lists. * * @return A list of booleans representing whether the caller has the permissions specified (in * the order of the given permissions) @@ -382,6 +357,10 @@ public String value() { * @see * Resource Manager testIamPermissions + * @see Supported Cloud Platform + * Services */ - List testPermissions(String projectId, Permission first, Permission... others); + List testPermissions( + String projectId, String firstPermission, String... otherPermissions); } diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java index d9911b911f0b..5526918bc1eb 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java @@ -216,19 +216,13 @@ public com.google.api.services.cloudresourcemanager.model.Policy call() { } @Override - public List testPermissions(final String projectId, final List permissions) { + public List testPermissions(final String projectId, final List permissions) { try { return runWithRetries( new Callable>() { @Override public List call() { - return resourceManagerRpc.testPermissions(projectId, - Lists.transform(permissions, new Function() { - @Override - public String apply(Permission permission) { - return permission.value(); - } - })); + return resourceManagerRpc.testPermissions(projectId, permissions); } }, options().retryParams(), EXCEPTION_HANDLER); } catch (RetryHelperException ex) { @@ -237,8 +231,9 @@ public String apply(Permission permission) { } @Override - public List testPermissions(String projectId, Permission first, Permission... others) { - return testPermissions(projectId, Lists.asList(first, others)); + public List testPermissions( + String projectId, String firstPermission, String... otherPermissions) { + return testPermissions(projectId, Lists.asList(firstPermission, otherPermissions)); } private Map optionMap(Option... options) { diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java index 8ddca18b6261..4d466e55a897 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -18,7 +18,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.io.ByteStreams; import com.google.gcloud.AuthCredentials; -import com.google.gcloud.resourcemanager.ResourceManager.Permission; import com.google.gcloud.resourcemanager.ResourceManagerOptions; import com.sun.net.httpserver.Headers; @@ -38,7 +37,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Random; @@ -66,7 +64,8 @@ *
    1. IAM policies are set to an empty policy with version 0 (only legacy roles supported) upon * project creation. The actual service will not have an empty list of bindings and may also * set your version to 1. - *
    2. There is no input validation for the policy provided when replacing a policy. + *
    3. There is no input validation for the policy provided when replacing a policy or calling + * testIamPermissions. *
    4. In this mock, projects never move from the DELETE_REQUESTED lifecycle state to * DELETE_IN_PROGRESS without an explicit call to the utility method * {@link #changeLifecycleState}. Similarly, a project is never completely removed without an @@ -89,12 +88,8 @@ public class LocalResourceManagerHelper { private static final Pattern LIST_FIELDS_PATTERN = Pattern.compile("(.*?)projects\\((.*?)\\)(.*?)"); private static final String[] NO_FIELDS = {}; - private static final Set PERMISSIONS = new HashSet<>(); static { - for (Permission permission : Permission.values()) { - PERMISSIONS.add(permission.value()); - } try { BASE_CONTEXT = new URI(CONTEXT); } catch (URISyntaxException e) { @@ -635,11 +630,6 @@ synchronized Response testPermissions(String projectId, List permissions if (!projects.containsKey(projectId)) { return Error.PERMISSION_DENIED.response("Project " + projectId + " not found."); } - for (String p : permissions) { - if (!PERMISSIONS.contains(p)) { - return Error.INVALID_ARGUMENT.response("Invalid permission: " + p); - } - } try { return new Response(HTTP_OK, jsonFactory.toString(new TestIamPermissionsResponse().setPermissions(permissions))); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java index 829094816664..75df0ef9e3ae 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/LocalResourceManagerHelperTest.java @@ -676,13 +676,6 @@ public void testTestPermissions() { assertEquals("Project nonexistent-project not found.", e.getMessage()); } rpc.create(PARTIAL_PROJECT); - try { - rpc.testPermissions(PARTIAL_PROJECT.getProjectId(), ImmutableList.of("get")); - fail("Invalid permission."); - } catch (ResourceManagerException e) { - assertEquals(400, e.code()); - assertEquals("Invalid permission: get", e.getMessage()); - } assertEquals(ImmutableList.of(true), rpc.testPermissions(PARTIAL_PROJECT.getProjectId(), permissions)); } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java index 7315b9f92565..04826dd9540f 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/PolicyTest.java @@ -18,12 +18,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; -import com.google.common.collect.ImmutableSet; import com.google.gcloud.Identity; -import com.google.gcloud.resourcemanager.Policy.Role; -import com.google.gcloud.resourcemanager.Policy.Role.Type; +import com.google.gcloud.resourcemanager.Policy.ProjectRole; import org.junit.Test; @@ -37,10 +34,10 @@ public class PolicyTest { private static final Identity GROUP = Identity.group("group@gmail.com"); private static final Identity DOMAIN = Identity.domain("google.com"); private static final Policy SIMPLE_POLICY = Policy.builder() - .addIdentity(Role.owner(), USER) - .addIdentity(Role.viewer(), ALL_USERS) - .addIdentity(Role.editor(), ALL_AUTH_USERS, DOMAIN) - .addIdentity(Role.rawRole("some-role"), SERVICE_ACCOUNT, GROUP) + .addIdentity(ProjectRole.OWNER.value(), USER) + .addIdentity(ProjectRole.VIEWER.value(), ALL_USERS) + .addIdentity(ProjectRole.EDITOR.value(), ALL_AUTH_USERS, DOMAIN) + .addIdentity("roles/some-role", SERVICE_ACCOUNT, GROUP) .build(); private static final Policy FULL_POLICY = new Policy.Builder(SIMPLE_POLICY.bindings(), "etag", 1).build(); @@ -57,21 +54,13 @@ public void testPolicyToAndFromPb() { assertEquals(SIMPLE_POLICY, Policy.fromPb(SIMPLE_POLICY.toPb())); } - @Test - public void testRoleType() { - assertEquals(Type.OWNER, Role.owner().type()); - assertEquals(Type.EDITOR, Role.editor().type()); - assertEquals(Type.VIEWER, Role.viewer().type()); - assertNull(Role.rawRole("raw-role").type()); - } - @Test public void testEquals() { Policy copy = Policy.builder() - .addIdentity(Role.owner(), USER) - .addIdentity(Role.viewer(), ALL_USERS) - .addIdentity(Role.editor(), ALL_AUTH_USERS, DOMAIN) - .addIdentity(Role.rawRole("some-role"), SERVICE_ACCOUNT, GROUP) + .addIdentity(ProjectRole.OWNER.value(), USER) + .addIdentity(ProjectRole.VIEWER.value(), ALL_USERS) + .addIdentity(ProjectRole.EDITOR.value(), ALL_AUTH_USERS, DOMAIN) + .addIdentity("roles/some-role", SERVICE_ACCOUNT, GROUP) .build(); assertEquals(SIMPLE_POLICY, copy); assertNotEquals(SIMPLE_POLICY, FULL_POLICY); diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java index 53b37111b705..acce6f84c680 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java @@ -27,11 +27,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.gcloud.Identity; -import com.google.gcloud.resourcemanager.Policy.Role; +import com.google.gcloud.resourcemanager.Policy.ProjectRole; import com.google.gcloud.resourcemanager.ProjectInfo.ResourceId; -import com.google.gcloud.resourcemanager.ResourceManager.Permission; import org.junit.After; import org.junit.Before; @@ -58,8 +56,8 @@ public class ProjectTest { private static final Identity SERVICE_ACCOUNT = Identity.serviceAccount("service-account@gmail.com"); private static final Policy POLICY = Policy.builder() - .addIdentity(Role.owner(), USER) - .addIdentity(Role.editor(), SERVICE_ACCOUNT) + .addIdentity(ProjectRole.OWNER.value(), USER) + .addIdentity(ProjectRole.EDITOR.value(), SERVICE_ACCOUNT) .build(); private ResourceManager serviceMockReturnsOptions = createStrictMock(ResourceManager.class); @@ -239,16 +237,19 @@ public void testReplacePolicy() { @Test public void testTestPermissions() { List response = ImmutableList.of(true, true); + String getPermission = "resourcemanager.projects.get"; + String deletePermission = "resourcemanager.projects.delete"; expect(resourceManager.options()).andReturn(mockOptions).times(1); - expect(resourceManager.testPermissions(PROJECT_ID, Permission.GET, Permission.DELETE)) + expect(resourceManager.testPermissions(PROJECT_ID, getPermission, deletePermission)) .andReturn(response); expect(resourceManager.testPermissions( - PROJECT_ID, ImmutableList.of(Permission.GET, Permission.DELETE))).andReturn(response); + PROJECT_ID, ImmutableList.of(getPermission, deletePermission))) + .andReturn(response); replay(resourceManager); initializeProject(); - assertEquals(response, project.testPermissions(Permission.GET, Permission.DELETE)); + assertEquals(response, project.testPermissions(getPermission, deletePermission)); assertEquals( - response, project.testPermissions(ImmutableList.of(Permission.GET, Permission.DELETE))); + response, project.testPermissions(ImmutableList.of(getPermission, deletePermission))); } private void compareProjects(Project expected, Project value) { diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java index 9cb9bfcba02f..2525039e9c0d 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java @@ -29,9 +29,8 @@ import com.google.common.collect.ImmutableMap; import com.google.gcloud.Identity; import com.google.gcloud.Page; -import com.google.gcloud.resourcemanager.Policy.Role; +import com.google.gcloud.resourcemanager.Policy.ProjectRole; import com.google.gcloud.resourcemanager.ProjectInfo.ResourceId; -import com.google.gcloud.resourcemanager.ResourceManager.Permission; import com.google.gcloud.resourcemanager.ResourceManager.ProjectField; import com.google.gcloud.resourcemanager.ResourceManager.ProjectGetOption; import com.google.gcloud.resourcemanager.ResourceManager.ProjectListOption; @@ -71,10 +70,12 @@ public class ResourceManagerImplTest { .parent(PARENT) .build(); private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); - private static final Policy POLICY = Policy.builder() - .addIdentity(Role.owner(), Identity.user("me@gmail.com")) - .addIdentity(Role.editor(), Identity.serviceAccount("serviceaccount@gmail.com")) - .build(); + private static final Policy POLICY = + Policy.builder() + .addIdentity(ProjectRole.OWNER.value(), Identity.user("me@gmail.com")) + .addIdentity( + ProjectRole.EDITOR.value(), Identity.serviceAccount("serviceaccount@gmail.com")) + .build(); @Rule public ExpectedException thrown = ExpectedException.none(); @@ -369,7 +370,7 @@ public void testReplacePolicy() { @Test public void testTestPermissions() { - List permissions = ImmutableList.of(Permission.GET); + List permissions = ImmutableList.of("resourcemanager.projects.get"); try { RESOURCE_MANAGER.testPermissions("nonexistent-project", permissions); fail("Nonexistent project"); @@ -380,8 +381,12 @@ public void testTestPermissions() { RESOURCE_MANAGER.create(PARTIAL_PROJECT); assertEquals(ImmutableList.of(true), RESOURCE_MANAGER.testPermissions(PARTIAL_PROJECT.projectId(), permissions)); - assertEquals(ImmutableList.of(true, true), RESOURCE_MANAGER.testPermissions( - PARTIAL_PROJECT.projectId(), Permission.DELETE, Permission.GET)); + assertEquals( + ImmutableList.of(true, true), + RESOURCE_MANAGER.testPermissions( + PARTIAL_PROJECT.projectId(), + "resourcemanager.projects.delete", + "resourcemanager.projects.get")); } @Test diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java index 1c0b9c68c86d..4bc1bcede195 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java @@ -21,6 +21,7 @@ import com.google.gcloud.Identity; import com.google.gcloud.PageImpl; import com.google.gcloud.Restorable; +import com.google.gcloud.resourcemanager.Policy.ProjectRole; import java.io.Serializable; import java.util.Collections; @@ -45,8 +46,9 @@ public class SerializationTest extends BaseSerializationTest { ResourceManager.ProjectGetOption.fields(ResourceManager.ProjectField.NAME); private static final ResourceManager.ProjectListOption PROJECT_LIST_OPTION = ResourceManager.ProjectListOption.filter("name:*"); - private static final Policy POLICY = - Policy.builder().addIdentity(Policy.Role.viewer(), Identity.user("abc@gmail.com")).build(); + private static final Policy POLICY = Policy.builder() + .addIdentity(ProjectRole.VIEWER.value(), Identity.user("abc@gmail.com")) + .build(); private static final ResourceManagerException RESOURCE_MANAGER_EXCEPTION = new ResourceManagerException(42, "message"); From 52bf6c1001716cd5f2145ff3be40631d542cd200 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 21 Mar 2016 19:51:37 -0700 Subject: [PATCH 163/203] remove varargs for testPermissions and other minor fixes --- .../google/gcloud/resourcemanager/Policy.java | 4 ++-- .../gcloud/resourcemanager/Project.java | 23 ------------------- .../resourcemanager/ResourceManager.java | 22 ------------------ .../resourcemanager/ResourceManagerImpl.java | 7 ------ .../gcloud/resourcemanager/ProjectTest.java | 3 --- .../ResourceManagerImplTest.java | 6 ----- 6 files changed, 2 insertions(+), 63 deletions(-) diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java index 884f474bed59..219d74262319 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Policy.java @@ -47,7 +47,7 @@ public class Policy extends IamPolicy { /** * The project-level roles in an IAM policy. This enum is not an exhaustive list of all roles * you can use in an IAM policy. You can also use service-specific roles (e.g. - * roles/pubsub.editor). See the Supported Cloud Platform Services page for links + * "roles/pubsub.editor"). See the Supported Cloud Platform Services page for links * to service-specific roles. * * @see Supported Cloud @@ -74,7 +74,7 @@ public enum ProjectRole { */ OWNER("roles/owner"); - String value; + private final String value; private ProjectRole(String value) { this.value = value; diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java index de5e6c336af4..bf9cf0e01a6d 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/Project.java @@ -251,29 +251,6 @@ List testPermissions(List permissions) { return resourceManager.testPermissions(projectId(), permissions); } - /** - * Returns the permissions that a caller has on this project. You typically don't call this method - * if you're using Google Cloud Platform directly to manage permissions. This method is intended - * for integration with your proprietary software, such as a customized graphical user interface. - * For example, the Cloud Platform Console tests IAM permissions internally to determine which UI - * should be available to the logged-in user. Each service that supports IAM lists the possible - * permissions; see the Supported Cloud Platform services page below for links to these - * lists. - * - * @return a list of booleans representing whether the caller has the permissions specified (in - * the order of the given permissions) - * @throws ResourceManagerException upon failure - * @see - * Resource Manager testIamPermissions - * @see Supported Cloud Platform - * Services - */ - List testPermissions(String firstPermission, String... otherPermissions) { - return resourceManager.testPermissions(projectId(), firstPermission, otherPermissions); - } - @Override public Builder toBuilder() { return new Builder(this); diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java index 708bd711b477..70eeb9c8eb50 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManager.java @@ -341,26 +341,4 @@ public static ProjectListOption fields(ProjectField... fields) { * Services */ List testPermissions(String projectId, List permissions); - - /** - * Returns the permissions that a caller has on the specified project. You typically don't call - * this method if you're using Google Cloud Platform directly to manage permissions. This method - * is intended for integration with your proprietary software, such as a customized graphical user - * interface. For example, the Cloud Platform Console tests IAM permissions internally to - * determine which UI should be available to the logged-in user. Each service that supports IAM - * lists the possible permissions; see the Supported Cloud Platform services page below for - * links to these lists. - * - * @return A list of booleans representing whether the caller has the permissions specified (in - * the order of the given permissions) - * @throws ResourceManagerException upon failure - * @see - * Resource Manager testIamPermissions - * @see Supported Cloud Platform - * Services - */ - List testPermissions( - String projectId, String firstPermission, String... otherPermissions); } diff --git a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java index 5526918bc1eb..e4663cb74cb9 100644 --- a/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java +++ b/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceManagerImpl.java @@ -23,7 +23,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gcloud.BaseService; import com.google.gcloud.Page; @@ -230,12 +229,6 @@ public List call() { } } - @Override - public List testPermissions( - String projectId, String firstPermission, String... otherPermissions) { - return testPermissions(projectId, Lists.asList(firstPermission, otherPermissions)); - } - private Map optionMap(Option... options) { Map temp = Maps.newEnumMap(ResourceManagerRpc.Option.class); for (Option option : options) { diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java index acce6f84c680..0f4c205dde17 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java @@ -240,14 +240,11 @@ public void testTestPermissions() { String getPermission = "resourcemanager.projects.get"; String deletePermission = "resourcemanager.projects.delete"; expect(resourceManager.options()).andReturn(mockOptions).times(1); - expect(resourceManager.testPermissions(PROJECT_ID, getPermission, deletePermission)) - .andReturn(response); expect(resourceManager.testPermissions( PROJECT_ID, ImmutableList.of(getPermission, deletePermission))) .andReturn(response); replay(resourceManager); initializeProject(); - assertEquals(response, project.testPermissions(getPermission, deletePermission)); assertEquals( response, project.testPermissions(ImmutableList.of(getPermission, deletePermission))); } diff --git a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java index 2525039e9c0d..7d52901aa372 100644 --- a/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java +++ b/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceManagerImplTest.java @@ -381,12 +381,6 @@ public void testTestPermissions() { RESOURCE_MANAGER.create(PARTIAL_PROJECT); assertEquals(ImmutableList.of(true), RESOURCE_MANAGER.testPermissions(PARTIAL_PROJECT.projectId(), permissions)); - assertEquals( - ImmutableList.of(true, true), - RESOURCE_MANAGER.testPermissions( - PARTIAL_PROJECT.projectId(), - "resourcemanager.projects.delete", - "resourcemanager.projects.get")); } @Test From b7c6da4702a665b31e74ea6aef8b7dd7c89e0ce5 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Tue, 22 Mar 2016 17:13:45 +0100 Subject: [PATCH 164/203] Rename startPageToken to pageToken in Storage and BigQuery --- .../main/java/com/google/gcloud/bigquery/BigQuery.java | 10 +++++----- .../com/google/gcloud/bigquery/BigQueryImplTest.java | 10 +++++----- .../main/java/com/google/gcloud/storage/Storage.java | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java index e06c8d86ee5f..14e324a43370 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java @@ -180,7 +180,7 @@ public static DatasetListOption pageSize(long pageSize) { /** * Returns an option to specify the page token from which to start listing datasets. */ - public static DatasetListOption startPageToken(String pageToken) { + public static DatasetListOption pageToken(String pageToken) { return new DatasetListOption(BigQueryRpc.Option.PAGE_TOKEN, pageToken); } @@ -256,7 +256,7 @@ public static TableListOption pageSize(long pageSize) { /** * Returns an option to specify the page token from which to start listing tables. */ - public static TableListOption startPageToken(String pageToken) { + public static TableListOption pageToken(String pageToken) { return new TableListOption(BigQueryRpc.Option.PAGE_TOKEN, pageToken); } } @@ -305,7 +305,7 @@ public static TableDataListOption pageSize(long pageSize) { /** * Returns an option to specify the page token from which to start listing table data. */ - public static TableDataListOption startPageToken(String pageToken) { + public static TableDataListOption pageToken(String pageToken) { return new TableDataListOption(BigQueryRpc.Option.PAGE_TOKEN, pageToken); } @@ -362,7 +362,7 @@ public static JobListOption pageSize(long pageSize) { /** * Returns an option to specify the page token from which to start listing jobs. */ - public static JobListOption startPageToken(String pageToken) { + public static JobListOption pageToken(String pageToken) { return new JobListOption(BigQueryRpc.Option.PAGE_TOKEN, pageToken); } @@ -428,7 +428,7 @@ public static QueryResultsOption pageSize(long pageSize) { /** * Returns an option to specify the page token from which to start getting query results. */ - public static QueryResultsOption startPageToken(String pageToken) { + public static QueryResultsOption pageToken(String pageToken) { return new QueryResultsOption(BigQueryRpc.Option.PAGE_TOKEN, pageToken); } diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java index b398f238386a..a6f512800024 100644 --- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java +++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java @@ -169,7 +169,7 @@ public class BigQueryImplTest { private static final BigQuery.DatasetListOption DATASET_LIST_ALL = BigQuery.DatasetListOption.all(); private static final BigQuery.DatasetListOption DATASET_LIST_PAGE_TOKEN = - BigQuery.DatasetListOption.startPageToken("cursor"); + BigQuery.DatasetListOption.pageToken("cursor"); private static final BigQuery.DatasetListOption DATASET_LIST_PAGE_SIZE = BigQuery.DatasetListOption.pageSize(42L); private static final Map DATASET_LIST_OPTIONS = ImmutableMap.of( @@ -191,7 +191,7 @@ public class BigQueryImplTest { private static final BigQuery.TableListOption TABLE_LIST_PAGE_SIZE = BigQuery.TableListOption.pageSize(42L); private static final BigQuery.TableListOption TABLE_LIST_PAGE_TOKEN = - BigQuery.TableListOption.startPageToken("cursor"); + BigQuery.TableListOption.pageToken("cursor"); private static final Map TABLE_LIST_OPTIONS = ImmutableMap.of( BigQueryRpc.Option.MAX_RESULTS, 42L, BigQueryRpc.Option.PAGE_TOKEN, "cursor"); @@ -200,7 +200,7 @@ public class BigQueryImplTest { private static final BigQuery.TableDataListOption TABLE_DATA_LIST_PAGE_SIZE = BigQuery.TableDataListOption.pageSize(42L); private static final BigQuery.TableDataListOption TABLE_DATA_LIST_PAGE_TOKEN = - BigQuery.TableDataListOption.startPageToken("cursor"); + BigQuery.TableDataListOption.pageToken("cursor"); private static final BigQuery.TableDataListOption TABLE_DATA_LIST_START_INDEX = BigQuery.TableDataListOption.startIndex(0L); private static final Map TABLE_DATA_LIST_OPTIONS = ImmutableMap.of( @@ -220,7 +220,7 @@ public class BigQueryImplTest { private static final BigQuery.JobListOption JOB_LIST_STATE_FILTER = BigQuery.JobListOption.stateFilter(JobStatus.State.DONE, JobStatus.State.PENDING); private static final BigQuery.JobListOption JOB_LIST_PAGE_TOKEN = - BigQuery.JobListOption.startPageToken("cursor"); + BigQuery.JobListOption.pageToken("cursor"); private static final BigQuery.JobListOption JOB_LIST_PAGE_SIZE = BigQuery.JobListOption.pageSize(42L); private static final Map JOB_LIST_OPTIONS = ImmutableMap.of( @@ -235,7 +235,7 @@ public class BigQueryImplTest { private static final BigQuery.QueryResultsOption QUERY_RESULTS_OPTION_INDEX = BigQuery.QueryResultsOption.startIndex(1024L); private static final BigQuery.QueryResultsOption QUERY_RESULTS_OPTION_PAGE_TOKEN = - BigQuery.QueryResultsOption.startPageToken("cursor"); + BigQuery.QueryResultsOption.pageToken("cursor"); private static final BigQuery.QueryResultsOption QUERY_RESULTS_OPTION_PAGE_SIZE = BigQuery.QueryResultsOption.pageSize(0L); private static final Map QUERY_RESULTS_OPTIONS = ImmutableMap.of( diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java index b4fbe45244b0..78f421e94e52 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java @@ -634,7 +634,7 @@ public static BucketListOption pageSize(long pageSize) { /** * Returns an option to specify the page token from which to start listing buckets. */ - public static BucketListOption startPageToken(String pageToken) { + public static BucketListOption pageToken(String pageToken) { return new BucketListOption(StorageRpc.Option.PAGE_TOKEN, pageToken); } @@ -680,7 +680,7 @@ public static BlobListOption pageSize(long pageSize) { /** * Returns an option to specify the page token from which to start listing blobs. */ - public static BlobListOption startPageToken(String pageToken) { + public static BlobListOption pageToken(String pageToken) { return new BlobListOption(StorageRpc.Option.PAGE_TOKEN, pageToken); } From e946b76d00bd174c9d0fd767915b3c2808e10e0f Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 23 Mar 2016 13:16:21 -0700 Subject: [PATCH 165/203] Updated the version in pom. --- gcloud-java-dns/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud-java-dns/pom.xml b/gcloud-java-dns/pom.xml index 1a559473cc82..a690a1e509a7 100644 --- a/gcloud-java-dns/pom.xml +++ b/gcloud-java-dns/pom.xml @@ -13,7 +13,7 @@ com.google.gcloud gcloud-java-pom - 0.1.5-SNAPSHOT + 0.1.6-SNAPSHOT gcloud-java-dns From 5c3fc94f60391db0c32b6d8055101c0abb9bd0e9 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Wed, 23 Mar 2016 12:43:05 -0700 Subject: [PATCH 166/203] Refactored the serialization test to use the base test --- gcloud-java-dns/pom.xml | 7 +++ .../google/gcloud/dns/SerializationTest.java | 50 +++++++------------ 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/gcloud-java-dns/pom.xml b/gcloud-java-dns/pom.xml index a690a1e509a7..b55200b8fc7d 100644 --- a/gcloud-java-dns/pom.xml +++ b/gcloud-java-dns/pom.xml @@ -40,6 +40,13 @@ + + ${project.groupId} + gcloud-java-core + ${project.version} + test-jar + test + junit junit diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java index c2bf9cfca0bb..7a0c32036878 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java @@ -16,24 +16,17 @@ package com.google.gcloud.dns; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; - import com.google.common.collect.ImmutableList; +import com.google.gcloud.AuthCredentials; +import com.google.gcloud.BaseSerializationTest; +import com.google.gcloud.Restorable; import com.google.gcloud.RetryParams; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.io.Serializable; import java.math.BigInteger; import java.util.concurrent.TimeUnit; -public class SerializationTest { +public class SerializationTest extends BaseSerializationTest { private static final ZoneInfo FULL_ZONE_INFO = Zone.of("some zone name", "www.example.com", "some descriptions").toBuilder() @@ -86,31 +79,24 @@ public class SerializationTest { .startTimeMillis(132L) .build(); - @Test - public void testModelAndRequests() throws Exception { - Serializable[] objects = {FULL_ZONE_INFO, PARTIAL_ZONE_INFO, ZONE_LIST_OPTION, + @Override + protected Serializable[] serializableObjects() { + DnsOptions options = DnsOptions.builder() + .authCredentials(AuthCredentials.createForAppEngine()) + .projectId("id1") + .build(); + DnsOptions otherOptions = options.toBuilder() + .authCredentials(null) + .build(); + return new Serializable[]{FULL_ZONE_INFO, PARTIAL_ZONE_INFO, ZONE_LIST_OPTION, DNS_REOCRD_LIST_OPTION, CHANGE_REQUEST_LIST_OPTION, ZONE_OPTION, CHANGE_REQUEST_OPTION, PROJECT_OPTION, PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, OPTIONS, FULL_ZONE, PARTIAL_ZONE, OPTIONS, CHANGE_REQUEST_PARTIAL, DNS_RECORD_PARTIAL, DNS_RECORD_COMPLETE, - CHANGE_REQUEST_COMPLETE}; - for (Serializable obj : objects) { - Object copy = serializeAndDeserialize(obj); - assertEquals(obj, obj); - assertEquals(obj, copy); - assertNotSame(obj, copy); - assertEquals(copy, copy); - } + CHANGE_REQUEST_COMPLETE, options, otherOptions}; } - @SuppressWarnings("unchecked") - private T serializeAndDeserialize(T obj) throws IOException, ClassNotFoundException { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { - output.writeObject(obj); - } - try (ObjectInputStream input = - new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) { - return (T) input.readObject(); - } + @Override + protected Restorable[] restorableObjects() { + return new Restorable[0]; } } From 1a5aade24d7cf0b7d0ee64eb80c3726174800446 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Tue, 22 Mar 2016 17:08:11 -0700 Subject: [PATCH 167/203] Renamed DnsRecord to RecordSet. Fixes #779. --- README.md | 12 +- gcloud-java-dns/README.md | 70 ++++---- .../com/google/gcloud/dns/ChangeRequest.java | 62 +++---- .../main/java/com/google/gcloud/dns/Dns.java | 67 +++---- .../java/com/google/gcloud/dns/DnsImpl.java | 26 +-- .../com/google/gcloud/dns/ProjectInfo.java | 23 +-- .../dns/{DnsRecord.java => RecordSet.java} | 56 +++--- .../main/java/com/google/gcloud/dns/Zone.java | 14 +- .../com/google/gcloud/dns/package-info.java | 2 +- .../google/gcloud/dns/spi/DefaultDnsRpc.java | 2 +- .../com/google/gcloud/dns/spi/DnsRpc.java | 4 +- .../gcloud/dns/testing/LocalDnsHelper.java | 44 ++--- .../gcloud/dns/testing/OptionParsers.java | 12 +- .../google/gcloud/dns/ChangeRequestTest.java | 22 +-- .../com/google/gcloud/dns/DnsImplTest.java | 36 ++-- .../java/com/google/gcloud/dns/DnsTest.java | 48 ++--- ...{DnsRecordTest.java => RecordSetTest.java} | 75 ++++---- .../google/gcloud/dns/SerializationTest.java | 20 +-- .../java/com/google/gcloud/dns/ZoneTest.java | 42 ++--- .../com/google/gcloud/dns/it/ITDnsTest.java | 170 +++++++++--------- .../dns/testing/LocalDnsHelperTest.java | 44 ++--- gcloud-java-examples/README.md | 2 +- .../gcloud/examples/dns/DnsExample.java | 36 ++-- ...rds.java => CreateOrUpdateRecordSets.java} | 16 +- .../examples/dns/snippets/DeleteZone.java | 10 +- ...java => ManipulateZonesAndRecordSets.java} | 32 ++-- 26 files changed, 477 insertions(+), 470 deletions(-) rename gcloud-java-dns/src/main/java/com/google/gcloud/dns/{DnsRecord.java => RecordSet.java} (83%) rename gcloud-java-dns/src/test/java/com/google/gcloud/dns/{DnsRecordTest.java => RecordSetTest.java} (63%) rename gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/{CreateOrUpdateDnsRecords.java => CreateOrUpdateRecordSets.java} (83%) rename gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/{ManipulateZonesAndRecords.java => ManipulateZonesAndRecordSets.java} (84%) diff --git a/README.md b/README.md index a753a96c8b21..52229f6d5d34 100644 --- a/README.md +++ b/README.md @@ -249,13 +249,13 @@ ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description); Zone zone = dns.create(zoneInfo); ``` -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). +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). ```java import com.google.gcloud.dns.ChangeRequest; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsOptions; -import com.google.gcloud.dns.DnsRecord; +import com.google.gcloud.dns.RecordSet; import com.google.gcloud.dns.Zone; import java.util.Iterator; @@ -265,7 +265,7 @@ Dns dns = DnsOptions.defaultInstance().service(); String zoneName = "my-unique-zone"; Zone zone = dns.getZone(zoneName); String ip = "12.13.14.15"; -DnsRecord toCreate = DnsRecord.builder("www.someexampledomain.com.", DnsRecord.Type.A) +RecordSet toCreate = RecordSet.builder("www.someexampledomain.com.", RecordSet.Type.A) .ttl(24, TimeUnit.HOURS) .addRecord(ip) .build(); @@ -273,9 +273,9 @@ ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate); // Verify that the record does not exist yet. // If it does exist, we will overwrite it with our prepared record. -Iterator recordIterator = zone.listDnsRecords().iterateAll(); -while (recordIterator.hasNext()) { - DnsRecord current = recordIterator.next(); +Iterator recordSetIterator = zone.listRecordSets().iterateAll(); +while (recordSetIterator.hasNext()) { + RecordSet current = recordSetIterator.next(); if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) { changeBuilder.delete(current); diff --git a/gcloud-java-dns/README.md b/gcloud-java-dns/README.md index 4f65d8e3b814..a2c3238d1f8f 100644 --- a/gcloud-java-dns/README.md +++ b/gcloud-java-dns/README.md @@ -92,7 +92,7 @@ Dns dns = DnsOptions.defaultInstance().service(); For other authentication options, see the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) page. #### Managing Zones -DNS records in `gcloud-java-dns` are managed inside containers called "zones". `ZoneInfo` is a class +Record sets in `gcloud-java-dns` are managed inside containers called "zones". `ZoneInfo` is a class which encapsulates metadata that describe a zone in Google Cloud DNS. `Zone`, a subclass of `ZoneInfo`, adds service-related functionality over `ZoneInfo`. @@ -100,7 +100,7 @@ functionality over `ZoneInfo`. exists within your project, you'll get a helpful error message telling you to choose another name. In the code below, replace "my-unique-zone" with a unique zone name. See more about naming rules [here](https://cloud.google.com/dns/api/v1/managedZones#name).* -In this code snippet, we create a new zone to manage DNS records for domain `someexampledomain.com.` +In this code snippet, we create a new zone to manage record sets for domain `someexampledomain.com.` *Important: The service may require that you verify ownership of the domain for which you are creating a zone. Hence, we recommend that you do so beforehand. You can verify ownership of @@ -128,8 +128,8 @@ Zone zone = dns.create(zoneInfo); System.out.printf("Zone was created and assigned ID %s.%n", zone.id()); ``` -You now have an empty zone hosted in Google Cloud DNS which is ready to be populated with DNS -records for domain name `someexampledomain.com.` Upon creating the zone, the cloud service +You now have an empty zone hosted in Google Cloud DNS which is ready to be populated with +record sets for domain name `someexampledomain.com.` Upon creating the zone, the cloud service assigned a set of DNS servers to host records for this zone and created the required SOA and NS records for the domain. The following snippet prints the list of servers assigned to the zone created above. First, import @@ -152,15 +152,15 @@ You can now instruct your domain registrar to [update your domain name servers] As soon as this happens and the change propagates through cached values in DNS resolvers, all the DNS queries will be directed to and answered by the Google Cloud DNS service. -#### Creating DNS Records -Now that we have a zone, we can add some DNS records. The DNS records held within zones are +#### Creating Record Sets +Now that we have a zone, we can add some record sets. The record sets held within zones are modified by "change requests". In this example, we create and apply a change request to -our zone that creates a DNS record of type A and points URL www.someexampledomain.com to +our zone that creates a record set of type A and points URL www.someexampledomain.com to IP address 12.13.14.15. Start by adding ```java import com.google.gcloud.dns.ChangeRequest; -import com.google.gcloud.dns.DnsRecord; +import com.google.gcloud.dns.RecordSet; import java.util.concurrent.TimeUnit; ``` @@ -168,9 +168,9 @@ import java.util.concurrent.TimeUnit; and proceed with: ```java -// Prepare a www.someexampledomain.com. type A record with ttl of 24 hours +// Prepare a www.someexampledomain.com. type A record set with ttl of 24 hours String ip = "12.13.14.15"; -DnsRecord toCreate = DnsRecord.builder("www.someexampledomain.com.", DnsRecord.Type.A) +RecordSet toCreate = RecordSet.builder("www." + zone.dnsName(), RecordSet.Type.A) .ttl(24, TimeUnit.HOURS) .addRecord(ip) .build(); @@ -182,12 +182,12 @@ ChangeRequest changeRequest = ChangeRequest.builder().add(toCreate).build(); changeRequest = zone.applyChangeRequest(changeRequest); ``` -The `addRecord` method of `DnsRecord.Builder` accepts records in the form of -strings. The format of the strings depends on the type of the DNS record to be added. -More information on the supported DNS record types and record formats can be found [here](https://cloud.google.com/dns/what-is-cloud-dns#supported_record_types). +The `addRecord` method of `RecordSet.Builder` accepts records in the form of +strings. The format of the strings depends on the type of the record sets to be added. +More information on the supported record set types and record formats can be found [here](https://cloud.google.com/dns/what-is-cloud-dns#supported_record_types). -If you already have a DNS record, Cloud DNS will return an error upon an attempt to create a duplicate of it. -You can modify the code above to create a DNS record or update it if it already exists by making the +If you already have a record set, Cloud DNS will return an error upon an attempt to create a duplicate of it. +You can modify the code above to create a record set or update it if it already exists by making the following adjustment in your imports ```java @@ -202,9 +202,9 @@ ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate); // Verify the type A record does not exist yet. // If it does exist, we will overwrite it with our prepared record. -Iterator recordIterator = zone.listDnsRecords().iterateAll(); -while (recordIterator.hasNext()) { - DnsRecord current = recordIterator.next(); +Iterator recordSetIterator = zone.listRecordSets().iterateAll(); +while (recordSetIterator.hasNext()) { + RecordSet current = recordSetIterator.next(); if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) { changeBuilder.delete(current); } @@ -235,15 +235,15 @@ Change requests are applied atomically to all the assigned DNS servers at once. happens, it may still take a while for the change to be registered by the DNS cache resolvers. See more on this topic [here](https://cloud.google.com/dns/monitoring). -#### Listing Zones and DNS Records -Suppose that you have added more zones and DNS records, and now you want to list them. +#### Listing Zones and Record Sets +Suppose that you have added more zones and record sets, and now you want to list them. First, import the following (unless you have done so in the previous section): ```java import java.util.Iterator; ``` -Then add the following code to list all your zones and DNS records. +Then add the following code to list all your zones and record sets. ```java // List all your zones @@ -254,11 +254,11 @@ while (zoneIterator.hasNext()) { counter++; } -// List the DNS records in a particular zone -Iterator recordIterator = zone.listDnsRecords().iterateAll(); -System.out.println(String.format("DNS records inside %s:", zone.name())); -while (recordIterator.hasNext()) { - System.out.println(recordIterator.next()); +// List the record sets in a particular zone +recordSetIterator = zone.listRecordSets().iterateAll(); +System.out.println(String.format("Record sets inside %s:", zone.name())); +while (recordSetIterator.hasNext()) { + System.out.println(recordSetIterator.next()); } ``` @@ -276,15 +276,15 @@ while (changeIterator.hasNext()) { #### Deleting Zones If you no longer want to host a zone in Cloud DNS, you can delete it. -First, you need to empty the zone by deleting all its records except for the default SOA and NS records. +First, you need to empty the zone by deleting all its records except for the default SOA and NS record sets. ```java -// Make a change for deleting the records -ChangeRequest.Builder changeBuilder = ChangeRequest.builder(); +// Make a change for deleting the record sets +changeBuilder = ChangeRequest.builder(); while (recordIterator.hasNext()) { - DnsRecord current = recordIterator.next(); + RecordSet current = recordIterator.next(); // SOA and NS records cannot be deleted - if (!DnsRecord.Type.SOA.equals(current.type()) && !DnsRecord.Type.NS.equals(current.type())) { + if (!RecordSet.Type.SOA.equals(current.type()) && !RecordSet.Type.NS.equals(current.type())) { changeBuilder.delete(current); } } @@ -324,11 +324,11 @@ if (result) { We composed some of the aforementioned snippets into complete executable code samples. In [CreateZones.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateZone.java) -we create a zone. In [CreateOrUpdateDnsRecords.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateDnsRecords.java) -we create a type A record for a zone, or update an existing type A record to a new IP address. We +we create a zone. In [CreateOrUpdateRecordSets.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateRecordSets.java) +we create a type A record set for a zone, or update an existing type A record set to a new IP address. We demonstrate how to delete a zone in [DeleteZone.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java). -Finally, in [ManipulateZonesAndRecords.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecords.java) -we assemble all the code snippets together and create zone, create or update a DNS record, list zones, list DNS records, list changes, and +Finally, in [ManipulateZonesAndRecordSets.java](../gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java) +we assemble all the code snippets together and create zone, create or update a record set, list zones, list record sets, list changes, and delete a zone. The applications assume that they are running on Compute Engine or from your own desktop. To run any of these examples on App Engine, simply move the code from the main method to your application's servlet class and change the print statements to display on your webpage. diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java index 76d231b704c4..757d844cc3da 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java @@ -33,7 +33,7 @@ import java.util.Objects; /** - * A class representing an atomic update to a collection of {@link DnsRecord}s within a {@code + * A class representing an atomic update to a collection of {@link RecordSet}s within a {@code * Zone}. * * @see Google Cloud DNS documentation @@ -48,8 +48,8 @@ public ChangeRequest apply(com.google.api.services.dns.model.Change pb) { } }; private static final long serialVersionUID = -9027378042756366333L; - private final List additions; - private final List deletions; + private final List additions; + private final List deletions; private final String id; private final Long startTimeMillis; private final Status status; @@ -70,8 +70,8 @@ public enum Status { */ public static class Builder { - private List additions = new LinkedList<>(); - private List deletions = new LinkedList<>(); + private List additions = new LinkedList<>(); + private List deletions = new LinkedList<>(); private String id; private Long startTimeMillis; private Status status; @@ -88,43 +88,43 @@ private Builder() { } /** - * Sets a collection of {@link DnsRecord}s which are to be added to the zone upon executing this + * Sets a collection of {@link RecordSet}s which are to be added to the zone upon executing this * {@code ChangeRequest}. */ - public Builder additions(List additions) { + public Builder additions(List additions) { this.additions = Lists.newLinkedList(checkNotNull(additions)); return this; } /** - * Sets a collection of {@link DnsRecord}s which are to be deleted from the zone upon executing + * Sets a collection of {@link RecordSet}s which are to be deleted from the zone upon executing * this {@code ChangeRequest}. */ - public Builder deletions(List deletions) { + public Builder deletions(List deletions) { this.deletions = Lists.newLinkedList(checkNotNull(deletions)); return this; } /** - * Adds a {@link DnsRecord} to be added to the zone upon executing this {@code + * Adds a {@link RecordSet} to be added to the zone upon executing this {@code * ChangeRequest}. */ - public Builder add(DnsRecord record) { - this.additions.add(checkNotNull(record)); + public Builder add(RecordSet recordSet) { + this.additions.add(checkNotNull(recordSet)); return this; } /** - * Adds a {@link DnsRecord} to be deleted to the zone upon executing this + * Adds a {@link RecordSet} to be deleted to the zone upon executing this * {@code ChangeRequest}. */ - public Builder delete(DnsRecord record) { - this.deletions.add(checkNotNull(record)); + public Builder delete(RecordSet recordSet) { + this.deletions.add(checkNotNull(recordSet)); return this; } /** - * Clears the collection of {@link DnsRecord}s which are to be added to the zone upon executing + * Clears the collection of {@link RecordSet}s which are to be added to the zone upon executing * this {@code ChangeRequest}. */ public Builder clearAdditions() { @@ -133,7 +133,7 @@ public Builder clearAdditions() { } /** - * Clears the collection of {@link DnsRecord}s which are to be deleted from the zone upon + * Clears the collection of {@link RecordSet}s which are to be deleted from the zone upon * executing this {@code ChangeRequest}. */ public Builder clearDeletions() { @@ -142,20 +142,20 @@ public Builder clearDeletions() { } /** - * Removes a single {@link DnsRecord} from the collection of records to be + * Removes a single {@link RecordSet} from the collection of records to be * added to the zone upon executing this {@code ChangeRequest}. */ - public Builder removeAddition(DnsRecord record) { - this.additions.remove(record); + public Builder removeAddition(RecordSet recordSet) { + this.additions.remove(recordSet); return this; } /** - * Removes a single {@link DnsRecord} from the collection of records to be + * Removes a single {@link RecordSet} from the collection of records to be * deleted from the zone upon executing this {@code ChangeRequest}. */ - public Builder removeDeletion(DnsRecord record) { - this.deletions.remove(record); + public Builder removeDeletion(RecordSet recordSet) { + this.deletions.remove(recordSet); return this; } @@ -215,18 +215,18 @@ public Builder toBuilder() { } /** - * Returns the list of {@link DnsRecord}s to be added to the zone upon submitting this {@code + * Returns the list of {@link RecordSet}s to be added to the zone upon submitting this {@code * ChangeRequest}. */ - public List additions() { + public List additions() { return additions; } /** - * Returns the list of {@link DnsRecord}s to be deleted from the zone upon submitting this {@code + * Returns the list of {@link RecordSet}s to be deleted from the zone upon submitting this {@code * ChangeRequest}. */ - public List deletions() { + public List deletions() { return deletions; } @@ -267,9 +267,9 @@ com.google.api.services.dns.model.Change toPb() { pb.setStatus(status().name().toLowerCase()); } // set a list of additions - pb.setAdditions(Lists.transform(additions(), DnsRecord.TO_PB_FUNCTION)); + pb.setAdditions(Lists.transform(additions(), RecordSet.TO_PB_FUNCTION)); // set a list of deletions - pb.setDeletions(Lists.transform(deletions(), DnsRecord.TO_PB_FUNCTION)); + pb.setDeletions(Lists.transform(deletions(), RecordSet.TO_PB_FUNCTION)); return pb; } @@ -286,10 +286,10 @@ static ChangeRequest fromPb(com.google.api.services.dns.model.Change pb) { builder.status(ChangeRequest.Status.valueOf(pb.getStatus().toUpperCase())); } if (pb.getDeletions() != null) { - builder.deletions(Lists.transform(pb.getDeletions(), DnsRecord.FROM_PB_FUNCTION)); + builder.deletions(Lists.transform(pb.getDeletions(), RecordSet.FROM_PB_FUNCTION)); } if (pb.getAdditions() != null) { - builder.additions(Lists.transform(pb.getAdditions(), DnsRecord.FROM_PB_FUNCTION)); + builder.additions(Lists.transform(pb.getAdditions(), RecordSet.FROM_PB_FUNCTION)); } return builder.build(); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index 6ce6b4c19994..f8614a8d6169 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -101,13 +101,13 @@ static String selector(ZoneField... fields) { } /** - * The fields of a DNS record. + * The fields of a record set. * *

      These values can be used to specify the fields to include in a partial response when calling - * {@link Dns#listDnsRecords(String, DnsRecordListOption...)}. The name and type are always + * {@link Dns#listRecordSets(String, RecordSetListOption...)}. The name and type are always * returned even if not selected. */ - enum DnsRecordField { + enum RecordSetField { DNS_RECORDS("rrdatas"), NAME("name"), TTL("ttl"), @@ -115,7 +115,7 @@ enum DnsRecordField { private final String selector; - DnsRecordField(String selector) { + RecordSetField(String selector) { this.selector = selector; } @@ -123,11 +123,11 @@ String selector() { return selector; } - static String selector(DnsRecordField... fields) { + static String selector(RecordSetField... fields) { Set fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1); fieldStrings.add(NAME.selector()); fieldStrings.add(TYPE.selector()); - for (DnsRecordField field : fields) { + for (RecordSetField field : fields) { fieldStrings.add(field.selector()); } return Joiner.on(',').join(fieldStrings); @@ -180,28 +180,29 @@ public String selector() { } /** - * Class that for specifying DNS record options. + * Class for specifying record set listing options. */ - class DnsRecordListOption extends AbstractOption implements Serializable { + class RecordSetListOption extends AbstractOption implements Serializable { private static final long serialVersionUID = 1009627025381096098L; - DnsRecordListOption(DnsRpc.Option option, Object value) { + RecordSetListOption(DnsRpc.Option option, Object value) { super(option, value); } /** - * Returns an option to specify the DNS record's fields to be returned by the RPC call. + * Returns an option to specify the record set's fields to be returned by the RPC call. * *

      If this option is not provided all record fields are returned. {@code - * DnsRecordField.fields} can be used to specify only the fields of interest. The name of the - * DNS record always returned, even if not specified. {@link DnsRecordField} provides a list of - * fields that can be used. + * RecordSetField.fields} can be used to specify only the fields of interest. The name of the + * record set in always returned, even if not specified. {@link RecordSetField} provides a list + * of fields that can be used. */ - public static DnsRecordListOption fields(DnsRecordField... fields) { + public static RecordSetListOption fields(RecordSetField... fields) { StringBuilder builder = new StringBuilder(); - builder.append("nextPageToken,rrsets(").append(DnsRecordField.selector(fields)).append(')'); - return new DnsRecordListOption(DnsRpc.Option.FIELDS, builder.toString()); + builder.append("nextPageToken,rrsets(").append(RecordSetField.selector(fields)) + .append(')'); + return new RecordSetListOption(DnsRpc.Option.FIELDS, builder.toString()); } /** @@ -210,33 +211,33 @@ public static DnsRecordListOption fields(DnsRecordField... fields) { *

      The page token (returned from a previous call to list) indicates from where listing should * continue. */ - public static DnsRecordListOption pageToken(String pageToken) { - return new DnsRecordListOption(DnsRpc.Option.PAGE_TOKEN, pageToken); + public static RecordSetListOption pageToken(String pageToken) { + return new RecordSetListOption(DnsRpc.Option.PAGE_TOKEN, pageToken); } /** - * The maximum number of DNS records to return per RPC. + * The maximum number of record sets to return per RPC. * - *

      The server can return fewer records than requested. When there are more results than the - * page size, the server will return a page token that can be used to fetch other results. + *

      The server can return fewer record sets than requested. When there are more results than + * the page size, the server will return a page token that can be used to fetch other results. */ - public static DnsRecordListOption pageSize(int pageSize) { - return new DnsRecordListOption(DnsRpc.Option.PAGE_SIZE, pageSize); + public static RecordSetListOption pageSize(int pageSize) { + return new RecordSetListOption(DnsRpc.Option.PAGE_SIZE, pageSize); } /** - * Restricts the list to only DNS records with this fully qualified domain name. + * Restricts the list to only record sets with this fully qualified domain name. */ - public static DnsRecordListOption dnsName(String dnsName) { - return new DnsRecordListOption(DnsRpc.Option.NAME, dnsName); + public static RecordSetListOption dnsName(String dnsName) { + return new RecordSetListOption(DnsRpc.Option.NAME, dnsName); } /** - * Restricts the list to return only records of this type. If present, {@link - * Dns.DnsRecordListOption#dnsName(String)} must also be present. + * Restricts the list to return only record sets of this type. If present, {@link + * RecordSetListOption#dnsName(String)} must also be present. */ - public static DnsRecordListOption type(DnsRecord.Type type) { - return new DnsRecordListOption(DnsRpc.Option.DNS_TYPE, type.name()); + public static RecordSetListOption type(RecordSet.Type type) { + return new RecordSetListOption(DnsRpc.Option.DNS_TYPE, type.name()); } } @@ -478,16 +479,16 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { boolean delete(String zoneName); // delete does not admit any options /** - * Lists the DNS records in the zone identified by name. + * Lists the record sets in the zone identified by name. * *

      The fields to be returned, page size and page tokens can be specified using {@link - * DnsRecordListOption}s. + * RecordSetListOption}s. * * @throws DnsException upon failure or if the zone cannot be found * @see Cloud DNS * ResourceRecordSets: list */ - Page listDnsRecords(String zoneName, DnsRecordListOption... options); + Page listRecordSets(String zoneName, RecordSetListOption... options); /** * Retrieves the information about the current project. The returned fields can be optionally diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java index a60cfd9151da..2fbf4e8b5a79 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java @@ -85,7 +85,7 @@ public Page nextPage() { } } - private static class DnsRecordPageFetcher implements PageImpl.NextPageFetcher { + private static class DnsRecordPageFetcher implements PageImpl.NextPageFetcher { private static final long serialVersionUID = -6039369212511530846L; private final Map requestOptions; @@ -101,8 +101,8 @@ private static class DnsRecordPageFetcher implements PageImpl.NextPageFetcher nextPage() { - return listDnsRecords(zoneName, serviceOptions, requestOptions); + public Page nextPage() { + return listRecordSets(zoneName, serviceOptions, requestOptions); } } @@ -178,29 +178,29 @@ public DnsRpc.ListResult call() { } @Override - public Page listDnsRecords(String zoneName, DnsRecordListOption... options) { - return listDnsRecords(zoneName, options(), optionMap(options)); + public Page listRecordSets(String zoneName, RecordSetListOption... options) { + return listRecordSets(zoneName, options(), optionMap(options)); } - private static Page listDnsRecords(final String zoneName, + private static Page listRecordSets(final String zoneName, final DnsOptions serviceOptions, final Map optionsMap) { try { - // get a list of resource record sets + // get a list of record sets final DnsRpc rpc = serviceOptions.rpc(); DnsRpc.ListResult result = runWithRetries( new Callable>() { @Override public DnsRpc.ListResult call() { - return rpc.listDnsRecords(zoneName, optionsMap); + return rpc.listRecordSets(zoneName, optionsMap); } }, serviceOptions.retryParams(), EXCEPTION_HANDLER); String cursor = result.pageToken(); - // transform that list into dns records - Iterable records = result.results() == null - ? ImmutableList.of() - : Iterables.transform(result.results(), DnsRecord.FROM_PB_FUNCTION); + // transform that list into record sets + Iterable recordSets = result.results() == null + ? ImmutableList.of() + : Iterables.transform(result.results(), RecordSet.FROM_PB_FUNCTION); return new PageImpl<>(new DnsRecordPageFetcher(zoneName, serviceOptions, cursor, optionsMap), - cursor, records); + cursor, recordSets); } catch (RetryHelperException e) { throw DnsException.translateAndThrow(e); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java index f7b12b94bae8..319f06ad2444 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ProjectInfo.java @@ -26,8 +26,8 @@ /** * The class provides the Google Cloud DNS information associated with this project. A project is a - * top level container for resources including {@code Zone}s. Projects can be created only in - * the APIs console. + * top level container for resources including {@code Zone}s. Projects can be created only in the + * APIs console. * * @see Google Cloud DNS documentation */ @@ -62,11 +62,11 @@ public static class Quota implements Serializable { * builder. */ Quota(int zones, - int resourceRecordsPerRrset, - int rrsetAdditionsPerChange, - int rrsetDeletionsPerChange, - int rrsetsPerZone, - int totalRrdataSizePerChange) { + int resourceRecordsPerRrset, + int rrsetAdditionsPerChange, + int rrsetDeletionsPerChange, + int rrsetsPerZone, + int totalRrdataSizePerChange) { this.zones = zones; this.resourceRecordsPerRrset = resourceRecordsPerRrset; this.rrsetAdditionsPerChange = rrsetAdditionsPerChange; @@ -83,21 +83,22 @@ public int zones() { } /** - * Returns the maximum allowed number of records per {@link DnsRecord}. + * Returns the maximum allowed number of records per {@link RecordSet}. */ public int resourceRecordsPerRrset() { return resourceRecordsPerRrset; } /** - * Returns the maximum allowed number of {@link DnsRecord}s to add per {@link ChangeRequest}. + * Returns the maximum allowed number of {@link RecordSet}s to add per {@link + * ChangeRequest}. */ public int rrsetAdditionsPerChange() { return rrsetAdditionsPerChange; } /** - * Returns the maximum allowed number of {@link DnsRecord}s to delete per {@link + * Returns the maximum allowed number of {@link RecordSet}s to delete per {@link * ChangeRequest}. */ public int rrsetDeletionsPerChange() { @@ -105,7 +106,7 @@ public int rrsetDeletionsPerChange() { } /** - * Returns the maximum allowed number of {@link DnsRecord}s per {@link ZoneInfo} in the + * Returns the maximum allowed number of {@link RecordSet}s per {@link ZoneInfo} in the * project. */ public int rrsetsPerZone() { diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/RecordSet.java similarity index 83% rename from gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java rename to gcloud-java-dns/src/main/java/com/google/gcloud/dns/RecordSet.java index c4e710bd0365..dc6d956406c3 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsRecord.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/RecordSet.java @@ -35,28 +35,28 @@ /** * A class that represents a Google Cloud DNS record set. * - *

      A {@code DnsRecord} is the unit of data that will be returned by the DNS servers upon a DNS - * request for a specific domain. The {@code DnsRecord} holds the current state of the DNS records + *

      A {@code RecordSet} is the unit of data that will be returned by the DNS servers upon a DNS + * request for a specific domain. The {@code RecordSet} holds the current state of the DNS records * that make up a zone. You can read the records but you cannot modify them directly. Rather, you - * edit the records in a zone by creating a ChangeRequest. + * edit the records in a zone by creating a {@link ChangeRequest}. * * @see Google Cloud DNS * documentation */ -public class DnsRecord implements Serializable { +public class RecordSet implements Serializable { - static final Function FROM_PB_FUNCTION = - new Function() { + static final Function FROM_PB_FUNCTION = + new Function() { @Override - public DnsRecord apply(com.google.api.services.dns.model.ResourceRecordSet pb) { - return DnsRecord.fromPb(pb); + public RecordSet apply(ResourceRecordSet pb) { + return RecordSet.fromPb(pb); } }; - static final Function TO_PB_FUNCTION = - new Function() { + static final Function TO_PB_FUNCTION = + new Function() { @Override - public com.google.api.services.dns.model.ResourceRecordSet apply(DnsRecord error) { - return error.toPb(); + public ResourceRecordSet apply(RecordSet recordSet) { + return recordSet.toPb(); } }; private static final long serialVersionUID = 8148009870800115261L; @@ -124,7 +124,7 @@ public enum Type { } /** - * A builder of {@link DnsRecord}. + * A builder for {@link RecordSet}. */ public static class Builder { @@ -140,9 +140,9 @@ private Builder(String name, Type type) { /** * Creates a builder and pre-populates attributes with the values from the provided {@code - * DnsRecord} instance. + * RecordSet} instance. */ - private Builder(DnsRecord record) { + private Builder(RecordSet record) { this.name = record.name; this.ttl = record.ttl; this.type = record.type; @@ -186,7 +186,7 @@ public Builder records(List records) { } /** - * Sets name for this DNS record set. For example, www.example.com. + * Sets the name for this record set. For example, www.example.com. */ public Builder name(String name) { this.name = checkNotNull(name); @@ -198,7 +198,7 @@ public Builder name(String name) { * The maximum duration must be equivalent to at most {@link Integer#MAX_VALUE} seconds. * * @param duration A non-negative number of time units - * @param unit The unit of the ttl parameter + * @param unit The unit of the ttl parameter */ public Builder ttl(int duration, TimeUnit unit) { checkArgument(duration >= 0, @@ -219,14 +219,14 @@ public Builder type(Type type) { } /** - * Builds the DNS record. + * Builds the record set. */ - public DnsRecord build() { - return new DnsRecord(this); + public RecordSet build() { + return new RecordSet(this); } } - private DnsRecord(Builder builder) { + private RecordSet(Builder builder) { this.name = builder.name; this.rrdatas = ImmutableList.copyOf(builder.rrdatas); this.ttl = builder.ttl; @@ -241,35 +241,35 @@ public Builder toBuilder() { } /** - * Creates a {@code DnsRecord} builder for the given {@code name} and {@code type}. + * Creates a {@code RecordSet} builder for the given {@code name} and {@code type}. */ public static Builder builder(String name, Type type) { return new Builder(name, type); } /** - * Returns the user-assigned name of this DNS record. + * Returns the user-assigned name of this record set. */ public String name() { return name; } /** - * Returns a list of DNS record stored in this record set. + * Returns a list of records stored in this record set. */ public List records() { return rrdatas; } /** - * Returns the number of seconds that this DnsResource can be cached by resolvers. + * Returns the number of seconds that this record set can be cached by resolvers. */ public Integer ttl() { return ttl; } /** - * Returns the type of this DNS record. + * Returns the type of this record set. */ public Type type() { return type; @@ -282,7 +282,7 @@ public int hashCode() { @Override public boolean equals(Object obj) { - return (obj instanceof DnsRecord) && Objects.equals(this.toPb(), ((DnsRecord) obj).toPb()); + return obj instanceof RecordSet && Objects.equals(this.toPb(), ((RecordSet) obj).toPb()); } com.google.api.services.dns.model.ResourceRecordSet toPb() { @@ -295,7 +295,7 @@ com.google.api.services.dns.model.ResourceRecordSet toPb() { return pb; } - static DnsRecord fromPb(com.google.api.services.dns.model.ResourceRecordSet pb) { + static RecordSet fromPb(com.google.api.services.dns.model.ResourceRecordSet pb) { Builder builder = builder(pb.getName(), Type.valueOf(pb.getType())); if (pb.getRrdatas() != null) { builder.records(pb.getRrdatas()); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index 41507647543a..aed99dbd0001 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -28,10 +28,10 @@ /** * A Google Cloud DNS Zone object. * - *

      A zone is the container for all of your DNS records that share the same DNS name prefix, for + *

      A zone is the container for all of your record sets that share the same DNS name prefix, for * example, example.com. Zones are automatically assigned a set of name servers when they are * created to handle responding to DNS queries for that zone. A zone has quotas for the number of - * resource records that it can include. + * record sets that it can include. * * @see Google Cloud DNS managed zone * documentation @@ -135,14 +135,14 @@ public boolean delete() { } /** - * Lists all {@link DnsRecord}s associated with this zone. The method searches for zone by name. + * Lists all {@link RecordSet}s associated with this zone. The method searches for zone by name. * - * @param options optional restriction on listing and fields of {@link DnsRecord}s returned - * @return a page of DNS records + * @param options optional restriction on listing and fields of {@link RecordSet}s returned + * @return a page of record sets * @throws DnsException upon failure or if the zone is not found */ - public Page listDnsRecords(Dns.DnsRecordListOption... options) { - return dns.listDnsRecords(name(), options); + public Page listRecordSets(Dns.RecordSetListOption... options) { + return dns.listRecordSets(name(), options); } /** diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java index 8a137285c357..69bee930df62 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java @@ -42,7 +42,7 @@ * String zoneName = "my-unique-zone"; * Zone zone = dns.getZone(zoneName); * String ip = "12.13.14.15"; - * DnsRecord toCreate = DnsRecord.builder("www.someexampledomain.com.", DnsRecord.Type.A) + * RecordSet toCreate = RecordSet.builder("www.someexampledomain.com.", RecordSet.Type.A) * .ttl(24, TimeUnit.HOURS) * .addRecord(ip) * .build(); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DefaultDnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DefaultDnsRpc.java index f8b8adb87ada..cbebd19d0d73 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DefaultDnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DefaultDnsRpc.java @@ -112,7 +112,7 @@ public boolean deleteZone(String zoneName) throws DnsException { } @Override - public ListResult listDnsRecords(String zoneName, Map options) + public ListResult listRecordSets(String zoneName, Map options) throws DnsException { // options are fields, page token, dns name, type try { diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DnsRpc.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DnsRpc.java index bde93b99bfdd..c7478016db27 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DnsRpc.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DnsRpc.java @@ -120,13 +120,13 @@ public String pageToken() { boolean deleteZone(String zoneName) throws DnsException; /** - * Lists DNS records for a given zone. + * Lists record sets for a given zone. * * @param zoneName name of the zone to be listed * @param options a map of options for the service call * @throws DnsException upon failure or if zone was not found */ - ListResult listDnsRecords(String zoneName, Map options) + ListResult listRecordSets(String zoneName, Map options) throws DnsException; /** diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java index 3b18ec5ce55b..0ae2c37b9b4d 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/LocalDnsHelper.java @@ -90,8 +90,8 @@ * privileges to manipulate any project. Similarly, the local simulation does not require * verification of domain name ownership. Any request for creating a managed zone will be approved. * The mock does not track quota and will allow the user to exceed it. The mock provides only basic - * validation of the DNS data for records of type A and AAAA. It does not validate any other record - * types. + * validation of the DNS data for record sets of type A and AAAA. It does not validate any other + * record set types. */ public class LocalDnsHelper { @@ -470,7 +470,7 @@ static Response toListResponse(List serializedObjects, String context, S } /** - * Prepares DNS records that are created by default for each zone. + * Prepares record sets that are created by default for each zone. */ private static ImmutableSortedMap defaultRecords(ManagedZone zone) { ResourceRecordSet soa = new ResourceRecordSet(); @@ -508,7 +508,7 @@ static List randomNameservers() { } /** - * Returns a hex string id (used for a dns record) unique within the set of ids. + * Returns a hex string id (used for a record set) unique within the set of ids. */ @VisibleForTesting static String getUniqueId(Set ids) { @@ -521,14 +521,14 @@ static String getUniqueId(Set ids) { } /** - * Tests if a DNS record matches name and type (if provided). Used for filtering. + * Tests if a record set matches name and type (if provided). Used for filtering. */ @VisibleForTesting - static boolean matchesCriteria(ResourceRecordSet record, String name, String type) { - if (type != null && !record.getType().equals(type)) { + static boolean matchesCriteria(ResourceRecordSet recordSet, String name, String type) { + if (type != null && !recordSet.getType().equals(type)) { return false; } - return name == null || record.getName().equals(name); + return name == null || recordSet.getName().equals(name); } /** @@ -871,7 +871,7 @@ Response listZones(String projectId, String query) { } /** - * Lists DNS records for a zone. Next page token is the ID of the last record listed. + * Lists record sets for a zone. Next page token is the ID of the last record listed. */ @VisibleForTesting Response listDnsRecords(String projectId, String zoneName, String query) { @@ -898,18 +898,18 @@ Response listDnsRecords(String projectId, String zoneName, String query) { boolean hasMorePages = false; LinkedList serializedRrsets = new LinkedList<>(); String lastRecordId = null; - for (String recordId : fragment.keySet()) { - ResourceRecordSet record = fragment.get(recordId); - if (matchesCriteria(record, name, type)) { + for (String recordSetId : fragment.keySet()) { + ResourceRecordSet recordSet = fragment.get(recordSetId); + if (matchesCriteria(recordSet, name, type)) { if (sizeReached) { // we do not add this, just note that there would be more and there should be a token hasMorePages = true; break; } else { - lastRecordId = recordId; + lastRecordId = recordSetId; try { serializedRrsets.addLast(jsonFactory.toString( - OptionParsers.extractFields(record, fields))); + OptionParsers.extractFields(recordSet, fields))); } catch (IOException e) { return Error.INTERNAL_ERROR.response(String.format( "Error when serializing resource record set in managed zone %s in project %s", @@ -1128,8 +1128,8 @@ static Response checkRrset(ResourceRecordSet rrset, ZoneContainer zone, int inde } /** - * Checks against duplicate additions (for each record to be added that already exists, we must - * have a matching deletion. Furthermore, check that mandatory SOA and NS records stay. + * Checks against duplicate additions (for each record set to be added that already exists, we + * must have a matching deletion. Furthermore, check that mandatory SOA and NS records stay. */ static Response checkAdditionsDeletions(List additions, List deletions, ZoneContainer zone) { @@ -1139,7 +1139,7 @@ static Response checkAdditionsDeletions(List additions, for (ResourceRecordSet wrappedRrset : zone.dnsRecords().get().values()) { if (rrset.getName().equals(wrappedRrset.getName()) && rrset.getType().equals(wrappedRrset.getType()) - // such a record exist and we must have a deletion + // such a record set exists and we must have a deletion && (deletions == null || !deletions.contains(wrappedRrset))) { return Error.ALREADY_EXISTS.response(String.format( "The 'entity.change.additions[%s]' resource named '%s (%s)' already exists.", @@ -1181,10 +1181,10 @@ static Response checkAdditionsDeletions(List additions, /** * Helper for searching rrsets in a collection. */ - private static ResourceRecordSet findByNameAndType(Iterable records, + private static ResourceRecordSet findByNameAndType(Iterable recordSets, String name, String type) { - if (records != null) { - for (ResourceRecordSet rrset : records) { + if (recordSets != null) { + for (ResourceRecordSet rrset : recordSets) { if ((name == null || name.equals(rrset.getName())) && (type == null || type.equals(rrset.getType()))) { return rrset; @@ -1195,7 +1195,7 @@ private static ResourceRecordSet findByNameAndType(Iterable r } /** - * We only provide the most basic validation for A and AAAA records. + * We only provide the most basic validation for A and AAAA record sets. */ static boolean checkRrData(String data, String type) { switch (type) { @@ -1233,7 +1233,7 @@ static Response checkListOptions(Map options) { return Error.INVALID.response(String.format( "Invalid value for 'parameters.dnsName': '%s'", dnsName)); } - // for listing dns records, name must be fully qualified + // for listing record sets, name must be fully qualified String name = (String) options.get("name"); if (name != null && !name.endsWith(".")) { return Error.INVALID.response(String.format( diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java index ecd7e8179efe..578a0b52db3d 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/OptionParsers.java @@ -166,26 +166,26 @@ static ResourceRecordSet extractFields(ResourceRecordSet fullRecord, String... f if (fields == null || fields.length == 0) { return fullRecord; } - ResourceRecordSet record = new ResourceRecordSet(); + ResourceRecordSet recordSet = new ResourceRecordSet(); for (String field : fields) { switch (field) { case "name": - record.setName(fullRecord.getName()); + recordSet.setName(fullRecord.getName()); break; case "rrdatas": - record.setRrdatas(fullRecord.getRrdatas()); + recordSet.setRrdatas(fullRecord.getRrdatas()); break; case "type": - record.setType(fullRecord.getType()); + recordSet.setType(fullRecord.getType()); break; case "ttl": - record.setTtl(fullRecord.getTtl()); + recordSet.setTtl(fullRecord.getTtl()); break; default: break; } } - return record; + return recordSet; } static Map parseListChangesOptions(String query) { diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java index 8b40a4dcff34..fe726acb7c10 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java @@ -35,16 +35,16 @@ public class ChangeRequestTest { private static final Long START_TIME_MILLIS = 12334567890L; private static final ChangeRequest.Status STATUS = ChangeRequest.Status.PENDING; private static final String NAME1 = "dns1"; - private static final DnsRecord.Type TYPE1 = DnsRecord.Type.A; + private static final RecordSet.Type TYPE1 = RecordSet.Type.A; private static final String NAME2 = "dns2"; - private static final DnsRecord.Type TYPE2 = DnsRecord.Type.AAAA; + private static final RecordSet.Type TYPE2 = RecordSet.Type.AAAA; private static final String NAME3 = "dns3"; - private static final DnsRecord.Type TYPE3 = DnsRecord.Type.MX; - private static final DnsRecord RECORD1 = DnsRecord.builder(NAME1, TYPE1).build(); - private static final DnsRecord RECORD2 = DnsRecord.builder(NAME2, TYPE2).build(); - private static final DnsRecord RECORD3 = DnsRecord.builder(NAME3, TYPE3).build(); - private static final List ADDITIONS = ImmutableList.of(RECORD1, RECORD2); - private static final List DELETIONS = ImmutableList.of(RECORD3); + private static final RecordSet.Type TYPE3 = RecordSet.Type.MX; + private static final RecordSet RECORD1 = RecordSet.builder(NAME1, TYPE1).build(); + private static final RecordSet RECORD2 = RecordSet.builder(NAME2, TYPE2).build(); + private static final RecordSet RECORD3 = RecordSet.builder(NAME3, TYPE3).build(); + private static final List ADDITIONS = ImmutableList.of(RECORD1, RECORD2); + private static final List DELETIONS = ImmutableList.of(RECORD3); private static final ChangeRequest CHANGE = ChangeRequest.builder() .add(RECORD1) .add(RECORD2) @@ -70,7 +70,7 @@ public void testBuilder() { assertEquals(START_TIME_MILLIS, CHANGE.startTimeMillis()); assertEquals(ADDITIONS, CHANGE.additions()); assertEquals(DELETIONS, CHANGE.deletions()); - List recordList = ImmutableList.of(RECORD1); + List recordList = ImmutableList.of(RECORD1); ChangeRequest another = CHANGE.toBuilder().additions(recordList).build(); assertEquals(recordList, another.additions()); assertEquals(CHANGE.deletions(), another.deletions()); @@ -160,7 +160,7 @@ public void testClearAdditions() { public void testAddAddition() { try { CHANGE.toBuilder().add(null); - fail("Should not be able to add null DnsRecord."); + fail("Should not be able to add null RecordSet."); } catch (NullPointerException e) { // expected } @@ -172,7 +172,7 @@ public void testAddAddition() { public void testAddDeletion() { try { CHANGE.toBuilder().delete(null); - fail("Should not be able to delete null DnsRecord."); + fail("Should not be able to delete null RecordSet."); } catch (NullPointerException e) { // expected } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java index a97c9c408036..ab2dba0a566c 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java @@ -21,7 +21,6 @@ import com.google.api.services.dns.model.Change; import com.google.api.services.dns.model.ManagedZone; -import com.google.api.services.dns.model.ResourceRecordSet; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; @@ -46,10 +45,10 @@ public class DnsImplTest { private static final String DNS_NAME = "example.com."; private static final String DESCRIPTION = "desc"; private static final String CHANGE_ID = "some change id"; - private static final DnsRecord DNS_RECORD1 = DnsRecord.builder("Something", DnsRecord.Type.AAAA) - .build(); - private static final DnsRecord DNS_RECORD2 = DnsRecord.builder("Different", DnsRecord.Type.AAAA) - .build(); + private static final RecordSet DNS_RECORD1 = + RecordSet.builder("Something", RecordSet.Type.AAAA).build(); + private static final RecordSet DNS_RECORD2 = + RecordSet.builder("Different", RecordSet.Type.AAAA).build(); private static final Integer MAX_SIZE = 20; private static final String PAGE_TOKEN = "some token"; private static final ZoneInfo ZONE_INFO = ZoneInfo.of(ZONE_NAME, DNS_NAME, DESCRIPTION); @@ -70,7 +69,8 @@ public class DnsImplTest { CHANGE_REQUEST_PARTIAL.toPb())); private static final DnsRpc.ListResult LIST_RESULT_OF_PB_ZONES = DnsRpc.ListResult.of("cursor", ImmutableList.of(ZONE_INFO.toPb())); - private static final DnsRpc.ListResult LIST_OF_PB_DNS_RECORDS = + private static final DnsRpc.ListResult + LIST_OF_PB_DNS_RECORDS = DnsRpc.ListResult.of("cursor", ImmutableList.of(DNS_RECORD1.toPb(), DNS_RECORD2.toPb())); // Field options @@ -91,12 +91,12 @@ public class DnsImplTest { Dns.ChangeRequestListOption.pageToken(PAGE_TOKEN), Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS), Dns.ChangeRequestListOption.sortOrder(Dns.SortingOrder.ASCENDING)}; - private static final Dns.DnsRecordListOption[] DNS_RECORD_LIST_OPTIONS = { - Dns.DnsRecordListOption.pageSize(MAX_SIZE), - Dns.DnsRecordListOption.pageToken(PAGE_TOKEN), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL), - Dns.DnsRecordListOption.dnsName(DNS_NAME), - Dns.DnsRecordListOption.type(DnsRecord.Type.AAAA)}; + private static final Dns.RecordSetListOption[] DNS_RECORD_LIST_OPTIONS = { + Dns.RecordSetListOption.pageSize(MAX_SIZE), + Dns.RecordSetListOption.pageToken(PAGE_TOKEN), + Dns.RecordSetListOption.fields(Dns.RecordSetField.TTL), + Dns.RecordSetListOption.dnsName(DNS_NAME), + Dns.RecordSetListOption.type(RecordSet.Type.AAAA)}; // Other private static final Map EMPTY_RPC_OPTIONS = ImmutableMap.of(); @@ -338,11 +338,11 @@ public void testListZonesWithOptions() { @Test public void testListDnsRecords() { - EasyMock.expect(dnsRpcMock.listDnsRecords(ZONE_INFO.name(), EMPTY_RPC_OPTIONS)) + EasyMock.expect(dnsRpcMock.listRecordSets(ZONE_INFO.name(), EMPTY_RPC_OPTIONS)) .andReturn(LIST_OF_PB_DNS_RECORDS); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - Page dnsPage = dns.listDnsRecords(ZONE_INFO.name()); + Page dnsPage = dns.listRecordSets(ZONE_INFO.name()); assertEquals(2, Lists.newArrayList(dnsPage.values()).size()); assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD1)); assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD2)); @@ -351,11 +351,11 @@ public void testListDnsRecords() { @Test public void testListDnsRecordsWithOptions() { Capture> capturedOptions = Capture.newInstance(); - EasyMock.expect(dnsRpcMock.listDnsRecords(EasyMock.eq(ZONE_NAME), + EasyMock.expect(dnsRpcMock.listRecordSets(EasyMock.eq(ZONE_NAME), EasyMock.capture(capturedOptions))).andReturn(LIST_OF_PB_DNS_RECORDS); EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl - Page dnsPage = dns.listDnsRecords(ZONE_NAME, DNS_RECORD_LIST_OPTIONS); + Page dnsPage = dns.listRecordSets(ZONE_NAME, DNS_RECORD_LIST_OPTIONS); assertEquals(2, Lists.newArrayList(dnsPage.values()).size()); assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD1)); assertTrue(Lists.newArrayList(dnsPage.values()).contains(DNS_RECORD2)); @@ -365,8 +365,8 @@ public void testListDnsRecordsWithOptions() { .get(DNS_RECORD_LIST_OPTIONS[1].rpcOption()); assertEquals(PAGE_TOKEN, selector); selector = (String) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[2].rpcOption()); - assertTrue(selector.contains(Dns.DnsRecordField.NAME.selector())); - assertTrue(selector.contains(Dns.DnsRecordField.TTL.selector())); + assertTrue(selector.contains(Dns.RecordSetField.NAME.selector())); + assertTrue(selector.contains(Dns.RecordSetField.TTL.selector())); selector = (String) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[3].rpcOption()); assertEquals(DNS_RECORD_LIST_OPTIONS[3].value(), selector); String type = (String) capturedOptions.getValue().get(DNS_RECORD_LIST_OPTIONS[4] diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java index 2e233e2df62a..df86d6ebd495 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsTest.java @@ -30,36 +30,36 @@ public class DnsTest { private static final String DNS_NAME = "www.example.com."; @Test - public void testDnsRecordListOption() { + public void testRecordSetListOption() { // dns name String dnsName = "some name"; - Dns.DnsRecordListOption dnsRecordListOption = Dns.DnsRecordListOption.dnsName(dnsName); - assertEquals(dnsName, dnsRecordListOption.value()); - assertEquals(DnsRpc.Option.NAME, dnsRecordListOption.rpcOption()); + Dns.RecordSetListOption recordSetListOption = Dns.RecordSetListOption.dnsName(dnsName); + assertEquals(dnsName, recordSetListOption.value()); + assertEquals(DnsRpc.Option.NAME, recordSetListOption.rpcOption()); // page token - dnsRecordListOption = Dns.DnsRecordListOption.pageToken(PAGE_TOKEN); - assertEquals(PAGE_TOKEN, dnsRecordListOption.value()); - assertEquals(DnsRpc.Option.PAGE_TOKEN, dnsRecordListOption.rpcOption()); + recordSetListOption = Dns.RecordSetListOption.pageToken(PAGE_TOKEN); + assertEquals(PAGE_TOKEN, recordSetListOption.value()); + assertEquals(DnsRpc.Option.PAGE_TOKEN, recordSetListOption.rpcOption()); // page size - dnsRecordListOption = Dns.DnsRecordListOption.pageSize(PAGE_SIZE); - assertEquals(PAGE_SIZE, dnsRecordListOption.value()); - assertEquals(DnsRpc.Option.PAGE_SIZE, dnsRecordListOption.rpcOption()); + recordSetListOption = Dns.RecordSetListOption.pageSize(PAGE_SIZE); + assertEquals(PAGE_SIZE, recordSetListOption.value()); + assertEquals(DnsRpc.Option.PAGE_SIZE, recordSetListOption.rpcOption()); // record type - DnsRecord.Type recordType = DnsRecord.Type.AAAA; - dnsRecordListOption = Dns.DnsRecordListOption.type(recordType); - assertEquals(recordType.name(), dnsRecordListOption.value()); - assertEquals(DnsRpc.Option.DNS_TYPE, dnsRecordListOption.rpcOption()); + RecordSet.Type recordType = RecordSet.Type.AAAA; + recordSetListOption = Dns.RecordSetListOption.type(recordType); + assertEquals(recordType.name(), recordSetListOption.value()); + assertEquals(DnsRpc.Option.DNS_TYPE, recordSetListOption.rpcOption()); // fields - dnsRecordListOption = Dns.DnsRecordListOption.fields(Dns.DnsRecordField.NAME, - Dns.DnsRecordField.TTL); - assertEquals(DnsRpc.Option.FIELDS, dnsRecordListOption.rpcOption()); - assertTrue(dnsRecordListOption.value() instanceof String); - assertTrue(((String) dnsRecordListOption.value()).contains( - Dns.DnsRecordField.NAME.selector())); - assertTrue(((String) dnsRecordListOption.value()).contains( - Dns.DnsRecordField.TTL.selector())); - assertTrue(((String) dnsRecordListOption.value()).contains( - Dns.DnsRecordField.NAME.selector())); + recordSetListOption = Dns.RecordSetListOption.fields(Dns.RecordSetField.NAME, + Dns.RecordSetField.TTL); + assertEquals(DnsRpc.Option.FIELDS, recordSetListOption.rpcOption()); + assertTrue(recordSetListOption.value() instanceof String); + assertTrue(((String) recordSetListOption.value()).contains( + Dns.RecordSetField.NAME.selector())); + assertTrue(((String) recordSetListOption.value()).contains( + Dns.RecordSetField.TTL.selector())); + assertTrue(((String) recordSetListOption.value()).contains( + Dns.RecordSetField.NAME.selector())); } @Test diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/RecordSetTest.java similarity index 63% rename from gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java rename to gcloud-java-dns/src/test/java/com/google/gcloud/dns/RecordSetTest.java index 5fc972cede78..369e078a48c7 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsRecordTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/RecordSetTest.java @@ -16,7 +16,7 @@ package com.google.gcloud.dns; -import static com.google.gcloud.dns.DnsRecord.builder; +import static com.google.gcloud.dns.RecordSet.builder; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; @@ -26,35 +26,35 @@ import java.util.concurrent.TimeUnit; -public class DnsRecordTest { +public class RecordSetTest { private static final String NAME = "example.com."; private static final Integer TTL = 3600; private static final TimeUnit UNIT = TimeUnit.HOURS; private static final Integer UNIT_TTL = 1; - private static final DnsRecord.Type TYPE = DnsRecord.Type.AAAA; - private static final DnsRecord record = builder(NAME, TYPE) + private static final RecordSet.Type TYPE = RecordSet.Type.AAAA; + private static final RecordSet recordSet = builder(NAME, TYPE) .ttl(UNIT_TTL, UNIT) .build(); @Test public void testDefaultDnsRecord() { - DnsRecord record = builder(NAME, TYPE).build(); - assertEquals(0, record.records().size()); - assertEquals(TYPE, record.type()); - assertEquals(NAME, record.name()); + RecordSet recordSet = builder(NAME, TYPE).build(); + assertEquals(0, recordSet.records().size()); + assertEquals(TYPE, recordSet.type()); + assertEquals(NAME, recordSet.name()); } @Test public void testBuilder() { - assertEquals(NAME, record.name()); - assertEquals(TTL, record.ttl()); - assertEquals(TYPE, record.type()); - assertEquals(0, record.records().size()); + assertEquals(NAME, recordSet.name()); + assertEquals(TTL, recordSet.ttl()); + assertEquals(TYPE, recordSet.type()); + assertEquals(0, recordSet.records().size()); // verify that one can add records to the record set - String testingRecord = "Testing record"; - String anotherTestingRecord = "Another record 123"; - DnsRecord anotherRecord = record.toBuilder() + String testingRecord = "Testing recordSet"; + String anotherTestingRecord = "Another recordSet 123"; + RecordSet anotherRecord = recordSet.toBuilder() .addRecord(testingRecord) .addRecord(anotherTestingRecord) .build(); @@ -79,47 +79,47 @@ public void testValidTtl() { } catch (IllegalArgumentException e) { // expected } - DnsRecord record = DnsRecord.builder(NAME, TYPE).ttl(UNIT_TTL, UNIT).build(); + RecordSet record = RecordSet.builder(NAME, TYPE).ttl(UNIT_TTL, UNIT).build(); assertEquals(TTL, record.ttl()); } @Test public void testEqualsAndNotEquals() { - DnsRecord clone = record.toBuilder().build(); - assertEquals(record, clone); - clone = record.toBuilder().addRecord("another record").build(); - assertNotEquals(record, clone); + RecordSet clone = recordSet.toBuilder().build(); + assertEquals(recordSet, clone); + clone = recordSet.toBuilder().addRecord("another recordSet").build(); + assertNotEquals(recordSet, clone); String differentName = "totally different name"; - clone = record.toBuilder().name(differentName).build(); - assertNotEquals(record, clone); - clone = record.toBuilder().ttl(record.ttl() + 1, TimeUnit.SECONDS).build(); - assertNotEquals(record, clone); - clone = record.toBuilder().type(DnsRecord.Type.TXT).build(); - assertNotEquals(record, clone); + clone = recordSet.toBuilder().name(differentName).build(); + assertNotEquals(recordSet, clone); + clone = recordSet.toBuilder().ttl(recordSet.ttl() + 1, TimeUnit.SECONDS).build(); + assertNotEquals(recordSet, clone); + clone = recordSet.toBuilder().type(RecordSet.Type.TXT).build(); + assertNotEquals(recordSet, clone); } @Test public void testSameHashCodeOnEquals() { - int hash = record.hashCode(); - DnsRecord clone = record.toBuilder().build(); + int hash = recordSet.hashCode(); + RecordSet clone = recordSet.toBuilder().build(); assertEquals(clone.hashCode(), hash); } @Test public void testToAndFromPb() { - assertEquals(record, DnsRecord.fromPb(record.toPb())); - DnsRecord partial = builder(NAME, TYPE).build(); - assertEquals(partial, DnsRecord.fromPb(partial.toPb())); + assertEquals(recordSet, RecordSet.fromPb(recordSet.toPb())); + RecordSet partial = builder(NAME, TYPE).build(); + assertEquals(partial, RecordSet.fromPb(partial.toPb())); partial = builder(NAME, TYPE).addRecord("test").build(); - assertEquals(partial, DnsRecord.fromPb(partial.toPb())); + assertEquals(partial, RecordSet.fromPb(partial.toPb())); partial = builder(NAME, TYPE).ttl(15, TimeUnit.SECONDS).build(); - assertEquals(partial, DnsRecord.fromPb(partial.toPb())); + assertEquals(partial, RecordSet.fromPb(partial.toPb())); } @Test public void testToBuilder() { - assertEquals(record, record.toBuilder().build()); - DnsRecord partial = builder(NAME, TYPE).build(); + assertEquals(recordSet, recordSet.toBuilder().build()); + RecordSet partial = builder(NAME, TYPE).build(); assertEquals(partial, partial.toBuilder().build()); partial = builder(NAME, TYPE).addRecord("test").build(); assertEquals(partial, partial.toBuilder().build()); @@ -130,7 +130,8 @@ public void testToBuilder() { @Test public void clearRecordSet() { // make sure that we are starting not empty - DnsRecord clone = record.toBuilder().addRecord("record").addRecord("another").build(); + RecordSet clone = + recordSet.toBuilder().addRecord("record").addRecord("another").build(); assertNotEquals(0, clone.records().size()); clone = clone.toBuilder().clearRecords().build(); assertEquals(0, clone.records().size()); @@ -141,7 +142,7 @@ public void clearRecordSet() { public void removeFromRecordSet() { String recordString = "record"; // make sure that we are starting not empty - DnsRecord clone = record.toBuilder().addRecord(recordString).build(); + RecordSet clone = recordSet.toBuilder().addRecord(recordString).build(); assertNotEquals(0, clone.records().size()); clone = clone.toBuilder().removeRecord(recordString).build(); assertEquals(0, clone.records().size()); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java index 7a0c32036878..c06cd096bf1e 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java @@ -45,8 +45,8 @@ public class SerializationTest extends BaseSerializationTest { .build(); private static final Dns.ZoneListOption ZONE_LIST_OPTION = Dns.ZoneListOption.dnsName("www.example.com."); - private static final Dns.DnsRecordListOption DNS_REOCRD_LIST_OPTION = - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL); + private static final Dns.RecordSetListOption RECORD_SET_LIST_OPTION = + Dns.RecordSetListOption.fields(Dns.RecordSetField.TTL); private static final Dns.ChangeRequestListOption CHANGE_REQUEST_LIST_OPTION = Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.STATUS); private static final Dns.ZoneOption ZONE_OPTION = @@ -64,16 +64,16 @@ public class SerializationTest extends BaseSerializationTest { private static final Zone PARTIAL_ZONE = new Zone(DNS, new ZoneInfo.BuilderImpl(PARTIAL_ZONE_INFO)); private static final ChangeRequest CHANGE_REQUEST_PARTIAL = ChangeRequest.builder().build(); - private static final DnsRecord DNS_RECORD_PARTIAL = - DnsRecord.builder("www.www.com", DnsRecord.Type.AAAA).build(); - private static final DnsRecord DNS_RECORD_COMPLETE = - DnsRecord.builder("www.sadfa.com", DnsRecord.Type.A) + private static final RecordSet RECORD_SET_PARTIAL = + RecordSet.builder("www.www.com", RecordSet.Type.AAAA).build(); + private static final RecordSet RECORD_SET_COMPLETE = + RecordSet.builder("www.sadfa.com", RecordSet.Type.A) .ttl(12, TimeUnit.HOURS) .addRecord("record") .build(); private static final ChangeRequest CHANGE_REQUEST_COMPLETE = ChangeRequest.builder() - .add(DNS_RECORD_COMPLETE) - .delete(DNS_RECORD_PARTIAL) + .add(RECORD_SET_COMPLETE) + .delete(RECORD_SET_PARTIAL) .status(ChangeRequest.Status.PENDING) .id("some id") .startTimeMillis(132L) @@ -89,9 +89,9 @@ protected Serializable[] serializableObjects() { .authCredentials(null) .build(); return new Serializable[]{FULL_ZONE_INFO, PARTIAL_ZONE_INFO, ZONE_LIST_OPTION, - DNS_REOCRD_LIST_OPTION, CHANGE_REQUEST_LIST_OPTION, ZONE_OPTION, CHANGE_REQUEST_OPTION, + RECORD_SET_LIST_OPTION, CHANGE_REQUEST_LIST_OPTION, ZONE_OPTION, CHANGE_REQUEST_OPTION, PROJECT_OPTION, PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, OPTIONS, FULL_ZONE, PARTIAL_ZONE, - OPTIONS, CHANGE_REQUEST_PARTIAL, DNS_RECORD_PARTIAL, DNS_RECORD_COMPLETE, + OPTIONS, CHANGE_REQUEST_PARTIAL, RECORD_SET_PARTIAL, RECORD_SET_COMPLETE, CHANGE_REQUEST_COMPLETE, options, otherOptions}; } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index 759c34fc1167..bd59f8c140e9 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -50,12 +50,12 @@ public class ZoneTest { .build(); private static final ZoneInfo NO_ID_INFO = ZoneInfo.of(ZONE_NAME, "another-example.com", "description").toBuilder() - .creationTimeMillis(893123464L) - .build(); + .creationTimeMillis(893123464L) + .build(); private static final Dns.ZoneOption ZONE_FIELD_OPTIONS = Dns.ZoneOption.fields(Dns.ZoneField.CREATION_TIME); - private static final Dns.DnsRecordListOption DNS_RECORD_OPTIONS = - Dns.DnsRecordListOption.dnsName("some-dns"); + private static final Dns.RecordSetListOption DNS_RECORD_OPTIONS = + Dns.RecordSetListOption.dnsName("some-dns"); private static final Dns.ChangeRequestOption CHANGE_REQUEST_FIELD_OPTIONS = Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME); private static final Dns.ChangeRequestListOption CHANGE_REQUEST_LIST_OPTIONS = @@ -120,51 +120,51 @@ public void deleteByNameAndNotFound() { @Test public void listDnsRecordsByNameAndFound() { @SuppressWarnings("unchecked") - Page pageMock = createStrictMock(Page.class); + Page pageMock = createStrictMock(Page.class); replay(pageMock); - expect(dns.listDnsRecords(ZONE_NAME)).andReturn(pageMock); - expect(dns.listDnsRecords(ZONE_NAME)).andReturn(pageMock); + expect(dns.listRecordSets(ZONE_NAME)).andReturn(pageMock); + expect(dns.listRecordSets(ZONE_NAME)).andReturn(pageMock); // again for options - expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); - expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); + expect(dns.listRecordSets(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); + expect(dns.listRecordSets(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); replay(dns); - Page result = zone.listDnsRecords(); + Page result = zone.listRecordSets(); assertSame(pageMock, result); - result = zoneNoId.listDnsRecords(); + result = zoneNoId.listRecordSets(); assertSame(pageMock, result); verify(pageMock); - zone.listDnsRecords(DNS_RECORD_OPTIONS); // check options - zoneNoId.listDnsRecords(DNS_RECORD_OPTIONS); // check options + zone.listRecordSets(DNS_RECORD_OPTIONS); // check options + zoneNoId.listRecordSets(DNS_RECORD_OPTIONS); // check options } @Test public void listDnsRecordsByNameAndNotFound() { - expect(dns.listDnsRecords(ZONE_NAME)).andThrow(EXCEPTION); - expect(dns.listDnsRecords(ZONE_NAME)).andThrow(EXCEPTION); + expect(dns.listRecordSets(ZONE_NAME)).andThrow(EXCEPTION); + expect(dns.listRecordSets(ZONE_NAME)).andThrow(EXCEPTION); // again for options - expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andThrow(EXCEPTION); - expect(dns.listDnsRecords(ZONE_NAME, DNS_RECORD_OPTIONS)).andThrow(EXCEPTION); + expect(dns.listRecordSets(ZONE_NAME, DNS_RECORD_OPTIONS)).andThrow(EXCEPTION); + expect(dns.listRecordSets(ZONE_NAME, DNS_RECORD_OPTIONS)).andThrow(EXCEPTION); replay(dns); try { - zoneNoId.listDnsRecords(); + zoneNoId.listRecordSets(); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected } try { - zone.listDnsRecords(); + zone.listRecordSets(); fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected } try { - zoneNoId.listDnsRecords(DNS_RECORD_OPTIONS); // check options + zoneNoId.listRecordSets(DNS_RECORD_OPTIONS); // check options fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected } try { - zone.listDnsRecords(DNS_RECORD_OPTIONS); // check options + zone.listRecordSets(DNS_RECORD_OPTIONS); // check options fail("Parent container not found, should throw an exception."); } catch (DnsException e) { // expected diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java index bfea46dfe039..8f7626a5ae0a 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java @@ -29,8 +29,8 @@ import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsException; import com.google.gcloud.dns.DnsOptions; -import com.google.gcloud.dns.DnsRecord; import com.google.gcloud.dns.ProjectInfo; +import com.google.gcloud.dns.RecordSet; import com.google.gcloud.dns.Zone; import com.google.gcloud.dns.ZoneInfo; @@ -66,13 +66,13 @@ public class ITDnsTest { ZoneInfo.of(ZONE_NAME_TOO_LONG, ZONE_DNS_NAME1, ZONE_DESCRIPTION1); private static final ZoneInfo ZONE_DNS_NO_PERIOD = ZoneInfo.of(ZONE_NAME1, ZONE_DNS_NAME_NO_PERIOD, ZONE_DESCRIPTION1); - private static final DnsRecord A_RECORD_ZONE1 = - DnsRecord.builder("www." + ZONE1.dnsName(), DnsRecord.Type.A) + private static final RecordSet A_RECORD_ZONE1 = + RecordSet.builder("www." + ZONE1.dnsName(), RecordSet.Type.A) .records(ImmutableList.of("123.123.55.1")) .ttl(25, TimeUnit.SECONDS) .build(); - private static final DnsRecord AAAA_RECORD_ZONE1 = - DnsRecord.builder("www." + ZONE1.dnsName(), DnsRecord.Type.AAAA) + private static final RecordSet AAAA_RECORD_ZONE1 = + RecordSet.builder("www." + ZONE1.dnsName(), RecordSet.Type.AAAA) .records(ImmutableList.of("ed:ed:12:aa:36:3:3:105")) .ttl(25, TimeUnit.SECONDS) .build(); @@ -98,12 +98,13 @@ private static void clear() { while (iterator.hasNext()) { waitForChangeToComplete(zoneName, iterator.next().id()); } - Iterator recordIterator = zone.listDnsRecords().iterateAll(); - List toDelete = new LinkedList<>(); - while (recordIterator.hasNext()) { - DnsRecord record = recordIterator.next(); - if (!ImmutableList.of(DnsRecord.Type.NS, DnsRecord.Type.SOA).contains(record.type())) { - toDelete.add(record); + Iterator recordSetIterator = zone.listRecordSets().iterateAll(); + List toDelete = new LinkedList<>(); + while (recordSetIterator.hasNext()) { + RecordSet recordSet = recordSetIterator.next(); + if (!ImmutableList.of(RecordSet.Type.NS, RecordSet.Type.SOA) + .contains(recordSet.type())) { + toDelete.add(recordSet); } } if (!toDelete.isEmpty()) { @@ -587,41 +588,42 @@ public void testCreateChange() { @Test public void testInvalidChangeRequest() { Zone zone = DNS.create(ZONE1); - DnsRecord validA = DnsRecord.builder("subdomain." + zone.dnsName(), DnsRecord.Type.A) - .records(ImmutableList.of("0.255.1.5")) - .build(); + RecordSet validA = + RecordSet.builder("subdomain." + zone.dnsName(), RecordSet.Type.A) + .records(ImmutableList.of("0.255.1.5")) + .build(); try { ChangeRequest validChange = ChangeRequest.builder().add(validA).build(); zone.applyChangeRequest(validChange); try { zone.applyChangeRequest(validChange); - fail("Created a record which already exists."); + fail("Created a record set which already exists."); } catch (DnsException ex) { // expected assertFalse(ex.retryable()); assertEquals(409, ex.code()); } // delete with field mismatch - DnsRecord mismatch = validA.toBuilder().ttl(20, TimeUnit.SECONDS).build(); + RecordSet mismatch = validA.toBuilder().ttl(20, TimeUnit.SECONDS).build(); ChangeRequest deletion = ChangeRequest.builder().delete(mismatch).build(); try { zone.applyChangeRequest(deletion); - fail("Deleted a record without a complete match."); + fail("Deleted a record set without a complete match."); } catch (DnsException ex) { // expected assertEquals(412, ex.code()); assertFalse(ex.retryable()); } // delete and add SOA - Iterator recordIterator = zone.listDnsRecords().iterateAll(); - LinkedList deletions = new LinkedList<>(); - LinkedList additions = new LinkedList<>(); - while (recordIterator.hasNext()) { - DnsRecord record = recordIterator.next(); - if (record.type() == DnsRecord.Type.SOA) { - deletions.add(record); + Iterator recordSetIterator = zone.listRecordSets().iterateAll(); + LinkedList deletions = new LinkedList<>(); + LinkedList additions = new LinkedList<>(); + while (recordSetIterator.hasNext()) { + RecordSet recordSet = recordSetIterator.next(); + if (recordSet.type() == RecordSet.Type.SOA) { + deletions.add(recordSet); // the subdomain is necessary to get 400 instead of 412 - DnsRecord copy = record.toBuilder().name("x." + record.name()).build(); + RecordSet copy = recordSet.toBuilder().name("x." + recordSet.name()).build(); additions.add(copy); break; } @@ -831,92 +833,93 @@ public void testGetProject() { public void testListDnsRecords() { try { Zone zone = DNS.create(ZONE1); - ImmutableList dnsRecords = ImmutableList.copyOf( - DNS.listDnsRecords(zone.name()).iterateAll()); - assertEquals(2, dnsRecords.size()); - ImmutableList defaultRecords = - ImmutableList.of(DnsRecord.Type.NS, DnsRecord.Type.SOA); - for (DnsRecord record : dnsRecords) { - assertTrue(defaultRecords.contains(record.type())); + ImmutableList recordSets = ImmutableList.copyOf( + DNS.listRecordSets(zone.name()).iterateAll()); + assertEquals(2, recordSets.size()); + ImmutableList defaultRecords = + ImmutableList.of(RecordSet.Type.NS, RecordSet.Type.SOA); + for (RecordSet recordSet : recordSets) { + assertTrue(defaultRecords.contains(recordSet.type())); } // field options - Iterator dnsRecordIterator = DNS.listDnsRecords(zone.name(), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TTL)).iterateAll(); + Iterator recordSetIterator = DNS.listRecordSets(zone.name(), + Dns.RecordSetListOption.fields(Dns.RecordSetField.TTL)).iterateAll(); int counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).ttl(), record.ttl()); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertTrue(record.records().isEmpty()); + while (recordSetIterator.hasNext()) { + RecordSet recordSet = recordSetIterator.next(); + assertEquals(recordSets.get(counter).ttl(), recordSet.ttl()); + assertEquals(recordSets.get(counter).name(), recordSet.name()); + assertEquals(recordSets.get(counter).type(), recordSet.type()); + assertTrue(recordSet.records().isEmpty()); counter++; } assertEquals(2, counter); - dnsRecordIterator = DNS.listDnsRecords(zone.name(), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.NAME)).iterateAll(); + recordSetIterator = DNS.listRecordSets(zone.name(), + Dns.RecordSetListOption.fields(Dns.RecordSetField.NAME)).iterateAll(); counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertTrue(record.records().isEmpty()); - assertNull(record.ttl()); + while (recordSetIterator.hasNext()) { + RecordSet recordSet = recordSetIterator.next(); + assertEquals(recordSets.get(counter).name(), recordSet.name()); + assertEquals(recordSets.get(counter).type(), recordSet.type()); + assertTrue(recordSet.records().isEmpty()); + assertNull(recordSet.ttl()); counter++; } assertEquals(2, counter); - dnsRecordIterator = DNS.listDnsRecords(zone.name(), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.DNS_RECORDS)).iterateAll(); + recordSetIterator = DNS.listRecordSets(zone.name(), + Dns.RecordSetListOption.fields(Dns.RecordSetField.DNS_RECORDS)) + .iterateAll(); counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).records(), record.records()); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertNull(record.ttl()); + while (recordSetIterator.hasNext()) { + RecordSet recordSet = recordSetIterator.next(); + assertEquals(recordSets.get(counter).records(), recordSet.records()); + assertEquals(recordSets.get(counter).name(), recordSet.name()); + assertEquals(recordSets.get(counter).type(), recordSet.type()); + assertNull(recordSet.ttl()); counter++; } assertEquals(2, counter); - dnsRecordIterator = DNS.listDnsRecords(zone.name(), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), - Dns.DnsRecordListOption.pageSize(1)).iterateAll(); // also test paging + recordSetIterator = DNS.listRecordSets(zone.name(), + Dns.RecordSetListOption.fields(Dns.RecordSetField.TYPE), + Dns.RecordSetListOption.pageSize(1)).iterateAll(); // also test paging counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(dnsRecords.get(counter).type(), record.type()); - assertEquals(dnsRecords.get(counter).name(), record.name()); - assertTrue(record.records().isEmpty()); - assertNull(record.ttl()); + while (recordSetIterator.hasNext()) { + RecordSet recordSet = recordSetIterator.next(); + assertEquals(recordSets.get(counter).type(), recordSet.type()); + assertEquals(recordSets.get(counter).name(), recordSet.name()); + assertTrue(recordSet.records().isEmpty()); + assertNull(recordSet.ttl()); counter++; } assertEquals(2, counter); // test page size - Page dnsRecordPage = DNS.listDnsRecords(zone.name(), - Dns.DnsRecordListOption.fields(Dns.DnsRecordField.TYPE), - Dns.DnsRecordListOption.pageSize(1)); - assertEquals(1, ImmutableList.copyOf(dnsRecordPage.values().iterator()).size()); + Page recordSetPage = DNS.listRecordSets(zone.name(), + Dns.RecordSetListOption.fields(Dns.RecordSetField.TYPE), + Dns.RecordSetListOption.pageSize(1)); + assertEquals(1, ImmutableList.copyOf(recordSetPage.values().iterator()).size()); // test name filter ChangeRequest change = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1); waitForChangeToComplete(ZONE1.name(), change.id()); - dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), - Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name())).iterateAll(); + recordSetIterator = DNS.listRecordSets(ZONE1.name(), + Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.name())).iterateAll(); counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); + while (recordSetIterator.hasNext()) { + RecordSet recordSet = recordSetIterator.next(); assertTrue(ImmutableList.of(A_RECORD_ZONE1.type(), AAAA_RECORD_ZONE1.type()) - .contains(record.type())); + .contains(recordSet.type())); counter++; } assertEquals(2, counter); // test type filter waitForChangeToComplete(ZONE1.name(), change.id()); - dnsRecordIterator = DNS.listDnsRecords(ZONE1.name(), - Dns.DnsRecordListOption.dnsName(A_RECORD_ZONE1.name()), - Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())) + recordSetIterator = DNS.listRecordSets(ZONE1.name(), + Dns.RecordSetListOption.dnsName(A_RECORD_ZONE1.name()), + Dns.RecordSetListOption.type(A_RECORD_ZONE1.type())) .iterateAll(); counter = 0; - while (dnsRecordIterator.hasNext()) { - DnsRecord record = dnsRecordIterator.next(); - assertEquals(A_RECORD_ZONE1, record); + while (recordSetIterator.hasNext()) { + RecordSet recordSet = recordSetIterator.next(); + assertEquals(A_RECORD_ZONE1, recordSet); counter++; } assertEquals(1, counter); @@ -924,7 +927,8 @@ public void testListDnsRecords() { // check wrong arguments try { // name is not set - DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.type(A_RECORD_ZONE1.type())); + DNS.listRecordSets(ZONE1.name(), + Dns.RecordSetListOption.type(A_RECORD_ZONE1.type())); fail(); } catch (DnsException ex) { // expected @@ -932,7 +936,7 @@ public void testListDnsRecords() { assertFalse(ex.retryable()); } try { - DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.pageSize(0)); + DNS.listRecordSets(ZONE1.name(), Dns.RecordSetListOption.pageSize(0)); fail(); } catch (DnsException ex) { // expected @@ -940,7 +944,7 @@ public void testListDnsRecords() { assertFalse(ex.retryable()); } try { - DNS.listDnsRecords(ZONE1.name(), Dns.DnsRecordListOption.pageSize(-1)); + DNS.listRecordSets(ZONE1.name(), Dns.RecordSetListOption.pageSize(-1)); fail(); } catch (DnsException ex) { // expected diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java index 59002131cc9d..44516f47c657 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/testing/LocalDnsHelperTest.java @@ -131,7 +131,7 @@ public void testCreateZone() { ManagedZone created = RPC.create(ZONE1, EMPTY_RPC_OPTIONS); // check that default records were created DnsRpc.ListResult listResult - = RPC.listDnsRecords(ZONE1.getName(), EMPTY_RPC_OPTIONS); + = RPC.listRecordSets(ZONE1.getName(), EMPTY_RPC_OPTIONS); ImmutableList defaultTypes = ImmutableList.of("SOA", "NS"); Iterator iterator = listResult.results().iterator(); assertTrue(defaultTypes.contains(iterator.next().getType())); @@ -395,7 +395,7 @@ private static void executeCreateAndApplyChangeTest(DnsRpc rpc) { rpc.applyChangeRequest(ZONE1.getName(), CHANGE_KEEP, EMPTY_RPC_OPTIONS); waitForChangeToComplete(rpc, ZONE1.getName(), "3"); Iterable results = - rpc.listDnsRecords(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); + rpc.listRecordSets(ZONE1.getName(), EMPTY_RPC_OPTIONS).results(); List defaults = ImmutableList.of("SOA", "NS"); boolean rrsetKeep = false; boolean rrset1 = false; @@ -692,7 +692,7 @@ public void testListZones() { public void testListDnsRecords() { // no zone exists try { - RPC.listDnsRecords(ZONE_NAME1, EMPTY_RPC_OPTIONS); + RPC.listRecordSets(ZONE_NAME1, EMPTY_RPC_OPTIONS); fail(); } catch (DnsException ex) { // expected @@ -702,19 +702,19 @@ public void testListDnsRecords() { // zone exists but has no records RPC.create(ZONE1, EMPTY_RPC_OPTIONS); Iterable results = - RPC.listDnsRecords(ZONE_NAME1, EMPTY_RPC_OPTIONS).results(); + RPC.listRecordSets(ZONE_NAME1, EMPTY_RPC_OPTIONS).results(); ImmutableList records = ImmutableList.copyOf(results); assertEquals(2, records.size()); // contains default NS and SOA // zone has records RPC.applyChangeRequest(ZONE_NAME1, CHANGE_KEEP, EMPTY_RPC_OPTIONS); - results = RPC.listDnsRecords(ZONE_NAME1, EMPTY_RPC_OPTIONS).results(); + results = RPC.listRecordSets(ZONE_NAME1, EMPTY_RPC_OPTIONS).results(); records = ImmutableList.copyOf(results); assertEquals(3, records.size()); // error in options Map options = new HashMap<>(); options.put(DnsRpc.Option.PAGE_SIZE, 0); try { - RPC.listDnsRecords(ZONE1.getName(), options); + RPC.listRecordSets(ZONE1.getName(), options); fail(); } catch (DnsException ex) { // expected @@ -723,7 +723,7 @@ public void testListDnsRecords() { } options.put(DnsRpc.Option.PAGE_SIZE, -1); try { - RPC.listDnsRecords(ZONE1.getName(), options); + RPC.listRecordSets(ZONE1.getName(), options); fail(); } catch (DnsException ex) { // expected @@ -731,14 +731,14 @@ public void testListDnsRecords() { assertTrue(ex.getMessage().contains("parameters.maxResults")); } options.put(DnsRpc.Option.PAGE_SIZE, 15); - results = RPC.listDnsRecords(ZONE1.getName(), options).results(); + results = RPC.listRecordSets(ZONE1.getName(), options).results(); records = ImmutableList.copyOf(results); assertEquals(3, records.size()); // dnsName filter options = new HashMap<>(); options.put(DnsRpc.Option.NAME, "aaa"); try { - RPC.listDnsRecords(ZONE1.getName(), options); + RPC.listRecordSets(ZONE1.getName(), options); fail(); } catch (DnsException ex) { // expected @@ -746,13 +746,13 @@ public void testListDnsRecords() { assertTrue(ex.getMessage().contains("parameters.name")); } options.put(DnsRpc.Option.NAME, "aaa."); - results = RPC.listDnsRecords(ZONE1.getName(), options).results(); + results = RPC.listRecordSets(ZONE1.getName(), options).results(); records = ImmutableList.copyOf(results); assertEquals(0, records.size()); options.put(DnsRpc.Option.NAME, null); options.put(DnsRpc.Option.DNS_TYPE, "A"); try { - RPC.listDnsRecords(ZONE1.getName(), options); + RPC.listRecordSets(ZONE1.getName(), options); fail(); } catch (DnsException ex) { // expected @@ -762,7 +762,7 @@ public void testListDnsRecords() { options.put(DnsRpc.Option.NAME, "aaa."); options.put(DnsRpc.Option.DNS_TYPE, "a"); try { - RPC.listDnsRecords(ZONE1.getName(), options); + RPC.listRecordSets(ZONE1.getName(), options); fail(); } catch (DnsException ex) { // expected @@ -771,14 +771,14 @@ public void testListDnsRecords() { } options.put(DnsRpc.Option.NAME, DNS_NAME); options.put(DnsRpc.Option.DNS_TYPE, "SOA"); - results = RPC.listDnsRecords(ZONE1.getName(), options).results(); + results = RPC.listRecordSets(ZONE1.getName(), options).results(); records = ImmutableList.copyOf(results); assertEquals(1, records.size()); // field options options = new HashMap<>(); options.put(DnsRpc.Option.FIELDS, "rrsets(name)"); DnsRpc.ListResult listResult = - RPC.listDnsRecords(ZONE1.getName(), options); + RPC.listRecordSets(ZONE1.getName(), options); records = ImmutableList.copyOf(listResult.results()); ResourceRecordSet record = records.get(0); assertNotNull(record.getName()); @@ -787,7 +787,7 @@ public void testListDnsRecords() { assertNull(record.getTtl()); assertNull(listResult.pageToken()); options.put(DnsRpc.Option.FIELDS, "rrsets(rrdatas)"); - listResult = RPC.listDnsRecords(ZONE1.getName(), options); + listResult = RPC.listRecordSets(ZONE1.getName(), options); records = ImmutableList.copyOf(listResult.results()); record = records.get(0); assertNull(record.getName()); @@ -796,7 +796,7 @@ record = records.get(0); assertNull(record.getTtl()); assertNull(listResult.pageToken()); options.put(DnsRpc.Option.FIELDS, "rrsets(ttl)"); - listResult = RPC.listDnsRecords(ZONE1.getName(), options); + listResult = RPC.listRecordSets(ZONE1.getName(), options); records = ImmutableList.copyOf(listResult.results()); record = records.get(0); assertNull(record.getName()); @@ -805,7 +805,7 @@ record = records.get(0); assertNotNull(record.getTtl()); assertNull(listResult.pageToken()); options.put(DnsRpc.Option.FIELDS, "rrsets(type)"); - listResult = RPC.listDnsRecords(ZONE1.getName(), options); + listResult = RPC.listRecordSets(ZONE1.getName(), options); records = ImmutableList.copyOf(listResult.results()); record = records.get(0); assertNull(record.getName()); @@ -814,7 +814,7 @@ record = records.get(0); assertNull(record.getTtl()); assertNull(listResult.pageToken()); options.put(DnsRpc.Option.FIELDS, "nextPageToken"); - listResult = RPC.listDnsRecords(ZONE1.getName(), options); + listResult = RPC.listRecordSets(ZONE1.getName(), options); records = ImmutableList.copyOf(listResult.results()); record = records.get(0); assertNull(record.getName()); @@ -824,7 +824,7 @@ record = records.get(0); assertNull(listResult.pageToken()); options.put(DnsRpc.Option.FIELDS, "nextPageToken,rrsets(name,rrdatas)"); options.put(DnsRpc.Option.PAGE_SIZE, 1); - listResult = RPC.listDnsRecords(ZONE1.getName(), options); + listResult = RPC.listRecordSets(ZONE1.getName(), options); records = ImmutableList.copyOf(listResult.results()); assertEquals(1, records.size()); record = records.get(0); @@ -973,15 +973,15 @@ public void testListChanges() { public void testDnsRecordPaging() { RPC.create(ZONE1, EMPTY_RPC_OPTIONS); List complete = ImmutableList.copyOf( - RPC.listDnsRecords(ZONE1.getName(), EMPTY_RPC_OPTIONS).results()); + RPC.listRecordSets(ZONE1.getName(), EMPTY_RPC_OPTIONS).results()); Map options = new HashMap<>(); options.put(DnsRpc.Option.PAGE_SIZE, 1); - DnsRpc.ListResult listResult = RPC.listDnsRecords(ZONE1.getName(), options); + DnsRpc.ListResult listResult = RPC.listRecordSets(ZONE1.getName(), options); ImmutableList records = ImmutableList.copyOf(listResult.results()); assertEquals(1, records.size()); assertEquals(complete.get(0), records.get(0)); options.put(DnsRpc.Option.PAGE_TOKEN, listResult.pageToken()); - listResult = RPC.listDnsRecords(ZONE1.getName(), options); + listResult = RPC.listRecordSets(ZONE1.getName(), options); records = ImmutableList.copyOf(listResult.results()); assertEquals(1, records.size()); assertEquals(complete.get(1), records.get(0)); diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md index fc9ce9ef653d..8084cee562f0 100644 --- a/gcloud-java-examples/README.md +++ b/gcloud-java-examples/README.md @@ -75,7 +75,7 @@ To run examples from your command line: Note that you have to enable the Google Cloud DNS API on the [Google Developers Console][developers-console] before running the following commands. You will need to replace the domain name `elaborateexample.com` with your own domain name with [verified ownership] (https://www.google.com/webmasters/verification/home). - Also, note that the example creates and deletes DNS records of type A only. Operations with other record types are not implemented in the example. + Also, note that the example creates and deletes record sets of type A only. Operations with other record types are not implemented in the example. ``` mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="create some-sample-zone elaborateexample.com. description" mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.dns.DnsExample" -Dexec.args="list" diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java index 1b6ba8f179da..40ce61b07281 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java @@ -21,8 +21,8 @@ import com.google.gcloud.dns.ChangeRequest; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsOptions; -import com.google.gcloud.dns.DnsRecord; import com.google.gcloud.dns.ProjectInfo; +import com.google.gcloud.dns.RecordSet; import com.google.gcloud.dns.Zone; import com.google.gcloud.dns.ZoneInfo; @@ -38,8 +38,8 @@ /** * An example of using Google Cloud DNS. * - *

      This example creates, deletes, gets, and lists zones. It also creates and deletes DNS records - * of type A, and lists DNS records. + *

      This example creates, deletes, gets, and lists zones. It also creates and deletes + * record sets of type A, and lists record sets. * *

      Steps needed for running the example: *

        @@ -203,12 +203,12 @@ public void run(Dns dns, String... args) { if (args.length > 3) { ttl = Integer.parseInt(args[3]); } - DnsRecord record = DnsRecord.builder(recordName, DnsRecord.Type.A) + RecordSet recordSet = RecordSet.builder(recordName, RecordSet.Type.A) .records(ImmutableList.of(ip)) .ttl(ttl, TimeUnit.SECONDS) .build(); ChangeRequest changeRequest = ChangeRequest.builder() - .delete(record) + .delete(recordSet) .build(); changeRequest = dns.applyChangeRequest(zoneName, changeRequest); System.out.printf("The request for deleting A record %s for zone %s was successfully " @@ -238,7 +238,7 @@ public boolean check(String... args) { private static class AddDnsRecordAction implements DnsAction { /** - * Adds a DNS record of type A. The last parameter is ttl and is not required. If ttl is not + * Adds a record set of type A. The last parameter is ttl and is not required. If ttl is not * provided, a default value of 0 will be used. */ @Override @@ -250,11 +250,11 @@ public void run(Dns dns, String... args) { if (args.length > 3) { ttl = Integer.parseInt(args[3]); } - DnsRecord record = DnsRecord.builder(recordName, DnsRecord.Type.A) + RecordSet recordSet = RecordSet.builder(recordName, RecordSet.Type.A) .records(ImmutableList.of(ip)) .ttl(ttl, TimeUnit.SECONDS) .build(); - ChangeRequest changeRequest = ChangeRequest.builder().add(record).build(); + ChangeRequest changeRequest = ChangeRequest.builder().add(recordSet).build(); changeRequest = dns.applyChangeRequest(zoneName, changeRequest); System.out.printf("The request for adding A record %s for zone %s was successfully " + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); @@ -283,21 +283,21 @@ public boolean check(String... args) { private static class ListDnsRecordsAction implements DnsAction { /** - * Lists all the DNS records in the given zone. + * Lists all the record sets in the given zone. */ @Override public void run(Dns dns, String... args) { String zoneName = args[0]; - Iterator iterator = dns.listDnsRecords(zoneName).iterateAll(); + Iterator iterator = dns.listRecordSets(zoneName).iterateAll(); if (iterator.hasNext()) { - System.out.printf("DNS records for zone %s:%n", zoneName); + System.out.printf("Record sets for zone %s:%n", zoneName); while (iterator.hasNext()) { - DnsRecord record = iterator.next(); - System.out.printf("%nRecord name: %s%nTTL: %s%nRecords: %s%n", record.name(), - record.ttl(), Joiner.on(", ").join(record.records())); + RecordSet recordSet = iterator.next(); + System.out.printf("%nRecord name: %s%nTTL: %s%nRecords: %s%n", recordSet.name(), + recordSet.ttl(), Joiner.on(", ").join(recordSet.records())); } } else { - System.out.printf("Zone %s has no DNS records.%n", zoneName); + System.out.printf("Zone %s has no record sets records.%n", zoneName); } } @@ -361,8 +361,8 @@ private static class ListAction implements DnsAction { /** * Invokes a list action. If no parameter is provided, lists all zones. If zone name is the only - * parameter provided, lists both DNS records and changes. Otherwise, invokes listing changes or - * zones based on the parameter provided. + * parameter provided, lists both record sets and changes. Otherwise, invokes listing + * changes or zones based on the parameter provided. */ @Override public void run(Dns dns, String... args) { @@ -406,7 +406,7 @@ public void run(Dns dns, String... args) { ProjectInfo.Quota quota = project.quota(); System.out.printf("Project id: %s%nQuota:%n", dns.options().projectId()); System.out.printf("\tZones: %d%n", quota.zones()); - System.out.printf("\tDNS records per zone: %d%n", quota.rrsetsPerZone()); + System.out.printf("\tRecord sets per zone: %d%n", quota.rrsetsPerZone()); System.out.printf("\tRecord sets per DNS record: %d%n", quota.resourceRecordsPerRrset()); System.out.printf("\tAdditions per change: %d%n", quota.rrsetAdditionsPerChange()); diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateDnsRecords.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateRecordSets.java similarity index 83% rename from gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateDnsRecords.java rename to gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateRecordSets.java index 71327ba98a96..74647daf666e 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateDnsRecords.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateRecordSets.java @@ -25,16 +25,16 @@ import com.google.gcloud.dns.ChangeRequest; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsOptions; -import com.google.gcloud.dns.DnsRecord; +import com.google.gcloud.dns.RecordSet; import com.google.gcloud.dns.Zone; import java.util.Iterator; import java.util.concurrent.TimeUnit; /** - * A snippet for Google Cloud DNS showing how to create and update a DNS record. + * A snippet for Google Cloud DNS showing how to create and update a resource record set. */ -public class CreateOrUpdateDnsRecords { +public class CreateOrUpdateRecordSets { public static void main(String... args) { // Create a service object. @@ -47,9 +47,9 @@ public static void main(String... args) { // Get zone from the service Zone zone = dns.getZone(zoneName); - // Prepare a www.. type A record with ttl of 24 hours + // Prepare a www.. type A record set with ttl of 24 hours String ip = "12.13.14.15"; - DnsRecord toCreate = DnsRecord.builder("www." + zone.dnsName(), DnsRecord.Type.A) + RecordSet toCreate = RecordSet.builder("www." + zone.dnsName(), RecordSet.Type.A) .ttl(24, TimeUnit.HOURS) .addRecord(ip) .build(); @@ -59,9 +59,9 @@ public static void main(String... args) { // Verify a www.. type A record does not exist yet. // If it does exist, we will overwrite it with our prepared record. - Iterator recordIterator = zone.listDnsRecords().iterateAll(); - while (recordIterator.hasNext()) { - DnsRecord current = recordIterator.next(); + Iterator recordSetIterator = zone.listRecordSets().iterateAll(); + while (recordSetIterator.hasNext()) { + RecordSet current = recordSetIterator.next(); if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) { changeBuilder.delete(current); } diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java index e841a4cd54ed..27377345b62f 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java @@ -25,7 +25,7 @@ import com.google.gcloud.dns.ChangeRequest; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsOptions; -import com.google.gcloud.dns.DnsRecord; +import com.google.gcloud.dns.RecordSet; import java.util.Iterator; @@ -43,15 +43,15 @@ public static void main(String... args) { // Change this to a zone name that exists within your project and that you want to delete. String zoneName = "my-unique-zone"; - // Get iterator for the existing records which have to be deleted before deleting the zone - Iterator recordIterator = dns.listDnsRecords(zoneName).iterateAll(); + // Get iterator for the existing record sets which have to be deleted before deleting the zone + Iterator recordIterator = dns.listRecordSets(zoneName).iterateAll(); // Make a change for deleting the records ChangeRequest.Builder changeBuilder = ChangeRequest.builder(); while (recordIterator.hasNext()) { - DnsRecord current = recordIterator.next(); + RecordSet current = recordIterator.next(); // SOA and NS records cannot be deleted - if (!DnsRecord.Type.SOA.equals(current.type()) && !DnsRecord.Type.NS.equals(current.type())) { + if (!RecordSet.Type.SOA.equals(current.type()) && !RecordSet.Type.NS.equals(current.type())) { changeBuilder.delete(current); } } diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecords.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java similarity index 84% rename from gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecords.java rename to gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java index 4de262386d53..6d9d09d704a6 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecords.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java @@ -25,7 +25,7 @@ import com.google.gcloud.dns.ChangeRequest; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsOptions; -import com.google.gcloud.dns.DnsRecord; +import com.google.gcloud.dns.RecordSet; import com.google.gcloud.dns.Zone; import com.google.gcloud.dns.ZoneInfo; @@ -35,9 +35,9 @@ /** * A complete snippet for Google Cloud DNS showing how to create and delete a zone. It also shows - * how to create, list and delete DNS records, and how to list changes. + * how to create, list and delete record sets, and how to list changes. */ -public class ManipulateZonesAndRecords { +public class ManipulateZonesAndRecordSets { public static void main(String... args) { Dns dns = DnsOptions.defaultInstance().service(); @@ -60,7 +60,7 @@ public static void main(String... args) { // Prepare a www.someexampledomain.com. type A record with ttl of 24 hours String ip = "12.13.14.15"; - DnsRecord toCreate = DnsRecord.builder("www.someexampledomain.com.", DnsRecord.Type.A) + RecordSet toCreate = RecordSet.builder("www.someexampledomain.com.", RecordSet.Type.A) .ttl(24, TimeUnit.HOURS) .addRecord(ip) .build(); @@ -70,9 +70,9 @@ public static void main(String... args) { // Verify the type A record does not exist yet. // If it does exist, we will overwrite it with our prepared record. - Iterator recordIterator = zone.listDnsRecords().iterateAll(); - while (recordIterator.hasNext()) { - DnsRecord current = recordIterator.next(); + Iterator recordSetIterator = zone.listRecordSets().iterateAll(); + while (recordSetIterator.hasNext()) { + RecordSet current = recordSetIterator.next(); if (toCreate.name().equals(current.name()) && toCreate.type().equals(current.type())) { changeBuilder.delete(current); } @@ -100,11 +100,11 @@ public static void main(String... args) { counter++; } - // List the DNS records in a particular zone - recordIterator = zone.listDnsRecords().iterateAll(); - System.out.println(String.format("DNS records inside %s:", zone.name())); - while (recordIterator.hasNext()) { - System.out.println(recordIterator.next()); + // List the record sets in a particular zone + recordSetIterator = zone.listRecordSets().iterateAll(); + System.out.println(String.format("Record sets inside %s:", zone.name())); + while (recordSetIterator.hasNext()) { + System.out.println(recordSetIterator.next()); } // List the change requests applied to a particular zone @@ -114,12 +114,12 @@ public static void main(String... args) { System.out.println(changeIterator.next()); } - // Make a change for deleting the records + // Make a change for deleting the record sets changeBuilder = ChangeRequest.builder(); - while (recordIterator.hasNext()) { - DnsRecord current = recordIterator.next(); + while (recordSetIterator.hasNext()) { + RecordSet current = recordSetIterator.next(); // SOA and NS records cannot be deleted - if (!DnsRecord.Type.SOA.equals(current.type()) && !DnsRecord.Type.NS.equals(current.type())) { + if (!RecordSet.Type.SOA.equals(current.type()) && !RecordSet.Type.NS.equals(current.type())) { changeBuilder.delete(current); } } From 01e23100fb12bf855f31b2ab8c4d12e43de9aab8 Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Thu, 24 Mar 2016 16:46:09 -0700 Subject: [PATCH 168/203] Turned ChangeRequest into a functional object. --- .../com/google/gcloud/dns/ChangeRequest.java | 265 ++++--------- .../google/gcloud/dns/ChangeRequestInfo.java | 347 ++++++++++++++++++ .../main/java/com/google/gcloud/dns/Dns.java | 4 +- .../java/com/google/gcloud/dns/DnsImpl.java | 11 +- .../main/java/com/google/gcloud/dns/Zone.java | 2 +- .../gcloud/dns/ChangeRequestInfoTest.java | 218 +++++++++++ .../google/gcloud/dns/ChangeRequestTest.java | 269 +++++--------- .../com/google/gcloud/dns/DnsImplTest.java | 4 +- .../google/gcloud/dns/SerializationTest.java | 14 +- .../java/com/google/gcloud/dns/ZoneTest.java | 44 ++- .../com/google/gcloud/dns/it/ITDnsTest.java | 13 +- 11 files changed, 791 insertions(+), 400 deletions(-) create mode 100644 gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java create mode 100644 gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java index 757d844cc3da..ad1c65f7cb0f 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java @@ -16,19 +16,11 @@ package com.google.gcloud.dns; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.api.services.dns.model.Change; import com.google.common.base.Function; -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -import org.joda.time.DateTime; -import org.joda.time.format.ISODateTimeFormat; -import java.io.Serializable; -import java.util.LinkedList; +import java.io.IOException; +import java.io.ObjectInputStream; import java.util.List; import java.util.Objects; @@ -38,21 +30,12 @@ * * @see Google Cloud DNS documentation */ -public class ChangeRequest implements Serializable { +public class ChangeRequest extends ChangeRequestInfo { - static final Function FROM_PB_FUNCTION = - new Function() { - @Override - public ChangeRequest apply(com.google.api.services.dns.model.Change pb) { - return ChangeRequest.fromPb(pb); - } - }; private static final long serialVersionUID = -9027378042756366333L; - private final List additions; - private final List deletions; - private final String id; - private final Long startTimeMillis; - private final Status status; + private final DnsOptions options; + private final String zoneName; + private transient Dns dns; /** * This enumerates the possible states of a {@code ChangeRequest}. @@ -68,250 +51,152 @@ public enum Status { /** * A builder for {@code ChangeRequest}s. */ - public static class Builder { + public static class Builder extends ChangeRequestInfo.Builder { - private List additions = new LinkedList<>(); - private List deletions = new LinkedList<>(); - private String id; - private Long startTimeMillis; - private Status status; + private final Dns dns; + private final String zoneName; + private final ChangeRequestInfo.BuilderImpl infoBuilder; private Builder(ChangeRequest cr) { - this.additions = Lists.newLinkedList(cr.additions()); - this.deletions = Lists.newLinkedList(cr.deletions()); - this.id = cr.id(); - this.startTimeMillis = cr.startTimeMillis(); - this.status = cr.status(); + this.dns = cr.dns; + this.zoneName = cr.zoneName; + this.infoBuilder = new ChangeRequestInfo.BuilderImpl(cr); } - private Builder() { - } - - /** - * Sets a collection of {@link RecordSet}s which are to be added to the zone upon executing this - * {@code ChangeRequest}. - */ + @Override public Builder additions(List additions) { - this.additions = Lists.newLinkedList(checkNotNull(additions)); + infoBuilder.additions(additions); return this; } - /** - * Sets a collection of {@link RecordSet}s which are to be deleted from the zone upon executing - * this {@code ChangeRequest}. - */ + @Override public Builder deletions(List deletions) { - this.deletions = Lists.newLinkedList(checkNotNull(deletions)); + infoBuilder.deletions(deletions); return this; } - /** - * Adds a {@link RecordSet} to be added to the zone upon executing this {@code - * ChangeRequest}. - */ + @Override public Builder add(RecordSet recordSet) { - this.additions.add(checkNotNull(recordSet)); + infoBuilder.add(recordSet); return this; } - /** - * Adds a {@link RecordSet} to be deleted to the zone upon executing this - * {@code ChangeRequest}. - */ + @Override public Builder delete(RecordSet recordSet) { - this.deletions.add(checkNotNull(recordSet)); + infoBuilder.delete(recordSet); return this; } - /** - * Clears the collection of {@link RecordSet}s which are to be added to the zone upon executing - * this {@code ChangeRequest}. - */ + @Override public Builder clearAdditions() { - this.additions.clear(); + infoBuilder.clearAdditions(); return this; } - /** - * Clears the collection of {@link RecordSet}s which are to be deleted from the zone upon - * executing this {@code ChangeRequest}. - */ + @Override public Builder clearDeletions() { - this.deletions.clear(); + infoBuilder.clearDeletions(); return this; } - /** - * Removes a single {@link RecordSet} from the collection of records to be - * added to the zone upon executing this {@code ChangeRequest}. - */ + @Override public Builder removeAddition(RecordSet recordSet) { - this.additions.remove(recordSet); + infoBuilder.removeAddition(recordSet); return this; } - /** - * Removes a single {@link RecordSet} from the collection of records to be - * deleted from the zone upon executing this {@code ChangeRequest}. - */ + @Override public Builder removeDeletion(RecordSet recordSet) { - this.deletions.remove(recordSet); + infoBuilder.removeDeletion(recordSet); return this; } - /** - * Associates a server-assigned id to this {@code ChangeRequest}. - */ + @Override Builder id(String id) { - this.id = checkNotNull(id); + infoBuilder.id(id); return this; } - /** - * Sets the time when this {@code ChangeRequest} was started by a server. - */ + @Override Builder startTimeMillis(long startTimeMillis) { - this.startTimeMillis = startTimeMillis; + infoBuilder.startTimeMillis(startTimeMillis); return this; } - /** - * Sets the current status of this {@code ChangeRequest}. - */ + @Override Builder status(Status status) { - this.status = checkNotNull(status); + infoBuilder.status(status); return this; } - /** - * Creates a {@code ChangeRequest} instance populated by the values associated with this - * builder. - */ + @Override public ChangeRequest build() { - return new ChangeRequest(this); + return new ChangeRequest(dns, zoneName, infoBuilder); } } - private ChangeRequest(Builder builder) { - this.additions = ImmutableList.copyOf(builder.additions); - this.deletions = ImmutableList.copyOf(builder.deletions); - this.id = builder.id; - this.startTimeMillis = builder.startTimeMillis; - this.status = builder.status; - } - - /** - * Returns an empty builder for the {@code ChangeRequest} class. - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Creates a builder populated with values of this {@code ChangeRequest}. - */ - public Builder toBuilder() { - return new Builder(this); - } - - /** - * Returns the list of {@link RecordSet}s to be added to the zone upon submitting this {@code - * ChangeRequest}. - */ - public List additions() { - return additions; + ChangeRequest(Dns dns, String zoneName, ChangeRequest.BuilderImpl infoBuilder) { + super(infoBuilder); + this.zoneName = zoneName; + this.dns = dns; + this.options = dns.options(); } - /** - * Returns the list of {@link RecordSet}s to be deleted from the zone upon submitting this {@code - * ChangeRequest}. - */ - public List deletions() { - return deletions; + static Function fromPbFunction(final Dns dns, final String zoneName) { + return new Function() { + @Override + public ChangeRequest apply(com.google.api.services.dns.model.Change pb) { + return ChangeRequest.fromPb(dns, zoneName, pb); + } + }; } /** - * Returns the id assigned to this {@code ChangeRequest} by the server. + * Returns the name of the {@link Zone} associated with this change request. */ - public String id() { - return id; + public String zoneName() { + return this.zoneName; } /** - * Returns the time when this {@code ChangeRequest} was started by the server. + * Returns the {@link Dns} service object associated with this change request. */ - public Long startTimeMillis() { - return startTimeMillis; + public Dns dns() { + return dns; } /** - * Returns the status of this {@code ChangeRequest}. + * Applies this change request to a zone that it is associated with. */ - public Status status() { - return status; + public ChangeRequest applyTo(Dns.ChangeRequestOption... options) { + return dns.applyChangeRequest(zoneName, this, options); } - com.google.api.services.dns.model.Change toPb() { - com.google.api.services.dns.model.Change pb = - new com.google.api.services.dns.model.Change(); - // set id - if (id() != null) { - pb.setId(id()); - } - // set timestamp - if (startTimeMillis() != null) { - pb.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC().print(startTimeMillis())); - } - // set status - if (status() != null) { - pb.setStatus(status().name().toLowerCase()); - } - // set a list of additions - pb.setAdditions(Lists.transform(additions(), RecordSet.TO_PB_FUNCTION)); - // set a list of deletions - pb.setDeletions(Lists.transform(deletions(), RecordSet.TO_PB_FUNCTION)); - return pb; - } - - static ChangeRequest fromPb(com.google.api.services.dns.model.Change pb) { - Builder builder = builder(); - if (pb.getId() != null) { - builder.id(pb.getId()); - } - if (pb.getStartTime() != null) { - builder.startTimeMillis(DateTime.parse(pb.getStartTime()).getMillis()); - } - if (pb.getStatus() != null) { - // we are assuming that status indicated in pb is a lower case version of the enum name - builder.status(ChangeRequest.Status.valueOf(pb.getStatus().toUpperCase())); - } - if (pb.getDeletions() != null) { - builder.deletions(Lists.transform(pb.getDeletions(), RecordSet.FROM_PB_FUNCTION)); - } - if (pb.getAdditions() != null) { - builder.additions(Lists.transform(pb.getAdditions(), RecordSet.FROM_PB_FUNCTION)); - } - return builder.build(); + @Override + public Builder toBuilder() { + return new Builder(this); } @Override - public boolean equals(Object other) { - return (other instanceof ChangeRequest) && toPb().equals(((ChangeRequest) other).toPb()); + public boolean equals(Object obj) { + return obj instanceof ChangeRequest && Objects.equals(toPb(), ((ChangeRequest) obj).toPb()) + && Objects.equals(options, ((ChangeRequest) obj).options) + && Objects.equals(zoneName, ((ChangeRequest) obj).zoneName); } @Override public int hashCode() { - return Objects.hash(additions, deletions, id, startTimeMillis, status); + return Objects.hash(super.hashCode(), options, zoneName); } - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("additions", additions) - .add("deletions", deletions) - .add("id", id) - .add("startTimeMillis", startTimeMillis) - .add("status", status) - .toString(); + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + this.dns = options.service(); + } + + static ChangeRequest fromPb(Dns dns, String zoneName, + com.google.api.services.dns.model.Change pb) { + ChangeRequestInfo info = ChangeRequestInfo.fromPb(pb); + return new ChangeRequest(dns, zoneName, new ChangeRequestInfo.BuilderImpl(info)); } } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java new file mode 100644 index 000000000000..25b915521b13 --- /dev/null +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java @@ -0,0 +1,347 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.services.dns.model.Change; +import com.google.common.base.Function; +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; + +import org.joda.time.DateTime; +import org.joda.time.format.ISODateTimeFormat; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; + +/** + * A class representing an atomic update to a collection of {@link RecordSet}s within a {@code + * Zone}. + * + * @see Google Cloud DNS documentation + */ +public class ChangeRequestInfo implements Serializable { + + static final Function FROM_PB_FUNCTION = + new Function() { + @Override + public ChangeRequestInfo apply(Change pb) { + return ChangeRequestInfo.fromPb(pb); + } + }; + private static final long serialVersionUID = -9027378042756366333L; + private final List additions; + private final List deletions; + private final String id; + private final Long startTimeMillis; + private final ChangeRequest.Status status; + + /** + * A builder for {@code ChangeRequestInfo}. + */ + public abstract static class Builder { + + /** + * Sets a collection of {@link RecordSet}s which are to be added to the zone upon executing this + * {@code ChangeRequestInfo}. + */ + public abstract Builder additions(List additions); + + /** + * Sets a collection of {@link RecordSet}s which are to be deleted from the zone upon executing + * this {@code ChangeRequestInfo}. + */ + public abstract Builder deletions(List deletions); + + /** + * Adds a {@link RecordSet} to be added to the zone upon executing this {@code + * ChangeRequestInfo}. + */ + public abstract Builder add(RecordSet recordSet); + + /** + * Adds a {@link RecordSet} to be deleted to the zone upon executing this + * {@code ChangeRequestInfo}. + */ + public abstract Builder delete(RecordSet recordSet); + + /** + * Clears the collection of {@link RecordSet}s which are to be added to the zone upon executing + * this {@code ChangeRequestInfo}. + */ + public abstract Builder clearAdditions(); + + /** + * Clears the collection of {@link RecordSet}s which are to be deleted from the zone upon + * executing this {@code ChangeRequestInfo}. + */ + public abstract Builder clearDeletions(); + + /** + * Removes a single {@link RecordSet} from the collection of records to be + * added to the zone upon executing this {@code ChangeRequestInfo}. + */ + public abstract Builder removeAddition(RecordSet recordSet); + + /** + * Removes a single {@link RecordSet} from the collection of records to be + * deleted from the zone upon executing this {@code ChangeRequestInfo}. + */ + public abstract Builder removeDeletion(RecordSet recordSet); + + /** + * Associates a server-assigned id to this {@code ChangeRequestInfo}. + */ + abstract Builder id(String id); + + /** + * Sets the time when this change request was started by a server. + */ + abstract Builder startTimeMillis(long startTimeMillis); + + /** + * Sets the current status of this {@code ChangeRequest}. + */ + abstract Builder status(ChangeRequest.Status status); + + /** + * Creates a {@code ChangeRequestInfo} instance populated by the values associated with this + * builder. + */ + public abstract ChangeRequestInfo build(); + } + + static class BuilderImpl extends Builder { + private List additions; + private List deletions; + private String id; + private Long startTimeMillis; + private ChangeRequest.Status status; + + BuilderImpl() { + this.additions = new LinkedList<>(); + this.deletions = new LinkedList<>(); + } + + BuilderImpl(ChangeRequestInfo info) { + this.additions = Lists.newLinkedList(info.additions()); + this.deletions = Lists.newLinkedList(info.deletions()); + this.id = info.id(); + this.startTimeMillis = info.startTimeMillis; + this.status = info.status; + } + + @Override + public Builder additions(List additions) { + this.additions = Lists.newLinkedList(checkNotNull(additions)); + return this; + } + + @Override + public Builder deletions(List deletions) { + this.deletions = Lists.newLinkedList(checkNotNull(deletions)); + return this; + } + + @Override + public Builder add(RecordSet recordSet) { + this.additions.add(checkNotNull(recordSet)); + return this; + } + + @Override + public Builder delete(RecordSet recordSet) { + this.deletions.add(checkNotNull(recordSet)); + return this; + } + + @Override + public Builder clearAdditions() { + this.additions.clear(); + return this; + } + + @Override + public Builder clearDeletions() { + this.deletions.clear(); + return this; + } + + @Override + public Builder removeAddition(RecordSet recordSet) { + this.additions.remove(recordSet); + return this; + } + + @Override + public Builder removeDeletion(RecordSet recordSet) { + this.deletions.remove(recordSet); + return this; + } + + @Override + public ChangeRequestInfo build() { + return new ChangeRequestInfo(this); + } + + @Override + Builder id(String id) { + this.id = checkNotNull(id); + return this; + } + + @Override + Builder startTimeMillis(long startTimeMillis) { + this.startTimeMillis = startTimeMillis; + return this; + } + + @Override + Builder status(ChangeRequest.Status status) { + this.status = checkNotNull(status); + return this; + } + } + + ChangeRequestInfo(BuilderImpl builder) { + this.additions = ImmutableList.copyOf(builder.additions); + this.deletions = ImmutableList.copyOf(builder.deletions); + this.id = builder.id; + this.startTimeMillis = builder.startTimeMillis; + this.status = builder.status; + } + + /** + * Returns an empty builder for the {@code ChangeRequestInfo} class. + */ + public static Builder builder() { + return new BuilderImpl(); + } + + /** + * Creates a builder populated with values of this {@code ChangeRequestInfo}. + */ + public Builder toBuilder() { + return new BuilderImpl(this); + } + + /** + * Returns the list of {@link RecordSet}s to be added to the zone upon submitting this change + * request. + */ + public List additions() { + return additions; + } + + /** + * Returns the list of {@link RecordSet}s to be deleted from the zone upon submitting this change + * request. + */ + public List deletions() { + return deletions; + } + + /** + * Returns the id assigned to this {@code ChangeRequest} by the server. + */ + public String id() { + return id; + } + + /** + * Returns the time when this {@code ChangeRequest} was started by the server. + */ + public Long startTimeMillis() { + return startTimeMillis; + } + + /** + * Returns the status of this {@code ChangeRequest}. + */ + public ChangeRequest.Status status() { + return status; + } + + com.google.api.services.dns.model.Change toPb() { + com.google.api.services.dns.model.Change pb = + new com.google.api.services.dns.model.Change(); + // set id + if (id() != null) { + pb.setId(id()); + } + // set timestamp + if (startTimeMillis() != null) { + pb.setStartTime(ISODateTimeFormat.dateTime().withZoneUTC().print(startTimeMillis())); + } + // set status + if (status() != null) { + pb.setStatus(status().name().toLowerCase()); + } + // set a list of additions + pb.setAdditions(Lists.transform(additions(), RecordSet.TO_PB_FUNCTION)); + // set a list of deletions + pb.setDeletions(Lists.transform(deletions(), RecordSet.TO_PB_FUNCTION)); + return pb; + } + + static ChangeRequestInfo fromPb(com.google.api.services.dns.model.Change pb) { + Builder builder = builder(); + if (pb.getId() != null) { + builder.id(pb.getId()); + } + if (pb.getStartTime() != null) { + builder.startTimeMillis(DateTime.parse(pb.getStartTime()).getMillis()); + } + if (pb.getStatus() != null) { + // we are assuming that status indicated in pb is a lower case version of the enum name + builder.status(ChangeRequest.Status.valueOf(pb.getStatus().toUpperCase())); + } + if (pb.getDeletions() != null) { + builder.deletions(Lists.transform(pb.getDeletions(), RecordSet.FROM_PB_FUNCTION)); + } + if (pb.getAdditions() != null) { + builder.additions(Lists.transform(pb.getAdditions(), RecordSet.FROM_PB_FUNCTION)); + } + return builder.build(); + } + + @Override + public boolean equals(Object other) { + return (other instanceof ChangeRequestInfo) + && toPb().equals(((ChangeRequestInfo) other).toPb()); + } + + @Override + public int hashCode() { + return Objects.hash(additions, deletions, id, startTimeMillis, status); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("additions", additions) + .add("deletions", deletions) + .add("id", id) + .add("startTimeMillis", startTimeMillis) + .add("status", status) + .toString(); + } +} diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java index f8614a8d6169..f2b42f30a9f6 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java @@ -138,7 +138,7 @@ static String selector(RecordSetField... fields) { * The fields of a change request. * *

        These values can be used to specify the fields to include in a partial response when calling - * {@link Dns#applyChangeRequest(String, ChangeRequest, ChangeRequestOption...)} The ID is always + * {@link Dns#applyChangeRequest(String, ChangeRequestInfo, ChangeRequestOption...)} The ID is always * returned even if not selected. */ enum ChangeRequestField { @@ -508,7 +508,7 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { * @throws DnsException upon failure if zone is not found * @see Cloud DNS Changes: create */ - ChangeRequest applyChangeRequest(String zoneName, ChangeRequest changeRequest, + ChangeRequest applyChangeRequest(String zoneName, ChangeRequestInfo changeRequest, ChangeRequestOption... options); /** diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java index 2fbf4e8b5a79..4e2bd1b207d5 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java @@ -169,7 +169,8 @@ public DnsRpc.ListResult call() { // transform that list into change request objects Iterable changes = result.results() == null ? ImmutableList.of() - : Iterables.transform(result.results(), ChangeRequest.FROM_PB_FUNCTION); + : Iterables.transform(result.results(), + ChangeRequest.fromPbFunction(serviceOptions.service(), zoneName)); return new PageImpl<>(new ChangeRequestPageFetcher(zoneName, serviceOptions, cursor, optionsMap), cursor, changes); } catch (RetryHelperException e) { @@ -272,8 +273,8 @@ public com.google.api.services.dns.model.Project call() { } @Override - public ChangeRequest applyChangeRequest(final String zoneName, final ChangeRequest changeRequest, - Dns.ChangeRequestOption... options) { + public ChangeRequest applyChangeRequest(final String zoneName, + final ChangeRequestInfo changeRequest, ChangeRequestOption... options) { final Map optionsMap = optionMap(options); try { com.google.api.services.dns.model.Change answer = @@ -284,7 +285,7 @@ public com.google.api.services.dns.model.Change call() { return dnsRpc.applyChangeRequest(zoneName, changeRequest.toPb(), optionsMap); } }, options().retryParams(), EXCEPTION_HANDLER); - return answer == null ? null : fromPb(answer); // should never be null + return answer == null ? null : fromPb(this, zoneName, answer); // should never be null } catch (RetryHelper.RetryHelperException ex) { throw DnsException.translateAndThrow(ex); } @@ -303,7 +304,7 @@ public com.google.api.services.dns.model.Change call() { return dnsRpc.getChangeRequest(zoneName, changeRequestId, optionsMap); } }, options().retryParams(), EXCEPTION_HANDLER); - return answer == null ? null : fromPb(answer); + return answer == null ? null : ChangeRequest.fromPb(this, zoneName, answer); } catch (RetryHelper.RetryHelperException ex) { throw DnsException.translateAndThrow(ex); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index aed99dbd0001..88b9e7273e9c 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -153,7 +153,7 @@ public Page listRecordSets(Dns.RecordSetListOption... options) { * @return ChangeRequest with server-assigned ID * @throws DnsException upon failure or if the zone is not found */ - public ChangeRequest applyChangeRequest(ChangeRequest changeRequest, + public ChangeRequest applyChangeRequest(ChangeRequestInfo changeRequest, Dns.ChangeRequestOption... options) { checkNotNull(changeRequest); return dns.applyChangeRequest(name(), changeRequest, options); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java new file mode 100644 index 000000000000..55f2af0824ec --- /dev/null +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestInfoTest.java @@ -0,0 +1,218 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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.gcloud.dns; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.common.collect.ImmutableList; + +import org.junit.Test; + +import java.util.List; + +public class ChangeRequestInfoTest { + + private static final String ID = "cr-id-1"; + private static final Long START_TIME_MILLIS = 12334567890L; + private static final ChangeRequest.Status STATUS = ChangeRequest.Status.PENDING; + private static final String NAME1 = "dns1"; + private static final RecordSet.Type TYPE1 = RecordSet.Type.A; + private static final String NAME2 = "dns2"; + private static final RecordSet.Type TYPE2 = RecordSet.Type.AAAA; + private static final String NAME3 = "dns3"; + private static final RecordSet.Type TYPE3 = RecordSet.Type.MX; + private static final RecordSet RECORD1 = RecordSet.builder(NAME1, TYPE1).build(); + private static final RecordSet RECORD2 = RecordSet.builder(NAME2, TYPE2).build(); + private static final RecordSet RECORD3 = RecordSet.builder(NAME3, TYPE3).build(); + private static final List ADDITIONS = ImmutableList.of(RECORD1, RECORD2); + private static final List DELETIONS = ImmutableList.of(RECORD3); + private static final ChangeRequestInfo CHANGE = ChangeRequest.builder() + .add(RECORD1) + .add(RECORD2) + .delete(RECORD3) + .startTimeMillis(START_TIME_MILLIS) + .status(STATUS) + .id(ID) + .build(); + + @Test + public void testEmptyBuilder() { + ChangeRequestInfo cr = ChangeRequest.builder().build(); + assertNotNull(cr.deletions()); + assertTrue(cr.deletions().isEmpty()); + assertNotNull(cr.additions()); + assertTrue(cr.additions().isEmpty()); + } + + @Test + public void testBuilder() { + assertEquals(ID, CHANGE.id()); + assertEquals(STATUS, CHANGE.status()); + assertEquals(START_TIME_MILLIS, CHANGE.startTimeMillis()); + assertEquals(ADDITIONS, CHANGE.additions()); + assertEquals(DELETIONS, CHANGE.deletions()); + List recordList = ImmutableList.of(RECORD1); + ChangeRequestInfo another = CHANGE.toBuilder().additions(recordList).build(); + assertEquals(recordList, another.additions()); + assertEquals(CHANGE.deletions(), another.deletions()); + another = CHANGE.toBuilder().deletions(recordList).build(); + assertEquals(recordList, another.deletions()); + assertEquals(CHANGE.additions(), another.additions()); + } + + @Test + public void testEqualsAndNotEquals() { + ChangeRequestInfo clone = CHANGE.toBuilder().build(); + assertEquals(CHANGE, clone); + clone = ChangeRequest.fromPb(CHANGE.toPb()); + assertEquals(CHANGE, clone); + clone = CHANGE.toBuilder().id("some-other-id").build(); + assertNotEquals(CHANGE, clone); + clone = CHANGE.toBuilder().startTimeMillis(CHANGE.startTimeMillis() + 1).build(); + assertNotEquals(CHANGE, clone); + clone = CHANGE.toBuilder().add(RECORD3).build(); + assertNotEquals(CHANGE, clone); + clone = CHANGE.toBuilder().delete(RECORD1).build(); + assertNotEquals(CHANGE, clone); + ChangeRequestInfo empty = ChangeRequest.builder().build(); + assertNotEquals(CHANGE, empty); + assertEquals(empty, ChangeRequest.builder().build()); + } + + @Test + public void testSameHashCodeOnEquals() { + ChangeRequestInfo clone = CHANGE.toBuilder().build(); + assertEquals(CHANGE, clone); + assertEquals(CHANGE.hashCode(), clone.hashCode()); + ChangeRequestInfo empty = ChangeRequest.builder().build(); + assertEquals(empty.hashCode(), ChangeRequest.builder().build().hashCode()); + } + + @Test + public void testToAndFromPb() { + assertEquals(CHANGE, ChangeRequest.fromPb(CHANGE.toPb())); + ChangeRequestInfo partial = ChangeRequest.builder().build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().id(ID).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().add(RECORD1).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().delete(RECORD1).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().additions(ADDITIONS).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().deletions(DELETIONS).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().startTimeMillis(START_TIME_MILLIS).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + partial = ChangeRequest.builder().status(STATUS).build(); + assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); + } + + @Test + public void testToBuilder() { + assertEquals(CHANGE, CHANGE.toBuilder().build()); + ChangeRequestInfo partial = ChangeRequest.builder().build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().id(ID).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().add(RECORD1).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().delete(RECORD1).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().additions(ADDITIONS).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().deletions(DELETIONS).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().startTimeMillis(START_TIME_MILLIS).build(); + assertEquals(partial, partial.toBuilder().build()); + partial = ChangeRequest.builder().status(STATUS).build(); + assertEquals(partial, partial.toBuilder().build()); + } + + @Test + public void testClearAdditions() { + ChangeRequestInfo clone = CHANGE.toBuilder().clearAdditions().build(); + assertTrue(clone.additions().isEmpty()); + assertFalse(clone.deletions().isEmpty()); + } + + @Test + public void testAddAddition() { + try { + CHANGE.toBuilder().add(null); + fail("Should not be able to add null RecordSet."); + } catch (NullPointerException e) { + // expected + } + ChangeRequestInfo clone = CHANGE.toBuilder().add(RECORD1).build(); + assertEquals(CHANGE.additions().size() + 1, clone.additions().size()); + } + + @Test + public void testAddDeletion() { + try { + CHANGE.toBuilder().delete(null); + fail("Should not be able to delete null RecordSet."); + } catch (NullPointerException e) { + // expected + } + ChangeRequestInfo clone = CHANGE.toBuilder().delete(RECORD1).build(); + assertEquals(CHANGE.deletions().size() + 1, clone.deletions().size()); + } + + @Test + public void testClearDeletions() { + ChangeRequestInfo clone = CHANGE.toBuilder().clearDeletions().build(); + assertTrue(clone.deletions().isEmpty()); + assertFalse(clone.additions().isEmpty()); + } + + @Test + public void testRemoveAddition() { + ChangeRequestInfo clone = CHANGE.toBuilder().removeAddition(RECORD1).build(); + assertTrue(clone.additions().contains(RECORD2)); + assertFalse(clone.additions().contains(RECORD1)); + assertTrue(clone.deletions().contains(RECORD3)); + clone = CHANGE.toBuilder().removeAddition(RECORD2).removeAddition(RECORD1).build(); + assertFalse(clone.additions().contains(RECORD2)); + assertFalse(clone.additions().contains(RECORD1)); + assertTrue(clone.additions().isEmpty()); + assertTrue(clone.deletions().contains(RECORD3)); + } + + @Test + public void testRemoveDeletion() { + ChangeRequestInfo clone = CHANGE.toBuilder().removeDeletion(RECORD3).build(); + assertTrue(clone.deletions().isEmpty()); + } + + @Test + public void testDateParsing() { + String startTime = "2016-01-26T18:33:43.512Z"; // obtained from service + com.google.api.services.dns.model.Change change = CHANGE.toPb().setStartTime(startTime); + ChangeRequestInfo converted = ChangeRequest.fromPb(change); + assertNotNull(converted.startTimeMillis()); + assertEquals(change, converted.toPb()); + assertEquals(change.getStartTime(), converted.toPb().getStartTime()); + } +} diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java index fe726acb7c10..8d6cc799cad8 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java @@ -16,203 +16,132 @@ package com.google.gcloud.dns; +import static org.easymock.EasyMock.createStrictMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.reset; +import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; +import org.junit.After; +import org.junit.Before; import org.junit.Test; -import java.util.List; - public class ChangeRequestTest { - private static final String ID = "cr-id-1"; - private static final Long START_TIME_MILLIS = 12334567890L; - private static final ChangeRequest.Status STATUS = ChangeRequest.Status.PENDING; - private static final String NAME1 = "dns1"; - private static final RecordSet.Type TYPE1 = RecordSet.Type.A; - private static final String NAME2 = "dns2"; - private static final RecordSet.Type TYPE2 = RecordSet.Type.AAAA; - private static final String NAME3 = "dns3"; - private static final RecordSet.Type TYPE3 = RecordSet.Type.MX; - private static final RecordSet RECORD1 = RecordSet.builder(NAME1, TYPE1).build(); - private static final RecordSet RECORD2 = RecordSet.builder(NAME2, TYPE2).build(); - private static final RecordSet RECORD3 = RecordSet.builder(NAME3, TYPE3).build(); - private static final List ADDITIONS = ImmutableList.of(RECORD1, RECORD2); - private static final List DELETIONS = ImmutableList.of(RECORD3); - private static final ChangeRequest CHANGE = ChangeRequest.builder() - .add(RECORD1) - .add(RECORD2) - .delete(RECORD3) - .startTimeMillis(START_TIME_MILLIS) - .status(STATUS) - .id(ID) + private static final String ZONE_NAME = "dns-zone-name"; + private static final ChangeRequestInfo CHANGE_REQUEST_INFO = ChangeRequest.builder() + .add(RecordSet.builder("name", RecordSet.Type.A).build()) + .delete(RecordSet.builder("othername", RecordSet.Type.AAAA).build()) .build(); - - @Test - public void testEmptyBuilder() { - ChangeRequest cr = ChangeRequest.builder().build(); - assertNotNull(cr.deletions()); - assertTrue(cr.deletions().isEmpty()); - assertNotNull(cr.additions()); - assertTrue(cr.additions().isEmpty()); - } - - @Test - public void testBuilder() { - assertEquals(ID, CHANGE.id()); - assertEquals(STATUS, CHANGE.status()); - assertEquals(START_TIME_MILLIS, CHANGE.startTimeMillis()); - assertEquals(ADDITIONS, CHANGE.additions()); - assertEquals(DELETIONS, CHANGE.deletions()); - List recordList = ImmutableList.of(RECORD1); - ChangeRequest another = CHANGE.toBuilder().additions(recordList).build(); - assertEquals(recordList, another.additions()); - assertEquals(CHANGE.deletions(), another.deletions()); - another = CHANGE.toBuilder().deletions(recordList).build(); - assertEquals(recordList, another.deletions()); - assertEquals(CHANGE.additions(), another.additions()); - } - - @Test - public void testEqualsAndNotEquals() { - ChangeRequest clone = CHANGE.toBuilder().build(); - assertEquals(CHANGE, clone); - clone = ChangeRequest.fromPb(CHANGE.toPb()); - assertEquals(CHANGE, clone); - clone = CHANGE.toBuilder().id("some-other-id").build(); - assertNotEquals(CHANGE, clone); - clone = CHANGE.toBuilder().startTimeMillis(CHANGE.startTimeMillis() + 1).build(); - assertNotEquals(CHANGE, clone); - clone = CHANGE.toBuilder().add(RECORD3).build(); - assertNotEquals(CHANGE, clone); - clone = CHANGE.toBuilder().delete(RECORD1).build(); - assertNotEquals(CHANGE, clone); - ChangeRequest empty = ChangeRequest.builder().build(); - assertNotEquals(CHANGE, empty); - assertEquals(empty, ChangeRequest.builder().build()); - } - - @Test - public void testSameHashCodeOnEquals() { - ChangeRequest clone = CHANGE.toBuilder().build(); - assertEquals(CHANGE, clone); - assertEquals(CHANGE.hashCode(), clone.hashCode()); - ChangeRequest empty = ChangeRequest.builder().build(); - assertEquals(empty.hashCode(), ChangeRequest.builder().build().hashCode()); - } - - @Test - public void testToAndFromPb() { - assertEquals(CHANGE, ChangeRequest.fromPb(CHANGE.toPb())); - ChangeRequest partial = ChangeRequest.builder().build(); - assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().id(ID).build(); - assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().add(RECORD1).build(); - assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().delete(RECORD1).build(); - assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().additions(ADDITIONS).build(); - assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().deletions(DELETIONS).build(); - assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().startTimeMillis(START_TIME_MILLIS).build(); - assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - partial = ChangeRequest.builder().status(STATUS).build(); - assertEquals(partial, ChangeRequest.fromPb(partial.toPb())); - } - - @Test - public void testToBuilder() { - assertEquals(CHANGE, CHANGE.toBuilder().build()); - ChangeRequest partial = ChangeRequest.builder().build(); - assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().id(ID).build(); - assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().add(RECORD1).build(); - assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().delete(RECORD1).build(); - assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().additions(ADDITIONS).build(); - assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().deletions(DELETIONS).build(); - assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().startTimeMillis(START_TIME_MILLIS).build(); - assertEquals(partial, partial.toBuilder().build()); - partial = ChangeRequest.builder().status(STATUS).build(); - assertEquals(partial, partial.toBuilder().build()); - } - - @Test - public void testClearAdditions() { - ChangeRequest clone = CHANGE.toBuilder().clearAdditions().build(); - assertTrue(clone.additions().isEmpty()); - assertFalse(clone.deletions().isEmpty()); + private static final DnsOptions OPTIONS = createStrictMock(DnsOptions.class); + + private Dns dns; + private ChangeRequest changeRequest; + private ChangeRequest changeRequestPartial; + + @Before + public void setUp() throws Exception { + dns = createStrictMock(Dns.class); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + replay(dns); + changeRequest = new ChangeRequest(dns, ZONE_NAME, new ChangeRequestInfo.BuilderImpl( + CHANGE_REQUEST_INFO.toBuilder() + .startTimeMillis(132L) + .id("12") + .status(ChangeRequest.Status.DONE) + .build())); + changeRequestPartial = new ChangeRequest(dns, ZONE_NAME, + new ChangeRequest.BuilderImpl(CHANGE_REQUEST_INFO)); + reset(dns); } - @Test - public void testAddAddition() { - try { - CHANGE.toBuilder().add(null); - fail("Should not be able to add null RecordSet."); - } catch (NullPointerException e) { - // expected - } - ChangeRequest clone = CHANGE.toBuilder().add(RECORD1).build(); - assertEquals(CHANGE.additions().size() + 1, clone.additions().size()); + @After + public void tearDown() throws Exception { + verify(dns); } @Test - public void testAddDeletion() { - try { - CHANGE.toBuilder().delete(null); - fail("Should not be able to delete null RecordSet."); - } catch (NullPointerException e) { - // expected - } - ChangeRequest clone = CHANGE.toBuilder().delete(RECORD1).build(); - assertEquals(CHANGE.deletions().size() + 1, clone.deletions().size()); + public void testConstructor() { + replay(dns); + assertEquals(CHANGE_REQUEST_INFO.toPb(), changeRequestPartial.toPb()); + assertNotNull(changeRequest.dns()); + assertEquals(ZONE_NAME, changeRequest.zoneName()); + assertNotNull(changeRequestPartial.dns()); + assertEquals(ZONE_NAME, changeRequestPartial.zoneName()); } @Test - public void testClearDeletions() { - ChangeRequest clone = CHANGE.toBuilder().clearDeletions().build(); - assertTrue(clone.deletions().isEmpty()); - assertFalse(clone.additions().isEmpty()); + public void testFromPb() { + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + replay(dns); + assertEquals(ChangeRequest.fromPb(dns, ZONE_NAME, changeRequest.toPb()), changeRequest); + assertEquals(ChangeRequest.fromPb(dns, ZONE_NAME, changeRequestPartial.toPb()), + changeRequestPartial); } @Test - public void testRemoveAddition() { - ChangeRequest clone = CHANGE.toBuilder().removeAddition(RECORD1).build(); - assertTrue(clone.additions().contains(RECORD2)); - assertFalse(clone.additions().contains(RECORD1)); - assertTrue(clone.deletions().contains(RECORD3)); - clone = CHANGE.toBuilder().removeAddition(RECORD2).removeAddition(RECORD1).build(); - assertFalse(clone.additions().contains(RECORD2)); - assertFalse(clone.additions().contains(RECORD1)); - assertTrue(clone.additions().isEmpty()); - assertTrue(clone.deletions().contains(RECORD3)); + public void testEqualsAndToBuilder() { + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + replay(dns); + ChangeRequest compare = changeRequest.toBuilder().build(); + assertEquals(changeRequest, compare); + assertEquals(changeRequest.hashCode(), compare.hashCode()); + compare = changeRequestPartial.toBuilder().build(); + assertEquals(changeRequestPartial, compare); + assertEquals(changeRequestPartial.hashCode(), compare.hashCode()); } @Test - public void testRemoveDeletion() { - ChangeRequest clone = CHANGE.toBuilder().removeDeletion(RECORD3).build(); - assertTrue(clone.deletions().isEmpty()); + public void testBuilder() { + // one for each build() call because it invokes a constructor + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); + replay(dns); + String id = changeRequest.id() + "aaa"; + assertEquals(id, changeRequest.toBuilder().id(id).build().id()); + ChangeRequest modified = + changeRequest.toBuilder().status(ChangeRequest.Status.PENDING).build(); + assertEquals(ChangeRequest.Status.PENDING, modified.status()); + modified = changeRequest.toBuilder().clearDeletions().build(); + assertTrue(modified.deletions().isEmpty()); + modified = changeRequest.toBuilder().clearAdditions().build(); + assertTrue(modified.additions().isEmpty()); + modified = changeRequest.toBuilder().additions(ImmutableList.of()).build(); + assertTrue(modified.additions().isEmpty()); + modified = changeRequest.toBuilder().deletions(ImmutableList.of()).build(); + assertTrue(modified.deletions().isEmpty()); + RecordSet cname = RecordSet.builder("last", RecordSet.Type.CNAME).build(); + modified = changeRequest.toBuilder().add(cname).build(); + assertTrue(modified.additions().contains(cname)); + modified = changeRequest.toBuilder().delete(cname).build(); + assertTrue(modified.deletions().contains(cname)); + modified = changeRequest.toBuilder().startTimeMillis(0L).build(); + assertEquals(new Long(0), modified.startTimeMillis()); } @Test - public void testDateParsing() { - String startTime = "2016-01-26T18:33:43.512Z"; // obtained from service - com.google.api.services.dns.model.Change change = CHANGE.toPb().setStartTime(startTime); - ChangeRequest converted = ChangeRequest.fromPb(change); - assertNotNull(converted.startTimeMillis()); - assertEquals(change, converted.toPb()); - assertEquals(change.getStartTime(), converted.toPb().getStartTime()); + public void testApplyTo() { + expect(dns.applyChangeRequest(ZONE_NAME, changeRequest)).andReturn(changeRequest); + expect(dns.applyChangeRequest(ZONE_NAME, changeRequest, + Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME))) + .andReturn(changeRequest); + replay(dns); + changeRequest.applyTo(); + changeRequest.applyTo(Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); } } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java index ab2dba0a566c..73548e9cbb91 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java @@ -53,10 +53,10 @@ public class DnsImplTest { private static final String PAGE_TOKEN = "some token"; private static final ZoneInfo ZONE_INFO = ZoneInfo.of(ZONE_NAME, DNS_NAME, DESCRIPTION); private static final ProjectInfo PROJECT_INFO = ProjectInfo.builder().build(); - private static final ChangeRequest CHANGE_REQUEST_PARTIAL = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE_REQUEST_PARTIAL = ChangeRequest.builder() .add(DNS_RECORD1) .build(); - private static final ChangeRequest CHANGE_REQUEST_COMPLETE = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE_REQUEST_COMPLETE = ChangeRequest.builder() .add(DNS_RECORD1) .startTimeMillis(123L) .status(ChangeRequest.Status.PENDING) diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java index c06cd096bf1e..4e492eff3526 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java @@ -63,7 +63,10 @@ public class SerializationTest extends BaseSerializationTest { private static final Zone FULL_ZONE = new Zone(DNS, new ZoneInfo.BuilderImpl(FULL_ZONE_INFO)); private static final Zone PARTIAL_ZONE = new Zone(DNS, new ZoneInfo.BuilderImpl(PARTIAL_ZONE_INFO)); - private static final ChangeRequest CHANGE_REQUEST_PARTIAL = ChangeRequest.builder().build(); + private static final ChangeRequestInfo CHANGE_REQUEST_INFO_PARTIAL = + ChangeRequest.builder().build(); + private static final ChangeRequest CHANGE_REQUEST_PARTIAL = new ChangeRequest(DNS, "name", + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_INFO_PARTIAL)); private static final RecordSet RECORD_SET_PARTIAL = RecordSet.builder("www.www.com", RecordSet.Type.AAAA).build(); private static final RecordSet RECORD_SET_COMPLETE = @@ -71,13 +74,15 @@ public class SerializationTest extends BaseSerializationTest { .ttl(12, TimeUnit.HOURS) .addRecord("record") .build(); - private static final ChangeRequest CHANGE_REQUEST_COMPLETE = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE_REQUEST_INFO_COMPLETE = ChangeRequest.builder() .add(RECORD_SET_COMPLETE) .delete(RECORD_SET_PARTIAL) .status(ChangeRequest.Status.PENDING) .id("some id") .startTimeMillis(132L) .build(); + private static final ChangeRequest CHANGE_REQUEST_COMPLETE = new ChangeRequest(DNS, "name", + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_INFO_COMPLETE)); @Override protected Serializable[] serializableObjects() { @@ -91,8 +96,9 @@ protected Serializable[] serializableObjects() { return new Serializable[]{FULL_ZONE_INFO, PARTIAL_ZONE_INFO, ZONE_LIST_OPTION, RECORD_SET_LIST_OPTION, CHANGE_REQUEST_LIST_OPTION, ZONE_OPTION, CHANGE_REQUEST_OPTION, PROJECT_OPTION, PARTIAL_PROJECT_INFO, FULL_PROJECT_INFO, OPTIONS, FULL_ZONE, PARTIAL_ZONE, - OPTIONS, CHANGE_REQUEST_PARTIAL, RECORD_SET_PARTIAL, RECORD_SET_COMPLETE, - CHANGE_REQUEST_COMPLETE, options, otherOptions}; + OPTIONS, CHANGE_REQUEST_INFO_PARTIAL, CHANGE_REQUEST_PARTIAL, RECORD_SET_PARTIAL, + RECORD_SET_COMPLETE, CHANGE_REQUEST_INFO_COMPLETE, CHANGE_REQUEST_COMPLETE, options, + otherOptions}; } @Override diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index bd59f8c140e9..3ed395bf6881 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -60,25 +60,29 @@ public class ZoneTest { Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME); private static final Dns.ChangeRequestListOption CHANGE_REQUEST_LIST_OPTIONS = Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.START_TIME); - private static final ChangeRequest CHANGE_REQUEST = ChangeRequest.builder().id("someid").build(); - private static final ChangeRequest CHANGE_REQUEST_AFTER = CHANGE_REQUEST.toBuilder() - .startTimeMillis(123465L).build(); - private static final ChangeRequest CHANGE_REQUEST_NO_ID = ChangeRequest.builder().build(); + private static final ChangeRequestInfo CHANGE_REQUEST = + ChangeRequest.builder().id("someid").build(); + private static final ChangeRequestInfo CHANGE_REQUEST_NO_ID = + ChangeRequest.builder().build(); private static final DnsException EXCEPTION = createStrictMock(DnsException.class); private static final DnsOptions OPTIONS = createStrictMock(DnsOptions.class); private Dns dns; private Zone zone; private Zone zoneNoId; + private ChangeRequest changeRequestAfter; @Before public void setUp() throws Exception { dns = createStrictMock(Dns.class); expect(dns.options()).andReturn(OPTIONS); expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS); replay(dns); zone = new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)); zoneNoId = new Zone(dns, new ZoneInfo.BuilderImpl(NO_ID_INFO)); + changeRequestAfter = new ChangeRequest(dns, ZONE_NAME, new ChangeRequestInfo.BuilderImpl( + CHANGE_REQUEST.toBuilder().startTimeMillis(123465L).build())); reset(dns); } @@ -208,24 +212,24 @@ public void reloadByNameAndNotFound() { @Test public void applyChangeByNameAndFound() { expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)) - .andReturn(CHANGE_REQUEST_AFTER); + .andReturn(changeRequestAfter); expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)) - .andReturn(CHANGE_REQUEST_AFTER); + .andReturn(changeRequestAfter); // again for options expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(CHANGE_REQUEST_AFTER); + .andReturn(changeRequestAfter); expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(CHANGE_REQUEST_AFTER); + .andReturn(changeRequestAfter); replay(dns); ChangeRequest result = zoneNoId.applyChangeRequest(CHANGE_REQUEST); - assertEquals(CHANGE_REQUEST_AFTER, result); + assertEquals(changeRequestAfter, result); result = zone.applyChangeRequest(CHANGE_REQUEST); - assertEquals(CHANGE_REQUEST_AFTER, result); + assertEquals(changeRequestAfter, result); // check options result = zoneNoId.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); - assertEquals(CHANGE_REQUEST_AFTER, result); + assertEquals(changeRequestAfter, result); result = zone.applyChangeRequest(CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS); - assertEquals(CHANGE_REQUEST_AFTER, result); + assertEquals(changeRequestAfter, result); } @Test @@ -298,24 +302,24 @@ public void applyNullChangeRequest() { @Test public void getChangeAndZoneFoundByName() { expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())) - .andReturn(CHANGE_REQUEST_AFTER); + .andReturn(changeRequestAfter); expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())) - .andReturn(CHANGE_REQUEST_AFTER); + .andReturn(changeRequestAfter); // again for options expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(CHANGE_REQUEST_AFTER); + .andReturn(changeRequestAfter); expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(CHANGE_REQUEST_AFTER); + .andReturn(changeRequestAfter); replay(dns); ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); - assertEquals(CHANGE_REQUEST_AFTER, result); + assertEquals(changeRequestAfter, result); result = zone.getChangeRequest(CHANGE_REQUEST.id()); - assertEquals(CHANGE_REQUEST_AFTER, result); + assertEquals(changeRequestAfter, result); // check options result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); - assertEquals(CHANGE_REQUEST_AFTER, result); + assertEquals(changeRequestAfter, result); result = zone.getChangeRequest(CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS); - assertEquals(CHANGE_REQUEST_AFTER, result); + assertEquals(changeRequestAfter, result); } @Test diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java index 8f7626a5ae0a..dd8e21043181 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/it/ITDnsTest.java @@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableList; import com.google.gcloud.Page; import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.ChangeRequestInfo; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsException; import com.google.gcloud.dns.DnsOptions; @@ -76,11 +77,11 @@ public class ITDnsTest { .records(ImmutableList.of("ed:ed:12:aa:36:3:3:105")) .ttl(25, TimeUnit.SECONDS) .build(); - private static final ChangeRequest CHANGE_ADD_ZONE1 = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE_ADD_ZONE1 = ChangeRequest.builder() .add(A_RECORD_ZONE1) .add(AAAA_RECORD_ZONE1) .build(); - private static final ChangeRequest CHANGE_DELETE_ZONE1 = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE_DELETE_ZONE1 = ChangeRequest.builder() .delete(A_RECORD_ZONE1) .delete(AAAA_RECORD_ZONE1) .build(); @@ -593,7 +594,7 @@ public void testInvalidChangeRequest() { .records(ImmutableList.of("0.255.1.5")) .build(); try { - ChangeRequest validChange = ChangeRequest.builder().add(validA).build(); + ChangeRequestInfo validChange = ChangeRequest.builder().add(validA).build(); zone.applyChangeRequest(validChange); try { zone.applyChangeRequest(validChange); @@ -605,7 +606,7 @@ public void testInvalidChangeRequest() { } // delete with field mismatch RecordSet mismatch = validA.toBuilder().ttl(20, TimeUnit.SECONDS).build(); - ChangeRequest deletion = ChangeRequest.builder().delete(mismatch).build(); + ChangeRequestInfo deletion = ChangeRequest.builder().delete(mismatch).build(); try { zone.applyChangeRequest(deletion); fail("Deleted a record set without a complete match."); @@ -629,7 +630,7 @@ public void testInvalidChangeRequest() { } } deletion = deletion.toBuilder().deletions(deletions).build(); - ChangeRequest addition = ChangeRequest.builder().additions(additions).build(); + ChangeRequestInfo addition = ChangeRequest.builder().additions(additions).build(); try { zone.applyChangeRequest(deletion); fail("Deleted SOA."); @@ -647,7 +648,7 @@ public void testInvalidChangeRequest() { assertEquals(400, ex.code()); } } finally { - ChangeRequest deletion = ChangeRequest.builder().delete(validA).build(); + ChangeRequestInfo deletion = ChangeRequest.builder().delete(validA).build(); ChangeRequest request = zone.applyChangeRequest(deletion); waitForChangeToComplete(zone.name(), request.id()); zone.delete(); From de8bf4bad79ffe422688fd69d12fa388bfb8b44d Mon Sep 17 00:00:00 2001 From: Martin Derka Date: Fri, 25 Mar 2016 09:49:23 -0700 Subject: [PATCH 169/203] Addressed comments. This includes: - Moved Status enum to ChangeRequestInfo. - Switching from ChangeRequest.builer() to ChangeRequestInfo.builder() - Fixing README accordingly - Used times() for mocking instead of repeated expect() - Snippets and documentation work with ChangeRequestInfo. Fixes #788. - Equals uses getClass instead if instanceof. - Removed unnecessary imports. --- README.md | 6 +- gcloud-java-dns/README.md | 26 ++++-- .../com/google/gcloud/dns/ChangeRequest.java | 81 ++++++++--------- .../google/gcloud/dns/ChangeRequestInfo.java | 35 +++++--- .../java/com/google/gcloud/dns/DnsImpl.java | 5 +- .../main/java/com/google/gcloud/dns/Zone.java | 2 +- .../com/google/gcloud/dns/package-info.java | 2 +- .../google/gcloud/dns/ChangeRequestTest.java | 43 ++++----- .../com/google/gcloud/dns/DnsImplTest.java | 32 ++++--- .../google/gcloud/dns/SerializationTest.java | 2 +- .../java/com/google/gcloud/dns/ZoneTest.java | 90 ++++++------------- .../gcloud/examples/dns/DnsExample.java | 11 +-- .../snippets/CreateOrUpdateRecordSets.java | 6 +- .../examples/dns/snippets/DeleteZone.java | 8 +- .../ManipulateZonesAndRecordSets.java | 9 +- 15 files changed, 171 insertions(+), 187 deletions(-) diff --git a/README.md b/README.md index 52229f6d5d34..6061d9dd4c8f 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ Zone zone = dns.create(zoneInfo); 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). ```java -import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.ChangeRequestInfo; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsOptions; import com.google.gcloud.dns.RecordSet; @@ -269,7 +269,7 @@ RecordSet toCreate = RecordSet.builder("www.someexampledomain.com.", RecordSet.T .ttl(24, TimeUnit.HOURS) .addRecord(ip) .build(); -ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate); +ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCreate); // Verify that the record does not exist yet. // If it does exist, we will overwrite it with our prepared record. @@ -282,7 +282,7 @@ while (recordSetIterator.hasNext()) { } } -ChangeRequest changeRequest = changeBuilder.build(); +ChangeRequestInfo changeRequest = changeBuilder.build(); zone.applyChangeRequest(changeRequest); ``` diff --git a/gcloud-java-dns/README.md b/gcloud-java-dns/README.md index a2c3238d1f8f..d2e4c85b3b76 100644 --- a/gcloud-java-dns/README.md +++ b/gcloud-java-dns/README.md @@ -159,7 +159,7 @@ our zone that creates a record set of type A and points URL www.someexampledomai IP address 12.13.14.15. Start by adding ```java -import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.ChangeRequestInfo; import com.google.gcloud.dns.RecordSet; import java.util.concurrent.TimeUnit; @@ -176,7 +176,7 @@ RecordSet toCreate = RecordSet.builder("www." + zone.dnsName(), RecordSet.Type.A .build(); // Make a change -ChangeRequest changeRequest = ChangeRequest.builder().add(toCreate).build(); +ChangeRequestInfo changeRequest = ChangeRequestInfo.builder().add(toCreate).build(); // Build and apply the change request to our zone changeRequest = zone.applyChangeRequest(changeRequest); @@ -198,7 +198,7 @@ and in the code ```java // Make a change -ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate); +ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCreate); // Verify the type A record does not exist yet. // If it does exist, we will overwrite it with our prepared record. @@ -211,7 +211,7 @@ while (recordSetIterator.hasNext()) { } // Build and apply the change request to our zone -ChangeRequest changeRequest = changeBuilder.build(); +ChangeRequestInfo changeRequest = changeBuilder.build(); zone.applyChangeRequest(changeRequest); ``` You can find more information about changes in the [Cloud DNS documentation] (https://cloud.google.com/dns/what-is-cloud-dns#cloud_dns_api_concepts). @@ -220,7 +220,7 @@ When the change request is applied, it is registered with the Cloud DNS service can wait for its completion as follows: ```java -while (ChangeRequest.Status.PENDING.equals(changeRequest.status())) { +while (ChangeRequestInfo.Status.PENDING.equals(changeRequest.status())) { try { Thread.sleep(500L); } catch (InterruptedException e) { @@ -262,9 +262,17 @@ while (recordSetIterator.hasNext()) { } ``` -You can also list the history of change requests that were applied to a zone: +You can also list the history of change requests that were applied to a zone. +First add: ```java +import java.util.ChangeRequest; +``` + +and then: + +```java + // List the change requests applied to a particular zone Iterator changeIterator = zone.listChangeRequests().iterateAll(); System.out.println(String.format("The history of changes in %s:", zone.name())); @@ -280,7 +288,7 @@ First, you need to empty the zone by deleting all its records except for the def ```java // Make a change for deleting the record sets -changeBuilder = ChangeRequest.builder(); +changeBuilder = ChangeRequestInfo.builder(); while (recordIterator.hasNext()) { RecordSet current = recordIterator.next(); // SOA and NS records cannot be deleted @@ -290,14 +298,14 @@ while (recordIterator.hasNext()) { } // Build and apply the change request to our zone if it contains records to delete -ChangeRequest changeRequest = changeBuilder.build(); +ChangeRequestInfo changeRequest = changeBuilder.build(); if (!changeRequest.deletions().isEmpty()) { changeRequest = dns.applyChangeRequest(zoneName, changeRequest); // Wait for change to finish, but save data traffic by transferring only ID and status Dns.ChangeRequestOption option = Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS); - while (ChangeRequest.Status.PENDING.equals(changeRequest.status())) { + while (ChangeRequestInfo.Status.PENDING.equals(changeRequest.status())) { System.out.println("Waiting for change to complete. Going to sleep for 500ms..."); try { Thread.sleep(500); diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java index ad1c65f7cb0f..4b6369976ca6 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequest.java @@ -16,6 +16,8 @@ package com.google.gcloud.dns; +import static com.google.common.base.Preconditions.checkNotNull; + import com.google.api.services.dns.model.Change; import com.google.common.base.Function; @@ -25,41 +27,30 @@ import java.util.Objects; /** - * A class representing an atomic update to a collection of {@link RecordSet}s within a {@code - * Zone}. + * An immutable class representing an atomic update to a collection of {@link RecordSet}s within a + * {@code Zone}. * * @see Google Cloud DNS documentation */ public class ChangeRequest extends ChangeRequestInfo { - private static final long serialVersionUID = -9027378042756366333L; + private static final long serialVersionUID = 5335667200595081449L; private final DnsOptions options; - private final String zoneName; + private final String zone; private transient Dns dns; - /** - * This enumerates the possible states of a {@code ChangeRequest}. - * - * @see Google Cloud DNS - * documentation - */ - public enum Status { - PENDING, - DONE - } - /** * A builder for {@code ChangeRequest}s. */ public static class Builder extends ChangeRequestInfo.Builder { private final Dns dns; - private final String zoneName; + private final String zone; private final ChangeRequestInfo.BuilderImpl infoBuilder; private Builder(ChangeRequest cr) { this.dns = cr.dns; - this.zoneName = cr.zoneName; + this.zone = cr.zone; this.infoBuilder = new ChangeRequestInfo.BuilderImpl(cr); } @@ -131,45 +122,36 @@ Builder status(Status status) { @Override public ChangeRequest build() { - return new ChangeRequest(dns, zoneName, infoBuilder); + return new ChangeRequest(dns, zone, infoBuilder); } } - ChangeRequest(Dns dns, String zoneName, ChangeRequest.BuilderImpl infoBuilder) { + ChangeRequest(Dns dns, String zone, ChangeRequest.BuilderImpl infoBuilder) { super(infoBuilder); - this.zoneName = zoneName; - this.dns = dns; + this.zone = checkNotNull(zone); + this.dns = checkNotNull(dns); this.options = dns.options(); } - static Function fromPbFunction(final Dns dns, final String zoneName) { - return new Function() { - @Override - public ChangeRequest apply(com.google.api.services.dns.model.Change pb) { - return ChangeRequest.fromPb(dns, zoneName, pb); - } - }; - } - /** * Returns the name of the {@link Zone} associated with this change request. */ - public String zoneName() { - return this.zoneName; + public String zone() { + return this.zone; } /** - * Returns the {@link Dns} service object associated with this change request. + * Returns the change request's {@code Dns} object used to issue requests. */ public Dns dns() { return dns; } /** - * Applies this change request to a zone that it is associated with. + * Applies this change request to the associated zone. */ public ChangeRequest applyTo(Dns.ChangeRequestOption... options) { - return dns.applyChangeRequest(zoneName, this, options); + return dns.applyChangeRequest(zone, this, options); } @Override @@ -179,24 +161,37 @@ public Builder toBuilder() { @Override public boolean equals(Object obj) { - return obj instanceof ChangeRequest && Objects.equals(toPb(), ((ChangeRequest) obj).toPb()) - && Objects.equals(options, ((ChangeRequest) obj).options) - && Objects.equals(zoneName, ((ChangeRequest) obj).zoneName); + if (obj == null || !obj.getClass().equals(ChangeRequest.class)) { + return false; + } else { + ChangeRequest other = (ChangeRequest) obj; + return Objects.equals(options, other.options) + && Objects.equals(zone, other.zone) + && Objects.equals(toPb(), other.toPb()); + } } @Override public int hashCode() { - return Objects.hash(super.hashCode(), options, zoneName); + return Objects.hash(super.hashCode(), options, zone); } - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); + private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException { + input.defaultReadObject(); this.dns = options.service(); } - static ChangeRequest fromPb(Dns dns, String zoneName, - com.google.api.services.dns.model.Change pb) { + static ChangeRequest fromPb(Dns dns, String zoneName, Change pb) { ChangeRequestInfo info = ChangeRequestInfo.fromPb(pb); return new ChangeRequest(dns, zoneName, new ChangeRequestInfo.BuilderImpl(info)); } + + static Function fromPbFunction(final Dns dns, final String zoneName) { + return new Function() { + @Override + public ChangeRequest apply(com.google.api.services.dns.model.Change pb) { + return ChangeRequest.fromPb(dns, zoneName, pb); + } + }; + } } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java index 25b915521b13..b63b4f4a0788 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/ChangeRequestInfo.java @@ -52,7 +52,18 @@ public ChangeRequestInfo apply(Change pb) { private final List deletions; private final String id; private final Long startTimeMillis; - private final ChangeRequest.Status status; + private final ChangeRequestInfo.Status status; + + /** + * This enumerates the possible states of a change request. + * + * @see Google Cloud DNS + * documentation + */ + public enum Status { + PENDING, + DONE + } /** * A builder for {@code ChangeRequestInfo}. @@ -110,7 +121,7 @@ public abstract static class Builder { /** * Associates a server-assigned id to this {@code ChangeRequestInfo}. */ - abstract Builder id(String id); + abstract Builder id(String id); /** * Sets the time when this change request was started by a server. @@ -134,7 +145,7 @@ static class BuilderImpl extends Builder { private List deletions; private String id; private Long startTimeMillis; - private ChangeRequest.Status status; + private ChangeRequestInfo.Status status; BuilderImpl() { this.additions = new LinkedList<>(); @@ -215,7 +226,7 @@ Builder startTimeMillis(long startTimeMillis) { } @Override - Builder status(ChangeRequest.Status status) { + Builder status(ChangeRequestInfo.Status status) { this.status = checkNotNull(status); return this; } @@ -274,15 +285,15 @@ public Long startTimeMillis() { } /** - * Returns the status of this {@code ChangeRequest}. + * Returns the status of this {@code ChangeRequest}. If the change request has not been applied + * yet, the status is {@code PENDING}. */ - public ChangeRequest.Status status() { + public ChangeRequestInfo.Status status() { return status; } - com.google.api.services.dns.model.Change toPb() { - com.google.api.services.dns.model.Change pb = - new com.google.api.services.dns.model.Change(); + Change toPb() { + Change pb = new Change(); // set id if (id() != null) { pb.setId(id()); @@ -302,7 +313,7 @@ com.google.api.services.dns.model.Change toPb() { return pb; } - static ChangeRequestInfo fromPb(com.google.api.services.dns.model.Change pb) { + static ChangeRequestInfo fromPb(Change pb) { Builder builder = builder(); if (pb.getId() != null) { builder.id(pb.getId()); @@ -325,8 +336,8 @@ static ChangeRequestInfo fromPb(com.google.api.services.dns.model.Change pb) { @Override public boolean equals(Object other) { - return (other instanceof ChangeRequestInfo) - && toPb().equals(((ChangeRequestInfo) other).toPb()); + return other != null && other.getClass().equals(ChangeRequestInfo.class) + && other instanceof ChangeRequestInfo && toPb().equals(((ChangeRequestInfo) other).toPb()); } @Override diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java index 4e2bd1b207d5..51ab0bd92720 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java @@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.gcloud.RetryHelper.RetryHelperException; import static com.google.gcloud.RetryHelper.runWithRetries; -import static com.google.gcloud.dns.ChangeRequest.fromPb; import com.google.api.services.dns.model.Change; import com.google.api.services.dns.model.ManagedZone; @@ -170,7 +169,7 @@ public DnsRpc.ListResult call() { Iterable changes = result.results() == null ? ImmutableList.of() : Iterables.transform(result.results(), - ChangeRequest.fromPbFunction(serviceOptions.service(), zoneName)); + ChangeRequest.fromPbFunction(serviceOptions.service(), zoneName)); return new PageImpl<>(new ChangeRequestPageFetcher(zoneName, serviceOptions, cursor, optionsMap), cursor, changes); } catch (RetryHelperException e) { @@ -285,7 +284,7 @@ public com.google.api.services.dns.model.Change call() { return dnsRpc.applyChangeRequest(zoneName, changeRequest.toPb(), optionsMap); } }, options().retryParams(), EXCEPTION_HANDLER); - return answer == null ? null : fromPb(this, zoneName, answer); // should never be null + return answer == null ? null : ChangeRequest.fromPb(this, zoneName, answer); // not null } catch (RetryHelper.RetryHelperException ex) { throw DnsException.translateAndThrow(ex); } diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java index 88b9e7273e9c..9930bfdbad67 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java @@ -146,7 +146,7 @@ public Page listRecordSets(Dns.RecordSetListOption... options) { } /** - * Submits {@link ChangeRequest} to the service for it to applied to this zone. The method + * Submits {@link ChangeRequestInfo} to the service for it to applied to this zone. The method * searches for zone by name. * * @param options optional restriction on what fields of {@link ChangeRequest} should be returned diff --git a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java index 69bee930df62..36f41852400c 100644 --- a/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java +++ b/gcloud-java-dns/src/main/java/com/google/gcloud/dns/package-info.java @@ -46,7 +46,7 @@ * .ttl(24, TimeUnit.HOURS) * .addRecord(ip) * .build(); - * ChangeRequest changeRequest = ChangeRequest.builder().add(toCreate).build(); + * ChangeRequestInfo changeRequest = ChangeRequestInfo.builder().add(toCreate).build(); * zone.applyChangeRequest(changeRequest); * }

    5. * diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java index 8d6cc799cad8..bfd1d0f512f4 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ChangeRequestTest.java @@ -23,6 +23,7 @@ import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import com.google.common.collect.ImmutableList; @@ -47,8 +48,7 @@ public class ChangeRequestTest { @Before public void setUp() throws Exception { dns = createStrictMock(Dns.class); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS).times(2); replay(dns); changeRequest = new ChangeRequest(dns, ZONE_NAME, new ChangeRequestInfo.BuilderImpl( CHANGE_REQUEST_INFO.toBuilder() @@ -68,28 +68,28 @@ public void tearDown() throws Exception { @Test public void testConstructor() { + expect(dns.options()).andReturn(OPTIONS); replay(dns); - assertEquals(CHANGE_REQUEST_INFO.toPb(), changeRequestPartial.toPb()); + assertEquals(new ChangeRequest(dns, ZONE_NAME, + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_INFO)), changeRequestPartial); assertNotNull(changeRequest.dns()); - assertEquals(ZONE_NAME, changeRequest.zoneName()); - assertNotNull(changeRequestPartial.dns()); - assertEquals(ZONE_NAME, changeRequestPartial.zoneName()); + assertEquals(ZONE_NAME, changeRequest.zone()); + assertSame(dns, changeRequestPartial.dns()); + assertEquals(ZONE_NAME, changeRequestPartial.zone()); } @Test public void testFromPb() { - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS).times(2); replay(dns); - assertEquals(ChangeRequest.fromPb(dns, ZONE_NAME, changeRequest.toPb()), changeRequest); - assertEquals(ChangeRequest.fromPb(dns, ZONE_NAME, changeRequestPartial.toPb()), - changeRequestPartial); + assertEquals(changeRequest, ChangeRequest.fromPb(dns, ZONE_NAME, changeRequest.toPb())); + assertEquals(changeRequestPartial, + ChangeRequest.fromPb(dns, ZONE_NAME, changeRequestPartial.toPb())); } @Test public void testEqualsAndToBuilder() { - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS).times(2); replay(dns); ChangeRequest compare = changeRequest.toBuilder().build(); assertEquals(changeRequest, compare); @@ -102,15 +102,7 @@ public void testEqualsAndToBuilder() { @Test public void testBuilder() { // one for each build() call because it invokes a constructor - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS).times(9); replay(dns); String id = changeRequest.id() + "aaa"; assertEquals(id, changeRequest.toBuilder().id(id).build().id()); @@ -131,7 +123,7 @@ public void testBuilder() { modified = changeRequest.toBuilder().delete(cname).build(); assertTrue(modified.deletions().contains(cname)); modified = changeRequest.toBuilder().startTimeMillis(0L).build(); - assertEquals(new Long(0), modified.startTimeMillis()); + assertEquals(Long.valueOf(0), modified.startTimeMillis()); } @Test @@ -141,7 +133,8 @@ public void testApplyTo() { Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME))) .andReturn(changeRequest); replay(dns); - changeRequest.applyTo(); - changeRequest.applyTo(Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); + assertSame(changeRequest, changeRequest.applyTo()); + assertSame(changeRequest, + changeRequest.applyTo(Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME))); } } diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java index 73548e9cbb91..94ed4a3da3f7 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/DnsImplTest.java @@ -53,10 +53,10 @@ public class DnsImplTest { private static final String PAGE_TOKEN = "some token"; private static final ZoneInfo ZONE_INFO = ZoneInfo.of(ZONE_NAME, DNS_NAME, DESCRIPTION); private static final ProjectInfo PROJECT_INFO = ProjectInfo.builder().build(); - private static final ChangeRequestInfo CHANGE_REQUEST_PARTIAL = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE_REQUEST_PARTIAL = ChangeRequestInfo.builder() .add(DNS_RECORD1) .build(); - private static final ChangeRequestInfo CHANGE_REQUEST_COMPLETE = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE_REQUEST_COMPLETE = ChangeRequestInfo.builder() .add(DNS_RECORD1) .startTimeMillis(123L) .status(ChangeRequest.Status.PENDING) @@ -221,7 +221,8 @@ public void testGetChangeRequest() { dns = options.service(); // creates DnsImpl ChangeRequest changeRequest = dns.getChangeRequest(ZONE_INFO.name(), CHANGE_REQUEST_COMPLETE.id()); - assertEquals(CHANGE_REQUEST_COMPLETE, changeRequest); + assertEquals(new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)), changeRequest); } @Test @@ -235,7 +236,8 @@ public void testGetChangeRequestWithOptions() { ChangeRequest changeRequest = dns.getChangeRequest(ZONE_INFO.name(), CHANGE_REQUEST_COMPLETE.id(), CHANGE_GET_FIELDS); String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.rpcOption()); - assertEquals(CHANGE_REQUEST_COMPLETE, changeRequest); + assertEquals(new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)), changeRequest); assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); } @@ -248,7 +250,8 @@ public void testApplyChangeRequest() { dns = options.service(); // creates DnsImpl ChangeRequest changeRequest = dns.applyChangeRequest(ZONE_INFO.name(), CHANGE_REQUEST_PARTIAL); - assertEquals(CHANGE_REQUEST_COMPLETE, changeRequest); + assertEquals(new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)), changeRequest); } @Test @@ -262,7 +265,8 @@ public void testApplyChangeRequestWithOptions() { ChangeRequest changeRequest = dns.applyChangeRequest(ZONE_INFO.name(), CHANGE_REQUEST_PARTIAL, CHANGE_GET_FIELDS); String selector = (String) capturedOptions.getValue().get(CHANGE_GET_FIELDS.rpcOption()); - assertEquals(CHANGE_REQUEST_COMPLETE, changeRequest); + assertEquals(new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)), changeRequest); assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector())); assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector())); } @@ -275,8 +279,12 @@ public void testListChangeRequests() { EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl Page changeRequestPage = dns.listChangeRequests(ZONE_INFO.name()); - assertTrue(Lists.newArrayList(changeRequestPage.values()).contains(CHANGE_REQUEST_COMPLETE)); - assertTrue(Lists.newArrayList(changeRequestPage.values()).contains(CHANGE_REQUEST_PARTIAL)); + assertTrue(Lists.newArrayList(changeRequestPage.values()).contains( + new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)))); + assertTrue(Lists.newArrayList(changeRequestPage.values()).contains( + new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_PARTIAL)))); assertEquals(2, Lists.newArrayList(changeRequestPage.values()).size()); } @@ -288,8 +296,12 @@ public void testListChangeRequestsWithOptions() { EasyMock.replay(dnsRpcMock); dns = options.service(); // creates DnsImpl Page changeRequestPage = dns.listChangeRequests(ZONE_NAME, CHANGE_LIST_OPTIONS); - assertTrue(Lists.newArrayList(changeRequestPage.values()).contains(CHANGE_REQUEST_COMPLETE)); - assertTrue(Lists.newArrayList(changeRequestPage.values()).contains(CHANGE_REQUEST_PARTIAL)); + assertTrue(Lists.newArrayList(changeRequestPage.values()).contains( + new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_COMPLETE)))); + assertTrue(Lists.newArrayList(changeRequestPage.values()).contains( + new ChangeRequest(dns, ZONE_INFO.name(), + new ChangeRequestInfo.BuilderImpl(CHANGE_REQUEST_PARTIAL)))); assertEquals(2, Lists.newArrayList(changeRequestPage.values()).size()); Integer size = (Integer) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[0].rpcOption()); assertEquals(MAX_SIZE, size); diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java index 4e492eff3526..ad25b31068dd 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/SerializationTest.java @@ -74,7 +74,7 @@ public class SerializationTest extends BaseSerializationTest { .ttl(12, TimeUnit.HOURS) .addRecord("record") .build(); - private static final ChangeRequestInfo CHANGE_REQUEST_INFO_COMPLETE = ChangeRequest.builder() + private static final ChangeRequestInfo CHANGE_REQUEST_INFO_COMPLETE = ChangeRequestInfo.builder() .add(RECORD_SET_COMPLETE) .delete(RECORD_SET_PARTIAL) .status(ChangeRequest.Status.PENDING) diff --git a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java index 3ed395bf6881..ba4493abfca8 100644 --- a/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java +++ b/gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java @@ -61,9 +61,9 @@ public class ZoneTest { private static final Dns.ChangeRequestListOption CHANGE_REQUEST_LIST_OPTIONS = Dns.ChangeRequestListOption.fields(Dns.ChangeRequestField.START_TIME); private static final ChangeRequestInfo CHANGE_REQUEST = - ChangeRequest.builder().id("someid").build(); + ChangeRequestInfo.builder().id("someid").build(); private static final ChangeRequestInfo CHANGE_REQUEST_NO_ID = - ChangeRequest.builder().build(); + ChangeRequestInfo.builder().build(); private static final DnsException EXCEPTION = createStrictMock(DnsException.class); private static final DnsOptions OPTIONS = createStrictMock(DnsOptions.class); @@ -75,9 +75,7 @@ public class ZoneTest { @Before public void setUp() throws Exception { dns = createStrictMock(Dns.class); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS).times(3); replay(dns); zone = new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO)); zoneNoId = new Zone(dns, new ZoneInfo.BuilderImpl(NO_ID_INFO)); @@ -101,8 +99,7 @@ public void testConstructor() { @Test public void deleteByNameAndFound() { - expect(dns.delete(ZONE_NAME)).andReturn(true); - expect(dns.delete(ZONE_NAME)).andReturn(true); + expect(dns.delete(ZONE_NAME)).andReturn(true).times(2); replay(dns); boolean result = zone.delete(); assertTrue(result); @@ -112,8 +109,7 @@ public void deleteByNameAndFound() { @Test public void deleteByNameAndNotFound() { - expect(dns.delete(ZONE_NAME)).andReturn(false); - expect(dns.delete(ZONE_NAME)).andReturn(false); + expect(dns.delete(ZONE_NAME)).andReturn(false).times(2); replay(dns); boolean result = zoneNoId.delete(); assertFalse(result); @@ -126,11 +122,9 @@ public void listDnsRecordsByNameAndFound() { @SuppressWarnings("unchecked") Page pageMock = createStrictMock(Page.class); replay(pageMock); - expect(dns.listRecordSets(ZONE_NAME)).andReturn(pageMock); - expect(dns.listRecordSets(ZONE_NAME)).andReturn(pageMock); + expect(dns.listRecordSets(ZONE_NAME)).andReturn(pageMock).times(2); // again for options - expect(dns.listRecordSets(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); - expect(dns.listRecordSets(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock); + expect(dns.listRecordSets(ZONE_NAME, DNS_RECORD_OPTIONS)).andReturn(pageMock).times(2); replay(dns); Page result = zone.listRecordSets(); assertSame(pageMock, result); @@ -143,11 +137,9 @@ public void listDnsRecordsByNameAndFound() { @Test public void listDnsRecordsByNameAndNotFound() { - expect(dns.listRecordSets(ZONE_NAME)).andThrow(EXCEPTION); - expect(dns.listRecordSets(ZONE_NAME)).andThrow(EXCEPTION); + expect(dns.listRecordSets(ZONE_NAME)).andThrow(EXCEPTION).times(2); // again for options - expect(dns.listRecordSets(ZONE_NAME, DNS_RECORD_OPTIONS)).andThrow(EXCEPTION); - expect(dns.listRecordSets(ZONE_NAME, DNS_RECORD_OPTIONS)).andThrow(EXCEPTION); + expect(dns.listRecordSets(ZONE_NAME, DNS_RECORD_OPTIONS)).andThrow(EXCEPTION).times(2); replay(dns); try { zoneNoId.listRecordSets(); @@ -177,8 +169,7 @@ public void listDnsRecordsByNameAndNotFound() { @Test public void reloadByNameAndFound() { - expect(dns.getZone(ZONE_NAME)).andReturn(zone); - expect(dns.getZone(ZONE_NAME)).andReturn(zone); + expect(dns.getZone(ZONE_NAME)).andReturn(zone).times(2); // again for options expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zoneNoId); expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(zone); @@ -195,11 +186,9 @@ public void reloadByNameAndFound() { @Test public void reloadByNameAndNotFound() { - expect(dns.getZone(ZONE_NAME)).andReturn(null); - expect(dns.getZone(ZONE_NAME)).andReturn(null); + expect(dns.getZone(ZONE_NAME)).andReturn(null).times(2); // again for options - expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(null); - expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(null); + expect(dns.getZone(ZONE_NAME, ZONE_FIELD_OPTIONS)).andReturn(null).times(2); replay(dns); Zone result = zoneNoId.reload(); assertNull(result); @@ -235,13 +224,10 @@ public void applyChangeByNameAndFound() { @Test public void applyChangeByNameAndNotFound() { // ID is not set - expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)).andThrow(EXCEPTION); - expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)).andThrow(EXCEPTION); + expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST)).andThrow(EXCEPTION).times(2); // again for options expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) - .andThrow(EXCEPTION); - expect(dns.applyChangeRequest(ZONE_NAME, CHANGE_REQUEST, CHANGE_REQUEST_FIELD_OPTIONS)) - .andThrow(EXCEPTION); + .andThrow(EXCEPTION).times(2); replay(dns); try { zoneNoId.applyChangeRequest(CHANGE_REQUEST); @@ -302,14 +288,10 @@ public void applyNullChangeRequest() { @Test public void getChangeAndZoneFoundByName() { expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())) - .andReturn(changeRequestAfter); - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())) - .andReturn(changeRequestAfter); + .andReturn(changeRequestAfter).times(2); // again for options expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(changeRequestAfter); - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(changeRequestAfter); + .andReturn(changeRequestAfter).times(2); replay(dns); ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); assertEquals(changeRequestAfter, result); @@ -324,13 +306,10 @@ public void getChangeAndZoneFoundByName() { @Test public void getChangeAndZoneNotFoundByName() { - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andThrow(EXCEPTION); - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andThrow(EXCEPTION); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andThrow(EXCEPTION).times(2); // again for options expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andThrow(EXCEPTION); - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andThrow(EXCEPTION); + .andThrow(EXCEPTION).times(2); replay(dns); try { zoneNoId.getChangeRequest(CHANGE_REQUEST.id()); @@ -361,13 +340,10 @@ public void getChangeAndZoneNotFoundByName() { @Test public void getChangedWhichDoesNotExistZoneFound() { - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null); - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null); + expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null).times(2); // again for options expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); - expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS)) - .andReturn(null); + .andReturn(null).times(2); replay(dns); assertNull(zoneNoId.getChangeRequest(CHANGE_REQUEST.id())); assertNull(zone.getChangeRequest(CHANGE_REQUEST.id())); @@ -438,13 +414,10 @@ public void listChangeRequestsAndZoneFound() { @SuppressWarnings("unchecked") Page pageMock = createStrictMock(Page.class); replay(pageMock); - expect(dns.listChangeRequests(ZONE_NAME)).andReturn(pageMock); - expect(dns.listChangeRequests(ZONE_NAME)).andReturn(pageMock); + expect(dns.listChangeRequests(ZONE_NAME)).andReturn(pageMock).times(2); // again for options expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)) - .andReturn(pageMock); - expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)) - .andReturn(pageMock); + .andReturn(pageMock).times(2); replay(dns); Page result = zoneNoId.listChangeRequests(); assertSame(pageMock, result); @@ -457,11 +430,10 @@ public void listChangeRequestsAndZoneFound() { @Test public void listChangeRequestsAndZoneNotFound() { - expect(dns.listChangeRequests(ZONE_NAME)).andThrow(EXCEPTION); - expect(dns.listChangeRequests(ZONE_NAME)).andThrow(EXCEPTION); + expect(dns.listChangeRequests(ZONE_NAME)).andThrow(EXCEPTION).times(2); // again for options - expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)).andThrow(EXCEPTION); - expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)).andThrow(EXCEPTION); + expect(dns.listChangeRequests(ZONE_NAME, CHANGE_REQUEST_LIST_OPTIONS)).andThrow(EXCEPTION) + .times(2); replay(dns); try { zoneNoId.listChangeRequests(); @@ -498,8 +470,7 @@ public void testFromPb() { @Test public void testEqualsAndToBuilder() { - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS).times(2); replay(dns); assertEquals(zone, zone.toBuilder().build()); assertEquals(zone.hashCode(), zone.toBuilder().build().hashCode()); @@ -508,14 +479,7 @@ public void testEqualsAndToBuilder() { @Test public void testBuilder() { // one for each build() call because it invokes a constructor - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); - expect(dns.options()).andReturn(OPTIONS); + expect(dns.options()).andReturn(OPTIONS).times(8); replay(dns); assertNotEquals(zone, zone.toBuilder() .id((new BigInteger(zone.id())).add(BigInteger.ONE).toString()) diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java index 40ce61b07281..a9e5c5d25377 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/DnsExample.java @@ -19,6 +19,7 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.ChangeRequestInfo; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsOptions; import com.google.gcloud.dns.ProjectInfo; @@ -207,7 +208,7 @@ public void run(Dns dns, String... args) { .records(ImmutableList.of(ip)) .ttl(ttl, TimeUnit.SECONDS) .build(); - ChangeRequest changeRequest = ChangeRequest.builder() + ChangeRequestInfo changeRequest = ChangeRequest.builder() .delete(recordSet) .build(); changeRequest = dns.applyChangeRequest(zoneName, changeRequest); @@ -254,7 +255,7 @@ public void run(Dns dns, String... args) { .records(ImmutableList.of(ip)) .ttl(ttl, TimeUnit.SECONDS) .build(); - ChangeRequest changeRequest = ChangeRequest.builder().add(recordSet).build(); + ChangeRequestInfo changeRequest = ChangeRequest.builder().add(recordSet).build(); changeRequest = dns.applyChangeRequest(zoneName, changeRequest); System.out.printf("The request for adding A record %s for zone %s was successfully " + "submitted and assigned ID %s.%n", recordName, zoneName, changeRequest.id()); @@ -444,9 +445,9 @@ private static void printZone(Zone zone) { System.out.printf("Name servers: %s%n", Joiner.on(", ").join(zone.nameServers())); } - private static ChangeRequest waitForChangeToFinish(Dns dns, String zoneName, - ChangeRequest request) { - ChangeRequest current = request; + private static ChangeRequestInfo waitForChangeToFinish(Dns dns, String zoneName, + ChangeRequestInfo request) { + ChangeRequestInfo current = request; while (current.status().equals(ChangeRequest.Status.PENDING)) { System.out.print("."); try { diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateRecordSets.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateRecordSets.java index 74647daf666e..e3ddbb10fc0f 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateRecordSets.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateRecordSets.java @@ -22,7 +22,7 @@ package com.google.gcloud.examples.dns.snippets; -import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.ChangeRequestInfo; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsOptions; import com.google.gcloud.dns.RecordSet; @@ -55,7 +55,7 @@ public static void main(String... args) { .build(); // Make a change - ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate); + ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCreate); // Verify a www.. type A record does not exist yet. // If it does exist, we will overwrite it with our prepared record. @@ -68,7 +68,7 @@ public static void main(String... args) { } // Build and apply the change request to our zone - ChangeRequest changeRequest = changeBuilder.build(); + ChangeRequestInfo changeRequest = changeBuilder.build(); zone.applyChangeRequest(changeRequest); } } diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java index 27377345b62f..63f26eeebb2a 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/DeleteZone.java @@ -22,7 +22,7 @@ package com.google.gcloud.examples.dns.snippets; -import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.ChangeRequestInfo; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsOptions; import com.google.gcloud.dns.RecordSet; @@ -47,7 +47,7 @@ public static void main(String... args) { Iterator recordIterator = dns.listRecordSets(zoneName).iterateAll(); // Make a change for deleting the records - ChangeRequest.Builder changeBuilder = ChangeRequest.builder(); + ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder(); while (recordIterator.hasNext()) { RecordSet current = recordIterator.next(); // SOA and NS records cannot be deleted @@ -57,14 +57,14 @@ public static void main(String... args) { } // Build and apply the change request to our zone if it contains records to delete - ChangeRequest changeRequest = changeBuilder.build(); + ChangeRequestInfo changeRequest = changeBuilder.build(); if (!changeRequest.deletions().isEmpty()) { changeRequest = dns.applyChangeRequest(zoneName, changeRequest); // Wait for change to finish, but save data traffic by transferring only ID and status Dns.ChangeRequestOption option = Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS); - while (ChangeRequest.Status.PENDING.equals(changeRequest.status())) { + while (ChangeRequestInfo.Status.PENDING.equals(changeRequest.status())) { System.out.println("Waiting for change to complete. Going to sleep for 500ms..."); try { Thread.sleep(500); diff --git a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java index 6d9d09d704a6..9c9a9e77289c 100644 --- a/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java +++ b/gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/ManipulateZonesAndRecordSets.java @@ -23,6 +23,7 @@ package com.google.gcloud.examples.dns.snippets; import com.google.gcloud.dns.ChangeRequest; +import com.google.gcloud.dns.ChangeRequestInfo; import com.google.gcloud.dns.Dns; import com.google.gcloud.dns.DnsOptions; import com.google.gcloud.dns.RecordSet; @@ -66,7 +67,7 @@ public static void main(String... args) { .build(); // Make a change - ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate); + ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCreate); // Verify the type A record does not exist yet. // If it does exist, we will overwrite it with our prepared record. @@ -79,10 +80,10 @@ public static void main(String... args) { } // Build and apply the change request to our zone - ChangeRequest changeRequest = changeBuilder.build(); + ChangeRequestInfo changeRequest = changeBuilder.build(); zone.applyChangeRequest(changeRequest); - while (ChangeRequest.Status.PENDING.equals(changeRequest.status())) { + while (ChangeRequestInfo.Status.PENDING.equals(changeRequest.status())) { try { Thread.sleep(500L); } catch (InterruptedException e) { @@ -115,7 +116,7 @@ public static void main(String... args) { } // Make a change for deleting the record sets - changeBuilder = ChangeRequest.builder(); + changeBuilder = ChangeRequestInfo.builder(); while (recordSetIterator.hasNext()) { RecordSet current = recordSetIterator.next(); // SOA and NS records cannot be deleted From 70148cee8f07b91980e6514b76a315e9234af4fd Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Fri, 30 Oct 2015 12:42:32 -0700 Subject: [PATCH 170/203] Initial GAX submission - generated classes only --- gcloud-java-gax/README.md | 55 + .../java/com/google/api/AnnotationsProto.java | 222 + .../src/main/java/com/google/api/Context.java | 779 +++ .../java/com/google/api/ContextOrBuilder.java | 53 + .../java/com/google/api/ContextProto.java | 64 + .../main/java/com/google/api/ContextRule.java | 922 ++++ .../com/google/api/ContextRuleOrBuilder.java | 99 + .../main/java/com/google/api/CustomError.java | 1016 ++++ .../com/google/api/CustomErrorOrBuilder.java | 93 + .../java/com/google/api/CustomErrorRule.java | 627 +++ .../google/api/CustomErrorRuleOrBuilder.java | 48 + .../com/google/api/CustomHttpPattern.java | 627 +++ .../api/CustomHttpPatternOrBuilder.java | 45 + .../java/com/google/api/Documentation.java | 1816 +++++++ .../google/api/DocumentationOrBuilder.java | 173 + .../com/google/api/DocumentationProto.java | 79 + .../com/google/api/DocumentationRule.java | 662 +++ .../api/DocumentationRuleOrBuilder.java | 55 + .../java/com/google/api/ErrorFormatProto.java | 65 + .../src/main/java/com/google/api/Http.java | 759 +++ .../java/com/google/api/HttpOrBuilder.java | 53 + .../main/java/com/google/api/HttpProto.java | 106 + .../main/java/com/google/api/HttpRule.java | 3069 +++++++++++ .../com/google/api/HttpRuleOrBuilder.java | 276 + .../java/com/google/api/MediaDownload.java | 399 ++ .../google/api/MediaDownloadOrBuilder.java | 18 + .../main/java/com/google/api/MediaUpload.java | 399 ++ .../com/google/api/MediaUploadOrBuilder.java | 18 + .../src/main/java/com/google/api/Page.java | 1176 +++++ .../java/com/google/api/PageOrBuilder.java | 120 + .../src/main/java/com/google/api/Service.java | 4591 +++++++++++++++++ .../java/com/google/api/ServiceOrBuilder.java | 530 ++ .../java/com/google/api/ServiceProto.java | 95 + .../main/java/com/google/api/Visibility.java | 1370 +++++ .../com/google/api/VisibilityOrBuilder.java | 148 + .../java/com/google/api/VisibilityProto.java | 70 + .../java/com/google/api/VisibilityRule.java | 998 ++++ .../google/api/VisibilityRuleOrBuilder.java | 110 + .../longrunning/CancelOperationRequest.java | 476 ++ .../CancelOperationRequestOrBuilder.java | 27 + .../longrunning/DeleteOperationRequest.java | 476 ++ .../DeleteOperationRequestOrBuilder.java | 27 + .../longrunning/GetOperationRequest.java | 476 ++ .../GetOperationRequestOrBuilder.java | 27 + .../longrunning/ListOperationsRequest.java | 848 +++ .../ListOperationsRequestOrBuilder.java | 72 + .../longrunning/ListOperationsResponse.java | 909 ++++ .../ListOperationsResponseOrBuilder.java | 71 + .../com/google/longrunning/Operation.java | 1383 +++++ .../longrunning/OperationOrBuilder.java | 123 + .../google/longrunning/OperationsGrpc.java | 306 ++ .../google/longrunning/OperationsProto.java | 146 + .../main/java/com/google/rpc/BadRequest.java | 1437 ++++++ .../com/google/rpc/BadRequestOrBuilder.java | 53 + .../src/main/java/com/google/rpc/Code.java | 543 ++ .../main/java/com/google/rpc/CodeProto.java | 46 + .../main/java/com/google/rpc/DebugInfo.java | 697 +++ .../com/google/rpc/DebugInfoOrBuilder.java | 62 + .../com/google/rpc/ErrorDetailsProto.java | 167 + .../src/main/java/com/google/rpc/Help.java | 1423 +++++ .../java/com/google/rpc/HelpOrBuilder.java | 53 + .../java/com/google/rpc/QuotaFailure.java | 1498 ++++++ .../com/google/rpc/QuotaFailureOrBuilder.java | 53 + .../main/java/com/google/rpc/RequestInfo.java | 643 +++ .../com/google/rpc/RequestInfoOrBuilder.java | 49 + .../java/com/google/rpc/ResourceInfo.java | 985 ++++ .../com/google/rpc/ResourceInfoOrBuilder.java | 97 + .../main/java/com/google/rpc/RetryInfo.java | 565 ++ .../com/google/rpc/RetryInfoOrBuilder.java | 34 + .../src/main/java/com/google/rpc/Status.java | 1092 ++++ .../java/com/google/rpc/StatusOrBuilder.java | 89 + .../main/java/com/google/rpc/StatusProto.java | 54 + .../src/main/java/com/google/type/Color.java | 1047 ++++ .../java/com/google/type/ColorOrBuilder.java | 85 + .../main/java/com/google/type/ColorProto.java | 55 + .../src/main/java/com/google/type/Date.java | 593 +++ .../java/com/google/type/DateOrBuilder.java | 38 + .../main/java/com/google/type/DateProto.java | 51 + .../main/java/com/google/type/DayOfWeek.java | 220 + .../java/com/google/type/DayOfWeekProto.java | 42 + .../src/main/java/com/google/type/LatLng.java | 513 ++ .../java/com/google/type/LatLngOrBuilder.java | 27 + .../java/com/google/type/LatLngProto.java | 51 + .../src/main/java/com/google/type/Money.java | 640 +++ .../java/com/google/type/MoneyOrBuilder.java | 51 + .../main/java/com/google/type/MoneyProto.java | 51 + .../main/java/com/google/type/TimeOfDay.java | 659 +++ .../com/google/type/TimeOfDayOrBuilder.java | 47 + .../java/com/google/type/TimeOfDayProto.java | 52 + gcloud-java-gax/pom.xml | 82 + 90 files changed, 41116 insertions(+) create mode 100644 gcloud-java-gax/README.md create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/AnnotationsProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Context.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ContextOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ContextProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ContextRule.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ContextRuleOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomError.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRule.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRuleOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPattern.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPatternOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Documentation.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRule.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRuleOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ErrorFormatProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Http.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/HttpOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/HttpProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/HttpRule.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/HttpRuleOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownload.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownloadOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/MediaUpload.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/MediaUploadOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Page.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/PageOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Service.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ServiceOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ServiceProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Visibility.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRule.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRuleOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequest.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequestOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequest.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequestOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequest.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequestOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequest.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequestOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponse.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponseOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/Operation.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsGrpc.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequest.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequestOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/Code.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/CodeProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfo.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfoOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/ErrorDetailsProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/Help.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/HelpOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailure.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailureOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfo.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfoOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfo.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfoOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfo.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfoOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/Status.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/Color.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/ColorOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/ColorProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/Date.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/DateOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/DateProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeek.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeekProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/LatLng.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/LatLngOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/LatLngProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/Money.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/MoneyOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/MoneyProto.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDay.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayOrBuilder.java create mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayProto.java create mode 100644 gcloud-java-gax/pom.xml diff --git a/gcloud-java-gax/README.md b/gcloud-java-gax/README.md new file mode 100644 index 000000000000..fe478991b1e7 --- /dev/null +++ b/gcloud-java-gax/README.md @@ -0,0 +1,55 @@ +Google Cloud Java Client +========================== + +Java idiomatic client for [Google Cloud Platform][cloud-platform] services. + +[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) +[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) + +- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) +- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs) +- [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html) + +This module provides common functionality and is required by the other service specific modules. + +Quickstart +---------- +Add this to your pom.xml file +```xml + + com.google.gcloud + gcloud-java-gax + 0.0.6 + +``` + +Contributing +------------ + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING] for more information on how to get started. + +Java Versions +------------- + +Java 7 or above is required for using this client. + +Versioning +---------- + +This library follows [Semantic Versioning] (http://semver.org/). + +It is currently in major version zero (``0.y.z``), which means that anything +may change at any time and the public API should not be considered +stable. + +License +------- + +Apache 2.0 - See [LICENSE] for more information. + + +[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md +[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE +[cloud-platform]: https://cloud.google.com/ diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/AnnotationsProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/AnnotationsProto.java new file mode 100644 index 000000000000..0281d9ddd73b --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/AnnotationsProto.java @@ -0,0 +1,222 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/annotations.proto + +package com.google.api; + +public final class AnnotationsProto { + private AnnotationsProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registry.add(com.google.api.AnnotationsProto.fileVisibility); + registry.add(com.google.api.AnnotationsProto.apiVisibility); + registry.add(com.google.api.AnnotationsProto.methodVisibility); + registry.add(com.google.api.AnnotationsProto.http); + registry.add(com.google.api.AnnotationsProto.messageVisibility); + registry.add(com.google.api.AnnotationsProto.customError); + registry.add(com.google.api.AnnotationsProto.fieldVisibility); + registry.add(com.google.api.AnnotationsProto.enumVisibility); + registry.add(com.google.api.AnnotationsProto.valueVisibility); + } + public static final int FILE_VISIBILITY_FIELD_NUMBER = 72295727; + /** + * extend .google.protobuf.FileOptions { ... } + * + *
      +   * See `VisibilityRule`.
      +   * 
      + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.FileOptions, + com.google.api.VisibilityRule> fileVisibility = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + com.google.api.VisibilityRule.class, + com.google.api.VisibilityRule.getDefaultInstance()); + public static final int API_VISIBILITY_FIELD_NUMBER = 72295727; + /** + * extend .google.protobuf.ServiceOptions { ... } + * + *
      +   * See `VisibilityRule`.
      +   * 
      + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.ServiceOptions, + com.google.api.VisibilityRule> apiVisibility = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + com.google.api.VisibilityRule.class, + com.google.api.VisibilityRule.getDefaultInstance()); + public static final int METHOD_VISIBILITY_FIELD_NUMBER = 72295727; + /** + * extend .google.protobuf.MethodOptions { ... } + * + *
      +   * See `VisibilityRule`.
      +   * 
      + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.MethodOptions, + com.google.api.VisibilityRule> methodVisibility = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + com.google.api.VisibilityRule.class, + com.google.api.VisibilityRule.getDefaultInstance()); + public static final int HTTP_FIELD_NUMBER = 72295728; + /** + * extend .google.protobuf.MethodOptions { ... } + * + *
      +   * See `HttpRule`.
      +   * 
      + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.MethodOptions, + com.google.api.HttpRule> http = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + com.google.api.HttpRule.class, + com.google.api.HttpRule.getDefaultInstance()); + public static final int MESSAGE_VISIBILITY_FIELD_NUMBER = 72295727; + /** + * extend .google.protobuf.MessageOptions { ... } + * + *
      +   * See `VisibilityRule`.
      +   * 
      + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.MessageOptions, + com.google.api.VisibilityRule> messageVisibility = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + com.google.api.VisibilityRule.class, + com.google.api.VisibilityRule.getDefaultInstance()); + public static final int CUSTOM_ERROR_FIELD_NUMBER = 79365461; + /** + * extend .google.protobuf.MessageOptions { ... } + * + *
      +   * See `CustomErrorRule`.
      +   * 
      + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.MessageOptions, + com.google.api.CustomErrorRule> customError = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + com.google.api.CustomErrorRule.class, + com.google.api.CustomErrorRule.getDefaultInstance()); + public static final int FIELD_VISIBILITY_FIELD_NUMBER = 72295727; + /** + * extend .google.protobuf.FieldOptions { ... } + * + *
      +   * See `VisibilityRule`.
      +   * 
      + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.FieldOptions, + com.google.api.VisibilityRule> fieldVisibility = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + com.google.api.VisibilityRule.class, + com.google.api.VisibilityRule.getDefaultInstance()); + public static final int ENUM_VISIBILITY_FIELD_NUMBER = 72295727; + /** + * extend .google.protobuf.EnumOptions { ... } + * + *
      +   * See `VisibilityRule`.
      +   * 
      + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.EnumOptions, + com.google.api.VisibilityRule> enumVisibility = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + com.google.api.VisibilityRule.class, + com.google.api.VisibilityRule.getDefaultInstance()); + public static final int VALUE_VISIBILITY_FIELD_NUMBER = 72295727; + /** + * extend .google.protobuf.EnumValueOptions { ... } + * + *
      +   * See `VisibilityRule`.
      +   * 
      + */ + public static final + com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.EnumValueOptions, + com.google.api.VisibilityRule> valueVisibility = com.google.protobuf.GeneratedMessage + .newFileScopedGeneratedExtension( + com.google.api.VisibilityRule.class, + com.google.api.VisibilityRule.getDefaultInstance()); + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\034google/api/annotations.proto\022\ngoogle.a" + + "pi\032 google/protobuf/descriptor.proto\032\026go" + + "ogle/api/error.proto\032\025google/api/http.pr" + + "oto\032\033google/api/visibility.proto:T\n\017file" + + "_visibility\022\034.google.protobuf.FileOption" + + "s\030\257\312\274\" \001(\0132\032.google.api.VisibilityRule:V" + + "\n\016api_visibility\022\037.google.protobuf.Servi" + + "ceOptions\030\257\312\274\" \001(\0132\032.google.api.Visibili" + + "tyRule:X\n\021method_visibility\022\036.google.pro" + + "tobuf.MethodOptions\030\257\312\274\" \001(\0132\032.google.ap", + "i.VisibilityRule:E\n\004http\022\036.google.protob" + + "uf.MethodOptions\030\260\312\274\" \001(\0132\024.google.api.H" + + "ttpRule:Z\n\022message_visibility\022\037.google.p" + + "rotobuf.MessageOptions\030\257\312\274\" \001(\0132\032.google" + + ".api.VisibilityRule:U\n\014custom_error\022\037.go" + + "ogle.protobuf.MessageOptions\030\325\212\354% \001(\0132\033." + + "google.api.CustomErrorRule:V\n\020field_visi" + + "bility\022\035.google.protobuf.FieldOptions\030\257\312" + + "\274\" \001(\0132\032.google.api.VisibilityRule:T\n\017en" + + "um_visibility\022\034.google.protobuf.EnumOpti", + "ons\030\257\312\274\" \001(\0132\032.google.api.VisibilityRule" + + ":Z\n\020value_visibility\022!.google.protobuf.E" + + "numValueOptions\030\257\312\274\" \001(\0132\032.google.api.Vi" + + "sibilityRuleB$\n\016com.google.apiB\020Annotati" + + "onsProtoP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.DescriptorProtos.getDescriptor(), + com.google.api.ErrorFormatProto.getDescriptor(), + com.google.api.HttpProto.getDescriptor(), + com.google.api.VisibilityProto.getDescriptor(), + }, assigner); + fileVisibility.internalInit(descriptor.getExtensions().get(0)); + apiVisibility.internalInit(descriptor.getExtensions().get(1)); + methodVisibility.internalInit(descriptor.getExtensions().get(2)); + http.internalInit(descriptor.getExtensions().get(3)); + messageVisibility.internalInit(descriptor.getExtensions().get(4)); + customError.internalInit(descriptor.getExtensions().get(5)); + fieldVisibility.internalInit(descriptor.getExtensions().get(6)); + enumVisibility.internalInit(descriptor.getExtensions().get(7)); + valueVisibility.internalInit(descriptor.getExtensions().get(8)); + com.google.protobuf.DescriptorProtos.getDescriptor(); + com.google.api.ErrorFormatProto.getDescriptor(); + com.google.api.HttpProto.getDescriptor(); + com.google.api.VisibilityProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Context.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Context.java new file mode 100644 index 000000000000..1385a7b9ea50 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/Context.java @@ -0,0 +1,779 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/context.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.Context} + * + *
      + * `Context` defines which contexts an API requests.
      + * Example:
      + *     context:
      + *       rules:
      + *       - selector: "*"
      + *         requested:
      + *         - google.rpc.context.ProjectContext
      + *         - google.rpc.context.OriginContext
      + * The above specifies that all methods in the API request
      + * `google.rpc.context.ProjectContext` and
      + * `google.rpc.context.OriginContext`.
      + * Available context types are defined in package
      + * `google.rpc.context`.
      + * 
      + */ +public final class Context extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.Context) + ContextOrBuilder { + // Use Context.newBuilder() to construct. + private Context(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Context() { + rules_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Context( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + rules_.add(input.readMessage(com.google.api.ContextRule.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.ContextProto.internal_static_google_api_Context_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.ContextProto.internal_static_google_api_Context_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Context.class, com.google.api.Context.Builder.class); + } + + public static final int RULES_FIELD_NUMBER = 1; + private java.util.List rules_; + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +   * List of rules for context, applicable to methods.
      +   * 
      + */ + public java.util.List getRulesList() { + return rules_; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +   * List of rules for context, applicable to methods.
      +   * 
      + */ + public java.util.List + getRulesOrBuilderList() { + return rules_; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +   * List of rules for context, applicable to methods.
      +   * 
      + */ + public int getRulesCount() { + return rules_.size(); + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +   * List of rules for context, applicable to methods.
      +   * 
      + */ + public com.google.api.ContextRule getRules(int index) { + return rules_.get(index); + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +   * List of rules for context, applicable to methods.
      +   * 
      + */ + public com.google.api.ContextRuleOrBuilder getRulesOrBuilder( + int index) { + return rules_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < rules_.size(); i++) { + output.writeMessage(1, rules_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < rules_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, rules_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.Context parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Context parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Context parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Context parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Context parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Context parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.Context parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.Context parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.Context parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Context parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.Context prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.Context} + * + *
      +   * `Context` defines which contexts an API requests.
      +   * Example:
      +   *     context:
      +   *       rules:
      +   *       - selector: "*"
      +   *         requested:
      +   *         - google.rpc.context.ProjectContext
      +   *         - google.rpc.context.OriginContext
      +   * The above specifies that all methods in the API request
      +   * `google.rpc.context.ProjectContext` and
      +   * `google.rpc.context.OriginContext`.
      +   * Available context types are defined in package
      +   * `google.rpc.context`.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.Context) + com.google.api.ContextOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.ContextProto.internal_static_google_api_Context_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.ContextProto.internal_static_google_api_Context_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Context.class, com.google.api.Context.Builder.class); + } + + // Construct using com.google.api.Context.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getRulesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + rulesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.ContextProto.internal_static_google_api_Context_descriptor; + } + + public com.google.api.Context getDefaultInstanceForType() { + return com.google.api.Context.getDefaultInstance(); + } + + public com.google.api.Context build() { + com.google.api.Context result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.Context buildPartial() { + com.google.api.Context result = new com.google.api.Context(this); + int from_bitField0_ = bitField0_; + if (rulesBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.rules_ = rules_; + } else { + result.rules_ = rulesBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.Context) { + return mergeFrom((com.google.api.Context)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.Context other) { + if (other == com.google.api.Context.getDefaultInstance()) return this; + if (rulesBuilder_ == null) { + if (!other.rules_.isEmpty()) { + if (rules_.isEmpty()) { + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureRulesIsMutable(); + rules_.addAll(other.rules_); + } + onChanged(); + } + } else { + if (!other.rules_.isEmpty()) { + if (rulesBuilder_.isEmpty()) { + rulesBuilder_.dispose(); + rulesBuilder_ = null; + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000001); + rulesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getRulesFieldBuilder() : null; + } else { + rulesBuilder_.addAllMessages(other.rules_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.Context parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.Context) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List rules_ = + java.util.Collections.emptyList(); + private void ensureRulesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = new java.util.ArrayList(rules_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.ContextRule, com.google.api.ContextRule.Builder, com.google.api.ContextRuleOrBuilder> rulesBuilder_; + + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public java.util.List getRulesList() { + if (rulesBuilder_ == null) { + return java.util.Collections.unmodifiableList(rules_); + } else { + return rulesBuilder_.getMessageList(); + } + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public int getRulesCount() { + if (rulesBuilder_ == null) { + return rules_.size(); + } else { + return rulesBuilder_.getCount(); + } + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public com.google.api.ContextRule getRules(int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); + } else { + return rulesBuilder_.getMessage(index); + } + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public Builder setRules( + int index, com.google.api.ContextRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.set(index, value); + onChanged(); + } else { + rulesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public Builder setRules( + int index, com.google.api.ContextRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.set(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public Builder addRules(com.google.api.ContextRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(value); + onChanged(); + } else { + rulesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public Builder addRules( + int index, com.google.api.ContextRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(index, value); + onChanged(); + } else { + rulesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public Builder addRules( + com.google.api.ContextRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public Builder addRules( + int index, com.google.api.ContextRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public Builder addAllRules( + java.lang.Iterable values) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, rules_); + onChanged(); + } else { + rulesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public Builder clearRules() { + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + rulesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public Builder removeRules(int index) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.remove(index); + onChanged(); + } else { + rulesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public com.google.api.ContextRule.Builder getRulesBuilder( + int index) { + return getRulesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public com.google.api.ContextRuleOrBuilder getRulesOrBuilder( + int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); } else { + return rulesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public java.util.List + getRulesOrBuilderList() { + if (rulesBuilder_ != null) { + return rulesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(rules_); + } + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public com.google.api.ContextRule.Builder addRulesBuilder() { + return getRulesFieldBuilder().addBuilder( + com.google.api.ContextRule.getDefaultInstance()); + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public com.google.api.ContextRule.Builder addRulesBuilder( + int index) { + return getRulesFieldBuilder().addBuilder( + index, com.google.api.ContextRule.getDefaultInstance()); + } + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +     * List of rules for context, applicable to methods.
      +     * 
      + */ + public java.util.List + getRulesBuilderList() { + return getRulesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.ContextRule, com.google.api.ContextRule.Builder, com.google.api.ContextRuleOrBuilder> + getRulesFieldBuilder() { + if (rulesBuilder_ == null) { + rulesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.api.ContextRule, com.google.api.ContextRule.Builder, com.google.api.ContextRuleOrBuilder>( + rules_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + rules_ = null; + } + return rulesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.Context) + } + + // @@protoc_insertion_point(class_scope:google.api.Context) + private static final com.google.api.Context DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.Context(); + } + + public static com.google.api.Context getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Context parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Context(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.Context getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextOrBuilder.java new file mode 100644 index 000000000000..97be9b0b3dd9 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextOrBuilder.java @@ -0,0 +1,53 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/context.proto + +package com.google.api; + +public interface ContextOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.Context) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +   * List of rules for context, applicable to methods.
      +   * 
      + */ + java.util.List + getRulesList(); + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +   * List of rules for context, applicable to methods.
      +   * 
      + */ + com.google.api.ContextRule getRules(int index); + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +   * List of rules for context, applicable to methods.
      +   * 
      + */ + int getRulesCount(); + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +   * List of rules for context, applicable to methods.
      +   * 
      + */ + java.util.List + getRulesOrBuilderList(); + /** + * repeated .google.api.ContextRule rules = 1; + * + *
      +   * List of rules for context, applicable to methods.
      +   * 
      + */ + com.google.api.ContextRuleOrBuilder getRulesOrBuilder( + int index); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextProto.java new file mode 100644 index 000000000000..755c670fa8af --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextProto.java @@ -0,0 +1,64 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/context.proto + +package com.google.api; + +public final class ContextProto { + private ContextProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_Context_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_Context_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_ContextRule_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_ContextRule_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\030google/api/context.proto\022\ngoogle.api\"1" + + "\n\007Context\022&\n\005rules\030\001 \003(\0132\027.google.api.Co" + + "ntextRule\"D\n\013ContextRule\022\020\n\010selector\030\001 \001" + + "(\t\022\021\n\trequested\030\002 \003(\t\022\020\n\010provided\030\003 \003(\tB" + + " \n\016com.google.apiB\014ContextProtoP\001b\006proto" + + "3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_google_api_Context_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_api_Context_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_Context_descriptor, + new java.lang.String[] { "Rules", }); + internal_static_google_api_ContextRule_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_api_ContextRule_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_ContextRule_descriptor, + new java.lang.String[] { "Selector", "Requested", "Provided", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRule.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRule.java new file mode 100644 index 000000000000..9857e3bfdd24 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRule.java @@ -0,0 +1,922 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/context.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.ContextRule} + * + *
      + * A context rule provides information about the context for an individual API
      + * element.
      + * 
      + */ +public final class ContextRule extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.ContextRule) + ContextRuleOrBuilder { + // Use ContextRule.newBuilder() to construct. + private ContextRule(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ContextRule() { + selector_ = ""; + requested_ = com.google.protobuf.LazyStringArrayList.EMPTY; + provided_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ContextRule( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + selector_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + requested_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + requested_.add(s); + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + provided_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000004; + } + provided_.add(s); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + requested_ = requested_.getUnmodifiableView(); + } + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + provided_ = provided_.getUnmodifiableView(); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.ContextProto.internal_static_google_api_ContextRule_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.ContextProto.internal_static_google_api_ContextRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.ContextRule.class, com.google.api.ContextRule.Builder.class); + } + + private int bitField0_; + public static final int SELECTOR_FIELD_NUMBER = 1; + private volatile java.lang.Object selector_; + /** + * optional string selector = 1; + * + *
      +   * Selects the methods to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } + } + /** + * optional string selector = 1; + * + *
      +   * Selects the methods to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REQUESTED_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList requested_; + /** + * repeated string requested = 2; + * + *
      +   * A list of full type names of requested contexts.
      +   * 
      + */ + public com.google.protobuf.ProtocolStringList + getRequestedList() { + return requested_; + } + /** + * repeated string requested = 2; + * + *
      +   * A list of full type names of requested contexts.
      +   * 
      + */ + public int getRequestedCount() { + return requested_.size(); + } + /** + * repeated string requested = 2; + * + *
      +   * A list of full type names of requested contexts.
      +   * 
      + */ + public java.lang.String getRequested(int index) { + return requested_.get(index); + } + /** + * repeated string requested = 2; + * + *
      +   * A list of full type names of requested contexts.
      +   * 
      + */ + public com.google.protobuf.ByteString + getRequestedBytes(int index) { + return requested_.getByteString(index); + } + + public static final int PROVIDED_FIELD_NUMBER = 3; + private com.google.protobuf.LazyStringList provided_; + /** + * repeated string provided = 3; + * + *
      +   * A list of full type names of provided contexts.
      +   * 
      + */ + public com.google.protobuf.ProtocolStringList + getProvidedList() { + return provided_; + } + /** + * repeated string provided = 3; + * + *
      +   * A list of full type names of provided contexts.
      +   * 
      + */ + public int getProvidedCount() { + return provided_.size(); + } + /** + * repeated string provided = 3; + * + *
      +   * A list of full type names of provided contexts.
      +   * 
      + */ + public java.lang.String getProvided(int index) { + return provided_.get(index); + } + /** + * repeated string provided = 3; + * + *
      +   * A list of full type names of provided contexts.
      +   * 
      + */ + public com.google.protobuf.ByteString + getProvidedBytes(int index) { + return provided_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSelectorBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, selector_); + } + for (int i = 0; i < requested_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, requested_.getRaw(i)); + } + for (int i = 0; i < provided_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, provided_.getRaw(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSelectorBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, selector_); + } + { + int dataSize = 0; + for (int i = 0; i < requested_.size(); i++) { + dataSize += computeStringSizeNoTag(requested_.getRaw(i)); + } + size += dataSize; + size += 1 * getRequestedList().size(); + } + { + int dataSize = 0; + for (int i = 0; i < provided_.size(); i++) { + dataSize += computeStringSizeNoTag(provided_.getRaw(i)); + } + size += dataSize; + size += 1 * getProvidedList().size(); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.ContextRule parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.ContextRule parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.ContextRule parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.ContextRule parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.ContextRule parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.ContextRule parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.ContextRule parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.ContextRule parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.ContextRule parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.ContextRule parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.ContextRule prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.ContextRule} + * + *
      +   * A context rule provides information about the context for an individual API
      +   * element.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.ContextRule) + com.google.api.ContextRuleOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.ContextProto.internal_static_google_api_ContextRule_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.ContextProto.internal_static_google_api_ContextRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.ContextRule.class, com.google.api.ContextRule.Builder.class); + } + + // Construct using com.google.api.ContextRule.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + selector_ = ""; + + requested_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + provided_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.ContextProto.internal_static_google_api_ContextRule_descriptor; + } + + public com.google.api.ContextRule getDefaultInstanceForType() { + return com.google.api.ContextRule.getDefaultInstance(); + } + + public com.google.api.ContextRule build() { + com.google.api.ContextRule result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.ContextRule buildPartial() { + com.google.api.ContextRule result = new com.google.api.ContextRule(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.selector_ = selector_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + requested_ = requested_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.requested_ = requested_; + if (((bitField0_ & 0x00000004) == 0x00000004)) { + provided_ = provided_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.provided_ = provided_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.ContextRule) { + return mergeFrom((com.google.api.ContextRule)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.ContextRule other) { + if (other == com.google.api.ContextRule.getDefaultInstance()) return this; + if (!other.getSelector().isEmpty()) { + selector_ = other.selector_; + onChanged(); + } + if (!other.requested_.isEmpty()) { + if (requested_.isEmpty()) { + requested_ = other.requested_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureRequestedIsMutable(); + requested_.addAll(other.requested_); + } + onChanged(); + } + if (!other.provided_.isEmpty()) { + if (provided_.isEmpty()) { + provided_ = other.provided_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureProvidedIsMutable(); + provided_.addAll(other.provided_); + } + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.ContextRule parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.ContextRule) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object selector_ = ""; + /** + * optional string selector = 1; + * + *
      +     * Selects the methods to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string selector = 1; + * + *
      +     * Selects the methods to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string selector = 1; + * + *
      +     * Selects the methods to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder setSelector( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + selector_ = value; + onChanged(); + return this; + } + /** + * optional string selector = 1; + * + *
      +     * Selects the methods to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder clearSelector() { + + selector_ = getDefaultInstance().getSelector(); + onChanged(); + return this; + } + /** + * optional string selector = 1; + * + *
      +     * Selects the methods to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder setSelectorBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + selector_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList requested_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureRequestedIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + requested_ = new com.google.protobuf.LazyStringArrayList(requested_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated string requested = 2; + * + *
      +     * A list of full type names of requested contexts.
      +     * 
      + */ + public com.google.protobuf.ProtocolStringList + getRequestedList() { + return requested_.getUnmodifiableView(); + } + /** + * repeated string requested = 2; + * + *
      +     * A list of full type names of requested contexts.
      +     * 
      + */ + public int getRequestedCount() { + return requested_.size(); + } + /** + * repeated string requested = 2; + * + *
      +     * A list of full type names of requested contexts.
      +     * 
      + */ + public java.lang.String getRequested(int index) { + return requested_.get(index); + } + /** + * repeated string requested = 2; + * + *
      +     * A list of full type names of requested contexts.
      +     * 
      + */ + public com.google.protobuf.ByteString + getRequestedBytes(int index) { + return requested_.getByteString(index); + } + /** + * repeated string requested = 2; + * + *
      +     * A list of full type names of requested contexts.
      +     * 
      + */ + public Builder setRequested( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureRequestedIsMutable(); + requested_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string requested = 2; + * + *
      +     * A list of full type names of requested contexts.
      +     * 
      + */ + public Builder addRequested( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureRequestedIsMutable(); + requested_.add(value); + onChanged(); + return this; + } + /** + * repeated string requested = 2; + * + *
      +     * A list of full type names of requested contexts.
      +     * 
      + */ + public Builder addAllRequested( + java.lang.Iterable values) { + ensureRequestedIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, requested_); + onChanged(); + return this; + } + /** + * repeated string requested = 2; + * + *
      +     * A list of full type names of requested contexts.
      +     * 
      + */ + public Builder clearRequested() { + requested_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * repeated string requested = 2; + * + *
      +     * A list of full type names of requested contexts.
      +     * 
      + */ + public Builder addRequestedBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureRequestedIsMutable(); + requested_.add(value); + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList provided_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureProvidedIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + provided_ = new com.google.protobuf.LazyStringArrayList(provided_); + bitField0_ |= 0x00000004; + } + } + /** + * repeated string provided = 3; + * + *
      +     * A list of full type names of provided contexts.
      +     * 
      + */ + public com.google.protobuf.ProtocolStringList + getProvidedList() { + return provided_.getUnmodifiableView(); + } + /** + * repeated string provided = 3; + * + *
      +     * A list of full type names of provided contexts.
      +     * 
      + */ + public int getProvidedCount() { + return provided_.size(); + } + /** + * repeated string provided = 3; + * + *
      +     * A list of full type names of provided contexts.
      +     * 
      + */ + public java.lang.String getProvided(int index) { + return provided_.get(index); + } + /** + * repeated string provided = 3; + * + *
      +     * A list of full type names of provided contexts.
      +     * 
      + */ + public com.google.protobuf.ByteString + getProvidedBytes(int index) { + return provided_.getByteString(index); + } + /** + * repeated string provided = 3; + * + *
      +     * A list of full type names of provided contexts.
      +     * 
      + */ + public Builder setProvided( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureProvidedIsMutable(); + provided_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string provided = 3; + * + *
      +     * A list of full type names of provided contexts.
      +     * 
      + */ + public Builder addProvided( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureProvidedIsMutable(); + provided_.add(value); + onChanged(); + return this; + } + /** + * repeated string provided = 3; + * + *
      +     * A list of full type names of provided contexts.
      +     * 
      + */ + public Builder addAllProvided( + java.lang.Iterable values) { + ensureProvidedIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, provided_); + onChanged(); + return this; + } + /** + * repeated string provided = 3; + * + *
      +     * A list of full type names of provided contexts.
      +     * 
      + */ + public Builder clearProvided() { + provided_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + /** + * repeated string provided = 3; + * + *
      +     * A list of full type names of provided contexts.
      +     * 
      + */ + public Builder addProvidedBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureProvidedIsMutable(); + provided_.add(value); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.ContextRule) + } + + // @@protoc_insertion_point(class_scope:google.api.ContextRule) + private static final com.google.api.ContextRule DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.ContextRule(); + } + + public static com.google.api.ContextRule getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ContextRule parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ContextRule(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.ContextRule getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRuleOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRuleOrBuilder.java new file mode 100644 index 000000000000..3174e0295a35 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRuleOrBuilder.java @@ -0,0 +1,99 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/context.proto + +package com.google.api; + +public interface ContextRuleOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.ContextRule) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string selector = 1; + * + *
      +   * Selects the methods to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + java.lang.String getSelector(); + /** + * optional string selector = 1; + * + *
      +   * Selects the methods to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + com.google.protobuf.ByteString + getSelectorBytes(); + + /** + * repeated string requested = 2; + * + *
      +   * A list of full type names of requested contexts.
      +   * 
      + */ + com.google.protobuf.ProtocolStringList + getRequestedList(); + /** + * repeated string requested = 2; + * + *
      +   * A list of full type names of requested contexts.
      +   * 
      + */ + int getRequestedCount(); + /** + * repeated string requested = 2; + * + *
      +   * A list of full type names of requested contexts.
      +   * 
      + */ + java.lang.String getRequested(int index); + /** + * repeated string requested = 2; + * + *
      +   * A list of full type names of requested contexts.
      +   * 
      + */ + com.google.protobuf.ByteString + getRequestedBytes(int index); + + /** + * repeated string provided = 3; + * + *
      +   * A list of full type names of provided contexts.
      +   * 
      + */ + com.google.protobuf.ProtocolStringList + getProvidedList(); + /** + * repeated string provided = 3; + * + *
      +   * A list of full type names of provided contexts.
      +   * 
      + */ + int getProvidedCount(); + /** + * repeated string provided = 3; + * + *
      +   * A list of full type names of provided contexts.
      +   * 
      + */ + java.lang.String getProvided(int index); + /** + * repeated string provided = 3; + * + *
      +   * A list of full type names of provided contexts.
      +   * 
      + */ + com.google.protobuf.ByteString + getProvidedBytes(int index); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomError.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomError.java new file mode 100644 index 000000000000..9b9b004161b3 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomError.java @@ -0,0 +1,1016 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/error.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.CustomError} + * + *
      + * Customize service error responses.  For example, list any service
      + * specific protobuf types that can appear in error detail lists of
      + * error responses.
      + * Example:
      + *     custom_error:
      + *       types:
      + *       - google.foo.v1.CustomError
      + *       - google.foo.v1.AnotherError
      + * (-- For internal Google service producers, instead of listing such
      + * custom error detail types in the YAML configuration file; Stubby
      + * annotation can be used.  Please, see //google/api/annotations.proto
      + * for more details. --)
      + * 
      + */ +public final class CustomError extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.CustomError) + CustomErrorOrBuilder { + // Use CustomError.newBuilder() to construct. + private CustomError(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private CustomError() { + rules_ = java.util.Collections.emptyList(); + types_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private CustomError( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + rules_.add(input.readMessage(com.google.api.CustomErrorRule.parser(), extensionRegistry)); + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + types_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + types_.add(s); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + } + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + types_ = types_.getUnmodifiableView(); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.ErrorFormatProto.internal_static_google_api_CustomError_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.ErrorFormatProto.internal_static_google_api_CustomError_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.CustomError.class, com.google.api.CustomError.Builder.class); + } + + public static final int RULES_FIELD_NUMBER = 1; + private java.util.List rules_; + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +   * The list of custom error rules to select to which messages this should
      +   * apply.
      +   * 
      + */ + public java.util.List getRulesList() { + return rules_; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +   * The list of custom error rules to select to which messages this should
      +   * apply.
      +   * 
      + */ + public java.util.List + getRulesOrBuilderList() { + return rules_; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +   * The list of custom error rules to select to which messages this should
      +   * apply.
      +   * 
      + */ + public int getRulesCount() { + return rules_.size(); + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +   * The list of custom error rules to select to which messages this should
      +   * apply.
      +   * 
      + */ + public com.google.api.CustomErrorRule getRules(int index) { + return rules_.get(index); + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +   * The list of custom error rules to select to which messages this should
      +   * apply.
      +   * 
      + */ + public com.google.api.CustomErrorRuleOrBuilder getRulesOrBuilder( + int index) { + return rules_.get(index); + } + + public static final int TYPES_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList types_; + /** + * repeated string types = 2; + * + *
      +   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +   * 
      + */ + public com.google.protobuf.ProtocolStringList + getTypesList() { + return types_; + } + /** + * repeated string types = 2; + * + *
      +   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +   * 
      + */ + public int getTypesCount() { + return types_.size(); + } + /** + * repeated string types = 2; + * + *
      +   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +   * 
      + */ + public java.lang.String getTypes(int index) { + return types_.get(index); + } + /** + * repeated string types = 2; + * + *
      +   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +   * 
      + */ + public com.google.protobuf.ByteString + getTypesBytes(int index) { + return types_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < rules_.size(); i++) { + output.writeMessage(1, rules_.get(i)); + } + for (int i = 0; i < types_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, types_.getRaw(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < rules_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, rules_.get(i)); + } + { + int dataSize = 0; + for (int i = 0; i < types_.size(); i++) { + dataSize += computeStringSizeNoTag(types_.getRaw(i)); + } + size += dataSize; + size += 1 * getTypesList().size(); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.CustomError parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.CustomError parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.CustomError parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.CustomError parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.CustomError parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.CustomError parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.CustomError parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.CustomError parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.CustomError parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.CustomError parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.CustomError prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.CustomError} + * + *
      +   * Customize service error responses.  For example, list any service
      +   * specific protobuf types that can appear in error detail lists of
      +   * error responses.
      +   * Example:
      +   *     custom_error:
      +   *       types:
      +   *       - google.foo.v1.CustomError
      +   *       - google.foo.v1.AnotherError
      +   * (-- For internal Google service producers, instead of listing such
      +   * custom error detail types in the YAML configuration file; Stubby
      +   * annotation can be used.  Please, see //google/api/annotations.proto
      +   * for more details. --)
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.CustomError) + com.google.api.CustomErrorOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.ErrorFormatProto.internal_static_google_api_CustomError_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.ErrorFormatProto.internal_static_google_api_CustomError_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.CustomError.class, com.google.api.CustomError.Builder.class); + } + + // Construct using com.google.api.CustomError.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getRulesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + rulesBuilder_.clear(); + } + types_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.ErrorFormatProto.internal_static_google_api_CustomError_descriptor; + } + + public com.google.api.CustomError getDefaultInstanceForType() { + return com.google.api.CustomError.getDefaultInstance(); + } + + public com.google.api.CustomError build() { + com.google.api.CustomError result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.CustomError buildPartial() { + com.google.api.CustomError result = new com.google.api.CustomError(this); + int from_bitField0_ = bitField0_; + if (rulesBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.rules_ = rules_; + } else { + result.rules_ = rulesBuilder_.build(); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + types_ = types_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.types_ = types_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.CustomError) { + return mergeFrom((com.google.api.CustomError)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.CustomError other) { + if (other == com.google.api.CustomError.getDefaultInstance()) return this; + if (rulesBuilder_ == null) { + if (!other.rules_.isEmpty()) { + if (rules_.isEmpty()) { + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureRulesIsMutable(); + rules_.addAll(other.rules_); + } + onChanged(); + } + } else { + if (!other.rules_.isEmpty()) { + if (rulesBuilder_.isEmpty()) { + rulesBuilder_.dispose(); + rulesBuilder_ = null; + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000001); + rulesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getRulesFieldBuilder() : null; + } else { + rulesBuilder_.addAllMessages(other.rules_); + } + } + } + if (!other.types_.isEmpty()) { + if (types_.isEmpty()) { + types_ = other.types_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureTypesIsMutable(); + types_.addAll(other.types_); + } + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.CustomError parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.CustomError) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List rules_ = + java.util.Collections.emptyList(); + private void ensureRulesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = new java.util.ArrayList(rules_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.CustomErrorRule, com.google.api.CustomErrorRule.Builder, com.google.api.CustomErrorRuleOrBuilder> rulesBuilder_; + + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public java.util.List getRulesList() { + if (rulesBuilder_ == null) { + return java.util.Collections.unmodifiableList(rules_); + } else { + return rulesBuilder_.getMessageList(); + } + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public int getRulesCount() { + if (rulesBuilder_ == null) { + return rules_.size(); + } else { + return rulesBuilder_.getCount(); + } + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public com.google.api.CustomErrorRule getRules(int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); + } else { + return rulesBuilder_.getMessage(index); + } + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public Builder setRules( + int index, com.google.api.CustomErrorRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.set(index, value); + onChanged(); + } else { + rulesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public Builder setRules( + int index, com.google.api.CustomErrorRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.set(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public Builder addRules(com.google.api.CustomErrorRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(value); + onChanged(); + } else { + rulesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public Builder addRules( + int index, com.google.api.CustomErrorRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(index, value); + onChanged(); + } else { + rulesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public Builder addRules( + com.google.api.CustomErrorRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public Builder addRules( + int index, com.google.api.CustomErrorRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public Builder addAllRules( + java.lang.Iterable values) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, rules_); + onChanged(); + } else { + rulesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public Builder clearRules() { + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + rulesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public Builder removeRules(int index) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.remove(index); + onChanged(); + } else { + rulesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public com.google.api.CustomErrorRule.Builder getRulesBuilder( + int index) { + return getRulesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public com.google.api.CustomErrorRuleOrBuilder getRulesOrBuilder( + int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); } else { + return rulesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public java.util.List + getRulesOrBuilderList() { + if (rulesBuilder_ != null) { + return rulesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(rules_); + } + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public com.google.api.CustomErrorRule.Builder addRulesBuilder() { + return getRulesFieldBuilder().addBuilder( + com.google.api.CustomErrorRule.getDefaultInstance()); + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public com.google.api.CustomErrorRule.Builder addRulesBuilder( + int index) { + return getRulesFieldBuilder().addBuilder( + index, com.google.api.CustomErrorRule.getDefaultInstance()); + } + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +     * The list of custom error rules to select to which messages this should
      +     * apply.
      +     * 
      + */ + public java.util.List + getRulesBuilderList() { + return getRulesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.CustomErrorRule, com.google.api.CustomErrorRule.Builder, com.google.api.CustomErrorRuleOrBuilder> + getRulesFieldBuilder() { + if (rulesBuilder_ == null) { + rulesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.api.CustomErrorRule, com.google.api.CustomErrorRule.Builder, com.google.api.CustomErrorRuleOrBuilder>( + rules_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + rules_ = null; + } + return rulesBuilder_; + } + + private com.google.protobuf.LazyStringList types_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureTypesIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + types_ = new com.google.protobuf.LazyStringArrayList(types_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated string types = 2; + * + *
      +     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +     * 
      + */ + public com.google.protobuf.ProtocolStringList + getTypesList() { + return types_.getUnmodifiableView(); + } + /** + * repeated string types = 2; + * + *
      +     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +     * 
      + */ + public int getTypesCount() { + return types_.size(); + } + /** + * repeated string types = 2; + * + *
      +     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +     * 
      + */ + public java.lang.String getTypes(int index) { + return types_.get(index); + } + /** + * repeated string types = 2; + * + *
      +     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +     * 
      + */ + public com.google.protobuf.ByteString + getTypesBytes(int index) { + return types_.getByteString(index); + } + /** + * repeated string types = 2; + * + *
      +     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +     * 
      + */ + public Builder setTypes( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureTypesIsMutable(); + types_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string types = 2; + * + *
      +     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +     * 
      + */ + public Builder addTypes( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureTypesIsMutable(); + types_.add(value); + onChanged(); + return this; + } + /** + * repeated string types = 2; + * + *
      +     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +     * 
      + */ + public Builder addAllTypes( + java.lang.Iterable values) { + ensureTypesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, types_); + onChanged(); + return this; + } + /** + * repeated string types = 2; + * + *
      +     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +     * 
      + */ + public Builder clearTypes() { + types_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * repeated string types = 2; + * + *
      +     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +     * 
      + */ + public Builder addTypesBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureTypesIsMutable(); + types_.add(value); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.CustomError) + } + + // @@protoc_insertion_point(class_scope:google.api.CustomError) + private static final com.google.api.CustomError DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.CustomError(); + } + + public static com.google.api.CustomError getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public CustomError parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new CustomError(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.CustomError getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorOrBuilder.java new file mode 100644 index 000000000000..9e7fc1d0b94d --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorOrBuilder.java @@ -0,0 +1,93 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/error.proto + +package com.google.api; + +public interface CustomErrorOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.CustomError) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +   * The list of custom error rules to select to which messages this should
      +   * apply.
      +   * 
      + */ + java.util.List + getRulesList(); + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +   * The list of custom error rules to select to which messages this should
      +   * apply.
      +   * 
      + */ + com.google.api.CustomErrorRule getRules(int index); + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +   * The list of custom error rules to select to which messages this should
      +   * apply.
      +   * 
      + */ + int getRulesCount(); + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +   * The list of custom error rules to select to which messages this should
      +   * apply.
      +   * 
      + */ + java.util.List + getRulesOrBuilderList(); + /** + * repeated .google.api.CustomErrorRule rules = 1; + * + *
      +   * The list of custom error rules to select to which messages this should
      +   * apply.
      +   * 
      + */ + com.google.api.CustomErrorRuleOrBuilder getRulesOrBuilder( + int index); + + /** + * repeated string types = 2; + * + *
      +   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +   * 
      + */ + com.google.protobuf.ProtocolStringList + getTypesList(); + /** + * repeated string types = 2; + * + *
      +   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +   * 
      + */ + int getTypesCount(); + /** + * repeated string types = 2; + * + *
      +   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +   * 
      + */ + java.lang.String getTypes(int index); + /** + * repeated string types = 2; + * + *
      +   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      +   * 
      + */ + com.google.protobuf.ByteString + getTypesBytes(int index); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRule.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRule.java new file mode 100644 index 000000000000..6f1333cb2e13 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRule.java @@ -0,0 +1,627 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/error.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.CustomErrorRule} + * + *
      + * A custom error rule.
      + * 
      + */ +public final class CustomErrorRule extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.CustomErrorRule) + CustomErrorRuleOrBuilder { + // Use CustomErrorRule.newBuilder() to construct. + private CustomErrorRule(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private CustomErrorRule() { + selector_ = ""; + stubbyBridge_ = 0; + isErrorType_ = false; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private CustomErrorRule( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + selector_ = s; + break; + } + case 16: { + + stubbyBridge_ = input.readInt32(); + break; + } + case 24: { + + isErrorType_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.ErrorFormatProto.internal_static_google_api_CustomErrorRule_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.ErrorFormatProto.internal_static_google_api_CustomErrorRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.CustomErrorRule.class, com.google.api.CustomErrorRule.Builder.class); + } + + public static final int SELECTOR_FIELD_NUMBER = 1; + private volatile java.lang.Object selector_; + /** + * optional string selector = 1; + * + *
      +   * Selects messages to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } + } + /** + * optional string selector = 1; + * + *
      +   * Selects messages to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STUBBY_BRIDGE_FIELD_NUMBER = 2; + private int stubbyBridge_; + /** + * optional int32 stubby_bridge = 2 [deprecated = true]; + * + *
      +   * (--The Stubby bridge of the message.--)
      +   * 
      + */ + @java.lang.Deprecated public int getStubbyBridge() { + return stubbyBridge_; + } + + public static final int IS_ERROR_TYPE_FIELD_NUMBER = 3; + private boolean isErrorType_; + /** + * optional bool is_error_type = 3; + * + *
      +   * Mark this message as possible payload in error response.  Otherwise,
      +   * objects of this type will be filtered when they appear in error payload.
      +   * 
      + */ + public boolean getIsErrorType() { + return isErrorType_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSelectorBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, selector_); + } + if (stubbyBridge_ != 0) { + output.writeInt32(2, stubbyBridge_); + } + if (isErrorType_ != false) { + output.writeBool(3, isErrorType_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSelectorBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, selector_); + } + if (stubbyBridge_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, stubbyBridge_); + } + if (isErrorType_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, isErrorType_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.CustomErrorRule parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.CustomErrorRule parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.CustomErrorRule parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.CustomErrorRule parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.CustomErrorRule parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.CustomErrorRule parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.CustomErrorRule parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.CustomErrorRule parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.CustomErrorRule parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.CustomErrorRule parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.CustomErrorRule prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.CustomErrorRule} + * + *
      +   * A custom error rule.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.CustomErrorRule) + com.google.api.CustomErrorRuleOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.ErrorFormatProto.internal_static_google_api_CustomErrorRule_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.ErrorFormatProto.internal_static_google_api_CustomErrorRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.CustomErrorRule.class, com.google.api.CustomErrorRule.Builder.class); + } + + // Construct using com.google.api.CustomErrorRule.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + selector_ = ""; + + stubbyBridge_ = 0; + + isErrorType_ = false; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.ErrorFormatProto.internal_static_google_api_CustomErrorRule_descriptor; + } + + public com.google.api.CustomErrorRule getDefaultInstanceForType() { + return com.google.api.CustomErrorRule.getDefaultInstance(); + } + + public com.google.api.CustomErrorRule build() { + com.google.api.CustomErrorRule result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.CustomErrorRule buildPartial() { + com.google.api.CustomErrorRule result = new com.google.api.CustomErrorRule(this); + result.selector_ = selector_; + result.stubbyBridge_ = stubbyBridge_; + result.isErrorType_ = isErrorType_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.CustomErrorRule) { + return mergeFrom((com.google.api.CustomErrorRule)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.CustomErrorRule other) { + if (other == com.google.api.CustomErrorRule.getDefaultInstance()) return this; + if (!other.getSelector().isEmpty()) { + selector_ = other.selector_; + onChanged(); + } + if (other.getStubbyBridge() != 0) { + setStubbyBridge(other.getStubbyBridge()); + } + if (other.getIsErrorType() != false) { + setIsErrorType(other.getIsErrorType()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.CustomErrorRule parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.CustomErrorRule) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object selector_ = ""; + /** + * optional string selector = 1; + * + *
      +     * Selects messages to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string selector = 1; + * + *
      +     * Selects messages to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string selector = 1; + * + *
      +     * Selects messages to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder setSelector( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + selector_ = value; + onChanged(); + return this; + } + /** + * optional string selector = 1; + * + *
      +     * Selects messages to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder clearSelector() { + + selector_ = getDefaultInstance().getSelector(); + onChanged(); + return this; + } + /** + * optional string selector = 1; + * + *
      +     * Selects messages to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder setSelectorBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + selector_ = value; + onChanged(); + return this; + } + + private int stubbyBridge_ ; + /** + * optional int32 stubby_bridge = 2 [deprecated = true]; + * + *
      +     * (--The Stubby bridge of the message.--)
      +     * 
      + */ + @java.lang.Deprecated public int getStubbyBridge() { + return stubbyBridge_; + } + /** + * optional int32 stubby_bridge = 2 [deprecated = true]; + * + *
      +     * (--The Stubby bridge of the message.--)
      +     * 
      + */ + @java.lang.Deprecated public Builder setStubbyBridge(int value) { + + stubbyBridge_ = value; + onChanged(); + return this; + } + /** + * optional int32 stubby_bridge = 2 [deprecated = true]; + * + *
      +     * (--The Stubby bridge of the message.--)
      +     * 
      + */ + @java.lang.Deprecated public Builder clearStubbyBridge() { + + stubbyBridge_ = 0; + onChanged(); + return this; + } + + private boolean isErrorType_ ; + /** + * optional bool is_error_type = 3; + * + *
      +     * Mark this message as possible payload in error response.  Otherwise,
      +     * objects of this type will be filtered when they appear in error payload.
      +     * 
      + */ + public boolean getIsErrorType() { + return isErrorType_; + } + /** + * optional bool is_error_type = 3; + * + *
      +     * Mark this message as possible payload in error response.  Otherwise,
      +     * objects of this type will be filtered when they appear in error payload.
      +     * 
      + */ + public Builder setIsErrorType(boolean value) { + + isErrorType_ = value; + onChanged(); + return this; + } + /** + * optional bool is_error_type = 3; + * + *
      +     * Mark this message as possible payload in error response.  Otherwise,
      +     * objects of this type will be filtered when they appear in error payload.
      +     * 
      + */ + public Builder clearIsErrorType() { + + isErrorType_ = false; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.CustomErrorRule) + } + + // @@protoc_insertion_point(class_scope:google.api.CustomErrorRule) + private static final com.google.api.CustomErrorRule DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.CustomErrorRule(); + } + + public static com.google.api.CustomErrorRule getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public CustomErrorRule parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new CustomErrorRule(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.CustomErrorRule getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRuleOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRuleOrBuilder.java new file mode 100644 index 000000000000..a4746577b373 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRuleOrBuilder.java @@ -0,0 +1,48 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/error.proto + +package com.google.api; + +public interface CustomErrorRuleOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.CustomErrorRule) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string selector = 1; + * + *
      +   * Selects messages to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + java.lang.String getSelector(); + /** + * optional string selector = 1; + * + *
      +   * Selects messages to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + com.google.protobuf.ByteString + getSelectorBytes(); + + /** + * optional int32 stubby_bridge = 2 [deprecated = true]; + * + *
      +   * (--The Stubby bridge of the message.--)
      +   * 
      + */ + @java.lang.Deprecated int getStubbyBridge(); + + /** + * optional bool is_error_type = 3; + * + *
      +   * Mark this message as possible payload in error response.  Otherwise,
      +   * objects of this type will be filtered when they appear in error payload.
      +   * 
      + */ + boolean getIsErrorType(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPattern.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPattern.java new file mode 100644 index 000000000000..e3a51cd280c7 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPattern.java @@ -0,0 +1,627 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.CustomHttpPattern} + * + *
      + * A custom pattern is used for defining custom HTTP verb.
      + * 
      + */ +public final class CustomHttpPattern extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.CustomHttpPattern) + CustomHttpPatternOrBuilder { + // Use CustomHttpPattern.newBuilder() to construct. + private CustomHttpPattern(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private CustomHttpPattern() { + kind_ = ""; + path_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private CustomHttpPattern( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + kind_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + path_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.HttpProto.internal_static_google_api_CustomHttpPattern_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.HttpProto.internal_static_google_api_CustomHttpPattern_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.CustomHttpPattern.class, com.google.api.CustomHttpPattern.Builder.class); + } + + public static final int KIND_FIELD_NUMBER = 1; + private volatile java.lang.Object kind_; + /** + * optional string kind = 1; + * + *
      +   * The name of this custom HTTP verb.
      +   * 
      + */ + public java.lang.String getKind() { + java.lang.Object ref = kind_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + kind_ = s; + return s; + } + } + /** + * optional string kind = 1; + * + *
      +   * The name of this custom HTTP verb.
      +   * 
      + */ + public com.google.protobuf.ByteString + getKindBytes() { + java.lang.Object ref = kind_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + kind_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PATH_FIELD_NUMBER = 2; + private volatile java.lang.Object path_; + /** + * optional string path = 2; + * + *
      +   * The path matched by this custom verb.
      +   * 
      + */ + public java.lang.String getPath() { + java.lang.Object ref = path_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + path_ = s; + return s; + } + } + /** + * optional string path = 2; + * + *
      +   * The path matched by this custom verb.
      +   * 
      + */ + public com.google.protobuf.ByteString + getPathBytes() { + java.lang.Object ref = path_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + path_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getKindBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, kind_); + } + if (!getPathBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, path_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getKindBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, kind_); + } + if (!getPathBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, path_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.CustomHttpPattern parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.CustomHttpPattern parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.CustomHttpPattern parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.CustomHttpPattern parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.CustomHttpPattern parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.CustomHttpPattern parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.CustomHttpPattern parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.CustomHttpPattern parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.CustomHttpPattern parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.CustomHttpPattern parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.CustomHttpPattern prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.CustomHttpPattern} + * + *
      +   * A custom pattern is used for defining custom HTTP verb.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.CustomHttpPattern) + com.google.api.CustomHttpPatternOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.HttpProto.internal_static_google_api_CustomHttpPattern_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.HttpProto.internal_static_google_api_CustomHttpPattern_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.CustomHttpPattern.class, com.google.api.CustomHttpPattern.Builder.class); + } + + // Construct using com.google.api.CustomHttpPattern.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + kind_ = ""; + + path_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.HttpProto.internal_static_google_api_CustomHttpPattern_descriptor; + } + + public com.google.api.CustomHttpPattern getDefaultInstanceForType() { + return com.google.api.CustomHttpPattern.getDefaultInstance(); + } + + public com.google.api.CustomHttpPattern build() { + com.google.api.CustomHttpPattern result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.CustomHttpPattern buildPartial() { + com.google.api.CustomHttpPattern result = new com.google.api.CustomHttpPattern(this); + result.kind_ = kind_; + result.path_ = path_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.CustomHttpPattern) { + return mergeFrom((com.google.api.CustomHttpPattern)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.CustomHttpPattern other) { + if (other == com.google.api.CustomHttpPattern.getDefaultInstance()) return this; + if (!other.getKind().isEmpty()) { + kind_ = other.kind_; + onChanged(); + } + if (!other.getPath().isEmpty()) { + path_ = other.path_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.CustomHttpPattern parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.CustomHttpPattern) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object kind_ = ""; + /** + * optional string kind = 1; + * + *
      +     * The name of this custom HTTP verb.
      +     * 
      + */ + public java.lang.String getKind() { + java.lang.Object ref = kind_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + kind_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string kind = 1; + * + *
      +     * The name of this custom HTTP verb.
      +     * 
      + */ + public com.google.protobuf.ByteString + getKindBytes() { + java.lang.Object ref = kind_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + kind_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string kind = 1; + * + *
      +     * The name of this custom HTTP verb.
      +     * 
      + */ + public Builder setKind( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + kind_ = value; + onChanged(); + return this; + } + /** + * optional string kind = 1; + * + *
      +     * The name of this custom HTTP verb.
      +     * 
      + */ + public Builder clearKind() { + + kind_ = getDefaultInstance().getKind(); + onChanged(); + return this; + } + /** + * optional string kind = 1; + * + *
      +     * The name of this custom HTTP verb.
      +     * 
      + */ + public Builder setKindBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + kind_ = value; + onChanged(); + return this; + } + + private java.lang.Object path_ = ""; + /** + * optional string path = 2; + * + *
      +     * The path matched by this custom verb.
      +     * 
      + */ + public java.lang.String getPath() { + java.lang.Object ref = path_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + path_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string path = 2; + * + *
      +     * The path matched by this custom verb.
      +     * 
      + */ + public com.google.protobuf.ByteString + getPathBytes() { + java.lang.Object ref = path_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + path_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string path = 2; + * + *
      +     * The path matched by this custom verb.
      +     * 
      + */ + public Builder setPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + path_ = value; + onChanged(); + return this; + } + /** + * optional string path = 2; + * + *
      +     * The path matched by this custom verb.
      +     * 
      + */ + public Builder clearPath() { + + path_ = getDefaultInstance().getPath(); + onChanged(); + return this; + } + /** + * optional string path = 2; + * + *
      +     * The path matched by this custom verb.
      +     * 
      + */ + public Builder setPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + path_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.CustomHttpPattern) + } + + // @@protoc_insertion_point(class_scope:google.api.CustomHttpPattern) + private static final com.google.api.CustomHttpPattern DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.CustomHttpPattern(); + } + + public static com.google.api.CustomHttpPattern getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public CustomHttpPattern parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new CustomHttpPattern(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.CustomHttpPattern getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPatternOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPatternOrBuilder.java new file mode 100644 index 000000000000..e45514be7749 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPatternOrBuilder.java @@ -0,0 +1,45 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +public interface CustomHttpPatternOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.CustomHttpPattern) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string kind = 1; + * + *
      +   * The name of this custom HTTP verb.
      +   * 
      + */ + java.lang.String getKind(); + /** + * optional string kind = 1; + * + *
      +   * The name of this custom HTTP verb.
      +   * 
      + */ + com.google.protobuf.ByteString + getKindBytes(); + + /** + * optional string path = 2; + * + *
      +   * The path matched by this custom verb.
      +   * 
      + */ + java.lang.String getPath(); + /** + * optional string path = 2; + * + *
      +   * The path matched by this custom verb.
      +   * 
      + */ + com.google.protobuf.ByteString + getPathBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Documentation.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Documentation.java new file mode 100644 index 000000000000..544435e99564 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/Documentation.java @@ -0,0 +1,1816 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/documentation.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.Documentation} + * + *
      + * `Documentation` provides the information for describing a service.
      + * Example:
      + *     documentation:
      + *       summary: >
      + *         The Google Calendar API gives access
      + *         to most calendar features.
      + *       pages:
      + *       - name: Overview
      + *         content: (== include google/foo/overview.md ==)
      + *       - name: Tutorial
      + *         content: (== include google/foo/tutorial.md ==)
      + *         subpages;
      + *         - name: Java
      + *           content: (== include google/foo/tutorial_java.md ==)
      + *       rules:
      + *       - selector: google.calendar.Calendar.Get
      + *         description: >
      + *           ...
      + *       - selector: google.calendar.Calendar.Put
      + *         description: >
      + *           ...
      + * Documentation is provided in markdown syntax. In addition to
      + * standard markdown features, definition lists, tables and fenced
      + * code blocks are supported. Section headers can be provided and are
      + * interpreted relative to the section nesting of the context where
      + * a documentation fragment is embedded.
      + * Documentation from the IDL is merged with documentation defined
      + * via the config at normalization time, where documentation provided
      + * by config rules overrides IDL provided.
      + * A number of constructs specific to the API platform are supported
      + * in documentation text.
      + * In order to reference a proto element, the following
      + * notation can be used:
      + * <pre><code>&#91;display text]&#91;fully.qualified.proto.name]
      + * &#91;fully.qualified.proto.name]&#91;]</code></pre>
      + * Text can be excluded from doc using the following notation:
      + * <pre><code>&#40;-- internal comment --&#41;</code></pre>
      + * Comments can be made conditional using a visibility label. The below
      + * text will be only rendered if the `BETA` label is available:
      + * <pre><code>&#40;--BETA: comment for BETA users --&#41;</code></pre>
      + * A few directives are available in documentation. Note that
      + * directives must appear on a single line to be properly
      + * identified. The `include` directive includes a markdown file from
      + * an external source:
      + *     (== include path/to/file> ==)
      + * The `resource_for` directive marks a message to be the resource of
      + * a collection in REST view. If it is not specified, tools attempt
      + * to infer the resource from the operations in a collection:
      + *     (== resource_for v1.shelves.books ==)
      + * The directive `suppress_warning` is not directly effecting documentation
      + * and is documented together with service config validation.
      + * 
      + */ +public final class Documentation extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.Documentation) + DocumentationOrBuilder { + // Use Documentation.newBuilder() to construct. + private Documentation(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Documentation() { + summary_ = ""; + pages_ = java.util.Collections.emptyList(); + rules_ = java.util.Collections.emptyList(); + documentationRootUrl_ = ""; + overview_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Documentation( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + summary_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + overview_ = s; + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + rules_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + rules_.add(input.readMessage(com.google.api.DocumentationRule.parser(), extensionRegistry)); + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + documentationRootUrl_ = s; + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + pages_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + pages_.add(input.readMessage(com.google.api.Page.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + } + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + pages_ = java.util.Collections.unmodifiableList(pages_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.DocumentationProto.internal_static_google_api_Documentation_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.DocumentationProto.internal_static_google_api_Documentation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Documentation.class, com.google.api.Documentation.Builder.class); + } + + private int bitField0_; + public static final int SUMMARY_FIELD_NUMBER = 1; + private volatile java.lang.Object summary_; + /** + * optional string summary = 1; + * + *
      +   * A short summary of what the service does. Can only be provided by
      +   * plain text.
      +   * 
      + */ + public java.lang.String getSummary() { + java.lang.Object ref = summary_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + summary_ = s; + return s; + } + } + /** + * optional string summary = 1; + * + *
      +   * A short summary of what the service does. Can only be provided by
      +   * plain text.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSummaryBytes() { + java.lang.Object ref = summary_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + summary_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGES_FIELD_NUMBER = 5; + private java.util.List pages_; + /** + * repeated .google.api.Page pages = 5; + * + *
      +   * The top level pages for the documentation set.
      +   * 
      + */ + public java.util.List getPagesList() { + return pages_; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +   * The top level pages for the documentation set.
      +   * 
      + */ + public java.util.List + getPagesOrBuilderList() { + return pages_; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +   * The top level pages for the documentation set.
      +   * 
      + */ + public int getPagesCount() { + return pages_.size(); + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +   * The top level pages for the documentation set.
      +   * 
      + */ + public com.google.api.Page getPages(int index) { + return pages_.get(index); + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +   * The top level pages for the documentation set.
      +   * 
      + */ + public com.google.api.PageOrBuilder getPagesOrBuilder( + int index) { + return pages_.get(index); + } + + public static final int RULES_FIELD_NUMBER = 3; + private java.util.List rules_; + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +   * Documentation rules for individual elements of the service.
      +   * 
      + */ + public java.util.List getRulesList() { + return rules_; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +   * Documentation rules for individual elements of the service.
      +   * 
      + */ + public java.util.List + getRulesOrBuilderList() { + return rules_; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +   * Documentation rules for individual elements of the service.
      +   * 
      + */ + public int getRulesCount() { + return rules_.size(); + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +   * Documentation rules for individual elements of the service.
      +   * 
      + */ + public com.google.api.DocumentationRule getRules(int index) { + return rules_.get(index); + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +   * Documentation rules for individual elements of the service.
      +   * 
      + */ + public com.google.api.DocumentationRuleOrBuilder getRulesOrBuilder( + int index) { + return rules_.get(index); + } + + public static final int DOCUMENTATION_ROOT_URL_FIELD_NUMBER = 4; + private volatile java.lang.Object documentationRootUrl_; + /** + * optional string documentation_root_url = 4; + * + *
      +   * The URL to the root of documentation.
      +   * 
      + */ + public java.lang.String getDocumentationRootUrl() { + java.lang.Object ref = documentationRootUrl_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + documentationRootUrl_ = s; + return s; + } + } + /** + * optional string documentation_root_url = 4; + * + *
      +   * The URL to the root of documentation.
      +   * 
      + */ + public com.google.protobuf.ByteString + getDocumentationRootUrlBytes() { + java.lang.Object ref = documentationRootUrl_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + documentationRootUrl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int OVERVIEW_FIELD_NUMBER = 2; + private volatile java.lang.Object overview_; + /** + * optional string overview = 2; + * + *
      +   * Declares a single overview page. For example:
      +   *     documentation:
      +   *       summary: ...
      +   *       overview: (== include overview.md ==)
      +   * This is a shortcut for the following declaration (using pages style):
      +   *     documentation:
      +   *       summary: ...
      +   *       pages:
      +   *       - name: Overview
      +   *         content: (== include overview.md ==)
      +   * Note: you cannot specify both `overview` field and `pages` field.
      +   * 
      + */ + public java.lang.String getOverview() { + java.lang.Object ref = overview_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + overview_ = s; + return s; + } + } + /** + * optional string overview = 2; + * + *
      +   * Declares a single overview page. For example:
      +   *     documentation:
      +   *       summary: ...
      +   *       overview: (== include overview.md ==)
      +   * This is a shortcut for the following declaration (using pages style):
      +   *     documentation:
      +   *       summary: ...
      +   *       pages:
      +   *       - name: Overview
      +   *         content: (== include overview.md ==)
      +   * Note: you cannot specify both `overview` field and `pages` field.
      +   * 
      + */ + public com.google.protobuf.ByteString + getOverviewBytes() { + java.lang.Object ref = overview_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + overview_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSummaryBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, summary_); + } + if (!getOverviewBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, overview_); + } + for (int i = 0; i < rules_.size(); i++) { + output.writeMessage(3, rules_.get(i)); + } + if (!getDocumentationRootUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, documentationRootUrl_); + } + for (int i = 0; i < pages_.size(); i++) { + output.writeMessage(5, pages_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSummaryBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, summary_); + } + if (!getOverviewBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, overview_); + } + for (int i = 0; i < rules_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, rules_.get(i)); + } + if (!getDocumentationRootUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, documentationRootUrl_); + } + for (int i = 0; i < pages_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, pages_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.Documentation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Documentation parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Documentation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Documentation parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Documentation parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Documentation parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.Documentation parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.Documentation parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.Documentation parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Documentation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.Documentation prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.Documentation} + * + *
      +   * `Documentation` provides the information for describing a service.
      +   * Example:
      +   *     documentation:
      +   *       summary: >
      +   *         The Google Calendar API gives access
      +   *         to most calendar features.
      +   *       pages:
      +   *       - name: Overview
      +   *         content: (== include google/foo/overview.md ==)
      +   *       - name: Tutorial
      +   *         content: (== include google/foo/tutorial.md ==)
      +   *         subpages;
      +   *         - name: Java
      +   *           content: (== include google/foo/tutorial_java.md ==)
      +   *       rules:
      +   *       - selector: google.calendar.Calendar.Get
      +   *         description: >
      +   *           ...
      +   *       - selector: google.calendar.Calendar.Put
      +   *         description: >
      +   *           ...
      +   * Documentation is provided in markdown syntax. In addition to
      +   * standard markdown features, definition lists, tables and fenced
      +   * code blocks are supported. Section headers can be provided and are
      +   * interpreted relative to the section nesting of the context where
      +   * a documentation fragment is embedded.
      +   * Documentation from the IDL is merged with documentation defined
      +   * via the config at normalization time, where documentation provided
      +   * by config rules overrides IDL provided.
      +   * A number of constructs specific to the API platform are supported
      +   * in documentation text.
      +   * In order to reference a proto element, the following
      +   * notation can be used:
      +   * <pre><code>&#91;display text]&#91;fully.qualified.proto.name]
      +   * &#91;fully.qualified.proto.name]&#91;]</code></pre>
      +   * Text can be excluded from doc using the following notation:
      +   * <pre><code>&#40;-- internal comment --&#41;</code></pre>
      +   * Comments can be made conditional using a visibility label. The below
      +   * text will be only rendered if the `BETA` label is available:
      +   * <pre><code>&#40;--BETA: comment for BETA users --&#41;</code></pre>
      +   * A few directives are available in documentation. Note that
      +   * directives must appear on a single line to be properly
      +   * identified. The `include` directive includes a markdown file from
      +   * an external source:
      +   *     (== include path/to/file> ==)
      +   * The `resource_for` directive marks a message to be the resource of
      +   * a collection in REST view. If it is not specified, tools attempt
      +   * to infer the resource from the operations in a collection:
      +   *     (== resource_for v1.shelves.books ==)
      +   * The directive `suppress_warning` is not directly effecting documentation
      +   * and is documented together with service config validation.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.Documentation) + com.google.api.DocumentationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.DocumentationProto.internal_static_google_api_Documentation_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.DocumentationProto.internal_static_google_api_Documentation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Documentation.class, com.google.api.Documentation.Builder.class); + } + + // Construct using com.google.api.Documentation.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPagesFieldBuilder(); + getRulesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + summary_ = ""; + + if (pagesBuilder_ == null) { + pages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + pagesBuilder_.clear(); + } + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + rulesBuilder_.clear(); + } + documentationRootUrl_ = ""; + + overview_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.DocumentationProto.internal_static_google_api_Documentation_descriptor; + } + + public com.google.api.Documentation getDefaultInstanceForType() { + return com.google.api.Documentation.getDefaultInstance(); + } + + public com.google.api.Documentation build() { + com.google.api.Documentation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.Documentation buildPartial() { + com.google.api.Documentation result = new com.google.api.Documentation(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.summary_ = summary_; + if (pagesBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + pages_ = java.util.Collections.unmodifiableList(pages_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.pages_ = pages_; + } else { + result.pages_ = pagesBuilder_.build(); + } + if (rulesBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.rules_ = rules_; + } else { + result.rules_ = rulesBuilder_.build(); + } + result.documentationRootUrl_ = documentationRootUrl_; + result.overview_ = overview_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.Documentation) { + return mergeFrom((com.google.api.Documentation)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.Documentation other) { + if (other == com.google.api.Documentation.getDefaultInstance()) return this; + if (!other.getSummary().isEmpty()) { + summary_ = other.summary_; + onChanged(); + } + if (pagesBuilder_ == null) { + if (!other.pages_.isEmpty()) { + if (pages_.isEmpty()) { + pages_ = other.pages_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensurePagesIsMutable(); + pages_.addAll(other.pages_); + } + onChanged(); + } + } else { + if (!other.pages_.isEmpty()) { + if (pagesBuilder_.isEmpty()) { + pagesBuilder_.dispose(); + pagesBuilder_ = null; + pages_ = other.pages_; + bitField0_ = (bitField0_ & ~0x00000002); + pagesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getPagesFieldBuilder() : null; + } else { + pagesBuilder_.addAllMessages(other.pages_); + } + } + } + if (rulesBuilder_ == null) { + if (!other.rules_.isEmpty()) { + if (rules_.isEmpty()) { + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureRulesIsMutable(); + rules_.addAll(other.rules_); + } + onChanged(); + } + } else { + if (!other.rules_.isEmpty()) { + if (rulesBuilder_.isEmpty()) { + rulesBuilder_.dispose(); + rulesBuilder_ = null; + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000004); + rulesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getRulesFieldBuilder() : null; + } else { + rulesBuilder_.addAllMessages(other.rules_); + } + } + } + if (!other.getDocumentationRootUrl().isEmpty()) { + documentationRootUrl_ = other.documentationRootUrl_; + onChanged(); + } + if (!other.getOverview().isEmpty()) { + overview_ = other.overview_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.Documentation parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.Documentation) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object summary_ = ""; + /** + * optional string summary = 1; + * + *
      +     * A short summary of what the service does. Can only be provided by
      +     * plain text.
      +     * 
      + */ + public java.lang.String getSummary() { + java.lang.Object ref = summary_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + summary_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string summary = 1; + * + *
      +     * A short summary of what the service does. Can only be provided by
      +     * plain text.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSummaryBytes() { + java.lang.Object ref = summary_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + summary_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string summary = 1; + * + *
      +     * A short summary of what the service does. Can only be provided by
      +     * plain text.
      +     * 
      + */ + public Builder setSummary( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + summary_ = value; + onChanged(); + return this; + } + /** + * optional string summary = 1; + * + *
      +     * A short summary of what the service does. Can only be provided by
      +     * plain text.
      +     * 
      + */ + public Builder clearSummary() { + + summary_ = getDefaultInstance().getSummary(); + onChanged(); + return this; + } + /** + * optional string summary = 1; + * + *
      +     * A short summary of what the service does. Can only be provided by
      +     * plain text.
      +     * 
      + */ + public Builder setSummaryBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + summary_ = value; + onChanged(); + return this; + } + + private java.util.List pages_ = + java.util.Collections.emptyList(); + private void ensurePagesIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + pages_ = new java.util.ArrayList(pages_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder> pagesBuilder_; + + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public java.util.List getPagesList() { + if (pagesBuilder_ == null) { + return java.util.Collections.unmodifiableList(pages_); + } else { + return pagesBuilder_.getMessageList(); + } + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public int getPagesCount() { + if (pagesBuilder_ == null) { + return pages_.size(); + } else { + return pagesBuilder_.getCount(); + } + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public com.google.api.Page getPages(int index) { + if (pagesBuilder_ == null) { + return pages_.get(index); + } else { + return pagesBuilder_.getMessage(index); + } + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public Builder setPages( + int index, com.google.api.Page value) { + if (pagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePagesIsMutable(); + pages_.set(index, value); + onChanged(); + } else { + pagesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public Builder setPages( + int index, com.google.api.Page.Builder builderForValue) { + if (pagesBuilder_ == null) { + ensurePagesIsMutable(); + pages_.set(index, builderForValue.build()); + onChanged(); + } else { + pagesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public Builder addPages(com.google.api.Page value) { + if (pagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePagesIsMutable(); + pages_.add(value); + onChanged(); + } else { + pagesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public Builder addPages( + int index, com.google.api.Page value) { + if (pagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePagesIsMutable(); + pages_.add(index, value); + onChanged(); + } else { + pagesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public Builder addPages( + com.google.api.Page.Builder builderForValue) { + if (pagesBuilder_ == null) { + ensurePagesIsMutable(); + pages_.add(builderForValue.build()); + onChanged(); + } else { + pagesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public Builder addPages( + int index, com.google.api.Page.Builder builderForValue) { + if (pagesBuilder_ == null) { + ensurePagesIsMutable(); + pages_.add(index, builderForValue.build()); + onChanged(); + } else { + pagesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public Builder addAllPages( + java.lang.Iterable values) { + if (pagesBuilder_ == null) { + ensurePagesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, pages_); + onChanged(); + } else { + pagesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public Builder clearPages() { + if (pagesBuilder_ == null) { + pages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + pagesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public Builder removePages(int index) { + if (pagesBuilder_ == null) { + ensurePagesIsMutable(); + pages_.remove(index); + onChanged(); + } else { + pagesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public com.google.api.Page.Builder getPagesBuilder( + int index) { + return getPagesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public com.google.api.PageOrBuilder getPagesOrBuilder( + int index) { + if (pagesBuilder_ == null) { + return pages_.get(index); } else { + return pagesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public java.util.List + getPagesOrBuilderList() { + if (pagesBuilder_ != null) { + return pagesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(pages_); + } + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public com.google.api.Page.Builder addPagesBuilder() { + return getPagesFieldBuilder().addBuilder( + com.google.api.Page.getDefaultInstance()); + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public com.google.api.Page.Builder addPagesBuilder( + int index) { + return getPagesFieldBuilder().addBuilder( + index, com.google.api.Page.getDefaultInstance()); + } + /** + * repeated .google.api.Page pages = 5; + * + *
      +     * The top level pages for the documentation set.
      +     * 
      + */ + public java.util.List + getPagesBuilderList() { + return getPagesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder> + getPagesFieldBuilder() { + if (pagesBuilder_ == null) { + pagesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder>( + pages_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + pages_ = null; + } + return pagesBuilder_; + } + + private java.util.List rules_ = + java.util.Collections.emptyList(); + private void ensureRulesIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + rules_ = new java.util.ArrayList(rules_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.DocumentationRule, com.google.api.DocumentationRule.Builder, com.google.api.DocumentationRuleOrBuilder> rulesBuilder_; + + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public java.util.List getRulesList() { + if (rulesBuilder_ == null) { + return java.util.Collections.unmodifiableList(rules_); + } else { + return rulesBuilder_.getMessageList(); + } + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public int getRulesCount() { + if (rulesBuilder_ == null) { + return rules_.size(); + } else { + return rulesBuilder_.getCount(); + } + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public com.google.api.DocumentationRule getRules(int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); + } else { + return rulesBuilder_.getMessage(index); + } + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public Builder setRules( + int index, com.google.api.DocumentationRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.set(index, value); + onChanged(); + } else { + rulesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public Builder setRules( + int index, com.google.api.DocumentationRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.set(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public Builder addRules(com.google.api.DocumentationRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(value); + onChanged(); + } else { + rulesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public Builder addRules( + int index, com.google.api.DocumentationRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(index, value); + onChanged(); + } else { + rulesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public Builder addRules( + com.google.api.DocumentationRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public Builder addRules( + int index, com.google.api.DocumentationRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public Builder addAllRules( + java.lang.Iterable values) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, rules_); + onChanged(); + } else { + rulesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public Builder clearRules() { + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + rulesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public Builder removeRules(int index) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.remove(index); + onChanged(); + } else { + rulesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public com.google.api.DocumentationRule.Builder getRulesBuilder( + int index) { + return getRulesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public com.google.api.DocumentationRuleOrBuilder getRulesOrBuilder( + int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); } else { + return rulesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public java.util.List + getRulesOrBuilderList() { + if (rulesBuilder_ != null) { + return rulesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(rules_); + } + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public com.google.api.DocumentationRule.Builder addRulesBuilder() { + return getRulesFieldBuilder().addBuilder( + com.google.api.DocumentationRule.getDefaultInstance()); + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public com.google.api.DocumentationRule.Builder addRulesBuilder( + int index) { + return getRulesFieldBuilder().addBuilder( + index, com.google.api.DocumentationRule.getDefaultInstance()); + } + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +     * Documentation rules for individual elements of the service.
      +     * 
      + */ + public java.util.List + getRulesBuilderList() { + return getRulesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.DocumentationRule, com.google.api.DocumentationRule.Builder, com.google.api.DocumentationRuleOrBuilder> + getRulesFieldBuilder() { + if (rulesBuilder_ == null) { + rulesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.api.DocumentationRule, com.google.api.DocumentationRule.Builder, com.google.api.DocumentationRuleOrBuilder>( + rules_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + rules_ = null; + } + return rulesBuilder_; + } + + private java.lang.Object documentationRootUrl_ = ""; + /** + * optional string documentation_root_url = 4; + * + *
      +     * The URL to the root of documentation.
      +     * 
      + */ + public java.lang.String getDocumentationRootUrl() { + java.lang.Object ref = documentationRootUrl_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + documentationRootUrl_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string documentation_root_url = 4; + * + *
      +     * The URL to the root of documentation.
      +     * 
      + */ + public com.google.protobuf.ByteString + getDocumentationRootUrlBytes() { + java.lang.Object ref = documentationRootUrl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + documentationRootUrl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string documentation_root_url = 4; + * + *
      +     * The URL to the root of documentation.
      +     * 
      + */ + public Builder setDocumentationRootUrl( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + documentationRootUrl_ = value; + onChanged(); + return this; + } + /** + * optional string documentation_root_url = 4; + * + *
      +     * The URL to the root of documentation.
      +     * 
      + */ + public Builder clearDocumentationRootUrl() { + + documentationRootUrl_ = getDefaultInstance().getDocumentationRootUrl(); + onChanged(); + return this; + } + /** + * optional string documentation_root_url = 4; + * + *
      +     * The URL to the root of documentation.
      +     * 
      + */ + public Builder setDocumentationRootUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + documentationRootUrl_ = value; + onChanged(); + return this; + } + + private java.lang.Object overview_ = ""; + /** + * optional string overview = 2; + * + *
      +     * Declares a single overview page. For example:
      +     *     documentation:
      +     *       summary: ...
      +     *       overview: (== include overview.md ==)
      +     * This is a shortcut for the following declaration (using pages style):
      +     *     documentation:
      +     *       summary: ...
      +     *       pages:
      +     *       - name: Overview
      +     *         content: (== include overview.md ==)
      +     * Note: you cannot specify both `overview` field and `pages` field.
      +     * 
      + */ + public java.lang.String getOverview() { + java.lang.Object ref = overview_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + overview_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string overview = 2; + * + *
      +     * Declares a single overview page. For example:
      +     *     documentation:
      +     *       summary: ...
      +     *       overview: (== include overview.md ==)
      +     * This is a shortcut for the following declaration (using pages style):
      +     *     documentation:
      +     *       summary: ...
      +     *       pages:
      +     *       - name: Overview
      +     *         content: (== include overview.md ==)
      +     * Note: you cannot specify both `overview` field and `pages` field.
      +     * 
      + */ + public com.google.protobuf.ByteString + getOverviewBytes() { + java.lang.Object ref = overview_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + overview_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string overview = 2; + * + *
      +     * Declares a single overview page. For example:
      +     *     documentation:
      +     *       summary: ...
      +     *       overview: (== include overview.md ==)
      +     * This is a shortcut for the following declaration (using pages style):
      +     *     documentation:
      +     *       summary: ...
      +     *       pages:
      +     *       - name: Overview
      +     *         content: (== include overview.md ==)
      +     * Note: you cannot specify both `overview` field and `pages` field.
      +     * 
      + */ + public Builder setOverview( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + overview_ = value; + onChanged(); + return this; + } + /** + * optional string overview = 2; + * + *
      +     * Declares a single overview page. For example:
      +     *     documentation:
      +     *       summary: ...
      +     *       overview: (== include overview.md ==)
      +     * This is a shortcut for the following declaration (using pages style):
      +     *     documentation:
      +     *       summary: ...
      +     *       pages:
      +     *       - name: Overview
      +     *         content: (== include overview.md ==)
      +     * Note: you cannot specify both `overview` field and `pages` field.
      +     * 
      + */ + public Builder clearOverview() { + + overview_ = getDefaultInstance().getOverview(); + onChanged(); + return this; + } + /** + * optional string overview = 2; + * + *
      +     * Declares a single overview page. For example:
      +     *     documentation:
      +     *       summary: ...
      +     *       overview: (== include overview.md ==)
      +     * This is a shortcut for the following declaration (using pages style):
      +     *     documentation:
      +     *       summary: ...
      +     *       pages:
      +     *       - name: Overview
      +     *         content: (== include overview.md ==)
      +     * Note: you cannot specify both `overview` field and `pages` field.
      +     * 
      + */ + public Builder setOverviewBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + overview_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.Documentation) + } + + // @@protoc_insertion_point(class_scope:google.api.Documentation) + private static final com.google.api.Documentation DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.Documentation(); + } + + public static com.google.api.Documentation getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Documentation parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Documentation(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.Documentation getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationOrBuilder.java new file mode 100644 index 000000000000..96368c4a792b --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationOrBuilder.java @@ -0,0 +1,173 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/documentation.proto + +package com.google.api; + +public interface DocumentationOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.Documentation) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string summary = 1; + * + *
      +   * A short summary of what the service does. Can only be provided by
      +   * plain text.
      +   * 
      + */ + java.lang.String getSummary(); + /** + * optional string summary = 1; + * + *
      +   * A short summary of what the service does. Can only be provided by
      +   * plain text.
      +   * 
      + */ + com.google.protobuf.ByteString + getSummaryBytes(); + + /** + * repeated .google.api.Page pages = 5; + * + *
      +   * The top level pages for the documentation set.
      +   * 
      + */ + java.util.List + getPagesList(); + /** + * repeated .google.api.Page pages = 5; + * + *
      +   * The top level pages for the documentation set.
      +   * 
      + */ + com.google.api.Page getPages(int index); + /** + * repeated .google.api.Page pages = 5; + * + *
      +   * The top level pages for the documentation set.
      +   * 
      + */ + int getPagesCount(); + /** + * repeated .google.api.Page pages = 5; + * + *
      +   * The top level pages for the documentation set.
      +   * 
      + */ + java.util.List + getPagesOrBuilderList(); + /** + * repeated .google.api.Page pages = 5; + * + *
      +   * The top level pages for the documentation set.
      +   * 
      + */ + com.google.api.PageOrBuilder getPagesOrBuilder( + int index); + + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +   * Documentation rules for individual elements of the service.
      +   * 
      + */ + java.util.List + getRulesList(); + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +   * Documentation rules for individual elements of the service.
      +   * 
      + */ + com.google.api.DocumentationRule getRules(int index); + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +   * Documentation rules for individual elements of the service.
      +   * 
      + */ + int getRulesCount(); + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +   * Documentation rules for individual elements of the service.
      +   * 
      + */ + java.util.List + getRulesOrBuilderList(); + /** + * repeated .google.api.DocumentationRule rules = 3; + * + *
      +   * Documentation rules for individual elements of the service.
      +   * 
      + */ + com.google.api.DocumentationRuleOrBuilder getRulesOrBuilder( + int index); + + /** + * optional string documentation_root_url = 4; + * + *
      +   * The URL to the root of documentation.
      +   * 
      + */ + java.lang.String getDocumentationRootUrl(); + /** + * optional string documentation_root_url = 4; + * + *
      +   * The URL to the root of documentation.
      +   * 
      + */ + com.google.protobuf.ByteString + getDocumentationRootUrlBytes(); + + /** + * optional string overview = 2; + * + *
      +   * Declares a single overview page. For example:
      +   *     documentation:
      +   *       summary: ...
      +   *       overview: (== include overview.md ==)
      +   * This is a shortcut for the following declaration (using pages style):
      +   *     documentation:
      +   *       summary: ...
      +   *       pages:
      +   *       - name: Overview
      +   *         content: (== include overview.md ==)
      +   * Note: you cannot specify both `overview` field and `pages` field.
      +   * 
      + */ + java.lang.String getOverview(); + /** + * optional string overview = 2; + * + *
      +   * Declares a single overview page. For example:
      +   *     documentation:
      +   *       summary: ...
      +   *       overview: (== include overview.md ==)
      +   * This is a shortcut for the following declaration (using pages style):
      +   *     documentation:
      +   *       summary: ...
      +   *       pages:
      +   *       - name: Overview
      +   *         content: (== include overview.md ==)
      +   * Note: you cannot specify both `overview` field and `pages` field.
      +   * 
      + */ + com.google.protobuf.ByteString + getOverviewBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationProto.java new file mode 100644 index 000000000000..f31f29d4752c --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationProto.java @@ -0,0 +1,79 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/documentation.proto + +package com.google.api; + +public final class DocumentationProto { + private DocumentationProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_Documentation_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_Documentation_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_DocumentationRule_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_DocumentationRule_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_Page_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_Page_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\036google/api/documentation.proto\022\ngoogle" + + ".api\"\241\001\n\rDocumentation\022\017\n\007summary\030\001 \001(\t\022" + + "\037\n\005pages\030\005 \003(\0132\020.google.api.Page\022,\n\005rule" + + "s\030\003 \003(\0132\035.google.api.DocumentationRule\022\036" + + "\n\026documentation_root_url\030\004 \001(\t\022\020\n\010overvi" + + "ew\030\002 \001(\t\":\n\021DocumentationRule\022\020\n\010selecto" + + "r\030\001 \001(\t\022\023\n\013description\030\002 \001(\t\"I\n\004Page\022\014\n\004" + + "name\030\001 \001(\t\022\017\n\007content\030\002 \001(\t\022\"\n\010subpages\030" + + "\003 \003(\0132\020.google.api.PageB&\n\016com.google.ap" + + "iB\022DocumentationProtoP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_google_api_Documentation_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_api_Documentation_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_Documentation_descriptor, + new java.lang.String[] { "Summary", "Pages", "Rules", "DocumentationRootUrl", "Overview", }); + internal_static_google_api_DocumentationRule_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_api_DocumentationRule_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_DocumentationRule_descriptor, + new java.lang.String[] { "Selector", "Description", }); + internal_static_google_api_Page_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_api_Page_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_Page_descriptor, + new java.lang.String[] { "Name", "Content", "Subpages", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRule.java b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRule.java new file mode 100644 index 000000000000..5f9b9853026b --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRule.java @@ -0,0 +1,662 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/documentation.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.DocumentationRule} + * + *
      + * A documentation rule provides information about individual API elements.
      + * 
      + */ +public final class DocumentationRule extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.DocumentationRule) + DocumentationRuleOrBuilder { + // Use DocumentationRule.newBuilder() to construct. + private DocumentationRule(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private DocumentationRule() { + selector_ = ""; + description_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private DocumentationRule( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + selector_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + description_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.DocumentationProto.internal_static_google_api_DocumentationRule_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.DocumentationProto.internal_static_google_api_DocumentationRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.DocumentationRule.class, com.google.api.DocumentationRule.Builder.class); + } + + public static final int SELECTOR_FIELD_NUMBER = 1; + private volatile java.lang.Object selector_; + /** + * optional string selector = 1; + * + *
      +   * The selector is a comma-separated list of pattern. Each parttern is a
      +   * qualified name of the element which may end in "*", indicating a wildcard.
      +   * Wildcards are only allowed at the end and for a whole component of the
      +   * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      +   * specify a default for all applicable elements, the whole pattern "*"
      +   * is used.
      +   * 
      + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } + } + /** + * optional string selector = 1; + * + *
      +   * The selector is a comma-separated list of pattern. Each parttern is a
      +   * qualified name of the element which may end in "*", indicating a wildcard.
      +   * Wildcards are only allowed at the end and for a whole component of the
      +   * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      +   * specify a default for all applicable elements, the whole pattern "*"
      +   * is used.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DESCRIPTION_FIELD_NUMBER = 2; + private volatile java.lang.Object description_; + /** + * optional string description = 2; + * + *
      +   * Description of the selected API(s).
      +   * 
      + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } + } + /** + * optional string description = 2; + * + *
      +   * Description of the selected API(s).
      +   * 
      + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSelectorBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, selector_); + } + if (!getDescriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, description_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSelectorBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, selector_); + } + if (!getDescriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, description_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.DocumentationRule parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.DocumentationRule parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.DocumentationRule parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.DocumentationRule parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.DocumentationRule parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.DocumentationRule parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.DocumentationRule parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.DocumentationRule parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.DocumentationRule parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.DocumentationRule parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.DocumentationRule prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.DocumentationRule} + * + *
      +   * A documentation rule provides information about individual API elements.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.DocumentationRule) + com.google.api.DocumentationRuleOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.DocumentationProto.internal_static_google_api_DocumentationRule_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.DocumentationProto.internal_static_google_api_DocumentationRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.DocumentationRule.class, com.google.api.DocumentationRule.Builder.class); + } + + // Construct using com.google.api.DocumentationRule.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + selector_ = ""; + + description_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.DocumentationProto.internal_static_google_api_DocumentationRule_descriptor; + } + + public com.google.api.DocumentationRule getDefaultInstanceForType() { + return com.google.api.DocumentationRule.getDefaultInstance(); + } + + public com.google.api.DocumentationRule build() { + com.google.api.DocumentationRule result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.DocumentationRule buildPartial() { + com.google.api.DocumentationRule result = new com.google.api.DocumentationRule(this); + result.selector_ = selector_; + result.description_ = description_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.DocumentationRule) { + return mergeFrom((com.google.api.DocumentationRule)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.DocumentationRule other) { + if (other == com.google.api.DocumentationRule.getDefaultInstance()) return this; + if (!other.getSelector().isEmpty()) { + selector_ = other.selector_; + onChanged(); + } + if (!other.getDescription().isEmpty()) { + description_ = other.description_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.DocumentationRule parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.DocumentationRule) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object selector_ = ""; + /** + * optional string selector = 1; + * + *
      +     * The selector is a comma-separated list of pattern. Each parttern is a
      +     * qualified name of the element which may end in "*", indicating a wildcard.
      +     * Wildcards are only allowed at the end and for a whole component of the
      +     * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      +     * specify a default for all applicable elements, the whole pattern "*"
      +     * is used.
      +     * 
      + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string selector = 1; + * + *
      +     * The selector is a comma-separated list of pattern. Each parttern is a
      +     * qualified name of the element which may end in "*", indicating a wildcard.
      +     * Wildcards are only allowed at the end and for a whole component of the
      +     * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      +     * specify a default for all applicable elements, the whole pattern "*"
      +     * is used.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string selector = 1; + * + *
      +     * The selector is a comma-separated list of pattern. Each parttern is a
      +     * qualified name of the element which may end in "*", indicating a wildcard.
      +     * Wildcards are only allowed at the end and for a whole component of the
      +     * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      +     * specify a default for all applicable elements, the whole pattern "*"
      +     * is used.
      +     * 
      + */ + public Builder setSelector( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + selector_ = value; + onChanged(); + return this; + } + /** + * optional string selector = 1; + * + *
      +     * The selector is a comma-separated list of pattern. Each parttern is a
      +     * qualified name of the element which may end in "*", indicating a wildcard.
      +     * Wildcards are only allowed at the end and for a whole component of the
      +     * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      +     * specify a default for all applicable elements, the whole pattern "*"
      +     * is used.
      +     * 
      + */ + public Builder clearSelector() { + + selector_ = getDefaultInstance().getSelector(); + onChanged(); + return this; + } + /** + * optional string selector = 1; + * + *
      +     * The selector is a comma-separated list of pattern. Each parttern is a
      +     * qualified name of the element which may end in "*", indicating a wildcard.
      +     * Wildcards are only allowed at the end and for a whole component of the
      +     * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      +     * specify a default for all applicable elements, the whole pattern "*"
      +     * is used.
      +     * 
      + */ + public Builder setSelectorBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + selector_ = value; + onChanged(); + return this; + } + + private java.lang.Object description_ = ""; + /** + * optional string description = 2; + * + *
      +     * Description of the selected API(s).
      +     * 
      + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string description = 2; + * + *
      +     * Description of the selected API(s).
      +     * 
      + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string description = 2; + * + *
      +     * Description of the selected API(s).
      +     * 
      + */ + public Builder setDescription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + description_ = value; + onChanged(); + return this; + } + /** + * optional string description = 2; + * + *
      +     * Description of the selected API(s).
      +     * 
      + */ + public Builder clearDescription() { + + description_ = getDefaultInstance().getDescription(); + onChanged(); + return this; + } + /** + * optional string description = 2; + * + *
      +     * Description of the selected API(s).
      +     * 
      + */ + public Builder setDescriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + description_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.DocumentationRule) + } + + // @@protoc_insertion_point(class_scope:google.api.DocumentationRule) + private static final com.google.api.DocumentationRule DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.DocumentationRule(); + } + + public static com.google.api.DocumentationRule getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DocumentationRule parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new DocumentationRule(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.DocumentationRule getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRuleOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRuleOrBuilder.java new file mode 100644 index 000000000000..859e1afd25af --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRuleOrBuilder.java @@ -0,0 +1,55 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/documentation.proto + +package com.google.api; + +public interface DocumentationRuleOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.DocumentationRule) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string selector = 1; + * + *
      +   * The selector is a comma-separated list of pattern. Each parttern is a
      +   * qualified name of the element which may end in "*", indicating a wildcard.
      +   * Wildcards are only allowed at the end and for a whole component of the
      +   * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      +   * specify a default for all applicable elements, the whole pattern "*"
      +   * is used.
      +   * 
      + */ + java.lang.String getSelector(); + /** + * optional string selector = 1; + * + *
      +   * The selector is a comma-separated list of pattern. Each parttern is a
      +   * qualified name of the element which may end in "*", indicating a wildcard.
      +   * Wildcards are only allowed at the end and for a whole component of the
      +   * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      +   * specify a default for all applicable elements, the whole pattern "*"
      +   * is used.
      +   * 
      + */ + com.google.protobuf.ByteString + getSelectorBytes(); + + /** + * optional string description = 2; + * + *
      +   * Description of the selected API(s).
      +   * 
      + */ + java.lang.String getDescription(); + /** + * optional string description = 2; + * + *
      +   * Description of the selected API(s).
      +   * 
      + */ + com.google.protobuf.ByteString + getDescriptionBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ErrorFormatProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ErrorFormatProto.java new file mode 100644 index 000000000000..c1cbe4a2c182 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/ErrorFormatProto.java @@ -0,0 +1,65 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/error.proto + +package com.google.api; + +public final class ErrorFormatProto { + private ErrorFormatProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_CustomError_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_CustomError_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_CustomErrorRule_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_CustomErrorRule_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\026google/api/error.proto\022\ngoogle.api\"H\n\013" + + "CustomError\022*\n\005rules\030\001 \003(\0132\033.google.api." + + "CustomErrorRule\022\r\n\005types\030\002 \003(\t\"U\n\017Custom" + + "ErrorRule\022\020\n\010selector\030\001 \001(\t\022\031\n\rstubby_br" + + "idge\030\002 \001(\005B\002\030\001\022\025\n\ris_error_type\030\003 \001(\010B\'\n" + + "\016com.google.apiB\020ErrorFormatProtoP\001\370\001\001b\006" + + "proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_google_api_CustomError_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_api_CustomError_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_CustomError_descriptor, + new java.lang.String[] { "Rules", "Types", }); + internal_static_google_api_CustomErrorRule_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_api_CustomErrorRule_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_CustomErrorRule_descriptor, + new java.lang.String[] { "Selector", "StubbyBridge", "IsErrorType", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Http.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Http.java new file mode 100644 index 000000000000..b382bc022260 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/Http.java @@ -0,0 +1,759 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.Http} + * + *
      + * Defines the HTTP configuration for a service. It contains a list of
      + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
      + * to one or more HTTP REST API methods.
      + * 
      + */ +public final class Http extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.Http) + HttpOrBuilder { + // Use Http.newBuilder() to construct. + private Http(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Http() { + rules_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Http( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + rules_.add(input.readMessage(com.google.api.HttpRule.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.HttpProto.internal_static_google_api_Http_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.HttpProto.internal_static_google_api_Http_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Http.class, com.google.api.Http.Builder.class); + } + + public static final int RULES_FIELD_NUMBER = 1; + private java.util.List rules_; + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +   * A list of HTTP rules for configuring the HTTP REST API methods.
      +   * 
      + */ + public java.util.List getRulesList() { + return rules_; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +   * A list of HTTP rules for configuring the HTTP REST API methods.
      +   * 
      + */ + public java.util.List + getRulesOrBuilderList() { + return rules_; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +   * A list of HTTP rules for configuring the HTTP REST API methods.
      +   * 
      + */ + public int getRulesCount() { + return rules_.size(); + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +   * A list of HTTP rules for configuring the HTTP REST API methods.
      +   * 
      + */ + public com.google.api.HttpRule getRules(int index) { + return rules_.get(index); + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +   * A list of HTTP rules for configuring the HTTP REST API methods.
      +   * 
      + */ + public com.google.api.HttpRuleOrBuilder getRulesOrBuilder( + int index) { + return rules_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < rules_.size(); i++) { + output.writeMessage(1, rules_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < rules_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, rules_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.Http parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Http parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Http parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Http parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Http parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Http parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.Http parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.Http parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.Http parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Http parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.Http prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.Http} + * + *
      +   * Defines the HTTP configuration for a service. It contains a list of
      +   * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
      +   * to one or more HTTP REST API methods.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.Http) + com.google.api.HttpOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.HttpProto.internal_static_google_api_Http_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.HttpProto.internal_static_google_api_Http_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Http.class, com.google.api.Http.Builder.class); + } + + // Construct using com.google.api.Http.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getRulesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + rulesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.HttpProto.internal_static_google_api_Http_descriptor; + } + + public com.google.api.Http getDefaultInstanceForType() { + return com.google.api.Http.getDefaultInstance(); + } + + public com.google.api.Http build() { + com.google.api.Http result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.Http buildPartial() { + com.google.api.Http result = new com.google.api.Http(this); + int from_bitField0_ = bitField0_; + if (rulesBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.rules_ = rules_; + } else { + result.rules_ = rulesBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.Http) { + return mergeFrom((com.google.api.Http)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.Http other) { + if (other == com.google.api.Http.getDefaultInstance()) return this; + if (rulesBuilder_ == null) { + if (!other.rules_.isEmpty()) { + if (rules_.isEmpty()) { + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureRulesIsMutable(); + rules_.addAll(other.rules_); + } + onChanged(); + } + } else { + if (!other.rules_.isEmpty()) { + if (rulesBuilder_.isEmpty()) { + rulesBuilder_.dispose(); + rulesBuilder_ = null; + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000001); + rulesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getRulesFieldBuilder() : null; + } else { + rulesBuilder_.addAllMessages(other.rules_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.Http parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.Http) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List rules_ = + java.util.Collections.emptyList(); + private void ensureRulesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = new java.util.ArrayList(rules_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder> rulesBuilder_; + + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public java.util.List getRulesList() { + if (rulesBuilder_ == null) { + return java.util.Collections.unmodifiableList(rules_); + } else { + return rulesBuilder_.getMessageList(); + } + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public int getRulesCount() { + if (rulesBuilder_ == null) { + return rules_.size(); + } else { + return rulesBuilder_.getCount(); + } + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public com.google.api.HttpRule getRules(int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); + } else { + return rulesBuilder_.getMessage(index); + } + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public Builder setRules( + int index, com.google.api.HttpRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.set(index, value); + onChanged(); + } else { + rulesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public Builder setRules( + int index, com.google.api.HttpRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.set(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public Builder addRules(com.google.api.HttpRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(value); + onChanged(); + } else { + rulesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public Builder addRules( + int index, com.google.api.HttpRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(index, value); + onChanged(); + } else { + rulesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public Builder addRules( + com.google.api.HttpRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public Builder addRules( + int index, com.google.api.HttpRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public Builder addAllRules( + java.lang.Iterable values) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, rules_); + onChanged(); + } else { + rulesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public Builder clearRules() { + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + rulesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public Builder removeRules(int index) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.remove(index); + onChanged(); + } else { + rulesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public com.google.api.HttpRule.Builder getRulesBuilder( + int index) { + return getRulesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public com.google.api.HttpRuleOrBuilder getRulesOrBuilder( + int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); } else { + return rulesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public java.util.List + getRulesOrBuilderList() { + if (rulesBuilder_ != null) { + return rulesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(rules_); + } + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public com.google.api.HttpRule.Builder addRulesBuilder() { + return getRulesFieldBuilder().addBuilder( + com.google.api.HttpRule.getDefaultInstance()); + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public com.google.api.HttpRule.Builder addRulesBuilder( + int index) { + return getRulesFieldBuilder().addBuilder( + index, com.google.api.HttpRule.getDefaultInstance()); + } + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +     * A list of HTTP rules for configuring the HTTP REST API methods.
      +     * 
      + */ + public java.util.List + getRulesBuilderList() { + return getRulesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder> + getRulesFieldBuilder() { + if (rulesBuilder_ == null) { + rulesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder>( + rules_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + rules_ = null; + } + return rulesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.Http) + } + + // @@protoc_insertion_point(class_scope:google.api.Http) + private static final com.google.api.Http DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.Http(); + } + + public static com.google.api.Http getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Http parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Http(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.Http getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpOrBuilder.java new file mode 100644 index 000000000000..22192448d7ee --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpOrBuilder.java @@ -0,0 +1,53 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +public interface HttpOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.Http) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +   * A list of HTTP rules for configuring the HTTP REST API methods.
      +   * 
      + */ + java.util.List + getRulesList(); + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +   * A list of HTTP rules for configuring the HTTP REST API methods.
      +   * 
      + */ + com.google.api.HttpRule getRules(int index); + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +   * A list of HTTP rules for configuring the HTTP REST API methods.
      +   * 
      + */ + int getRulesCount(); + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +   * A list of HTTP rules for configuring the HTTP REST API methods.
      +   * 
      + */ + java.util.List + getRulesOrBuilderList(); + /** + * repeated .google.api.HttpRule rules = 1; + * + *
      +   * A list of HTTP rules for configuring the HTTP REST API methods.
      +   * 
      + */ + com.google.api.HttpRuleOrBuilder getRulesOrBuilder( + int index); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpProto.java new file mode 100644 index 000000000000..7ef3d1fdaa97 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpProto.java @@ -0,0 +1,106 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +public final class HttpProto { + private HttpProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_Http_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_Http_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_HttpRule_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_HttpRule_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_CustomHttpPattern_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_CustomHttpPattern_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_MediaUpload_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_MediaUpload_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_MediaDownload_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_MediaDownload_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\025google/api/http.proto\022\ngoogle.api\"+\n\004H" + + "ttp\022#\n\005rules\030\001 \003(\0132\024.google.api.HttpRule" + + "\"\314\002\n\010HttpRule\022\020\n\010selector\030\001 \001(\t\022\r\n\003get\030\002" + + " \001(\tH\000\022\r\n\003put\030\003 \001(\tH\000\022\016\n\004post\030\004 \001(\tH\000\022\020\n" + + "\006delete\030\005 \001(\tH\000\022\017\n\005patch\030\006 \001(\tH\000\022/\n\006cust" + + "om\030\010 \001(\0132\035.google.api.CustomHttpPatternH" + + "\000\022\014\n\004body\030\007 \001(\t\022-\n\014media_upload\030\t \001(\0132\027." + + "google.api.MediaUpload\0221\n\016media_download" + + "\030\n \001(\0132\031.google.api.MediaDownload\0221\n\023add" + + "itional_bindings\030\013 \003(\0132\024.google.api.Http", + "RuleB\t\n\007pattern\"/\n\021CustomHttpPattern\022\014\n\004" + + "kind\030\001 \001(\t\022\014\n\004path\030\002 \001(\t\"\036\n\013MediaUpload\022" + + "\017\n\007enabled\030\003 \001(\010\" \n\rMediaDownload\022\017\n\007ena" + + "bled\030\001 \001(\010B \n\016com.google.apiB\tHttpProtoP" + + "\001\370\001\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_google_api_Http_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_api_Http_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_Http_descriptor, + new java.lang.String[] { "Rules", }); + internal_static_google_api_HttpRule_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_api_HttpRule_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_HttpRule_descriptor, + new java.lang.String[] { "Selector", "Get", "Put", "Post", "Delete", "Patch", "Custom", "Body", "MediaUpload", "MediaDownload", "AdditionalBindings", "Pattern", }); + internal_static_google_api_CustomHttpPattern_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_api_CustomHttpPattern_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_CustomHttpPattern_descriptor, + new java.lang.String[] { "Kind", "Path", }); + internal_static_google_api_MediaUpload_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_api_MediaUpload_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_MediaUpload_descriptor, + new java.lang.String[] { "Enabled", }); + internal_static_google_api_MediaDownload_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_api_MediaDownload_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_MediaDownload_descriptor, + new java.lang.String[] { "Enabled", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRule.java b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRule.java new file mode 100644 index 000000000000..e37c48096fdd --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRule.java @@ -0,0 +1,3069 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.HttpRule} + * + *
      + * `HttpRule` defines the mapping of an RPC method to one or more HTTP
      + * REST APIs.  The mapping determines what portions of the request
      + * message are populated from the path, query parameters, or body of
      + * the HTTP request.  The mapping is typically specified as an
      + * `google.api.http` annotation, see "google/api/annotations.proto"
      + * for details.
      + * The mapping consists of a field specifying the path template and
      + * method kind.  The path template can refer to fields in the request
      + * message, as in the example below which describes a REST GET
      + * operation on a resource collection of messages:
      + * ```proto
      + * service Messaging {
      + *   rpc GetMessage(GetMessageRequest) returns (Message) {
      + *     option (google.api.http).get = "/v1/messages/{message_id}";
      + *   }
      + * }
      + * message GetMessageRequest {
      + *   string message_id = 1; // mapped to the URL
      + * }
      + * message Message {
      + *   string text = 1; // content of the resource
      + * }
      + * ```
      + * This definition enables an automatic, bidrectional mapping of HTTP
      + * JSON to RPC. Example:
      + * HTTP | RPC
      + * -----|-----
      + * `GET /v1/messages/123456`  | `GetMessage(message_id: "123456")`
      + * In general, not only fields but also field paths can be referenced
      + * from a path pattern. Fields mapped to the path pattern cannot be
      + * repeated and must have a primitive (non-message) type.
      + * Any fields in the request message which are not bound by the path
      + * pattern automatically become (optional) HTTP query
      + * parameters. Assume the following definition of the request message:
      + * ```proto
      + * message GetMessageRequest {
      + *   string message_id = 1; // mapped to the URL
      + *   int64 revision = 2;    // becomes a parameter
      + * }
      + * ```
      + * This enables a HTTP JSON to RPC mapping as below:
      + * HTTP | RPC
      + * -----|-----
      + * `GET /v1/messages/123456?revision=2` | `GetMessage(message_id: "123456" revision: 2)`
      + * Note that fields which are mapped to HTTP parameters must have a
      + * primitive type or a repeated primitive type. Message types are not
      + * allowed. In the case of a repeated type, the parameter can be
      + * repeated in the URL, as in `...?param=A&param=B`.
      + * For HTTP method kinds which allow a request body, the `body` field
      + * specifies the mapping. Consider a REST update method on the
      + * message resource collection:
      + * ```proto
      + * service Messaging {
      + *   rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
      + *     option (google.api.http) = {
      + *       put: "/v1/messages/{message_id}"
      + *       body: "message"
      + *   }
      + * }
      + * message UpdateMessageRequest {
      + *   string message_id = 1; // mapped to the URL
      + *   Message message = 2;   // mapped to the body
      + * }
      + * ```
      + * The following HTTP JSON to RPC mapping is enabled, where the
      + * representation of the JSON in the request body is determined by
      + * protos JSON encoding:
      + * HTTP | RPC
      + * -----|-----
      + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
      + * The special name `*` can be used in the body mapping to define that
      + * every field not bound by the path template should be mapped to the
      + * request body.  This enables the following alternative definition of
      + * the update method:
      + * ```proto
      + * service Messaging {
      + *   rpc UpdateMessage(Message) returns (Message) {
      + *     option (google.api.http) = {
      + *       put: "/v1/messages/{message_id}"
      + *       body: "*"
      + *   }
      + * }
      + * message Message {
      + *   string message_id = 2;
      + *   string text = 2;
      + * }
      + * ```
      + * The following HTTP JSON to RPC mapping is enabled:
      + * HTTP | RPC
      + * -----|-----
      + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`
      + * Note that when using `*` in the body mapping, it is not possible to
      + * have HTTP parameters, as all fields not bound by the path end in
      + * the body. This makes this option more rarely used in practice of
      + * defining REST APIs. The common usage of `*` is in custom methods
      + * which don't use the URL at all for transferring data.
      + * It is possible to define multiple HTTP methods for one RPC by using
      + * the `additional_bindings` option. Example:
      + * ```proto
      + * service Messaging {
      + *   rpc GetMessage(GetMessageRequest) returns (Message) {
      + *     option (google.api.http) = {
      + *       get: "/v1/messages/{message_id}"
      + *       additional_bindings {
      + *         get: "/v1/users/{user_id}/messages/{message_id}"
      + *       }
      + *   }
      + * }
      + * message GetMessageRequest {
      + *   string message_id = 1;
      + *   string user_id = 2;
      + * }
      + * ```
      + * This enables the following two alternative HTTP JSON to RPC
      + * mappings:
      + * HTTP | RPC
      + * -----|-----
      + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
      + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`
      + * # Rules for HTTP mapping
      + * The rules for mapping HTTP path, query parameters, and body fields
      + * to the request message are as follows:
      + * 1. The `body` field specifies either `*` or a field path, or is
      + *    omitted. If omitted, it assumes there is no HTTP body.
      + * 2. Leaf fields (recursive expansion of nested messages in the
      + *    request) can be classified into three types:
      + *     (a) Matched in the URL template.
      + *     (b) Covered by body (if body is `*`, everything except (a) fields;
      + *         else everything under the body field)
      + *     (c) All other fields.
      + * 3. URL query parameters found in the HTTP request are mapped to (c) fields.
      + * 4. Any body sent with an HTTP request can contain only (b) fields.
      + * The syntax of the path template is as follows:
      + *     Template = "/" Segments [ Verb ] ;
      + *     Segments = Segment { "/" Segment } ;
      + *     Segment  = "*" | "**" | LITERAL | Variable ;
      + *     Variable = "{" FieldPath [ "=" Segments ] "}" ;
      + *     FieldPath = IDENT { "." IDENT } ;
      + *     Verb     = ":" LITERAL ;
      + * The syntax `*` matches a single path segment. It follows the semantics of
      + * [RFC 6570](https://tools.ietf.org/html.rfc6570) Section 3.2.2 Simple String
      + * Expansion.
      + * The syntax `**` matches zero or more path segments. It follows the semantics
      + * of [RFC 6570](https://tools.ietf.org/html.rfc6570) Section 3.2.3 Reserved
      + * Expansion.
      + * The syntax `LITERAL` matches literal text in the URL path.
      + * The syntax `Variable` matches the entire path as specified by its template;
      + * this nested template must not contain further variables. If a variable
      + * matches a single path segment, its template may be omitted, e.g. `{var}`
      + * is equivalent to `{var=*}`.
      + * NOTE: the field paths in variables and in the `body` must not refer to
      + * repeated fields or map fields.
      + * Use CustomHttpPattern to specify any HTTP method that is not included in the
      + * `pattern` field, such as HEAD, or "*" to leave the HTTP method unspecified for
      + * a given URL path rule. The wild-card rule is useful for services that provide
      + * content to Web (HTML) clients.
      + * 
      + */ +public final class HttpRule extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.HttpRule) + HttpRuleOrBuilder { + // Use HttpRule.newBuilder() to construct. + private HttpRule(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private HttpRule() { + selector_ = ""; + body_ = ""; + additionalBindings_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private HttpRule( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + selector_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + patternCase_ = 2; + pattern_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + patternCase_ = 3; + pattern_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + patternCase_ = 4; + pattern_ = s; + break; + } + case 42: { + String s = input.readStringRequireUtf8(); + patternCase_ = 5; + pattern_ = s; + break; + } + case 50: { + String s = input.readStringRequireUtf8(); + patternCase_ = 6; + pattern_ = s; + break; + } + case 58: { + String s = input.readStringRequireUtf8(); + + body_ = s; + break; + } + case 66: { + com.google.api.CustomHttpPattern.Builder subBuilder = null; + if (patternCase_ == 8) { + subBuilder = ((com.google.api.CustomHttpPattern) pattern_).toBuilder(); + } + pattern_ = + input.readMessage(com.google.api.CustomHttpPattern.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((com.google.api.CustomHttpPattern) pattern_); + pattern_ = subBuilder.buildPartial(); + } + patternCase_ = 8; + break; + } + case 74: { + com.google.api.MediaUpload.Builder subBuilder = null; + if (mediaUpload_ != null) { + subBuilder = mediaUpload_.toBuilder(); + } + mediaUpload_ = input.readMessage(com.google.api.MediaUpload.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(mediaUpload_); + mediaUpload_ = subBuilder.buildPartial(); + } + + break; + } + case 82: { + com.google.api.MediaDownload.Builder subBuilder = null; + if (mediaDownload_ != null) { + subBuilder = mediaDownload_.toBuilder(); + } + mediaDownload_ = input.readMessage(com.google.api.MediaDownload.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(mediaDownload_); + mediaDownload_ = subBuilder.buildPartial(); + } + + break; + } + case 90: { + if (!((mutable_bitField0_ & 0x00000400) == 0x00000400)) { + additionalBindings_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000400; + } + additionalBindings_.add(input.readMessage(com.google.api.HttpRule.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000400) == 0x00000400)) { + additionalBindings_ = java.util.Collections.unmodifiableList(additionalBindings_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.HttpProto.internal_static_google_api_HttpRule_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.HttpProto.internal_static_google_api_HttpRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.HttpRule.class, com.google.api.HttpRule.Builder.class); + } + + private int bitField0_; + private int patternCase_ = 0; + private java.lang.Object pattern_; + public enum PatternCase + implements com.google.protobuf.Internal.EnumLite { + GET(2), + PUT(3), + POST(4), + DELETE(5), + PATCH(6), + CUSTOM(8), + PATTERN_NOT_SET(0); + private int value = 0; + private PatternCase(int value) { + this.value = value; + } + public static PatternCase valueOf(int value) { + switch (value) { + case 2: return GET; + case 3: return PUT; + case 4: return POST; + case 5: return DELETE; + case 6: return PATCH; + case 8: return CUSTOM; + case 0: return PATTERN_NOT_SET; + default: throw new java.lang.IllegalArgumentException( + "Value is undefined for this oneof enum."); + } + } + public int getNumber() { + return this.value; + } + }; + + public PatternCase + getPatternCase() { + return PatternCase.valueOf( + patternCase_); + } + + public static final int SELECTOR_FIELD_NUMBER = 1; + private volatile java.lang.Object selector_; + /** + * optional string selector = 1; + * + *
      +   * Selects methods to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } + } + /** + * optional string selector = 1; + * + *
      +   * Selects methods to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int GET_FIELD_NUMBER = 2; + /** + * optional string get = 2; + * + *
      +   * Used for listing and getting information about resources.
      +   * 
      + */ + public java.lang.String getGet() { + java.lang.Object ref = ""; + if (patternCase_ == 2) { + ref = pattern_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (patternCase_ == 2) { + pattern_ = s; + } + return s; + } + } + /** + * optional string get = 2; + * + *
      +   * Used for listing and getting information about resources.
      +   * 
      + */ + public com.google.protobuf.ByteString + getGetBytes() { + java.lang.Object ref = ""; + if (patternCase_ == 2) { + ref = pattern_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (patternCase_ == 2) { + pattern_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PUT_FIELD_NUMBER = 3; + /** + * optional string put = 3; + * + *
      +   * Used for updating a resource.
      +   * 
      + */ + public java.lang.String getPut() { + java.lang.Object ref = ""; + if (patternCase_ == 3) { + ref = pattern_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (patternCase_ == 3) { + pattern_ = s; + } + return s; + } + } + /** + * optional string put = 3; + * + *
      +   * Used for updating a resource.
      +   * 
      + */ + public com.google.protobuf.ByteString + getPutBytes() { + java.lang.Object ref = ""; + if (patternCase_ == 3) { + ref = pattern_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (patternCase_ == 3) { + pattern_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int POST_FIELD_NUMBER = 4; + /** + * optional string post = 4; + * + *
      +   * Used for creating a resource.
      +   * 
      + */ + public java.lang.String getPost() { + java.lang.Object ref = ""; + if (patternCase_ == 4) { + ref = pattern_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (patternCase_ == 4) { + pattern_ = s; + } + return s; + } + } + /** + * optional string post = 4; + * + *
      +   * Used for creating a resource.
      +   * 
      + */ + public com.google.protobuf.ByteString + getPostBytes() { + java.lang.Object ref = ""; + if (patternCase_ == 4) { + ref = pattern_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (patternCase_ == 4) { + pattern_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DELETE_FIELD_NUMBER = 5; + /** + * optional string delete = 5; + * + *
      +   * Used for deleting a resource.
      +   * 
      + */ + public java.lang.String getDelete() { + java.lang.Object ref = ""; + if (patternCase_ == 5) { + ref = pattern_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (patternCase_ == 5) { + pattern_ = s; + } + return s; + } + } + /** + * optional string delete = 5; + * + *
      +   * Used for deleting a resource.
      +   * 
      + */ + public com.google.protobuf.ByteString + getDeleteBytes() { + java.lang.Object ref = ""; + if (patternCase_ == 5) { + ref = pattern_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (patternCase_ == 5) { + pattern_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PATCH_FIELD_NUMBER = 6; + /** + * optional string patch = 6; + * + *
      +   * Used for updating a resource.
      +   * 
      + */ + public java.lang.String getPatch() { + java.lang.Object ref = ""; + if (patternCase_ == 6) { + ref = pattern_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (patternCase_ == 6) { + pattern_ = s; + } + return s; + } + } + /** + * optional string patch = 6; + * + *
      +   * Used for updating a resource.
      +   * 
      + */ + public com.google.protobuf.ByteString + getPatchBytes() { + java.lang.Object ref = ""; + if (patternCase_ == 6) { + ref = pattern_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (patternCase_ == 6) { + pattern_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CUSTOM_FIELD_NUMBER = 8; + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +   * Custom pattern is used for defining custom verbs.
      +   * 
      + */ + public com.google.api.CustomHttpPattern getCustom() { + if (patternCase_ == 8) { + return (com.google.api.CustomHttpPattern) pattern_; + } + return com.google.api.CustomHttpPattern.getDefaultInstance(); + } + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +   * Custom pattern is used for defining custom verbs.
      +   * 
      + */ + public com.google.api.CustomHttpPatternOrBuilder getCustomOrBuilder() { + if (patternCase_ == 8) { + return (com.google.api.CustomHttpPattern) pattern_; + } + return com.google.api.CustomHttpPattern.getDefaultInstance(); + } + + public static final int BODY_FIELD_NUMBER = 7; + private volatile java.lang.Object body_; + /** + * optional string body = 7; + * + *
      +   * The name of the request field whose value is mapped to the HTTP body, or
      +   * `*` for mapping all fields not captured by the path pattern to the HTTP
      +   * body. NOTE: the referred field must not be a repeated field.
      +   * 
      + */ + public java.lang.String getBody() { + java.lang.Object ref = body_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + body_ = s; + return s; + } + } + /** + * optional string body = 7; + * + *
      +   * The name of the request field whose value is mapped to the HTTP body, or
      +   * `*` for mapping all fields not captured by the path pattern to the HTTP
      +   * body. NOTE: the referred field must not be a repeated field.
      +   * 
      + */ + public com.google.protobuf.ByteString + getBodyBytes() { + java.lang.Object ref = body_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + body_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MEDIA_UPLOAD_FIELD_NUMBER = 9; + private com.google.api.MediaUpload mediaUpload_; + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + public boolean hasMediaUpload() { + return mediaUpload_ != null; + } + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + public com.google.api.MediaUpload getMediaUpload() { + return mediaUpload_ == null ? com.google.api.MediaUpload.getDefaultInstance() : mediaUpload_; + } + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + public com.google.api.MediaUploadOrBuilder getMediaUploadOrBuilder() { + return getMediaUpload(); + } + + public static final int MEDIA_DOWNLOAD_FIELD_NUMBER = 10; + private com.google.api.MediaDownload mediaDownload_; + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + public boolean hasMediaDownload() { + return mediaDownload_ != null; + } + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + public com.google.api.MediaDownload getMediaDownload() { + return mediaDownload_ == null ? com.google.api.MediaDownload.getDefaultInstance() : mediaDownload_; + } + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + public com.google.api.MediaDownloadOrBuilder getMediaDownloadOrBuilder() { + return getMediaDownload(); + } + + public static final int ADDITIONAL_BINDINGS_FIELD_NUMBER = 11; + private java.util.List additionalBindings_; + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +   * Additional HTTP bindings for the selector. Nested bindings must
      +   * not contain an `additional_bindings` field themselves (that is,
      +   * the nesting may only be one level deep).
      +   * 
      + */ + public java.util.List getAdditionalBindingsList() { + return additionalBindings_; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +   * Additional HTTP bindings for the selector. Nested bindings must
      +   * not contain an `additional_bindings` field themselves (that is,
      +   * the nesting may only be one level deep).
      +   * 
      + */ + public java.util.List + getAdditionalBindingsOrBuilderList() { + return additionalBindings_; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +   * Additional HTTP bindings for the selector. Nested bindings must
      +   * not contain an `additional_bindings` field themselves (that is,
      +   * the nesting may only be one level deep).
      +   * 
      + */ + public int getAdditionalBindingsCount() { + return additionalBindings_.size(); + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +   * Additional HTTP bindings for the selector. Nested bindings must
      +   * not contain an `additional_bindings` field themselves (that is,
      +   * the nesting may only be one level deep).
      +   * 
      + */ + public com.google.api.HttpRule getAdditionalBindings(int index) { + return additionalBindings_.get(index); + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +   * Additional HTTP bindings for the selector. Nested bindings must
      +   * not contain an `additional_bindings` field themselves (that is,
      +   * the nesting may only be one level deep).
      +   * 
      + */ + public com.google.api.HttpRuleOrBuilder getAdditionalBindingsOrBuilder( + int index) { + return additionalBindings_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSelectorBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, selector_); + } + if (patternCase_ == 2) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, pattern_); + } + if (patternCase_ == 3) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, pattern_); + } + if (patternCase_ == 4) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, pattern_); + } + if (patternCase_ == 5) { + com.google.protobuf.GeneratedMessage.writeString(output, 5, pattern_); + } + if (patternCase_ == 6) { + com.google.protobuf.GeneratedMessage.writeString(output, 6, pattern_); + } + if (!getBodyBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 7, body_); + } + if (patternCase_ == 8) { + output.writeMessage(8, (com.google.api.CustomHttpPattern) pattern_); + } + if (mediaUpload_ != null) { + output.writeMessage(9, getMediaUpload()); + } + if (mediaDownload_ != null) { + output.writeMessage(10, getMediaDownload()); + } + for (int i = 0; i < additionalBindings_.size(); i++) { + output.writeMessage(11, additionalBindings_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSelectorBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, selector_); + } + if (patternCase_ == 2) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, pattern_); + } + if (patternCase_ == 3) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pattern_); + } + if (patternCase_ == 4) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, pattern_); + } + if (patternCase_ == 5) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(5, pattern_); + } + if (patternCase_ == 6) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(6, pattern_); + } + if (!getBodyBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(7, body_); + } + if (patternCase_ == 8) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, (com.google.api.CustomHttpPattern) pattern_); + } + if (mediaUpload_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(9, getMediaUpload()); + } + if (mediaDownload_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(10, getMediaDownload()); + } + for (int i = 0; i < additionalBindings_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(11, additionalBindings_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.HttpRule parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.HttpRule parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.HttpRule parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.HttpRule parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.HttpRule parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.HttpRule parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.HttpRule parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.HttpRule parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.HttpRule parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.HttpRule parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.HttpRule prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.HttpRule} + * + *
      +   * `HttpRule` defines the mapping of an RPC method to one or more HTTP
      +   * REST APIs.  The mapping determines what portions of the request
      +   * message are populated from the path, query parameters, or body of
      +   * the HTTP request.  The mapping is typically specified as an
      +   * `google.api.http` annotation, see "google/api/annotations.proto"
      +   * for details.
      +   * The mapping consists of a field specifying the path template and
      +   * method kind.  The path template can refer to fields in the request
      +   * message, as in the example below which describes a REST GET
      +   * operation on a resource collection of messages:
      +   * ```proto
      +   * service Messaging {
      +   *   rpc GetMessage(GetMessageRequest) returns (Message) {
      +   *     option (google.api.http).get = "/v1/messages/{message_id}";
      +   *   }
      +   * }
      +   * message GetMessageRequest {
      +   *   string message_id = 1; // mapped to the URL
      +   * }
      +   * message Message {
      +   *   string text = 1; // content of the resource
      +   * }
      +   * ```
      +   * This definition enables an automatic, bidrectional mapping of HTTP
      +   * JSON to RPC. Example:
      +   * HTTP | RPC
      +   * -----|-----
      +   * `GET /v1/messages/123456`  | `GetMessage(message_id: "123456")`
      +   * In general, not only fields but also field paths can be referenced
      +   * from a path pattern. Fields mapped to the path pattern cannot be
      +   * repeated and must have a primitive (non-message) type.
      +   * Any fields in the request message which are not bound by the path
      +   * pattern automatically become (optional) HTTP query
      +   * parameters. Assume the following definition of the request message:
      +   * ```proto
      +   * message GetMessageRequest {
      +   *   string message_id = 1; // mapped to the URL
      +   *   int64 revision = 2;    // becomes a parameter
      +   * }
      +   * ```
      +   * This enables a HTTP JSON to RPC mapping as below:
      +   * HTTP | RPC
      +   * -----|-----
      +   * `GET /v1/messages/123456?revision=2` | `GetMessage(message_id: "123456" revision: 2)`
      +   * Note that fields which are mapped to HTTP parameters must have a
      +   * primitive type or a repeated primitive type. Message types are not
      +   * allowed. In the case of a repeated type, the parameter can be
      +   * repeated in the URL, as in `...?param=A&param=B`.
      +   * For HTTP method kinds which allow a request body, the `body` field
      +   * specifies the mapping. Consider a REST update method on the
      +   * message resource collection:
      +   * ```proto
      +   * service Messaging {
      +   *   rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
      +   *     option (google.api.http) = {
      +   *       put: "/v1/messages/{message_id}"
      +   *       body: "message"
      +   *   }
      +   * }
      +   * message UpdateMessageRequest {
      +   *   string message_id = 1; // mapped to the URL
      +   *   Message message = 2;   // mapped to the body
      +   * }
      +   * ```
      +   * The following HTTP JSON to RPC mapping is enabled, where the
      +   * representation of the JSON in the request body is determined by
      +   * protos JSON encoding:
      +   * HTTP | RPC
      +   * -----|-----
      +   * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
      +   * The special name `*` can be used in the body mapping to define that
      +   * every field not bound by the path template should be mapped to the
      +   * request body.  This enables the following alternative definition of
      +   * the update method:
      +   * ```proto
      +   * service Messaging {
      +   *   rpc UpdateMessage(Message) returns (Message) {
      +   *     option (google.api.http) = {
      +   *       put: "/v1/messages/{message_id}"
      +   *       body: "*"
      +   *   }
      +   * }
      +   * message Message {
      +   *   string message_id = 2;
      +   *   string text = 2;
      +   * }
      +   * ```
      +   * The following HTTP JSON to RPC mapping is enabled:
      +   * HTTP | RPC
      +   * -----|-----
      +   * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`
      +   * Note that when using `*` in the body mapping, it is not possible to
      +   * have HTTP parameters, as all fields not bound by the path end in
      +   * the body. This makes this option more rarely used in practice of
      +   * defining REST APIs. The common usage of `*` is in custom methods
      +   * which don't use the URL at all for transferring data.
      +   * It is possible to define multiple HTTP methods for one RPC by using
      +   * the `additional_bindings` option. Example:
      +   * ```proto
      +   * service Messaging {
      +   *   rpc GetMessage(GetMessageRequest) returns (Message) {
      +   *     option (google.api.http) = {
      +   *       get: "/v1/messages/{message_id}"
      +   *       additional_bindings {
      +   *         get: "/v1/users/{user_id}/messages/{message_id}"
      +   *       }
      +   *   }
      +   * }
      +   * message GetMessageRequest {
      +   *   string message_id = 1;
      +   *   string user_id = 2;
      +   * }
      +   * ```
      +   * This enables the following two alternative HTTP JSON to RPC
      +   * mappings:
      +   * HTTP | RPC
      +   * -----|-----
      +   * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
      +   * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`
      +   * # Rules for HTTP mapping
      +   * The rules for mapping HTTP path, query parameters, and body fields
      +   * to the request message are as follows:
      +   * 1. The `body` field specifies either `*` or a field path, or is
      +   *    omitted. If omitted, it assumes there is no HTTP body.
      +   * 2. Leaf fields (recursive expansion of nested messages in the
      +   *    request) can be classified into three types:
      +   *     (a) Matched in the URL template.
      +   *     (b) Covered by body (if body is `*`, everything except (a) fields;
      +   *         else everything under the body field)
      +   *     (c) All other fields.
      +   * 3. URL query parameters found in the HTTP request are mapped to (c) fields.
      +   * 4. Any body sent with an HTTP request can contain only (b) fields.
      +   * The syntax of the path template is as follows:
      +   *     Template = "/" Segments [ Verb ] ;
      +   *     Segments = Segment { "/" Segment } ;
      +   *     Segment  = "*" | "**" | LITERAL | Variable ;
      +   *     Variable = "{" FieldPath [ "=" Segments ] "}" ;
      +   *     FieldPath = IDENT { "." IDENT } ;
      +   *     Verb     = ":" LITERAL ;
      +   * The syntax `*` matches a single path segment. It follows the semantics of
      +   * [RFC 6570](https://tools.ietf.org/html.rfc6570) Section 3.2.2 Simple String
      +   * Expansion.
      +   * The syntax `**` matches zero or more path segments. It follows the semantics
      +   * of [RFC 6570](https://tools.ietf.org/html.rfc6570) Section 3.2.3 Reserved
      +   * Expansion.
      +   * The syntax `LITERAL` matches literal text in the URL path.
      +   * The syntax `Variable` matches the entire path as specified by its template;
      +   * this nested template must not contain further variables. If a variable
      +   * matches a single path segment, its template may be omitted, e.g. `{var}`
      +   * is equivalent to `{var=*}`.
      +   * NOTE: the field paths in variables and in the `body` must not refer to
      +   * repeated fields or map fields.
      +   * Use CustomHttpPattern to specify any HTTP method that is not included in the
      +   * `pattern` field, such as HEAD, or "*" to leave the HTTP method unspecified for
      +   * a given URL path rule. The wild-card rule is useful for services that provide
      +   * content to Web (HTML) clients.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.HttpRule) + com.google.api.HttpRuleOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.HttpProto.internal_static_google_api_HttpRule_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.HttpProto.internal_static_google_api_HttpRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.HttpRule.class, com.google.api.HttpRule.Builder.class); + } + + // Construct using com.google.api.HttpRule.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getAdditionalBindingsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + selector_ = ""; + + body_ = ""; + + if (mediaUploadBuilder_ == null) { + mediaUpload_ = null; + } else { + mediaUpload_ = null; + mediaUploadBuilder_ = null; + } + if (mediaDownloadBuilder_ == null) { + mediaDownload_ = null; + } else { + mediaDownload_ = null; + mediaDownloadBuilder_ = null; + } + if (additionalBindingsBuilder_ == null) { + additionalBindings_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000400); + } else { + additionalBindingsBuilder_.clear(); + } + patternCase_ = 0; + pattern_ = null; + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.HttpProto.internal_static_google_api_HttpRule_descriptor; + } + + public com.google.api.HttpRule getDefaultInstanceForType() { + return com.google.api.HttpRule.getDefaultInstance(); + } + + public com.google.api.HttpRule build() { + com.google.api.HttpRule result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.HttpRule buildPartial() { + com.google.api.HttpRule result = new com.google.api.HttpRule(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.selector_ = selector_; + if (patternCase_ == 2) { + result.pattern_ = pattern_; + } + if (patternCase_ == 3) { + result.pattern_ = pattern_; + } + if (patternCase_ == 4) { + result.pattern_ = pattern_; + } + if (patternCase_ == 5) { + result.pattern_ = pattern_; + } + if (patternCase_ == 6) { + result.pattern_ = pattern_; + } + if (patternCase_ == 8) { + if (customBuilder_ == null) { + result.pattern_ = pattern_; + } else { + result.pattern_ = customBuilder_.build(); + } + } + result.body_ = body_; + if (mediaUploadBuilder_ == null) { + result.mediaUpload_ = mediaUpload_; + } else { + result.mediaUpload_ = mediaUploadBuilder_.build(); + } + if (mediaDownloadBuilder_ == null) { + result.mediaDownload_ = mediaDownload_; + } else { + result.mediaDownload_ = mediaDownloadBuilder_.build(); + } + if (additionalBindingsBuilder_ == null) { + if (((bitField0_ & 0x00000400) == 0x00000400)) { + additionalBindings_ = java.util.Collections.unmodifiableList(additionalBindings_); + bitField0_ = (bitField0_ & ~0x00000400); + } + result.additionalBindings_ = additionalBindings_; + } else { + result.additionalBindings_ = additionalBindingsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + result.patternCase_ = patternCase_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.HttpRule) { + return mergeFrom((com.google.api.HttpRule)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.HttpRule other) { + if (other == com.google.api.HttpRule.getDefaultInstance()) return this; + if (!other.getSelector().isEmpty()) { + selector_ = other.selector_; + onChanged(); + } + if (!other.getBody().isEmpty()) { + body_ = other.body_; + onChanged(); + } + if (other.hasMediaUpload()) { + mergeMediaUpload(other.getMediaUpload()); + } + if (other.hasMediaDownload()) { + mergeMediaDownload(other.getMediaDownload()); + } + if (additionalBindingsBuilder_ == null) { + if (!other.additionalBindings_.isEmpty()) { + if (additionalBindings_.isEmpty()) { + additionalBindings_ = other.additionalBindings_; + bitField0_ = (bitField0_ & ~0x00000400); + } else { + ensureAdditionalBindingsIsMutable(); + additionalBindings_.addAll(other.additionalBindings_); + } + onChanged(); + } + } else { + if (!other.additionalBindings_.isEmpty()) { + if (additionalBindingsBuilder_.isEmpty()) { + additionalBindingsBuilder_.dispose(); + additionalBindingsBuilder_ = null; + additionalBindings_ = other.additionalBindings_; + bitField0_ = (bitField0_ & ~0x00000400); + additionalBindingsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getAdditionalBindingsFieldBuilder() : null; + } else { + additionalBindingsBuilder_.addAllMessages(other.additionalBindings_); + } + } + } + switch (other.getPatternCase()) { + case GET: { + patternCase_ = 2; + pattern_ = other.pattern_; + onChanged(); + break; + } + case PUT: { + patternCase_ = 3; + pattern_ = other.pattern_; + onChanged(); + break; + } + case POST: { + patternCase_ = 4; + pattern_ = other.pattern_; + onChanged(); + break; + } + case DELETE: { + patternCase_ = 5; + pattern_ = other.pattern_; + onChanged(); + break; + } + case PATCH: { + patternCase_ = 6; + pattern_ = other.pattern_; + onChanged(); + break; + } + case CUSTOM: { + mergeCustom(other.getCustom()); + break; + } + case PATTERN_NOT_SET: { + break; + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.HttpRule parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.HttpRule) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int patternCase_ = 0; + private java.lang.Object pattern_; + public PatternCase + getPatternCase() { + return PatternCase.valueOf( + patternCase_); + } + + public Builder clearPattern() { + patternCase_ = 0; + pattern_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object selector_ = ""; + /** + * optional string selector = 1; + * + *
      +     * Selects methods to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string selector = 1; + * + *
      +     * Selects methods to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string selector = 1; + * + *
      +     * Selects methods to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder setSelector( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + selector_ = value; + onChanged(); + return this; + } + /** + * optional string selector = 1; + * + *
      +     * Selects methods to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder clearSelector() { + + selector_ = getDefaultInstance().getSelector(); + onChanged(); + return this; + } + /** + * optional string selector = 1; + * + *
      +     * Selects methods to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder setSelectorBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + selector_ = value; + onChanged(); + return this; + } + + /** + * optional string get = 2; + * + *
      +     * Used for listing and getting information about resources.
      +     * 
      + */ + public java.lang.String getGet() { + java.lang.Object ref = ""; + if (patternCase_ == 2) { + ref = pattern_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (patternCase_ == 2) { + pattern_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string get = 2; + * + *
      +     * Used for listing and getting information about resources.
      +     * 
      + */ + public com.google.protobuf.ByteString + getGetBytes() { + java.lang.Object ref = ""; + if (patternCase_ == 2) { + ref = pattern_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (patternCase_ == 2) { + pattern_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string get = 2; + * + *
      +     * Used for listing and getting information about resources.
      +     * 
      + */ + public Builder setGet( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + patternCase_ = 2; + pattern_ = value; + onChanged(); + return this; + } + /** + * optional string get = 2; + * + *
      +     * Used for listing and getting information about resources.
      +     * 
      + */ + public Builder clearGet() { + if (patternCase_ == 2) { + patternCase_ = 0; + pattern_ = null; + onChanged(); + } + return this; + } + /** + * optional string get = 2; + * + *
      +     * Used for listing and getting information about resources.
      +     * 
      + */ + public Builder setGetBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + patternCase_ = 2; + pattern_ = value; + onChanged(); + return this; + } + + /** + * optional string put = 3; + * + *
      +     * Used for updating a resource.
      +     * 
      + */ + public java.lang.String getPut() { + java.lang.Object ref = ""; + if (patternCase_ == 3) { + ref = pattern_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (patternCase_ == 3) { + pattern_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string put = 3; + * + *
      +     * Used for updating a resource.
      +     * 
      + */ + public com.google.protobuf.ByteString + getPutBytes() { + java.lang.Object ref = ""; + if (patternCase_ == 3) { + ref = pattern_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (patternCase_ == 3) { + pattern_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string put = 3; + * + *
      +     * Used for updating a resource.
      +     * 
      + */ + public Builder setPut( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + patternCase_ = 3; + pattern_ = value; + onChanged(); + return this; + } + /** + * optional string put = 3; + * + *
      +     * Used for updating a resource.
      +     * 
      + */ + public Builder clearPut() { + if (patternCase_ == 3) { + patternCase_ = 0; + pattern_ = null; + onChanged(); + } + return this; + } + /** + * optional string put = 3; + * + *
      +     * Used for updating a resource.
      +     * 
      + */ + public Builder setPutBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + patternCase_ = 3; + pattern_ = value; + onChanged(); + return this; + } + + /** + * optional string post = 4; + * + *
      +     * Used for creating a resource.
      +     * 
      + */ + public java.lang.String getPost() { + java.lang.Object ref = ""; + if (patternCase_ == 4) { + ref = pattern_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (patternCase_ == 4) { + pattern_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string post = 4; + * + *
      +     * Used for creating a resource.
      +     * 
      + */ + public com.google.protobuf.ByteString + getPostBytes() { + java.lang.Object ref = ""; + if (patternCase_ == 4) { + ref = pattern_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (patternCase_ == 4) { + pattern_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string post = 4; + * + *
      +     * Used for creating a resource.
      +     * 
      + */ + public Builder setPost( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + patternCase_ = 4; + pattern_ = value; + onChanged(); + return this; + } + /** + * optional string post = 4; + * + *
      +     * Used for creating a resource.
      +     * 
      + */ + public Builder clearPost() { + if (patternCase_ == 4) { + patternCase_ = 0; + pattern_ = null; + onChanged(); + } + return this; + } + /** + * optional string post = 4; + * + *
      +     * Used for creating a resource.
      +     * 
      + */ + public Builder setPostBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + patternCase_ = 4; + pattern_ = value; + onChanged(); + return this; + } + + /** + * optional string delete = 5; + * + *
      +     * Used for deleting a resource.
      +     * 
      + */ + public java.lang.String getDelete() { + java.lang.Object ref = ""; + if (patternCase_ == 5) { + ref = pattern_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (patternCase_ == 5) { + pattern_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string delete = 5; + * + *
      +     * Used for deleting a resource.
      +     * 
      + */ + public com.google.protobuf.ByteString + getDeleteBytes() { + java.lang.Object ref = ""; + if (patternCase_ == 5) { + ref = pattern_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (patternCase_ == 5) { + pattern_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string delete = 5; + * + *
      +     * Used for deleting a resource.
      +     * 
      + */ + public Builder setDelete( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + patternCase_ = 5; + pattern_ = value; + onChanged(); + return this; + } + /** + * optional string delete = 5; + * + *
      +     * Used for deleting a resource.
      +     * 
      + */ + public Builder clearDelete() { + if (patternCase_ == 5) { + patternCase_ = 0; + pattern_ = null; + onChanged(); + } + return this; + } + /** + * optional string delete = 5; + * + *
      +     * Used for deleting a resource.
      +     * 
      + */ + public Builder setDeleteBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + patternCase_ = 5; + pattern_ = value; + onChanged(); + return this; + } + + /** + * optional string patch = 6; + * + *
      +     * Used for updating a resource.
      +     * 
      + */ + public java.lang.String getPatch() { + java.lang.Object ref = ""; + if (patternCase_ == 6) { + ref = pattern_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (patternCase_ == 6) { + pattern_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string patch = 6; + * + *
      +     * Used for updating a resource.
      +     * 
      + */ + public com.google.protobuf.ByteString + getPatchBytes() { + java.lang.Object ref = ""; + if (patternCase_ == 6) { + ref = pattern_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (patternCase_ == 6) { + pattern_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string patch = 6; + * + *
      +     * Used for updating a resource.
      +     * 
      + */ + public Builder setPatch( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + patternCase_ = 6; + pattern_ = value; + onChanged(); + return this; + } + /** + * optional string patch = 6; + * + *
      +     * Used for updating a resource.
      +     * 
      + */ + public Builder clearPatch() { + if (patternCase_ == 6) { + patternCase_ = 0; + pattern_ = null; + onChanged(); + } + return this; + } + /** + * optional string patch = 6; + * + *
      +     * Used for updating a resource.
      +     * 
      + */ + public Builder setPatchBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + patternCase_ = 6; + pattern_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.api.CustomHttpPattern, com.google.api.CustomHttpPattern.Builder, com.google.api.CustomHttpPatternOrBuilder> customBuilder_; + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +     * Custom pattern is used for defining custom verbs.
      +     * 
      + */ + public com.google.api.CustomHttpPattern getCustom() { + if (customBuilder_ == null) { + if (patternCase_ == 8) { + return (com.google.api.CustomHttpPattern) pattern_; + } + return com.google.api.CustomHttpPattern.getDefaultInstance(); + } else { + if (patternCase_ == 8) { + return customBuilder_.getMessage(); + } + return com.google.api.CustomHttpPattern.getDefaultInstance(); + } + } + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +     * Custom pattern is used for defining custom verbs.
      +     * 
      + */ + public Builder setCustom(com.google.api.CustomHttpPattern value) { + if (customBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pattern_ = value; + onChanged(); + } else { + customBuilder_.setMessage(value); + } + patternCase_ = 8; + return this; + } + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +     * Custom pattern is used for defining custom verbs.
      +     * 
      + */ + public Builder setCustom( + com.google.api.CustomHttpPattern.Builder builderForValue) { + if (customBuilder_ == null) { + pattern_ = builderForValue.build(); + onChanged(); + } else { + customBuilder_.setMessage(builderForValue.build()); + } + patternCase_ = 8; + return this; + } + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +     * Custom pattern is used for defining custom verbs.
      +     * 
      + */ + public Builder mergeCustom(com.google.api.CustomHttpPattern value) { + if (customBuilder_ == null) { + if (patternCase_ == 8 && + pattern_ != com.google.api.CustomHttpPattern.getDefaultInstance()) { + pattern_ = com.google.api.CustomHttpPattern.newBuilder((com.google.api.CustomHttpPattern) pattern_) + .mergeFrom(value).buildPartial(); + } else { + pattern_ = value; + } + onChanged(); + } else { + if (patternCase_ == 8) { + customBuilder_.mergeFrom(value); + } + customBuilder_.setMessage(value); + } + patternCase_ = 8; + return this; + } + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +     * Custom pattern is used for defining custom verbs.
      +     * 
      + */ + public Builder clearCustom() { + if (customBuilder_ == null) { + if (patternCase_ == 8) { + patternCase_ = 0; + pattern_ = null; + onChanged(); + } + } else { + if (patternCase_ == 8) { + patternCase_ = 0; + pattern_ = null; + } + customBuilder_.clear(); + } + return this; + } + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +     * Custom pattern is used for defining custom verbs.
      +     * 
      + */ + public com.google.api.CustomHttpPattern.Builder getCustomBuilder() { + return getCustomFieldBuilder().getBuilder(); + } + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +     * Custom pattern is used for defining custom verbs.
      +     * 
      + */ + public com.google.api.CustomHttpPatternOrBuilder getCustomOrBuilder() { + if ((patternCase_ == 8) && (customBuilder_ != null)) { + return customBuilder_.getMessageOrBuilder(); + } else { + if (patternCase_ == 8) { + return (com.google.api.CustomHttpPattern) pattern_; + } + return com.google.api.CustomHttpPattern.getDefaultInstance(); + } + } + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +     * Custom pattern is used for defining custom verbs.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.api.CustomHttpPattern, com.google.api.CustomHttpPattern.Builder, com.google.api.CustomHttpPatternOrBuilder> + getCustomFieldBuilder() { + if (customBuilder_ == null) { + if (!(patternCase_ == 8)) { + pattern_ = com.google.api.CustomHttpPattern.getDefaultInstance(); + } + customBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.api.CustomHttpPattern, com.google.api.CustomHttpPattern.Builder, com.google.api.CustomHttpPatternOrBuilder>( + (com.google.api.CustomHttpPattern) pattern_, + getParentForChildren(), + isClean()); + pattern_ = null; + } + patternCase_ = 8; + onChanged();; + return customBuilder_; + } + + private java.lang.Object body_ = ""; + /** + * optional string body = 7; + * + *
      +     * The name of the request field whose value is mapped to the HTTP body, or
      +     * `*` for mapping all fields not captured by the path pattern to the HTTP
      +     * body. NOTE: the referred field must not be a repeated field.
      +     * 
      + */ + public java.lang.String getBody() { + java.lang.Object ref = body_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + body_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string body = 7; + * + *
      +     * The name of the request field whose value is mapped to the HTTP body, or
      +     * `*` for mapping all fields not captured by the path pattern to the HTTP
      +     * body. NOTE: the referred field must not be a repeated field.
      +     * 
      + */ + public com.google.protobuf.ByteString + getBodyBytes() { + java.lang.Object ref = body_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + body_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string body = 7; + * + *
      +     * The name of the request field whose value is mapped to the HTTP body, or
      +     * `*` for mapping all fields not captured by the path pattern to the HTTP
      +     * body. NOTE: the referred field must not be a repeated field.
      +     * 
      + */ + public Builder setBody( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + body_ = value; + onChanged(); + return this; + } + /** + * optional string body = 7; + * + *
      +     * The name of the request field whose value is mapped to the HTTP body, or
      +     * `*` for mapping all fields not captured by the path pattern to the HTTP
      +     * body. NOTE: the referred field must not be a repeated field.
      +     * 
      + */ + public Builder clearBody() { + + body_ = getDefaultInstance().getBody(); + onChanged(); + return this; + } + /** + * optional string body = 7; + * + *
      +     * The name of the request field whose value is mapped to the HTTP body, or
      +     * `*` for mapping all fields not captured by the path pattern to the HTTP
      +     * body. NOTE: the referred field must not be a repeated field.
      +     * 
      + */ + public Builder setBodyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + body_ = value; + onChanged(); + return this; + } + + private com.google.api.MediaUpload mediaUpload_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.api.MediaUpload, com.google.api.MediaUpload.Builder, com.google.api.MediaUploadOrBuilder> mediaUploadBuilder_; + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public boolean hasMediaUpload() { + return mediaUploadBuilder_ != null || mediaUpload_ != null; + } + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public com.google.api.MediaUpload getMediaUpload() { + if (mediaUploadBuilder_ == null) { + return mediaUpload_ == null ? com.google.api.MediaUpload.getDefaultInstance() : mediaUpload_; + } else { + return mediaUploadBuilder_.getMessage(); + } + } + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public Builder setMediaUpload(com.google.api.MediaUpload value) { + if (mediaUploadBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mediaUpload_ = value; + onChanged(); + } else { + mediaUploadBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public Builder setMediaUpload( + com.google.api.MediaUpload.Builder builderForValue) { + if (mediaUploadBuilder_ == null) { + mediaUpload_ = builderForValue.build(); + onChanged(); + } else { + mediaUploadBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public Builder mergeMediaUpload(com.google.api.MediaUpload value) { + if (mediaUploadBuilder_ == null) { + if (mediaUpload_ != null) { + mediaUpload_ = + com.google.api.MediaUpload.newBuilder(mediaUpload_).mergeFrom(value).buildPartial(); + } else { + mediaUpload_ = value; + } + onChanged(); + } else { + mediaUploadBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public Builder clearMediaUpload() { + if (mediaUploadBuilder_ == null) { + mediaUpload_ = null; + onChanged(); + } else { + mediaUpload_ = null; + mediaUploadBuilder_ = null; + } + + return this; + } + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public com.google.api.MediaUpload.Builder getMediaUploadBuilder() { + + onChanged(); + return getMediaUploadFieldBuilder().getBuilder(); + } + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public com.google.api.MediaUploadOrBuilder getMediaUploadOrBuilder() { + if (mediaUploadBuilder_ != null) { + return mediaUploadBuilder_.getMessageOrBuilder(); + } else { + return mediaUpload_ == null ? + com.google.api.MediaUpload.getDefaultInstance() : mediaUpload_; + } + } + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.api.MediaUpload, com.google.api.MediaUpload.Builder, com.google.api.MediaUploadOrBuilder> + getMediaUploadFieldBuilder() { + if (mediaUploadBuilder_ == null) { + mediaUploadBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.api.MediaUpload, com.google.api.MediaUpload.Builder, com.google.api.MediaUploadOrBuilder>( + getMediaUpload(), + getParentForChildren(), + isClean()); + mediaUpload_ = null; + } + return mediaUploadBuilder_; + } + + private com.google.api.MediaDownload mediaDownload_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.api.MediaDownload, com.google.api.MediaDownload.Builder, com.google.api.MediaDownloadOrBuilder> mediaDownloadBuilder_; + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public boolean hasMediaDownload() { + return mediaDownloadBuilder_ != null || mediaDownload_ != null; + } + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public com.google.api.MediaDownload getMediaDownload() { + if (mediaDownloadBuilder_ == null) { + return mediaDownload_ == null ? com.google.api.MediaDownload.getDefaultInstance() : mediaDownload_; + } else { + return mediaDownloadBuilder_.getMessage(); + } + } + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public Builder setMediaDownload(com.google.api.MediaDownload value) { + if (mediaDownloadBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mediaDownload_ = value; + onChanged(); + } else { + mediaDownloadBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public Builder setMediaDownload( + com.google.api.MediaDownload.Builder builderForValue) { + if (mediaDownloadBuilder_ == null) { + mediaDownload_ = builderForValue.build(); + onChanged(); + } else { + mediaDownloadBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public Builder mergeMediaDownload(com.google.api.MediaDownload value) { + if (mediaDownloadBuilder_ == null) { + if (mediaDownload_ != null) { + mediaDownload_ = + com.google.api.MediaDownload.newBuilder(mediaDownload_).mergeFrom(value).buildPartial(); + } else { + mediaDownload_ = value; + } + onChanged(); + } else { + mediaDownloadBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public Builder clearMediaDownload() { + if (mediaDownloadBuilder_ == null) { + mediaDownload_ = null; + onChanged(); + } else { + mediaDownload_ = null; + mediaDownloadBuilder_ = null; + } + + return this; + } + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public com.google.api.MediaDownload.Builder getMediaDownloadBuilder() { + + onChanged(); + return getMediaDownloadFieldBuilder().getBuilder(); + } + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + public com.google.api.MediaDownloadOrBuilder getMediaDownloadOrBuilder() { + if (mediaDownloadBuilder_ != null) { + return mediaDownloadBuilder_.getMessageOrBuilder(); + } else { + return mediaDownload_ == null ? + com.google.api.MediaDownload.getDefaultInstance() : mediaDownload_; + } + } + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +     * Do not use this. For media support, add instead
      +     * [][google.bytestream.RestByteStream] as an API to your
      +     * configuration.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.api.MediaDownload, com.google.api.MediaDownload.Builder, com.google.api.MediaDownloadOrBuilder> + getMediaDownloadFieldBuilder() { + if (mediaDownloadBuilder_ == null) { + mediaDownloadBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.api.MediaDownload, com.google.api.MediaDownload.Builder, com.google.api.MediaDownloadOrBuilder>( + getMediaDownload(), + getParentForChildren(), + isClean()); + mediaDownload_ = null; + } + return mediaDownloadBuilder_; + } + + private java.util.List additionalBindings_ = + java.util.Collections.emptyList(); + private void ensureAdditionalBindingsIsMutable() { + if (!((bitField0_ & 0x00000400) == 0x00000400)) { + additionalBindings_ = new java.util.ArrayList(additionalBindings_); + bitField0_ |= 0x00000400; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder> additionalBindingsBuilder_; + + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public java.util.List getAdditionalBindingsList() { + if (additionalBindingsBuilder_ == null) { + return java.util.Collections.unmodifiableList(additionalBindings_); + } else { + return additionalBindingsBuilder_.getMessageList(); + } + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public int getAdditionalBindingsCount() { + if (additionalBindingsBuilder_ == null) { + return additionalBindings_.size(); + } else { + return additionalBindingsBuilder_.getCount(); + } + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public com.google.api.HttpRule getAdditionalBindings(int index) { + if (additionalBindingsBuilder_ == null) { + return additionalBindings_.get(index); + } else { + return additionalBindingsBuilder_.getMessage(index); + } + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public Builder setAdditionalBindings( + int index, com.google.api.HttpRule value) { + if (additionalBindingsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAdditionalBindingsIsMutable(); + additionalBindings_.set(index, value); + onChanged(); + } else { + additionalBindingsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public Builder setAdditionalBindings( + int index, com.google.api.HttpRule.Builder builderForValue) { + if (additionalBindingsBuilder_ == null) { + ensureAdditionalBindingsIsMutable(); + additionalBindings_.set(index, builderForValue.build()); + onChanged(); + } else { + additionalBindingsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public Builder addAdditionalBindings(com.google.api.HttpRule value) { + if (additionalBindingsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAdditionalBindingsIsMutable(); + additionalBindings_.add(value); + onChanged(); + } else { + additionalBindingsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public Builder addAdditionalBindings( + int index, com.google.api.HttpRule value) { + if (additionalBindingsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAdditionalBindingsIsMutable(); + additionalBindings_.add(index, value); + onChanged(); + } else { + additionalBindingsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public Builder addAdditionalBindings( + com.google.api.HttpRule.Builder builderForValue) { + if (additionalBindingsBuilder_ == null) { + ensureAdditionalBindingsIsMutable(); + additionalBindings_.add(builderForValue.build()); + onChanged(); + } else { + additionalBindingsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public Builder addAdditionalBindings( + int index, com.google.api.HttpRule.Builder builderForValue) { + if (additionalBindingsBuilder_ == null) { + ensureAdditionalBindingsIsMutable(); + additionalBindings_.add(index, builderForValue.build()); + onChanged(); + } else { + additionalBindingsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public Builder addAllAdditionalBindings( + java.lang.Iterable values) { + if (additionalBindingsBuilder_ == null) { + ensureAdditionalBindingsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, additionalBindings_); + onChanged(); + } else { + additionalBindingsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public Builder clearAdditionalBindings() { + if (additionalBindingsBuilder_ == null) { + additionalBindings_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000400); + onChanged(); + } else { + additionalBindingsBuilder_.clear(); + } + return this; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public Builder removeAdditionalBindings(int index) { + if (additionalBindingsBuilder_ == null) { + ensureAdditionalBindingsIsMutable(); + additionalBindings_.remove(index); + onChanged(); + } else { + additionalBindingsBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public com.google.api.HttpRule.Builder getAdditionalBindingsBuilder( + int index) { + return getAdditionalBindingsFieldBuilder().getBuilder(index); + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public com.google.api.HttpRuleOrBuilder getAdditionalBindingsOrBuilder( + int index) { + if (additionalBindingsBuilder_ == null) { + return additionalBindings_.get(index); } else { + return additionalBindingsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public java.util.List + getAdditionalBindingsOrBuilderList() { + if (additionalBindingsBuilder_ != null) { + return additionalBindingsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(additionalBindings_); + } + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public com.google.api.HttpRule.Builder addAdditionalBindingsBuilder() { + return getAdditionalBindingsFieldBuilder().addBuilder( + com.google.api.HttpRule.getDefaultInstance()); + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public com.google.api.HttpRule.Builder addAdditionalBindingsBuilder( + int index) { + return getAdditionalBindingsFieldBuilder().addBuilder( + index, com.google.api.HttpRule.getDefaultInstance()); + } + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +     * Additional HTTP bindings for the selector. Nested bindings must
      +     * not contain an `additional_bindings` field themselves (that is,
      +     * the nesting may only be one level deep).
      +     * 
      + */ + public java.util.List + getAdditionalBindingsBuilderList() { + return getAdditionalBindingsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder> + getAdditionalBindingsFieldBuilder() { + if (additionalBindingsBuilder_ == null) { + additionalBindingsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder>( + additionalBindings_, + ((bitField0_ & 0x00000400) == 0x00000400), + getParentForChildren(), + isClean()); + additionalBindings_ = null; + } + return additionalBindingsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.HttpRule) + } + + // @@protoc_insertion_point(class_scope:google.api.HttpRule) + private static final com.google.api.HttpRule DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.HttpRule(); + } + + public static com.google.api.HttpRule getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HttpRule parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new HttpRule(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.HttpRule getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRuleOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRuleOrBuilder.java new file mode 100644 index 000000000000..9a29370416a8 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRuleOrBuilder.java @@ -0,0 +1,276 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +public interface HttpRuleOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.HttpRule) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string selector = 1; + * + *
      +   * Selects methods to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + java.lang.String getSelector(); + /** + * optional string selector = 1; + * + *
      +   * Selects methods to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + com.google.protobuf.ByteString + getSelectorBytes(); + + /** + * optional string get = 2; + * + *
      +   * Used for listing and getting information about resources.
      +   * 
      + */ + java.lang.String getGet(); + /** + * optional string get = 2; + * + *
      +   * Used for listing and getting information about resources.
      +   * 
      + */ + com.google.protobuf.ByteString + getGetBytes(); + + /** + * optional string put = 3; + * + *
      +   * Used for updating a resource.
      +   * 
      + */ + java.lang.String getPut(); + /** + * optional string put = 3; + * + *
      +   * Used for updating a resource.
      +   * 
      + */ + com.google.protobuf.ByteString + getPutBytes(); + + /** + * optional string post = 4; + * + *
      +   * Used for creating a resource.
      +   * 
      + */ + java.lang.String getPost(); + /** + * optional string post = 4; + * + *
      +   * Used for creating a resource.
      +   * 
      + */ + com.google.protobuf.ByteString + getPostBytes(); + + /** + * optional string delete = 5; + * + *
      +   * Used for deleting a resource.
      +   * 
      + */ + java.lang.String getDelete(); + /** + * optional string delete = 5; + * + *
      +   * Used for deleting a resource.
      +   * 
      + */ + com.google.protobuf.ByteString + getDeleteBytes(); + + /** + * optional string patch = 6; + * + *
      +   * Used for updating a resource.
      +   * 
      + */ + java.lang.String getPatch(); + /** + * optional string patch = 6; + * + *
      +   * Used for updating a resource.
      +   * 
      + */ + com.google.protobuf.ByteString + getPatchBytes(); + + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +   * Custom pattern is used for defining custom verbs.
      +   * 
      + */ + com.google.api.CustomHttpPattern getCustom(); + /** + * optional .google.api.CustomHttpPattern custom = 8; + * + *
      +   * Custom pattern is used for defining custom verbs.
      +   * 
      + */ + com.google.api.CustomHttpPatternOrBuilder getCustomOrBuilder(); + + /** + * optional string body = 7; + * + *
      +   * The name of the request field whose value is mapped to the HTTP body, or
      +   * `*` for mapping all fields not captured by the path pattern to the HTTP
      +   * body. NOTE: the referred field must not be a repeated field.
      +   * 
      + */ + java.lang.String getBody(); + /** + * optional string body = 7; + * + *
      +   * The name of the request field whose value is mapped to the HTTP body, or
      +   * `*` for mapping all fields not captured by the path pattern to the HTTP
      +   * body. NOTE: the referred field must not be a repeated field.
      +   * 
      + */ + com.google.protobuf.ByteString + getBodyBytes(); + + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + boolean hasMediaUpload(); + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + com.google.api.MediaUpload getMediaUpload(); + /** + * optional .google.api.MediaUpload media_upload = 9; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + com.google.api.MediaUploadOrBuilder getMediaUploadOrBuilder(); + + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + boolean hasMediaDownload(); + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + com.google.api.MediaDownload getMediaDownload(); + /** + * optional .google.api.MediaDownload media_download = 10; + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + com.google.api.MediaDownloadOrBuilder getMediaDownloadOrBuilder(); + + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +   * Additional HTTP bindings for the selector. Nested bindings must
      +   * not contain an `additional_bindings` field themselves (that is,
      +   * the nesting may only be one level deep).
      +   * 
      + */ + java.util.List + getAdditionalBindingsList(); + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +   * Additional HTTP bindings for the selector. Nested bindings must
      +   * not contain an `additional_bindings` field themselves (that is,
      +   * the nesting may only be one level deep).
      +   * 
      + */ + com.google.api.HttpRule getAdditionalBindings(int index); + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +   * Additional HTTP bindings for the selector. Nested bindings must
      +   * not contain an `additional_bindings` field themselves (that is,
      +   * the nesting may only be one level deep).
      +   * 
      + */ + int getAdditionalBindingsCount(); + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +   * Additional HTTP bindings for the selector. Nested bindings must
      +   * not contain an `additional_bindings` field themselves (that is,
      +   * the nesting may only be one level deep).
      +   * 
      + */ + java.util.List + getAdditionalBindingsOrBuilderList(); + /** + * repeated .google.api.HttpRule additional_bindings = 11; + * + *
      +   * Additional HTTP bindings for the selector. Nested bindings must
      +   * not contain an `additional_bindings` field themselves (that is,
      +   * the nesting may only be one level deep).
      +   * 
      + */ + com.google.api.HttpRuleOrBuilder getAdditionalBindingsOrBuilder( + int index); + + public com.google.api.HttpRule.PatternCase getPatternCase(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownload.java b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownload.java new file mode 100644 index 000000000000..7134429cae8e --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownload.java @@ -0,0 +1,399 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.MediaDownload} + * + *
      + * Do not use this. For media support, add instead
      + * [][google.bytestream.RestByteStream] as an API to your
      + * configuration.
      + * 
      + */ +public final class MediaDownload extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.MediaDownload) + MediaDownloadOrBuilder { + // Use MediaDownload.newBuilder() to construct. + private MediaDownload(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private MediaDownload() { + enabled_ = false; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private MediaDownload( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + enabled_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.HttpProto.internal_static_google_api_MediaDownload_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.HttpProto.internal_static_google_api_MediaDownload_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.MediaDownload.class, com.google.api.MediaDownload.Builder.class); + } + + public static final int ENABLED_FIELD_NUMBER = 1; + private boolean enabled_; + /** + * optional bool enabled = 1; + * + *
      +   * Whether download is enabled.
      +   * 
      + */ + public boolean getEnabled() { + return enabled_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (enabled_ != false) { + output.writeBool(1, enabled_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (enabled_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, enabled_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.MediaDownload parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.MediaDownload parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.MediaDownload parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.MediaDownload parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.MediaDownload parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.MediaDownload parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.MediaDownload parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.MediaDownload parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.MediaDownload parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.MediaDownload parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.MediaDownload prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.MediaDownload} + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.MediaDownload) + com.google.api.MediaDownloadOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.HttpProto.internal_static_google_api_MediaDownload_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.HttpProto.internal_static_google_api_MediaDownload_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.MediaDownload.class, com.google.api.MediaDownload.Builder.class); + } + + // Construct using com.google.api.MediaDownload.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + enabled_ = false; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.HttpProto.internal_static_google_api_MediaDownload_descriptor; + } + + public com.google.api.MediaDownload getDefaultInstanceForType() { + return com.google.api.MediaDownload.getDefaultInstance(); + } + + public com.google.api.MediaDownload build() { + com.google.api.MediaDownload result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.MediaDownload buildPartial() { + com.google.api.MediaDownload result = new com.google.api.MediaDownload(this); + result.enabled_ = enabled_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.MediaDownload) { + return mergeFrom((com.google.api.MediaDownload)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.MediaDownload other) { + if (other == com.google.api.MediaDownload.getDefaultInstance()) return this; + if (other.getEnabled() != false) { + setEnabled(other.getEnabled()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.MediaDownload parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.MediaDownload) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private boolean enabled_ ; + /** + * optional bool enabled = 1; + * + *
      +     * Whether download is enabled.
      +     * 
      + */ + public boolean getEnabled() { + return enabled_; + } + /** + * optional bool enabled = 1; + * + *
      +     * Whether download is enabled.
      +     * 
      + */ + public Builder setEnabled(boolean value) { + + enabled_ = value; + onChanged(); + return this; + } + /** + * optional bool enabled = 1; + * + *
      +     * Whether download is enabled.
      +     * 
      + */ + public Builder clearEnabled() { + + enabled_ = false; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.MediaDownload) + } + + // @@protoc_insertion_point(class_scope:google.api.MediaDownload) + private static final com.google.api.MediaDownload DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.MediaDownload(); + } + + public static com.google.api.MediaDownload getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public MediaDownload parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new MediaDownload(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.MediaDownload getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownloadOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownloadOrBuilder.java new file mode 100644 index 000000000000..e07a3988c7fe --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownloadOrBuilder.java @@ -0,0 +1,18 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +public interface MediaDownloadOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.MediaDownload) + com.google.protobuf.MessageOrBuilder { + + /** + * optional bool enabled = 1; + * + *
      +   * Whether download is enabled.
      +   * 
      + */ + boolean getEnabled(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUpload.java b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUpload.java new file mode 100644 index 000000000000..856b2954dcea --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUpload.java @@ -0,0 +1,399 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.MediaUpload} + * + *
      + * Do not use this. For media support, add instead
      + * [][google.bytestream.RestByteStream] as an API to your
      + * configuration.
      + * 
      + */ +public final class MediaUpload extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.MediaUpload) + MediaUploadOrBuilder { + // Use MediaUpload.newBuilder() to construct. + private MediaUpload(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private MediaUpload() { + enabled_ = false; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private MediaUpload( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 24: { + + enabled_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.HttpProto.internal_static_google_api_MediaUpload_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.HttpProto.internal_static_google_api_MediaUpload_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.MediaUpload.class, com.google.api.MediaUpload.Builder.class); + } + + public static final int ENABLED_FIELD_NUMBER = 3; + private boolean enabled_; + /** + * optional bool enabled = 3; + * + *
      +   * Whether upload is enabled.
      +   * 
      + */ + public boolean getEnabled() { + return enabled_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (enabled_ != false) { + output.writeBool(3, enabled_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (enabled_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, enabled_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.MediaUpload parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.MediaUpload parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.MediaUpload parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.MediaUpload parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.MediaUpload parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.MediaUpload parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.MediaUpload parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.MediaUpload parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.MediaUpload parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.MediaUpload parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.MediaUpload prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.MediaUpload} + * + *
      +   * Do not use this. For media support, add instead
      +   * [][google.bytestream.RestByteStream] as an API to your
      +   * configuration.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.MediaUpload) + com.google.api.MediaUploadOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.HttpProto.internal_static_google_api_MediaUpload_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.HttpProto.internal_static_google_api_MediaUpload_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.MediaUpload.class, com.google.api.MediaUpload.Builder.class); + } + + // Construct using com.google.api.MediaUpload.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + enabled_ = false; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.HttpProto.internal_static_google_api_MediaUpload_descriptor; + } + + public com.google.api.MediaUpload getDefaultInstanceForType() { + return com.google.api.MediaUpload.getDefaultInstance(); + } + + public com.google.api.MediaUpload build() { + com.google.api.MediaUpload result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.MediaUpload buildPartial() { + com.google.api.MediaUpload result = new com.google.api.MediaUpload(this); + result.enabled_ = enabled_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.MediaUpload) { + return mergeFrom((com.google.api.MediaUpload)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.MediaUpload other) { + if (other == com.google.api.MediaUpload.getDefaultInstance()) return this; + if (other.getEnabled() != false) { + setEnabled(other.getEnabled()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.MediaUpload parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.MediaUpload) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private boolean enabled_ ; + /** + * optional bool enabled = 3; + * + *
      +     * Whether upload is enabled.
      +     * 
      + */ + public boolean getEnabled() { + return enabled_; + } + /** + * optional bool enabled = 3; + * + *
      +     * Whether upload is enabled.
      +     * 
      + */ + public Builder setEnabled(boolean value) { + + enabled_ = value; + onChanged(); + return this; + } + /** + * optional bool enabled = 3; + * + *
      +     * Whether upload is enabled.
      +     * 
      + */ + public Builder clearEnabled() { + + enabled_ = false; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.MediaUpload) + } + + // @@protoc_insertion_point(class_scope:google.api.MediaUpload) + private static final com.google.api.MediaUpload DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.MediaUpload(); + } + + public static com.google.api.MediaUpload getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public MediaUpload parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new MediaUpload(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.MediaUpload getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUploadOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUploadOrBuilder.java new file mode 100644 index 000000000000..a3c55034ce00 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUploadOrBuilder.java @@ -0,0 +1,18 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/http.proto + +package com.google.api; + +public interface MediaUploadOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.MediaUpload) + com.google.protobuf.MessageOrBuilder { + + /** + * optional bool enabled = 3; + * + *
      +   * Whether upload is enabled.
      +   * 
      + */ + boolean getEnabled(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Page.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Page.java new file mode 100644 index 000000000000..0ed13fb48cf4 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/Page.java @@ -0,0 +1,1176 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/documentation.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.Page} + * + *
      + * Represents a documentation page. A page can contain subpages to represent
      + * nested documentation set structure.
      + * 
      + */ +public final class Page extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.Page) + PageOrBuilder { + // Use Page.newBuilder() to construct. + private Page(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Page() { + name_ = ""; + content_ = ""; + subpages_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Page( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + content_ = s; + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + subpages_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + subpages_.add(input.readMessage(com.google.api.Page.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + subpages_ = java.util.Collections.unmodifiableList(subpages_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.DocumentationProto.internal_static_google_api_Page_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.DocumentationProto.internal_static_google_api_Page_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Page.class, com.google.api.Page.Builder.class); + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * optional string name = 1; + * + *
      +   * The name of the page. It will be used as an identity of the page to
      +   * generate URI of the page, text of the link to this page in navigation,
      +   * etc. The full page name (start from the root page name to this page
      +   * concatenated with `.`) can be used as reference to the page in your
      +   * documentation. For example:
      +   *     pages:
      +   *     - name: Tutorial
      +   *       content: (== include tutorial.md ==)
      +   *       subpages:
      +   *       - name: Java
      +   *         content: (== include tutorial_java.md ==)
      +   * You can reference `Java` page using Markdown reference link syntax:
      +   * `[Java][Tutorial.Java]`.
      +   * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + * + *
      +   * The name of the page. It will be used as an identity of the page to
      +   * generate URI of the page, text of the link to this page in navigation,
      +   * etc. The full page name (start from the root page name to this page
      +   * concatenated with `.`) can be used as reference to the page in your
      +   * documentation. For example:
      +   *     pages:
      +   *     - name: Tutorial
      +   *       content: (== include tutorial.md ==)
      +   *       subpages:
      +   *       - name: Java
      +   *         content: (== include tutorial_java.md ==)
      +   * You can reference `Java` page using Markdown reference link syntax:
      +   * `[Java][Tutorial.Java]`.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CONTENT_FIELD_NUMBER = 2; + private volatile java.lang.Object content_; + /** + * optional string content = 2; + * + *
      +   * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      +   * to include content from a Markdown file.
      +   * 
      + */ + public java.lang.String getContent() { + java.lang.Object ref = content_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + content_ = s; + return s; + } + } + /** + * optional string content = 2; + * + *
      +   * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      +   * to include content from a Markdown file.
      +   * 
      + */ + public com.google.protobuf.ByteString + getContentBytes() { + java.lang.Object ref = content_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SUBPAGES_FIELD_NUMBER = 3; + private java.util.List subpages_; + /** + * repeated .google.api.Page subpages = 3; + * + *
      +   * Subpages of this page. The order of subpages specified here will be
      +   * honored in the generated docset.
      +   * 
      + */ + public java.util.List getSubpagesList() { + return subpages_; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +   * Subpages of this page. The order of subpages specified here will be
      +   * honored in the generated docset.
      +   * 
      + */ + public java.util.List + getSubpagesOrBuilderList() { + return subpages_; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +   * Subpages of this page. The order of subpages specified here will be
      +   * honored in the generated docset.
      +   * 
      + */ + public int getSubpagesCount() { + return subpages_.size(); + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +   * Subpages of this page. The order of subpages specified here will be
      +   * honored in the generated docset.
      +   * 
      + */ + public com.google.api.Page getSubpages(int index) { + return subpages_.get(index); + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +   * Subpages of this page. The order of subpages specified here will be
      +   * honored in the generated docset.
      +   * 
      + */ + public com.google.api.PageOrBuilder getSubpagesOrBuilder( + int index) { + return subpages_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (!getContentBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, content_); + } + for (int i = 0; i < subpages_.size(); i++) { + output.writeMessage(3, subpages_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (!getContentBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, content_); + } + for (int i = 0; i < subpages_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, subpages_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.Page parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Page parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Page parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Page parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Page parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Page parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.Page parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.Page parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.Page parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Page parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.Page prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.Page} + * + *
      +   * Represents a documentation page. A page can contain subpages to represent
      +   * nested documentation set structure.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.Page) + com.google.api.PageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.DocumentationProto.internal_static_google_api_Page_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.DocumentationProto.internal_static_google_api_Page_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Page.class, com.google.api.Page.Builder.class); + } + + // Construct using com.google.api.Page.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getSubpagesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + content_ = ""; + + if (subpagesBuilder_ == null) { + subpages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + subpagesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.DocumentationProto.internal_static_google_api_Page_descriptor; + } + + public com.google.api.Page getDefaultInstanceForType() { + return com.google.api.Page.getDefaultInstance(); + } + + public com.google.api.Page build() { + com.google.api.Page result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.Page buildPartial() { + com.google.api.Page result = new com.google.api.Page(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.name_ = name_; + result.content_ = content_; + if (subpagesBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + subpages_ = java.util.Collections.unmodifiableList(subpages_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.subpages_ = subpages_; + } else { + result.subpages_ = subpagesBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.Page) { + return mergeFrom((com.google.api.Page)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.Page other) { + if (other == com.google.api.Page.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getContent().isEmpty()) { + content_ = other.content_; + onChanged(); + } + if (subpagesBuilder_ == null) { + if (!other.subpages_.isEmpty()) { + if (subpages_.isEmpty()) { + subpages_ = other.subpages_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureSubpagesIsMutable(); + subpages_.addAll(other.subpages_); + } + onChanged(); + } + } else { + if (!other.subpages_.isEmpty()) { + if (subpagesBuilder_.isEmpty()) { + subpagesBuilder_.dispose(); + subpagesBuilder_ = null; + subpages_ = other.subpages_; + bitField0_ = (bitField0_ & ~0x00000004); + subpagesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getSubpagesFieldBuilder() : null; + } else { + subpagesBuilder_.addAllMessages(other.subpages_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.Page parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.Page) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * optional string name = 1; + * + *
      +     * The name of the page. It will be used as an identity of the page to
      +     * generate URI of the page, text of the link to this page in navigation,
      +     * etc. The full page name (start from the root page name to this page
      +     * concatenated with `.`) can be used as reference to the page in your
      +     * documentation. For example:
      +     *     pages:
      +     *     - name: Tutorial
      +     *       content: (== include tutorial.md ==)
      +     *       subpages:
      +     *       - name: Java
      +     *         content: (== include tutorial_java.md ==)
      +     * You can reference `Java` page using Markdown reference link syntax:
      +     * `[Java][Tutorial.Java]`.
      +     * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the page. It will be used as an identity of the page to
      +     * generate URI of the page, text of the link to this page in navigation,
      +     * etc. The full page name (start from the root page name to this page
      +     * concatenated with `.`) can be used as reference to the page in your
      +     * documentation. For example:
      +     *     pages:
      +     *     - name: Tutorial
      +     *       content: (== include tutorial.md ==)
      +     *       subpages:
      +     *       - name: Java
      +     *         content: (== include tutorial_java.md ==)
      +     * You can reference `Java` page using Markdown reference link syntax:
      +     * `[Java][Tutorial.Java]`.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the page. It will be used as an identity of the page to
      +     * generate URI of the page, text of the link to this page in navigation,
      +     * etc. The full page name (start from the root page name to this page
      +     * concatenated with `.`) can be used as reference to the page in your
      +     * documentation. For example:
      +     *     pages:
      +     *     - name: Tutorial
      +     *       content: (== include tutorial.md ==)
      +     *       subpages:
      +     *       - name: Java
      +     *         content: (== include tutorial_java.md ==)
      +     * You can reference `Java` page using Markdown reference link syntax:
      +     * `[Java][Tutorial.Java]`.
      +     * 
      + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the page. It will be used as an identity of the page to
      +     * generate URI of the page, text of the link to this page in navigation,
      +     * etc. The full page name (start from the root page name to this page
      +     * concatenated with `.`) can be used as reference to the page in your
      +     * documentation. For example:
      +     *     pages:
      +     *     - name: Tutorial
      +     *       content: (== include tutorial.md ==)
      +     *       subpages:
      +     *       - name: Java
      +     *         content: (== include tutorial_java.md ==)
      +     * You can reference `Java` page using Markdown reference link syntax:
      +     * `[Java][Tutorial.Java]`.
      +     * 
      + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the page. It will be used as an identity of the page to
      +     * generate URI of the page, text of the link to this page in navigation,
      +     * etc. The full page name (start from the root page name to this page
      +     * concatenated with `.`) can be used as reference to the page in your
      +     * documentation. For example:
      +     *     pages:
      +     *     - name: Tutorial
      +     *       content: (== include tutorial.md ==)
      +     *       subpages:
      +     *       - name: Java
      +     *         content: (== include tutorial_java.md ==)
      +     * You can reference `Java` page using Markdown reference link syntax:
      +     * `[Java][Tutorial.Java]`.
      +     * 
      + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object content_ = ""; + /** + * optional string content = 2; + * + *
      +     * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      +     * to include content from a Markdown file.
      +     * 
      + */ + public java.lang.String getContent() { + java.lang.Object ref = content_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + content_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string content = 2; + * + *
      +     * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      +     * to include content from a Markdown file.
      +     * 
      + */ + public com.google.protobuf.ByteString + getContentBytes() { + java.lang.Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string content = 2; + * + *
      +     * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      +     * to include content from a Markdown file.
      +     * 
      + */ + public Builder setContent( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + content_ = value; + onChanged(); + return this; + } + /** + * optional string content = 2; + * + *
      +     * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      +     * to include content from a Markdown file.
      +     * 
      + */ + public Builder clearContent() { + + content_ = getDefaultInstance().getContent(); + onChanged(); + return this; + } + /** + * optional string content = 2; + * + *
      +     * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      +     * to include content from a Markdown file.
      +     * 
      + */ + public Builder setContentBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + content_ = value; + onChanged(); + return this; + } + + private java.util.List subpages_ = + java.util.Collections.emptyList(); + private void ensureSubpagesIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + subpages_ = new java.util.ArrayList(subpages_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder> subpagesBuilder_; + + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public java.util.List getSubpagesList() { + if (subpagesBuilder_ == null) { + return java.util.Collections.unmodifiableList(subpages_); + } else { + return subpagesBuilder_.getMessageList(); + } + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public int getSubpagesCount() { + if (subpagesBuilder_ == null) { + return subpages_.size(); + } else { + return subpagesBuilder_.getCount(); + } + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public com.google.api.Page getSubpages(int index) { + if (subpagesBuilder_ == null) { + return subpages_.get(index); + } else { + return subpagesBuilder_.getMessage(index); + } + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public Builder setSubpages( + int index, com.google.api.Page value) { + if (subpagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubpagesIsMutable(); + subpages_.set(index, value); + onChanged(); + } else { + subpagesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public Builder setSubpages( + int index, com.google.api.Page.Builder builderForValue) { + if (subpagesBuilder_ == null) { + ensureSubpagesIsMutable(); + subpages_.set(index, builderForValue.build()); + onChanged(); + } else { + subpagesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public Builder addSubpages(com.google.api.Page value) { + if (subpagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubpagesIsMutable(); + subpages_.add(value); + onChanged(); + } else { + subpagesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public Builder addSubpages( + int index, com.google.api.Page value) { + if (subpagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubpagesIsMutable(); + subpages_.add(index, value); + onChanged(); + } else { + subpagesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public Builder addSubpages( + com.google.api.Page.Builder builderForValue) { + if (subpagesBuilder_ == null) { + ensureSubpagesIsMutable(); + subpages_.add(builderForValue.build()); + onChanged(); + } else { + subpagesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public Builder addSubpages( + int index, com.google.api.Page.Builder builderForValue) { + if (subpagesBuilder_ == null) { + ensureSubpagesIsMutable(); + subpages_.add(index, builderForValue.build()); + onChanged(); + } else { + subpagesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public Builder addAllSubpages( + java.lang.Iterable values) { + if (subpagesBuilder_ == null) { + ensureSubpagesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, subpages_); + onChanged(); + } else { + subpagesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public Builder clearSubpages() { + if (subpagesBuilder_ == null) { + subpages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + subpagesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public Builder removeSubpages(int index) { + if (subpagesBuilder_ == null) { + ensureSubpagesIsMutable(); + subpages_.remove(index); + onChanged(); + } else { + subpagesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public com.google.api.Page.Builder getSubpagesBuilder( + int index) { + return getSubpagesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public com.google.api.PageOrBuilder getSubpagesOrBuilder( + int index) { + if (subpagesBuilder_ == null) { + return subpages_.get(index); } else { + return subpagesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public java.util.List + getSubpagesOrBuilderList() { + if (subpagesBuilder_ != null) { + return subpagesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(subpages_); + } + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public com.google.api.Page.Builder addSubpagesBuilder() { + return getSubpagesFieldBuilder().addBuilder( + com.google.api.Page.getDefaultInstance()); + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public com.google.api.Page.Builder addSubpagesBuilder( + int index) { + return getSubpagesFieldBuilder().addBuilder( + index, com.google.api.Page.getDefaultInstance()); + } + /** + * repeated .google.api.Page subpages = 3; + * + *
      +     * Subpages of this page. The order of subpages specified here will be
      +     * honored in the generated docset.
      +     * 
      + */ + public java.util.List + getSubpagesBuilderList() { + return getSubpagesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder> + getSubpagesFieldBuilder() { + if (subpagesBuilder_ == null) { + subpagesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder>( + subpages_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + subpages_ = null; + } + return subpagesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.Page) + } + + // @@protoc_insertion_point(class_scope:google.api.Page) + private static final com.google.api.Page DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.Page(); + } + + public static com.google.api.Page getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Page parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Page(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.Page getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/PageOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/PageOrBuilder.java new file mode 100644 index 000000000000..5a566c4ad030 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/PageOrBuilder.java @@ -0,0 +1,120 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/documentation.proto + +package com.google.api; + +public interface PageOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.Page) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 1; + * + *
      +   * The name of the page. It will be used as an identity of the page to
      +   * generate URI of the page, text of the link to this page in navigation,
      +   * etc. The full page name (start from the root page name to this page
      +   * concatenated with `.`) can be used as reference to the page in your
      +   * documentation. For example:
      +   *     pages:
      +   *     - name: Tutorial
      +   *       content: (== include tutorial.md ==)
      +   *       subpages:
      +   *       - name: Java
      +   *         content: (== include tutorial_java.md ==)
      +   * You can reference `Java` page using Markdown reference link syntax:
      +   * `[Java][Tutorial.Java]`.
      +   * 
      + */ + java.lang.String getName(); + /** + * optional string name = 1; + * + *
      +   * The name of the page. It will be used as an identity of the page to
      +   * generate URI of the page, text of the link to this page in navigation,
      +   * etc. The full page name (start from the root page name to this page
      +   * concatenated with `.`) can be used as reference to the page in your
      +   * documentation. For example:
      +   *     pages:
      +   *     - name: Tutorial
      +   *       content: (== include tutorial.md ==)
      +   *       subpages:
      +   *       - name: Java
      +   *         content: (== include tutorial_java.md ==)
      +   * You can reference `Java` page using Markdown reference link syntax:
      +   * `[Java][Tutorial.Java]`.
      +   * 
      + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * optional string content = 2; + * + *
      +   * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      +   * to include content from a Markdown file.
      +   * 
      + */ + java.lang.String getContent(); + /** + * optional string content = 2; + * + *
      +   * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      +   * to include content from a Markdown file.
      +   * 
      + */ + com.google.protobuf.ByteString + getContentBytes(); + + /** + * repeated .google.api.Page subpages = 3; + * + *
      +   * Subpages of this page. The order of subpages specified here will be
      +   * honored in the generated docset.
      +   * 
      + */ + java.util.List + getSubpagesList(); + /** + * repeated .google.api.Page subpages = 3; + * + *
      +   * Subpages of this page. The order of subpages specified here will be
      +   * honored in the generated docset.
      +   * 
      + */ + com.google.api.Page getSubpages(int index); + /** + * repeated .google.api.Page subpages = 3; + * + *
      +   * Subpages of this page. The order of subpages specified here will be
      +   * honored in the generated docset.
      +   * 
      + */ + int getSubpagesCount(); + /** + * repeated .google.api.Page subpages = 3; + * + *
      +   * Subpages of this page. The order of subpages specified here will be
      +   * honored in the generated docset.
      +   * 
      + */ + java.util.List + getSubpagesOrBuilderList(); + /** + * repeated .google.api.Page subpages = 3; + * + *
      +   * Subpages of this page. The order of subpages specified here will be
      +   * honored in the generated docset.
      +   * 
      + */ + com.google.api.PageOrBuilder getSubpagesOrBuilder( + int index); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Service.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Service.java new file mode 100644 index 000000000000..1ba6c8e37d79 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/Service.java @@ -0,0 +1,4591 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/service.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.Service} + * + *
      + * (== page basics ==)
      + * `Service` is the root object of the configuration schema. It
      + * describes basic information like the name of the service and the
      + * exposed API interfaces, and delegates other aspects to configuration
      + * sub-sections.
      + * Example:
      + *     type: google.api.Service
      + *     config_version: 1
      + *     name: calendar.googleapis.com
      + *     title: Google Calendar API
      + *     apis:
      + *     - name: google.calendar.Calendar
      + *     visibility:
      + *       rules:
      + *       - selector: "*"
      + *         restriction: TRUSTED_TESTER
      + *     backend:
      + *       rules:
      + *       - selector: "*"
      + *         address: calendar-prod-backend.gslb.googleapis.com
      + * 
      + */ +public final class Service extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.Service) + ServiceOrBuilder { + // Use Service.newBuilder() to construct. + private Service(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Service() { + name_ = ""; + title_ = ""; + producerProjectId_ = ""; + apis_ = java.util.Collections.emptyList(); + types_ = java.util.Collections.emptyList(); + enums_ = java.util.Collections.emptyList(); + systemTypes_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Service( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + title_ = s; + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + apis_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + apis_.add(input.readMessage(com.google.protobuf.Api.parser(), extensionRegistry)); + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + types_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000020; + } + types_.add(input.readMessage(com.google.protobuf.Type.parser(), extensionRegistry)); + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + enums_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000040; + } + enums_.add(input.readMessage(com.google.protobuf.Enum.parser(), extensionRegistry)); + break; + } + case 50: { + com.google.api.Documentation.Builder subBuilder = null; + if (documentation_ != null) { + subBuilder = documentation_.toBuilder(); + } + documentation_ = input.readMessage(com.google.api.Documentation.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(documentation_); + documentation_ = subBuilder.buildPartial(); + } + + break; + } + case 58: { + com.google.api.Visibility.Builder subBuilder = null; + if (visibility_ != null) { + subBuilder = visibility_.toBuilder(); + } + visibility_ = input.readMessage(com.google.api.Visibility.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(visibility_); + visibility_ = subBuilder.buildPartial(); + } + + break; + } + case 74: { + com.google.api.Http.Builder subBuilder = null; + if (http_ != null) { + subBuilder = http_.toBuilder(); + } + http_ = input.readMessage(com.google.api.Http.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(http_); + http_ = subBuilder.buildPartial(); + } + + break; + } + case 98: { + com.google.api.Context.Builder subBuilder = null; + if (context_ != null) { + subBuilder = context_.toBuilder(); + } + context_ = input.readMessage(com.google.api.Context.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(context_); + context_ = subBuilder.buildPartial(); + } + + break; + } + case 130: { + com.google.api.CustomError.Builder subBuilder = null; + if (customError_ != null) { + subBuilder = customError_.toBuilder(); + } + customError_ = input.readMessage(com.google.api.CustomError.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(customError_); + customError_ = subBuilder.buildPartial(); + } + + break; + } + case 162: { + com.google.protobuf.UInt32Value.Builder subBuilder = null; + if (configVersion_ != null) { + subBuilder = configVersion_.toBuilder(); + } + configVersion_ = input.readMessage(com.google.protobuf.UInt32Value.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(configVersion_); + configVersion_ = subBuilder.buildPartial(); + } + + break; + } + case 178: { + String s = input.readStringRequireUtf8(); + + producerProjectId_ = s; + break; + } + case 802: { + com.google.protobuf.Any.Builder subBuilder = null; + if (derivedData_ != null) { + subBuilder = derivedData_.toBuilder(); + } + derivedData_ = input.readMessage(com.google.protobuf.Any.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(derivedData_); + derivedData_ = subBuilder.buildPartial(); + } + + break; + } + case 818: { + if (!((mutable_bitField0_ & 0x00002000) == 0x00002000)) { + systemTypes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00002000; + } + systemTypes_.add(input.readMessage(com.google.protobuf.Type.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + apis_ = java.util.Collections.unmodifiableList(apis_); + } + if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + types_ = java.util.Collections.unmodifiableList(types_); + } + if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + enums_ = java.util.Collections.unmodifiableList(enums_); + } + if (((mutable_bitField0_ & 0x00002000) == 0x00002000)) { + systemTypes_ = java.util.Collections.unmodifiableList(systemTypes_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.ServiceProto.internal_static_google_api_Service_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.ServiceProto.internal_static_google_api_Service_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Service.class, com.google.api.Service.Builder.class); + } + + private int bitField0_; + public static final int CONFIG_VERSION_FIELD_NUMBER = 20; + private com.google.protobuf.UInt32Value configVersion_; + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +   * The version of the service configuration. The config version may
      +   * influence interpretation of the configuration, for example
      +   * determine defaults. This is documented together with applicable
      +   * options. The current default for the config version itself is `1`.
      +   * 
      + */ + public boolean hasConfigVersion() { + return configVersion_ != null; + } + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +   * The version of the service configuration. The config version may
      +   * influence interpretation of the configuration, for example
      +   * determine defaults. This is documented together with applicable
      +   * options. The current default for the config version itself is `1`.
      +   * 
      + */ + public com.google.protobuf.UInt32Value getConfigVersion() { + return configVersion_ == null ? com.google.protobuf.UInt32Value.getDefaultInstance() : configVersion_; + } + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +   * The version of the service configuration. The config version may
      +   * influence interpretation of the configuration, for example
      +   * determine defaults. This is documented together with applicable
      +   * options. The current default for the config version itself is `1`.
      +   * 
      + */ + public com.google.protobuf.UInt32ValueOrBuilder getConfigVersionOrBuilder() { + return getConfigVersion(); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * optional string name = 1; + * + *
      +   * The DNS address at which this service is available,
      +   * e.g. `calendar.googleapis.com`.
      +   * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + * + *
      +   * The DNS address at which this service is available,
      +   * e.g. `calendar.googleapis.com`.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TITLE_FIELD_NUMBER = 2; + private volatile java.lang.Object title_; + /** + * optional string title = 2; + * + *
      +   * The product title associated with this service.
      +   * 
      + */ + public java.lang.String getTitle() { + java.lang.Object ref = title_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + title_ = s; + return s; + } + } + /** + * optional string title = 2; + * + *
      +   * The product title associated with this service.
      +   * 
      + */ + public com.google.protobuf.ByteString + getTitleBytes() { + java.lang.Object ref = title_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + title_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PRODUCER_PROJECT_ID_FIELD_NUMBER = 22; + private volatile java.lang.Object producerProjectId_; + /** + * optional string producer_project_id = 22; + * + *
      +   * The id of the Google developer project that owns the service.
      +   * Members of this project can manage the service configuration,
      +   * manage consumption of the service, etc.
      +   * 
      + */ + public java.lang.String getProducerProjectId() { + java.lang.Object ref = producerProjectId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + producerProjectId_ = s; + return s; + } + } + /** + * optional string producer_project_id = 22; + * + *
      +   * The id of the Google developer project that owns the service.
      +   * Members of this project can manage the service configuration,
      +   * manage consumption of the service, etc.
      +   * 
      + */ + public com.google.protobuf.ByteString + getProducerProjectIdBytes() { + java.lang.Object ref = producerProjectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + producerProjectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int APIS_FIELD_NUMBER = 3; + private java.util.List apis_; + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +   * A list of API interfaces exported by this service. Only the `name` field
      +   * of the [google.protobuf.Api][] needs to be provided by the configuration
      +   * author, as the remaining fields will be derived from the IDL during the
      +   * normalization process. It is an error to specify an API interface here
      +   * which cannot be resolved against the associated IDL files.
      +   * 
      + */ + public java.util.List getApisList() { + return apis_; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +   * A list of API interfaces exported by this service. Only the `name` field
      +   * of the [google.protobuf.Api][] needs to be provided by the configuration
      +   * author, as the remaining fields will be derived from the IDL during the
      +   * normalization process. It is an error to specify an API interface here
      +   * which cannot be resolved against the associated IDL files.
      +   * 
      + */ + public java.util.List + getApisOrBuilderList() { + return apis_; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +   * A list of API interfaces exported by this service. Only the `name` field
      +   * of the [google.protobuf.Api][] needs to be provided by the configuration
      +   * author, as the remaining fields will be derived from the IDL during the
      +   * normalization process. It is an error to specify an API interface here
      +   * which cannot be resolved against the associated IDL files.
      +   * 
      + */ + public int getApisCount() { + return apis_.size(); + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +   * A list of API interfaces exported by this service. Only the `name` field
      +   * of the [google.protobuf.Api][] needs to be provided by the configuration
      +   * author, as the remaining fields will be derived from the IDL during the
      +   * normalization process. It is an error to specify an API interface here
      +   * which cannot be resolved against the associated IDL files.
      +   * 
      + */ + public com.google.protobuf.Api getApis(int index) { + return apis_.get(index); + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +   * A list of API interfaces exported by this service. Only the `name` field
      +   * of the [google.protobuf.Api][] needs to be provided by the configuration
      +   * author, as the remaining fields will be derived from the IDL during the
      +   * normalization process. It is an error to specify an API interface here
      +   * which cannot be resolved against the associated IDL files.
      +   * 
      + */ + public com.google.protobuf.ApiOrBuilder getApisOrBuilder( + int index) { + return apis_.get(index); + } + + public static final int TYPES_FIELD_NUMBER = 4; + private java.util.List types_; + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +   * A list of all proto message types included in this API service.
      +   * Types referenced directly or indirectly by the `apis` are
      +   * automatically included.  Messages which are not referenced but
      +   * shall be included, such as types used by the `google.protobuf.Any` type,
      +   * should be listed here by name. Example:
      +   *     types:
      +   *     - name: google.protobuf.Int32
      +   * 
      + */ + public java.util.List getTypesList() { + return types_; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +   * A list of all proto message types included in this API service.
      +   * Types referenced directly or indirectly by the `apis` are
      +   * automatically included.  Messages which are not referenced but
      +   * shall be included, such as types used by the `google.protobuf.Any` type,
      +   * should be listed here by name. Example:
      +   *     types:
      +   *     - name: google.protobuf.Int32
      +   * 
      + */ + public java.util.List + getTypesOrBuilderList() { + return types_; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +   * A list of all proto message types included in this API service.
      +   * Types referenced directly or indirectly by the `apis` are
      +   * automatically included.  Messages which are not referenced but
      +   * shall be included, such as types used by the `google.protobuf.Any` type,
      +   * should be listed here by name. Example:
      +   *     types:
      +   *     - name: google.protobuf.Int32
      +   * 
      + */ + public int getTypesCount() { + return types_.size(); + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +   * A list of all proto message types included in this API service.
      +   * Types referenced directly or indirectly by the `apis` are
      +   * automatically included.  Messages which are not referenced but
      +   * shall be included, such as types used by the `google.protobuf.Any` type,
      +   * should be listed here by name. Example:
      +   *     types:
      +   *     - name: google.protobuf.Int32
      +   * 
      + */ + public com.google.protobuf.Type getTypes(int index) { + return types_.get(index); + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +   * A list of all proto message types included in this API service.
      +   * Types referenced directly or indirectly by the `apis` are
      +   * automatically included.  Messages which are not referenced but
      +   * shall be included, such as types used by the `google.protobuf.Any` type,
      +   * should be listed here by name. Example:
      +   *     types:
      +   *     - name: google.protobuf.Int32
      +   * 
      + */ + public com.google.protobuf.TypeOrBuilder getTypesOrBuilder( + int index) { + return types_.get(index); + } + + public static final int ENUMS_FIELD_NUMBER = 5; + private java.util.List enums_; + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +   * A list of all enum types included in this API service.  Enums
      +   * referenced directly or indirectly by the `apis` are automatically
      +   * included.  Enums which are not referenced but shall be included
      +   * should be listed here by name. Example:
      +   *     enums:
      +   *     - name: google.someapi.v1.SomeEnum
      +   * 
      + */ + public java.util.List getEnumsList() { + return enums_; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +   * A list of all enum types included in this API service.  Enums
      +   * referenced directly or indirectly by the `apis` are automatically
      +   * included.  Enums which are not referenced but shall be included
      +   * should be listed here by name. Example:
      +   *     enums:
      +   *     - name: google.someapi.v1.SomeEnum
      +   * 
      + */ + public java.util.List + getEnumsOrBuilderList() { + return enums_; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +   * A list of all enum types included in this API service.  Enums
      +   * referenced directly or indirectly by the `apis` are automatically
      +   * included.  Enums which are not referenced but shall be included
      +   * should be listed here by name. Example:
      +   *     enums:
      +   *     - name: google.someapi.v1.SomeEnum
      +   * 
      + */ + public int getEnumsCount() { + return enums_.size(); + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +   * A list of all enum types included in this API service.  Enums
      +   * referenced directly or indirectly by the `apis` are automatically
      +   * included.  Enums which are not referenced but shall be included
      +   * should be listed here by name. Example:
      +   *     enums:
      +   *     - name: google.someapi.v1.SomeEnum
      +   * 
      + */ + public com.google.protobuf.Enum getEnums(int index) { + return enums_.get(index); + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +   * A list of all enum types included in this API service.  Enums
      +   * referenced directly or indirectly by the `apis` are automatically
      +   * included.  Enums which are not referenced but shall be included
      +   * should be listed here by name. Example:
      +   *     enums:
      +   *     - name: google.someapi.v1.SomeEnum
      +   * 
      + */ + public com.google.protobuf.EnumOrBuilder getEnumsOrBuilder( + int index) { + return enums_.get(index); + } + + public static final int DOCUMENTATION_FIELD_NUMBER = 6; + private com.google.api.Documentation documentation_; + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +   * Additional API documentation.
      +   * 
      + */ + public boolean hasDocumentation() { + return documentation_ != null; + } + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +   * Additional API documentation.
      +   * 
      + */ + public com.google.api.Documentation getDocumentation() { + return documentation_ == null ? com.google.api.Documentation.getDefaultInstance() : documentation_; + } + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +   * Additional API documentation.
      +   * 
      + */ + public com.google.api.DocumentationOrBuilder getDocumentationOrBuilder() { + return getDocumentation(); + } + + public static final int VISIBILITY_FIELD_NUMBER = 7; + private com.google.api.Visibility visibility_; + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +   * API visibility configuration.
      +   * 
      + */ + public boolean hasVisibility() { + return visibility_ != null; + } + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +   * API visibility configuration.
      +   * 
      + */ + public com.google.api.Visibility getVisibility() { + return visibility_ == null ? com.google.api.Visibility.getDefaultInstance() : visibility_; + } + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +   * API visibility configuration.
      +   * 
      + */ + public com.google.api.VisibilityOrBuilder getVisibilityOrBuilder() { + return getVisibility(); + } + + public static final int HTTP_FIELD_NUMBER = 9; + private com.google.api.Http http_; + /** + * optional .google.api.Http http = 9; + * + *
      +   * HTTP configuration.
      +   * 
      + */ + public boolean hasHttp() { + return http_ != null; + } + /** + * optional .google.api.Http http = 9; + * + *
      +   * HTTP configuration.
      +   * 
      + */ + public com.google.api.Http getHttp() { + return http_ == null ? com.google.api.Http.getDefaultInstance() : http_; + } + /** + * optional .google.api.Http http = 9; + * + *
      +   * HTTP configuration.
      +   * 
      + */ + public com.google.api.HttpOrBuilder getHttpOrBuilder() { + return getHttp(); + } + + public static final int CONTEXT_FIELD_NUMBER = 12; + private com.google.api.Context context_; + /** + * optional .google.api.Context context = 12; + * + *
      +   * Context configuration.
      +   * 
      + */ + public boolean hasContext() { + return context_ != null; + } + /** + * optional .google.api.Context context = 12; + * + *
      +   * Context configuration.
      +   * 
      + */ + public com.google.api.Context getContext() { + return context_ == null ? com.google.api.Context.getDefaultInstance() : context_; + } + /** + * optional .google.api.Context context = 12; + * + *
      +   * Context configuration.
      +   * 
      + */ + public com.google.api.ContextOrBuilder getContextOrBuilder() { + return getContext(); + } + + public static final int CUSTOM_ERROR_FIELD_NUMBER = 16; + private com.google.api.CustomError customError_; + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +   * Custom error configuration.
      +   * 
      + */ + public boolean hasCustomError() { + return customError_ != null; + } + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +   * Custom error configuration.
      +   * 
      + */ + public com.google.api.CustomError getCustomError() { + return customError_ == null ? com.google.api.CustomError.getDefaultInstance() : customError_; + } + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +   * Custom error configuration.
      +   * 
      + */ + public com.google.api.CustomErrorOrBuilder getCustomErrorOrBuilder() { + return getCustomError(); + } + + public static final int DERIVED_DATA_FIELD_NUMBER = 100; + private com.google.protobuf.Any derivedData_; + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +   * Service attributes derived by the configuration toolchain, for
      +   * use at runtime.  Type is defined in
      +   * `//google/internal/api/derived_service.proto`.
      +   * 
      + */ + public boolean hasDerivedData() { + return derivedData_ != null; + } + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +   * Service attributes derived by the configuration toolchain, for
      +   * use at runtime.  Type is defined in
      +   * `//google/internal/api/derived_service.proto`.
      +   * 
      + */ + public com.google.protobuf.Any getDerivedData() { + return derivedData_ == null ? com.google.protobuf.Any.getDefaultInstance() : derivedData_; + } + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +   * Service attributes derived by the configuration toolchain, for
      +   * use at runtime.  Type is defined in
      +   * `//google/internal/api/derived_service.proto`.
      +   * 
      + */ + public com.google.protobuf.AnyOrBuilder getDerivedDataOrBuilder() { + return getDerivedData(); + } + + public static final int SYSTEM_TYPES_FIELD_NUMBER = 102; + private java.util.List systemTypes_; + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +   * A list of all proto message types included in this API service.
      +   * It serves similar purpose as [google.api.Service.types], except that
      +   * these types are not needed by user-defined APIs. Therefore, they will not
      +   * show up in the generated discovery doc. This field should only be used
      +   * to define system APIs in ESF.
      +   * 
      + */ + public java.util.List getSystemTypesList() { + return systemTypes_; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +   * A list of all proto message types included in this API service.
      +   * It serves similar purpose as [google.api.Service.types], except that
      +   * these types are not needed by user-defined APIs. Therefore, they will not
      +   * show up in the generated discovery doc. This field should only be used
      +   * to define system APIs in ESF.
      +   * 
      + */ + public java.util.List + getSystemTypesOrBuilderList() { + return systemTypes_; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +   * A list of all proto message types included in this API service.
      +   * It serves similar purpose as [google.api.Service.types], except that
      +   * these types are not needed by user-defined APIs. Therefore, they will not
      +   * show up in the generated discovery doc. This field should only be used
      +   * to define system APIs in ESF.
      +   * 
      + */ + public int getSystemTypesCount() { + return systemTypes_.size(); + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +   * A list of all proto message types included in this API service.
      +   * It serves similar purpose as [google.api.Service.types], except that
      +   * these types are not needed by user-defined APIs. Therefore, they will not
      +   * show up in the generated discovery doc. This field should only be used
      +   * to define system APIs in ESF.
      +   * 
      + */ + public com.google.protobuf.Type getSystemTypes(int index) { + return systemTypes_.get(index); + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +   * A list of all proto message types included in this API service.
      +   * It serves similar purpose as [google.api.Service.types], except that
      +   * these types are not needed by user-defined APIs. Therefore, they will not
      +   * show up in the generated discovery doc. This field should only be used
      +   * to define system APIs in ESF.
      +   * 
      + */ + public com.google.protobuf.TypeOrBuilder getSystemTypesOrBuilder( + int index) { + return systemTypes_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (!getTitleBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, title_); + } + for (int i = 0; i < apis_.size(); i++) { + output.writeMessage(3, apis_.get(i)); + } + for (int i = 0; i < types_.size(); i++) { + output.writeMessage(4, types_.get(i)); + } + for (int i = 0; i < enums_.size(); i++) { + output.writeMessage(5, enums_.get(i)); + } + if (documentation_ != null) { + output.writeMessage(6, getDocumentation()); + } + if (visibility_ != null) { + output.writeMessage(7, getVisibility()); + } + if (http_ != null) { + output.writeMessage(9, getHttp()); + } + if (context_ != null) { + output.writeMessage(12, getContext()); + } + if (customError_ != null) { + output.writeMessage(16, getCustomError()); + } + if (configVersion_ != null) { + output.writeMessage(20, getConfigVersion()); + } + if (!getProducerProjectIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 22, producerProjectId_); + } + if (derivedData_ != null) { + output.writeMessage(100, getDerivedData()); + } + for (int i = 0; i < systemTypes_.size(); i++) { + output.writeMessage(102, systemTypes_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (!getTitleBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, title_); + } + for (int i = 0; i < apis_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, apis_.get(i)); + } + for (int i = 0; i < types_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, types_.get(i)); + } + for (int i = 0; i < enums_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, enums_.get(i)); + } + if (documentation_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, getDocumentation()); + } + if (visibility_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, getVisibility()); + } + if (http_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(9, getHttp()); + } + if (context_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(12, getContext()); + } + if (customError_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(16, getCustomError()); + } + if (configVersion_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(20, getConfigVersion()); + } + if (!getProducerProjectIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(22, producerProjectId_); + } + if (derivedData_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(100, getDerivedData()); + } + for (int i = 0; i < systemTypes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(102, systemTypes_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.Service parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Service parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Service parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Service parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Service parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Service parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.Service parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.Service parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.Service parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Service parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.Service prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.Service} + * + *
      +   * (== page basics ==)
      +   * `Service` is the root object of the configuration schema. It
      +   * describes basic information like the name of the service and the
      +   * exposed API interfaces, and delegates other aspects to configuration
      +   * sub-sections.
      +   * Example:
      +   *     type: google.api.Service
      +   *     config_version: 1
      +   *     name: calendar.googleapis.com
      +   *     title: Google Calendar API
      +   *     apis:
      +   *     - name: google.calendar.Calendar
      +   *     visibility:
      +   *       rules:
      +   *       - selector: "*"
      +   *         restriction: TRUSTED_TESTER
      +   *     backend:
      +   *       rules:
      +   *       - selector: "*"
      +   *         address: calendar-prod-backend.gslb.googleapis.com
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.Service) + com.google.api.ServiceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.ServiceProto.internal_static_google_api_Service_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.ServiceProto.internal_static_google_api_Service_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Service.class, com.google.api.Service.Builder.class); + } + + // Construct using com.google.api.Service.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getApisFieldBuilder(); + getTypesFieldBuilder(); + getEnumsFieldBuilder(); + getSystemTypesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (configVersionBuilder_ == null) { + configVersion_ = null; + } else { + configVersion_ = null; + configVersionBuilder_ = null; + } + name_ = ""; + + title_ = ""; + + producerProjectId_ = ""; + + if (apisBuilder_ == null) { + apis_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + apisBuilder_.clear(); + } + if (typesBuilder_ == null) { + types_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + } else { + typesBuilder_.clear(); + } + if (enumsBuilder_ == null) { + enums_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + } else { + enumsBuilder_.clear(); + } + if (documentationBuilder_ == null) { + documentation_ = null; + } else { + documentation_ = null; + documentationBuilder_ = null; + } + if (visibilityBuilder_ == null) { + visibility_ = null; + } else { + visibility_ = null; + visibilityBuilder_ = null; + } + if (httpBuilder_ == null) { + http_ = null; + } else { + http_ = null; + httpBuilder_ = null; + } + if (contextBuilder_ == null) { + context_ = null; + } else { + context_ = null; + contextBuilder_ = null; + } + if (customErrorBuilder_ == null) { + customError_ = null; + } else { + customError_ = null; + customErrorBuilder_ = null; + } + if (derivedDataBuilder_ == null) { + derivedData_ = null; + } else { + derivedData_ = null; + derivedDataBuilder_ = null; + } + if (systemTypesBuilder_ == null) { + systemTypes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00002000); + } else { + systemTypesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.ServiceProto.internal_static_google_api_Service_descriptor; + } + + public com.google.api.Service getDefaultInstanceForType() { + return com.google.api.Service.getDefaultInstance(); + } + + public com.google.api.Service build() { + com.google.api.Service result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.Service buildPartial() { + com.google.api.Service result = new com.google.api.Service(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (configVersionBuilder_ == null) { + result.configVersion_ = configVersion_; + } else { + result.configVersion_ = configVersionBuilder_.build(); + } + result.name_ = name_; + result.title_ = title_; + result.producerProjectId_ = producerProjectId_; + if (apisBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + apis_ = java.util.Collections.unmodifiableList(apis_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.apis_ = apis_; + } else { + result.apis_ = apisBuilder_.build(); + } + if (typesBuilder_ == null) { + if (((bitField0_ & 0x00000020) == 0x00000020)) { + types_ = java.util.Collections.unmodifiableList(types_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.types_ = types_; + } else { + result.types_ = typesBuilder_.build(); + } + if (enumsBuilder_ == null) { + if (((bitField0_ & 0x00000040) == 0x00000040)) { + enums_ = java.util.Collections.unmodifiableList(enums_); + bitField0_ = (bitField0_ & ~0x00000040); + } + result.enums_ = enums_; + } else { + result.enums_ = enumsBuilder_.build(); + } + if (documentationBuilder_ == null) { + result.documentation_ = documentation_; + } else { + result.documentation_ = documentationBuilder_.build(); + } + if (visibilityBuilder_ == null) { + result.visibility_ = visibility_; + } else { + result.visibility_ = visibilityBuilder_.build(); + } + if (httpBuilder_ == null) { + result.http_ = http_; + } else { + result.http_ = httpBuilder_.build(); + } + if (contextBuilder_ == null) { + result.context_ = context_; + } else { + result.context_ = contextBuilder_.build(); + } + if (customErrorBuilder_ == null) { + result.customError_ = customError_; + } else { + result.customError_ = customErrorBuilder_.build(); + } + if (derivedDataBuilder_ == null) { + result.derivedData_ = derivedData_; + } else { + result.derivedData_ = derivedDataBuilder_.build(); + } + if (systemTypesBuilder_ == null) { + if (((bitField0_ & 0x00002000) == 0x00002000)) { + systemTypes_ = java.util.Collections.unmodifiableList(systemTypes_); + bitField0_ = (bitField0_ & ~0x00002000); + } + result.systemTypes_ = systemTypes_; + } else { + result.systemTypes_ = systemTypesBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.Service) { + return mergeFrom((com.google.api.Service)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.Service other) { + if (other == com.google.api.Service.getDefaultInstance()) return this; + if (other.hasConfigVersion()) { + mergeConfigVersion(other.getConfigVersion()); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getTitle().isEmpty()) { + title_ = other.title_; + onChanged(); + } + if (!other.getProducerProjectId().isEmpty()) { + producerProjectId_ = other.producerProjectId_; + onChanged(); + } + if (apisBuilder_ == null) { + if (!other.apis_.isEmpty()) { + if (apis_.isEmpty()) { + apis_ = other.apis_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureApisIsMutable(); + apis_.addAll(other.apis_); + } + onChanged(); + } + } else { + if (!other.apis_.isEmpty()) { + if (apisBuilder_.isEmpty()) { + apisBuilder_.dispose(); + apisBuilder_ = null; + apis_ = other.apis_; + bitField0_ = (bitField0_ & ~0x00000010); + apisBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getApisFieldBuilder() : null; + } else { + apisBuilder_.addAllMessages(other.apis_); + } + } + } + if (typesBuilder_ == null) { + if (!other.types_.isEmpty()) { + if (types_.isEmpty()) { + types_ = other.types_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureTypesIsMutable(); + types_.addAll(other.types_); + } + onChanged(); + } + } else { + if (!other.types_.isEmpty()) { + if (typesBuilder_.isEmpty()) { + typesBuilder_.dispose(); + typesBuilder_ = null; + types_ = other.types_; + bitField0_ = (bitField0_ & ~0x00000020); + typesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getTypesFieldBuilder() : null; + } else { + typesBuilder_.addAllMessages(other.types_); + } + } + } + if (enumsBuilder_ == null) { + if (!other.enums_.isEmpty()) { + if (enums_.isEmpty()) { + enums_ = other.enums_; + bitField0_ = (bitField0_ & ~0x00000040); + } else { + ensureEnumsIsMutable(); + enums_.addAll(other.enums_); + } + onChanged(); + } + } else { + if (!other.enums_.isEmpty()) { + if (enumsBuilder_.isEmpty()) { + enumsBuilder_.dispose(); + enumsBuilder_ = null; + enums_ = other.enums_; + bitField0_ = (bitField0_ & ~0x00000040); + enumsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getEnumsFieldBuilder() : null; + } else { + enumsBuilder_.addAllMessages(other.enums_); + } + } + } + if (other.hasDocumentation()) { + mergeDocumentation(other.getDocumentation()); + } + if (other.hasVisibility()) { + mergeVisibility(other.getVisibility()); + } + if (other.hasHttp()) { + mergeHttp(other.getHttp()); + } + if (other.hasContext()) { + mergeContext(other.getContext()); + } + if (other.hasCustomError()) { + mergeCustomError(other.getCustomError()); + } + if (other.hasDerivedData()) { + mergeDerivedData(other.getDerivedData()); + } + if (systemTypesBuilder_ == null) { + if (!other.systemTypes_.isEmpty()) { + if (systemTypes_.isEmpty()) { + systemTypes_ = other.systemTypes_; + bitField0_ = (bitField0_ & ~0x00002000); + } else { + ensureSystemTypesIsMutable(); + systemTypes_.addAll(other.systemTypes_); + } + onChanged(); + } + } else { + if (!other.systemTypes_.isEmpty()) { + if (systemTypesBuilder_.isEmpty()) { + systemTypesBuilder_.dispose(); + systemTypesBuilder_ = null; + systemTypes_ = other.systemTypes_; + bitField0_ = (bitField0_ & ~0x00002000); + systemTypesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getSystemTypesFieldBuilder() : null; + } else { + systemTypesBuilder_.addAllMessages(other.systemTypes_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.Service parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.Service) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.UInt32Value configVersion_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.UInt32Value, com.google.protobuf.UInt32Value.Builder, com.google.protobuf.UInt32ValueOrBuilder> configVersionBuilder_; + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +     * The version of the service configuration. The config version may
      +     * influence interpretation of the configuration, for example
      +     * determine defaults. This is documented together with applicable
      +     * options. The current default for the config version itself is `1`.
      +     * 
      + */ + public boolean hasConfigVersion() { + return configVersionBuilder_ != null || configVersion_ != null; + } + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +     * The version of the service configuration. The config version may
      +     * influence interpretation of the configuration, for example
      +     * determine defaults. This is documented together with applicable
      +     * options. The current default for the config version itself is `1`.
      +     * 
      + */ + public com.google.protobuf.UInt32Value getConfigVersion() { + if (configVersionBuilder_ == null) { + return configVersion_ == null ? com.google.protobuf.UInt32Value.getDefaultInstance() : configVersion_; + } else { + return configVersionBuilder_.getMessage(); + } + } + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +     * The version of the service configuration. The config version may
      +     * influence interpretation of the configuration, for example
      +     * determine defaults. This is documented together with applicable
      +     * options. The current default for the config version itself is `1`.
      +     * 
      + */ + public Builder setConfigVersion(com.google.protobuf.UInt32Value value) { + if (configVersionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + configVersion_ = value; + onChanged(); + } else { + configVersionBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +     * The version of the service configuration. The config version may
      +     * influence interpretation of the configuration, for example
      +     * determine defaults. This is documented together with applicable
      +     * options. The current default for the config version itself is `1`.
      +     * 
      + */ + public Builder setConfigVersion( + com.google.protobuf.UInt32Value.Builder builderForValue) { + if (configVersionBuilder_ == null) { + configVersion_ = builderForValue.build(); + onChanged(); + } else { + configVersionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +     * The version of the service configuration. The config version may
      +     * influence interpretation of the configuration, for example
      +     * determine defaults. This is documented together with applicable
      +     * options. The current default for the config version itself is `1`.
      +     * 
      + */ + public Builder mergeConfigVersion(com.google.protobuf.UInt32Value value) { + if (configVersionBuilder_ == null) { + if (configVersion_ != null) { + configVersion_ = + com.google.protobuf.UInt32Value.newBuilder(configVersion_).mergeFrom(value).buildPartial(); + } else { + configVersion_ = value; + } + onChanged(); + } else { + configVersionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +     * The version of the service configuration. The config version may
      +     * influence interpretation of the configuration, for example
      +     * determine defaults. This is documented together with applicable
      +     * options. The current default for the config version itself is `1`.
      +     * 
      + */ + public Builder clearConfigVersion() { + if (configVersionBuilder_ == null) { + configVersion_ = null; + onChanged(); + } else { + configVersion_ = null; + configVersionBuilder_ = null; + } + + return this; + } + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +     * The version of the service configuration. The config version may
      +     * influence interpretation of the configuration, for example
      +     * determine defaults. This is documented together with applicable
      +     * options. The current default for the config version itself is `1`.
      +     * 
      + */ + public com.google.protobuf.UInt32Value.Builder getConfigVersionBuilder() { + + onChanged(); + return getConfigVersionFieldBuilder().getBuilder(); + } + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +     * The version of the service configuration. The config version may
      +     * influence interpretation of the configuration, for example
      +     * determine defaults. This is documented together with applicable
      +     * options. The current default for the config version itself is `1`.
      +     * 
      + */ + public com.google.protobuf.UInt32ValueOrBuilder getConfigVersionOrBuilder() { + if (configVersionBuilder_ != null) { + return configVersionBuilder_.getMessageOrBuilder(); + } else { + return configVersion_ == null ? + com.google.protobuf.UInt32Value.getDefaultInstance() : configVersion_; + } + } + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +     * The version of the service configuration. The config version may
      +     * influence interpretation of the configuration, for example
      +     * determine defaults. This is documented together with applicable
      +     * options. The current default for the config version itself is `1`.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.UInt32Value, com.google.protobuf.UInt32Value.Builder, com.google.protobuf.UInt32ValueOrBuilder> + getConfigVersionFieldBuilder() { + if (configVersionBuilder_ == null) { + configVersionBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.UInt32Value, com.google.protobuf.UInt32Value.Builder, com.google.protobuf.UInt32ValueOrBuilder>( + getConfigVersion(), + getParentForChildren(), + isClean()); + configVersion_ = null; + } + return configVersionBuilder_; + } + + private java.lang.Object name_ = ""; + /** + * optional string name = 1; + * + *
      +     * The DNS address at which this service is available,
      +     * e.g. `calendar.googleapis.com`.
      +     * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The DNS address at which this service is available,
      +     * e.g. `calendar.googleapis.com`.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The DNS address at which this service is available,
      +     * e.g. `calendar.googleapis.com`.
      +     * 
      + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The DNS address at which this service is available,
      +     * e.g. `calendar.googleapis.com`.
      +     * 
      + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The DNS address at which this service is available,
      +     * e.g. `calendar.googleapis.com`.
      +     * 
      + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object title_ = ""; + /** + * optional string title = 2; + * + *
      +     * The product title associated with this service.
      +     * 
      + */ + public java.lang.String getTitle() { + java.lang.Object ref = title_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + title_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string title = 2; + * + *
      +     * The product title associated with this service.
      +     * 
      + */ + public com.google.protobuf.ByteString + getTitleBytes() { + java.lang.Object ref = title_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + title_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string title = 2; + * + *
      +     * The product title associated with this service.
      +     * 
      + */ + public Builder setTitle( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + title_ = value; + onChanged(); + return this; + } + /** + * optional string title = 2; + * + *
      +     * The product title associated with this service.
      +     * 
      + */ + public Builder clearTitle() { + + title_ = getDefaultInstance().getTitle(); + onChanged(); + return this; + } + /** + * optional string title = 2; + * + *
      +     * The product title associated with this service.
      +     * 
      + */ + public Builder setTitleBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + title_ = value; + onChanged(); + return this; + } + + private java.lang.Object producerProjectId_ = ""; + /** + * optional string producer_project_id = 22; + * + *
      +     * The id of the Google developer project that owns the service.
      +     * Members of this project can manage the service configuration,
      +     * manage consumption of the service, etc.
      +     * 
      + */ + public java.lang.String getProducerProjectId() { + java.lang.Object ref = producerProjectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + producerProjectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string producer_project_id = 22; + * + *
      +     * The id of the Google developer project that owns the service.
      +     * Members of this project can manage the service configuration,
      +     * manage consumption of the service, etc.
      +     * 
      + */ + public com.google.protobuf.ByteString + getProducerProjectIdBytes() { + java.lang.Object ref = producerProjectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + producerProjectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string producer_project_id = 22; + * + *
      +     * The id of the Google developer project that owns the service.
      +     * Members of this project can manage the service configuration,
      +     * manage consumption of the service, etc.
      +     * 
      + */ + public Builder setProducerProjectId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + producerProjectId_ = value; + onChanged(); + return this; + } + /** + * optional string producer_project_id = 22; + * + *
      +     * The id of the Google developer project that owns the service.
      +     * Members of this project can manage the service configuration,
      +     * manage consumption of the service, etc.
      +     * 
      + */ + public Builder clearProducerProjectId() { + + producerProjectId_ = getDefaultInstance().getProducerProjectId(); + onChanged(); + return this; + } + /** + * optional string producer_project_id = 22; + * + *
      +     * The id of the Google developer project that owns the service.
      +     * Members of this project can manage the service configuration,
      +     * manage consumption of the service, etc.
      +     * 
      + */ + public Builder setProducerProjectIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + producerProjectId_ = value; + onChanged(); + return this; + } + + private java.util.List apis_ = + java.util.Collections.emptyList(); + private void ensureApisIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + apis_ = new java.util.ArrayList(apis_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Api, com.google.protobuf.Api.Builder, com.google.protobuf.ApiOrBuilder> apisBuilder_; + + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public java.util.List getApisList() { + if (apisBuilder_ == null) { + return java.util.Collections.unmodifiableList(apis_); + } else { + return apisBuilder_.getMessageList(); + } + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public int getApisCount() { + if (apisBuilder_ == null) { + return apis_.size(); + } else { + return apisBuilder_.getCount(); + } + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public com.google.protobuf.Api getApis(int index) { + if (apisBuilder_ == null) { + return apis_.get(index); + } else { + return apisBuilder_.getMessage(index); + } + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public Builder setApis( + int index, com.google.protobuf.Api value) { + if (apisBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureApisIsMutable(); + apis_.set(index, value); + onChanged(); + } else { + apisBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public Builder setApis( + int index, com.google.protobuf.Api.Builder builderForValue) { + if (apisBuilder_ == null) { + ensureApisIsMutable(); + apis_.set(index, builderForValue.build()); + onChanged(); + } else { + apisBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public Builder addApis(com.google.protobuf.Api value) { + if (apisBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureApisIsMutable(); + apis_.add(value); + onChanged(); + } else { + apisBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public Builder addApis( + int index, com.google.protobuf.Api value) { + if (apisBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureApisIsMutable(); + apis_.add(index, value); + onChanged(); + } else { + apisBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public Builder addApis( + com.google.protobuf.Api.Builder builderForValue) { + if (apisBuilder_ == null) { + ensureApisIsMutable(); + apis_.add(builderForValue.build()); + onChanged(); + } else { + apisBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public Builder addApis( + int index, com.google.protobuf.Api.Builder builderForValue) { + if (apisBuilder_ == null) { + ensureApisIsMutable(); + apis_.add(index, builderForValue.build()); + onChanged(); + } else { + apisBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public Builder addAllApis( + java.lang.Iterable values) { + if (apisBuilder_ == null) { + ensureApisIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, apis_); + onChanged(); + } else { + apisBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public Builder clearApis() { + if (apisBuilder_ == null) { + apis_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + apisBuilder_.clear(); + } + return this; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public Builder removeApis(int index) { + if (apisBuilder_ == null) { + ensureApisIsMutable(); + apis_.remove(index); + onChanged(); + } else { + apisBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public com.google.protobuf.Api.Builder getApisBuilder( + int index) { + return getApisFieldBuilder().getBuilder(index); + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public com.google.protobuf.ApiOrBuilder getApisOrBuilder( + int index) { + if (apisBuilder_ == null) { + return apis_.get(index); } else { + return apisBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public java.util.List + getApisOrBuilderList() { + if (apisBuilder_ != null) { + return apisBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(apis_); + } + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public com.google.protobuf.Api.Builder addApisBuilder() { + return getApisFieldBuilder().addBuilder( + com.google.protobuf.Api.getDefaultInstance()); + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public com.google.protobuf.Api.Builder addApisBuilder( + int index) { + return getApisFieldBuilder().addBuilder( + index, com.google.protobuf.Api.getDefaultInstance()); + } + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +     * A list of API interfaces exported by this service. Only the `name` field
      +     * of the [google.protobuf.Api][] needs to be provided by the configuration
      +     * author, as the remaining fields will be derived from the IDL during the
      +     * normalization process. It is an error to specify an API interface here
      +     * which cannot be resolved against the associated IDL files.
      +     * 
      + */ + public java.util.List + getApisBuilderList() { + return getApisFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Api, com.google.protobuf.Api.Builder, com.google.protobuf.ApiOrBuilder> + getApisFieldBuilder() { + if (apisBuilder_ == null) { + apisBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Api, com.google.protobuf.Api.Builder, com.google.protobuf.ApiOrBuilder>( + apis_, + ((bitField0_ & 0x00000010) == 0x00000010), + getParentForChildren(), + isClean()); + apis_ = null; + } + return apisBuilder_; + } + + private java.util.List types_ = + java.util.Collections.emptyList(); + private void ensureTypesIsMutable() { + if (!((bitField0_ & 0x00000020) == 0x00000020)) { + types_ = new java.util.ArrayList(types_); + bitField0_ |= 0x00000020; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder> typesBuilder_; + + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public java.util.List getTypesList() { + if (typesBuilder_ == null) { + return java.util.Collections.unmodifiableList(types_); + } else { + return typesBuilder_.getMessageList(); + } + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public int getTypesCount() { + if (typesBuilder_ == null) { + return types_.size(); + } else { + return typesBuilder_.getCount(); + } + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public com.google.protobuf.Type getTypes(int index) { + if (typesBuilder_ == null) { + return types_.get(index); + } else { + return typesBuilder_.getMessage(index); + } + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public Builder setTypes( + int index, com.google.protobuf.Type value) { + if (typesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTypesIsMutable(); + types_.set(index, value); + onChanged(); + } else { + typesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public Builder setTypes( + int index, com.google.protobuf.Type.Builder builderForValue) { + if (typesBuilder_ == null) { + ensureTypesIsMutable(); + types_.set(index, builderForValue.build()); + onChanged(); + } else { + typesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public Builder addTypes(com.google.protobuf.Type value) { + if (typesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTypesIsMutable(); + types_.add(value); + onChanged(); + } else { + typesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public Builder addTypes( + int index, com.google.protobuf.Type value) { + if (typesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTypesIsMutable(); + types_.add(index, value); + onChanged(); + } else { + typesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public Builder addTypes( + com.google.protobuf.Type.Builder builderForValue) { + if (typesBuilder_ == null) { + ensureTypesIsMutable(); + types_.add(builderForValue.build()); + onChanged(); + } else { + typesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public Builder addTypes( + int index, com.google.protobuf.Type.Builder builderForValue) { + if (typesBuilder_ == null) { + ensureTypesIsMutable(); + types_.add(index, builderForValue.build()); + onChanged(); + } else { + typesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public Builder addAllTypes( + java.lang.Iterable values) { + if (typesBuilder_ == null) { + ensureTypesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, types_); + onChanged(); + } else { + typesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public Builder clearTypes() { + if (typesBuilder_ == null) { + types_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + typesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public Builder removeTypes(int index) { + if (typesBuilder_ == null) { + ensureTypesIsMutable(); + types_.remove(index); + onChanged(); + } else { + typesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public com.google.protobuf.Type.Builder getTypesBuilder( + int index) { + return getTypesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public com.google.protobuf.TypeOrBuilder getTypesOrBuilder( + int index) { + if (typesBuilder_ == null) { + return types_.get(index); } else { + return typesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public java.util.List + getTypesOrBuilderList() { + if (typesBuilder_ != null) { + return typesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(types_); + } + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public com.google.protobuf.Type.Builder addTypesBuilder() { + return getTypesFieldBuilder().addBuilder( + com.google.protobuf.Type.getDefaultInstance()); + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public com.google.protobuf.Type.Builder addTypesBuilder( + int index) { + return getTypesFieldBuilder().addBuilder( + index, com.google.protobuf.Type.getDefaultInstance()); + } + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +     * A list of all proto message types included in this API service.
      +     * Types referenced directly or indirectly by the `apis` are
      +     * automatically included.  Messages which are not referenced but
      +     * shall be included, such as types used by the `google.protobuf.Any` type,
      +     * should be listed here by name. Example:
      +     *     types:
      +     *     - name: google.protobuf.Int32
      +     * 
      + */ + public java.util.List + getTypesBuilderList() { + return getTypesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder> + getTypesFieldBuilder() { + if (typesBuilder_ == null) { + typesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder>( + types_, + ((bitField0_ & 0x00000020) == 0x00000020), + getParentForChildren(), + isClean()); + types_ = null; + } + return typesBuilder_; + } + + private java.util.List enums_ = + java.util.Collections.emptyList(); + private void ensureEnumsIsMutable() { + if (!((bitField0_ & 0x00000040) == 0x00000040)) { + enums_ = new java.util.ArrayList(enums_); + bitField0_ |= 0x00000040; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Enum, com.google.protobuf.Enum.Builder, com.google.protobuf.EnumOrBuilder> enumsBuilder_; + + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public java.util.List getEnumsList() { + if (enumsBuilder_ == null) { + return java.util.Collections.unmodifiableList(enums_); + } else { + return enumsBuilder_.getMessageList(); + } + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public int getEnumsCount() { + if (enumsBuilder_ == null) { + return enums_.size(); + } else { + return enumsBuilder_.getCount(); + } + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public com.google.protobuf.Enum getEnums(int index) { + if (enumsBuilder_ == null) { + return enums_.get(index); + } else { + return enumsBuilder_.getMessage(index); + } + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public Builder setEnums( + int index, com.google.protobuf.Enum value) { + if (enumsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnumsIsMutable(); + enums_.set(index, value); + onChanged(); + } else { + enumsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public Builder setEnums( + int index, com.google.protobuf.Enum.Builder builderForValue) { + if (enumsBuilder_ == null) { + ensureEnumsIsMutable(); + enums_.set(index, builderForValue.build()); + onChanged(); + } else { + enumsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public Builder addEnums(com.google.protobuf.Enum value) { + if (enumsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnumsIsMutable(); + enums_.add(value); + onChanged(); + } else { + enumsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public Builder addEnums( + int index, com.google.protobuf.Enum value) { + if (enumsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnumsIsMutable(); + enums_.add(index, value); + onChanged(); + } else { + enumsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public Builder addEnums( + com.google.protobuf.Enum.Builder builderForValue) { + if (enumsBuilder_ == null) { + ensureEnumsIsMutable(); + enums_.add(builderForValue.build()); + onChanged(); + } else { + enumsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public Builder addEnums( + int index, com.google.protobuf.Enum.Builder builderForValue) { + if (enumsBuilder_ == null) { + ensureEnumsIsMutable(); + enums_.add(index, builderForValue.build()); + onChanged(); + } else { + enumsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public Builder addAllEnums( + java.lang.Iterable values) { + if (enumsBuilder_ == null) { + ensureEnumsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, enums_); + onChanged(); + } else { + enumsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public Builder clearEnums() { + if (enumsBuilder_ == null) { + enums_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + } else { + enumsBuilder_.clear(); + } + return this; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public Builder removeEnums(int index) { + if (enumsBuilder_ == null) { + ensureEnumsIsMutable(); + enums_.remove(index); + onChanged(); + } else { + enumsBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public com.google.protobuf.Enum.Builder getEnumsBuilder( + int index) { + return getEnumsFieldBuilder().getBuilder(index); + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public com.google.protobuf.EnumOrBuilder getEnumsOrBuilder( + int index) { + if (enumsBuilder_ == null) { + return enums_.get(index); } else { + return enumsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public java.util.List + getEnumsOrBuilderList() { + if (enumsBuilder_ != null) { + return enumsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(enums_); + } + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public com.google.protobuf.Enum.Builder addEnumsBuilder() { + return getEnumsFieldBuilder().addBuilder( + com.google.protobuf.Enum.getDefaultInstance()); + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public com.google.protobuf.Enum.Builder addEnumsBuilder( + int index) { + return getEnumsFieldBuilder().addBuilder( + index, com.google.protobuf.Enum.getDefaultInstance()); + } + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +     * A list of all enum types included in this API service.  Enums
      +     * referenced directly or indirectly by the `apis` are automatically
      +     * included.  Enums which are not referenced but shall be included
      +     * should be listed here by name. Example:
      +     *     enums:
      +     *     - name: google.someapi.v1.SomeEnum
      +     * 
      + */ + public java.util.List + getEnumsBuilderList() { + return getEnumsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Enum, com.google.protobuf.Enum.Builder, com.google.protobuf.EnumOrBuilder> + getEnumsFieldBuilder() { + if (enumsBuilder_ == null) { + enumsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Enum, com.google.protobuf.Enum.Builder, com.google.protobuf.EnumOrBuilder>( + enums_, + ((bitField0_ & 0x00000040) == 0x00000040), + getParentForChildren(), + isClean()); + enums_ = null; + } + return enumsBuilder_; + } + + private com.google.api.Documentation documentation_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.api.Documentation, com.google.api.Documentation.Builder, com.google.api.DocumentationOrBuilder> documentationBuilder_; + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +     * Additional API documentation.
      +     * 
      + */ + public boolean hasDocumentation() { + return documentationBuilder_ != null || documentation_ != null; + } + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +     * Additional API documentation.
      +     * 
      + */ + public com.google.api.Documentation getDocumentation() { + if (documentationBuilder_ == null) { + return documentation_ == null ? com.google.api.Documentation.getDefaultInstance() : documentation_; + } else { + return documentationBuilder_.getMessage(); + } + } + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +     * Additional API documentation.
      +     * 
      + */ + public Builder setDocumentation(com.google.api.Documentation value) { + if (documentationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + documentation_ = value; + onChanged(); + } else { + documentationBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +     * Additional API documentation.
      +     * 
      + */ + public Builder setDocumentation( + com.google.api.Documentation.Builder builderForValue) { + if (documentationBuilder_ == null) { + documentation_ = builderForValue.build(); + onChanged(); + } else { + documentationBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +     * Additional API documentation.
      +     * 
      + */ + public Builder mergeDocumentation(com.google.api.Documentation value) { + if (documentationBuilder_ == null) { + if (documentation_ != null) { + documentation_ = + com.google.api.Documentation.newBuilder(documentation_).mergeFrom(value).buildPartial(); + } else { + documentation_ = value; + } + onChanged(); + } else { + documentationBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +     * Additional API documentation.
      +     * 
      + */ + public Builder clearDocumentation() { + if (documentationBuilder_ == null) { + documentation_ = null; + onChanged(); + } else { + documentation_ = null; + documentationBuilder_ = null; + } + + return this; + } + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +     * Additional API documentation.
      +     * 
      + */ + public com.google.api.Documentation.Builder getDocumentationBuilder() { + + onChanged(); + return getDocumentationFieldBuilder().getBuilder(); + } + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +     * Additional API documentation.
      +     * 
      + */ + public com.google.api.DocumentationOrBuilder getDocumentationOrBuilder() { + if (documentationBuilder_ != null) { + return documentationBuilder_.getMessageOrBuilder(); + } else { + return documentation_ == null ? + com.google.api.Documentation.getDefaultInstance() : documentation_; + } + } + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +     * Additional API documentation.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.api.Documentation, com.google.api.Documentation.Builder, com.google.api.DocumentationOrBuilder> + getDocumentationFieldBuilder() { + if (documentationBuilder_ == null) { + documentationBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.api.Documentation, com.google.api.Documentation.Builder, com.google.api.DocumentationOrBuilder>( + getDocumentation(), + getParentForChildren(), + isClean()); + documentation_ = null; + } + return documentationBuilder_; + } + + private com.google.api.Visibility visibility_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.api.Visibility, com.google.api.Visibility.Builder, com.google.api.VisibilityOrBuilder> visibilityBuilder_; + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +     * API visibility configuration.
      +     * 
      + */ + public boolean hasVisibility() { + return visibilityBuilder_ != null || visibility_ != null; + } + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +     * API visibility configuration.
      +     * 
      + */ + public com.google.api.Visibility getVisibility() { + if (visibilityBuilder_ == null) { + return visibility_ == null ? com.google.api.Visibility.getDefaultInstance() : visibility_; + } else { + return visibilityBuilder_.getMessage(); + } + } + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +     * API visibility configuration.
      +     * 
      + */ + public Builder setVisibility(com.google.api.Visibility value) { + if (visibilityBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + visibility_ = value; + onChanged(); + } else { + visibilityBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +     * API visibility configuration.
      +     * 
      + */ + public Builder setVisibility( + com.google.api.Visibility.Builder builderForValue) { + if (visibilityBuilder_ == null) { + visibility_ = builderForValue.build(); + onChanged(); + } else { + visibilityBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +     * API visibility configuration.
      +     * 
      + */ + public Builder mergeVisibility(com.google.api.Visibility value) { + if (visibilityBuilder_ == null) { + if (visibility_ != null) { + visibility_ = + com.google.api.Visibility.newBuilder(visibility_).mergeFrom(value).buildPartial(); + } else { + visibility_ = value; + } + onChanged(); + } else { + visibilityBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +     * API visibility configuration.
      +     * 
      + */ + public Builder clearVisibility() { + if (visibilityBuilder_ == null) { + visibility_ = null; + onChanged(); + } else { + visibility_ = null; + visibilityBuilder_ = null; + } + + return this; + } + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +     * API visibility configuration.
      +     * 
      + */ + public com.google.api.Visibility.Builder getVisibilityBuilder() { + + onChanged(); + return getVisibilityFieldBuilder().getBuilder(); + } + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +     * API visibility configuration.
      +     * 
      + */ + public com.google.api.VisibilityOrBuilder getVisibilityOrBuilder() { + if (visibilityBuilder_ != null) { + return visibilityBuilder_.getMessageOrBuilder(); + } else { + return visibility_ == null ? + com.google.api.Visibility.getDefaultInstance() : visibility_; + } + } + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +     * API visibility configuration.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.api.Visibility, com.google.api.Visibility.Builder, com.google.api.VisibilityOrBuilder> + getVisibilityFieldBuilder() { + if (visibilityBuilder_ == null) { + visibilityBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.api.Visibility, com.google.api.Visibility.Builder, com.google.api.VisibilityOrBuilder>( + getVisibility(), + getParentForChildren(), + isClean()); + visibility_ = null; + } + return visibilityBuilder_; + } + + private com.google.api.Http http_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.api.Http, com.google.api.Http.Builder, com.google.api.HttpOrBuilder> httpBuilder_; + /** + * optional .google.api.Http http = 9; + * + *
      +     * HTTP configuration.
      +     * 
      + */ + public boolean hasHttp() { + return httpBuilder_ != null || http_ != null; + } + /** + * optional .google.api.Http http = 9; + * + *
      +     * HTTP configuration.
      +     * 
      + */ + public com.google.api.Http getHttp() { + if (httpBuilder_ == null) { + return http_ == null ? com.google.api.Http.getDefaultInstance() : http_; + } else { + return httpBuilder_.getMessage(); + } + } + /** + * optional .google.api.Http http = 9; + * + *
      +     * HTTP configuration.
      +     * 
      + */ + public Builder setHttp(com.google.api.Http value) { + if (httpBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + http_ = value; + onChanged(); + } else { + httpBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.api.Http http = 9; + * + *
      +     * HTTP configuration.
      +     * 
      + */ + public Builder setHttp( + com.google.api.Http.Builder builderForValue) { + if (httpBuilder_ == null) { + http_ = builderForValue.build(); + onChanged(); + } else { + httpBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.api.Http http = 9; + * + *
      +     * HTTP configuration.
      +     * 
      + */ + public Builder mergeHttp(com.google.api.Http value) { + if (httpBuilder_ == null) { + if (http_ != null) { + http_ = + com.google.api.Http.newBuilder(http_).mergeFrom(value).buildPartial(); + } else { + http_ = value; + } + onChanged(); + } else { + httpBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.api.Http http = 9; + * + *
      +     * HTTP configuration.
      +     * 
      + */ + public Builder clearHttp() { + if (httpBuilder_ == null) { + http_ = null; + onChanged(); + } else { + http_ = null; + httpBuilder_ = null; + } + + return this; + } + /** + * optional .google.api.Http http = 9; + * + *
      +     * HTTP configuration.
      +     * 
      + */ + public com.google.api.Http.Builder getHttpBuilder() { + + onChanged(); + return getHttpFieldBuilder().getBuilder(); + } + /** + * optional .google.api.Http http = 9; + * + *
      +     * HTTP configuration.
      +     * 
      + */ + public com.google.api.HttpOrBuilder getHttpOrBuilder() { + if (httpBuilder_ != null) { + return httpBuilder_.getMessageOrBuilder(); + } else { + return http_ == null ? + com.google.api.Http.getDefaultInstance() : http_; + } + } + /** + * optional .google.api.Http http = 9; + * + *
      +     * HTTP configuration.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.api.Http, com.google.api.Http.Builder, com.google.api.HttpOrBuilder> + getHttpFieldBuilder() { + if (httpBuilder_ == null) { + httpBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.api.Http, com.google.api.Http.Builder, com.google.api.HttpOrBuilder>( + getHttp(), + getParentForChildren(), + isClean()); + http_ = null; + } + return httpBuilder_; + } + + private com.google.api.Context context_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.api.Context, com.google.api.Context.Builder, com.google.api.ContextOrBuilder> contextBuilder_; + /** + * optional .google.api.Context context = 12; + * + *
      +     * Context configuration.
      +     * 
      + */ + public boolean hasContext() { + return contextBuilder_ != null || context_ != null; + } + /** + * optional .google.api.Context context = 12; + * + *
      +     * Context configuration.
      +     * 
      + */ + public com.google.api.Context getContext() { + if (contextBuilder_ == null) { + return context_ == null ? com.google.api.Context.getDefaultInstance() : context_; + } else { + return contextBuilder_.getMessage(); + } + } + /** + * optional .google.api.Context context = 12; + * + *
      +     * Context configuration.
      +     * 
      + */ + public Builder setContext(com.google.api.Context value) { + if (contextBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + context_ = value; + onChanged(); + } else { + contextBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.api.Context context = 12; + * + *
      +     * Context configuration.
      +     * 
      + */ + public Builder setContext( + com.google.api.Context.Builder builderForValue) { + if (contextBuilder_ == null) { + context_ = builderForValue.build(); + onChanged(); + } else { + contextBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.api.Context context = 12; + * + *
      +     * Context configuration.
      +     * 
      + */ + public Builder mergeContext(com.google.api.Context value) { + if (contextBuilder_ == null) { + if (context_ != null) { + context_ = + com.google.api.Context.newBuilder(context_).mergeFrom(value).buildPartial(); + } else { + context_ = value; + } + onChanged(); + } else { + contextBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.api.Context context = 12; + * + *
      +     * Context configuration.
      +     * 
      + */ + public Builder clearContext() { + if (contextBuilder_ == null) { + context_ = null; + onChanged(); + } else { + context_ = null; + contextBuilder_ = null; + } + + return this; + } + /** + * optional .google.api.Context context = 12; + * + *
      +     * Context configuration.
      +     * 
      + */ + public com.google.api.Context.Builder getContextBuilder() { + + onChanged(); + return getContextFieldBuilder().getBuilder(); + } + /** + * optional .google.api.Context context = 12; + * + *
      +     * Context configuration.
      +     * 
      + */ + public com.google.api.ContextOrBuilder getContextOrBuilder() { + if (contextBuilder_ != null) { + return contextBuilder_.getMessageOrBuilder(); + } else { + return context_ == null ? + com.google.api.Context.getDefaultInstance() : context_; + } + } + /** + * optional .google.api.Context context = 12; + * + *
      +     * Context configuration.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.api.Context, com.google.api.Context.Builder, com.google.api.ContextOrBuilder> + getContextFieldBuilder() { + if (contextBuilder_ == null) { + contextBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.api.Context, com.google.api.Context.Builder, com.google.api.ContextOrBuilder>( + getContext(), + getParentForChildren(), + isClean()); + context_ = null; + } + return contextBuilder_; + } + + private com.google.api.CustomError customError_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.api.CustomError, com.google.api.CustomError.Builder, com.google.api.CustomErrorOrBuilder> customErrorBuilder_; + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +     * Custom error configuration.
      +     * 
      + */ + public boolean hasCustomError() { + return customErrorBuilder_ != null || customError_ != null; + } + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +     * Custom error configuration.
      +     * 
      + */ + public com.google.api.CustomError getCustomError() { + if (customErrorBuilder_ == null) { + return customError_ == null ? com.google.api.CustomError.getDefaultInstance() : customError_; + } else { + return customErrorBuilder_.getMessage(); + } + } + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +     * Custom error configuration.
      +     * 
      + */ + public Builder setCustomError(com.google.api.CustomError value) { + if (customErrorBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + customError_ = value; + onChanged(); + } else { + customErrorBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +     * Custom error configuration.
      +     * 
      + */ + public Builder setCustomError( + com.google.api.CustomError.Builder builderForValue) { + if (customErrorBuilder_ == null) { + customError_ = builderForValue.build(); + onChanged(); + } else { + customErrorBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +     * Custom error configuration.
      +     * 
      + */ + public Builder mergeCustomError(com.google.api.CustomError value) { + if (customErrorBuilder_ == null) { + if (customError_ != null) { + customError_ = + com.google.api.CustomError.newBuilder(customError_).mergeFrom(value).buildPartial(); + } else { + customError_ = value; + } + onChanged(); + } else { + customErrorBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +     * Custom error configuration.
      +     * 
      + */ + public Builder clearCustomError() { + if (customErrorBuilder_ == null) { + customError_ = null; + onChanged(); + } else { + customError_ = null; + customErrorBuilder_ = null; + } + + return this; + } + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +     * Custom error configuration.
      +     * 
      + */ + public com.google.api.CustomError.Builder getCustomErrorBuilder() { + + onChanged(); + return getCustomErrorFieldBuilder().getBuilder(); + } + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +     * Custom error configuration.
      +     * 
      + */ + public com.google.api.CustomErrorOrBuilder getCustomErrorOrBuilder() { + if (customErrorBuilder_ != null) { + return customErrorBuilder_.getMessageOrBuilder(); + } else { + return customError_ == null ? + com.google.api.CustomError.getDefaultInstance() : customError_; + } + } + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +     * Custom error configuration.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.api.CustomError, com.google.api.CustomError.Builder, com.google.api.CustomErrorOrBuilder> + getCustomErrorFieldBuilder() { + if (customErrorBuilder_ == null) { + customErrorBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.api.CustomError, com.google.api.CustomError.Builder, com.google.api.CustomErrorOrBuilder>( + getCustomError(), + getParentForChildren(), + isClean()); + customError_ = null; + } + return customErrorBuilder_; + } + + private com.google.protobuf.Any derivedData_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> derivedDataBuilder_; + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +     * Service attributes derived by the configuration toolchain, for
      +     * use at runtime.  Type is defined in
      +     * `//google/internal/api/derived_service.proto`.
      +     * 
      + */ + public boolean hasDerivedData() { + return derivedDataBuilder_ != null || derivedData_ != null; + } + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +     * Service attributes derived by the configuration toolchain, for
      +     * use at runtime.  Type is defined in
      +     * `//google/internal/api/derived_service.proto`.
      +     * 
      + */ + public com.google.protobuf.Any getDerivedData() { + if (derivedDataBuilder_ == null) { + return derivedData_ == null ? com.google.protobuf.Any.getDefaultInstance() : derivedData_; + } else { + return derivedDataBuilder_.getMessage(); + } + } + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +     * Service attributes derived by the configuration toolchain, for
      +     * use at runtime.  Type is defined in
      +     * `//google/internal/api/derived_service.proto`.
      +     * 
      + */ + public Builder setDerivedData(com.google.protobuf.Any value) { + if (derivedDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + derivedData_ = value; + onChanged(); + } else { + derivedDataBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +     * Service attributes derived by the configuration toolchain, for
      +     * use at runtime.  Type is defined in
      +     * `//google/internal/api/derived_service.proto`.
      +     * 
      + */ + public Builder setDerivedData( + com.google.protobuf.Any.Builder builderForValue) { + if (derivedDataBuilder_ == null) { + derivedData_ = builderForValue.build(); + onChanged(); + } else { + derivedDataBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +     * Service attributes derived by the configuration toolchain, for
      +     * use at runtime.  Type is defined in
      +     * `//google/internal/api/derived_service.proto`.
      +     * 
      + */ + public Builder mergeDerivedData(com.google.protobuf.Any value) { + if (derivedDataBuilder_ == null) { + if (derivedData_ != null) { + derivedData_ = + com.google.protobuf.Any.newBuilder(derivedData_).mergeFrom(value).buildPartial(); + } else { + derivedData_ = value; + } + onChanged(); + } else { + derivedDataBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +     * Service attributes derived by the configuration toolchain, for
      +     * use at runtime.  Type is defined in
      +     * `//google/internal/api/derived_service.proto`.
      +     * 
      + */ + public Builder clearDerivedData() { + if (derivedDataBuilder_ == null) { + derivedData_ = null; + onChanged(); + } else { + derivedData_ = null; + derivedDataBuilder_ = null; + } + + return this; + } + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +     * Service attributes derived by the configuration toolchain, for
      +     * use at runtime.  Type is defined in
      +     * `//google/internal/api/derived_service.proto`.
      +     * 
      + */ + public com.google.protobuf.Any.Builder getDerivedDataBuilder() { + + onChanged(); + return getDerivedDataFieldBuilder().getBuilder(); + } + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +     * Service attributes derived by the configuration toolchain, for
      +     * use at runtime.  Type is defined in
      +     * `//google/internal/api/derived_service.proto`.
      +     * 
      + */ + public com.google.protobuf.AnyOrBuilder getDerivedDataOrBuilder() { + if (derivedDataBuilder_ != null) { + return derivedDataBuilder_.getMessageOrBuilder(); + } else { + return derivedData_ == null ? + com.google.protobuf.Any.getDefaultInstance() : derivedData_; + } + } + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +     * Service attributes derived by the configuration toolchain, for
      +     * use at runtime.  Type is defined in
      +     * `//google/internal/api/derived_service.proto`.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> + getDerivedDataFieldBuilder() { + if (derivedDataBuilder_ == null) { + derivedDataBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>( + getDerivedData(), + getParentForChildren(), + isClean()); + derivedData_ = null; + } + return derivedDataBuilder_; + } + + private java.util.List systemTypes_ = + java.util.Collections.emptyList(); + private void ensureSystemTypesIsMutable() { + if (!((bitField0_ & 0x00002000) == 0x00002000)) { + systemTypes_ = new java.util.ArrayList(systemTypes_); + bitField0_ |= 0x00002000; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder> systemTypesBuilder_; + + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public java.util.List getSystemTypesList() { + if (systemTypesBuilder_ == null) { + return java.util.Collections.unmodifiableList(systemTypes_); + } else { + return systemTypesBuilder_.getMessageList(); + } + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public int getSystemTypesCount() { + if (systemTypesBuilder_ == null) { + return systemTypes_.size(); + } else { + return systemTypesBuilder_.getCount(); + } + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public com.google.protobuf.Type getSystemTypes(int index) { + if (systemTypesBuilder_ == null) { + return systemTypes_.get(index); + } else { + return systemTypesBuilder_.getMessage(index); + } + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public Builder setSystemTypes( + int index, com.google.protobuf.Type value) { + if (systemTypesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSystemTypesIsMutable(); + systemTypes_.set(index, value); + onChanged(); + } else { + systemTypesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public Builder setSystemTypes( + int index, com.google.protobuf.Type.Builder builderForValue) { + if (systemTypesBuilder_ == null) { + ensureSystemTypesIsMutable(); + systemTypes_.set(index, builderForValue.build()); + onChanged(); + } else { + systemTypesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public Builder addSystemTypes(com.google.protobuf.Type value) { + if (systemTypesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSystemTypesIsMutable(); + systemTypes_.add(value); + onChanged(); + } else { + systemTypesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public Builder addSystemTypes( + int index, com.google.protobuf.Type value) { + if (systemTypesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSystemTypesIsMutable(); + systemTypes_.add(index, value); + onChanged(); + } else { + systemTypesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public Builder addSystemTypes( + com.google.protobuf.Type.Builder builderForValue) { + if (systemTypesBuilder_ == null) { + ensureSystemTypesIsMutable(); + systemTypes_.add(builderForValue.build()); + onChanged(); + } else { + systemTypesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public Builder addSystemTypes( + int index, com.google.protobuf.Type.Builder builderForValue) { + if (systemTypesBuilder_ == null) { + ensureSystemTypesIsMutable(); + systemTypes_.add(index, builderForValue.build()); + onChanged(); + } else { + systemTypesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public Builder addAllSystemTypes( + java.lang.Iterable values) { + if (systemTypesBuilder_ == null) { + ensureSystemTypesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, systemTypes_); + onChanged(); + } else { + systemTypesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public Builder clearSystemTypes() { + if (systemTypesBuilder_ == null) { + systemTypes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00002000); + onChanged(); + } else { + systemTypesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public Builder removeSystemTypes(int index) { + if (systemTypesBuilder_ == null) { + ensureSystemTypesIsMutable(); + systemTypes_.remove(index); + onChanged(); + } else { + systemTypesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public com.google.protobuf.Type.Builder getSystemTypesBuilder( + int index) { + return getSystemTypesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public com.google.protobuf.TypeOrBuilder getSystemTypesOrBuilder( + int index) { + if (systemTypesBuilder_ == null) { + return systemTypes_.get(index); } else { + return systemTypesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public java.util.List + getSystemTypesOrBuilderList() { + if (systemTypesBuilder_ != null) { + return systemTypesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(systemTypes_); + } + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public com.google.protobuf.Type.Builder addSystemTypesBuilder() { + return getSystemTypesFieldBuilder().addBuilder( + com.google.protobuf.Type.getDefaultInstance()); + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public com.google.protobuf.Type.Builder addSystemTypesBuilder( + int index) { + return getSystemTypesFieldBuilder().addBuilder( + index, com.google.protobuf.Type.getDefaultInstance()); + } + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +     * A list of all proto message types included in this API service.
      +     * It serves similar purpose as [google.api.Service.types], except that
      +     * these types are not needed by user-defined APIs. Therefore, they will not
      +     * show up in the generated discovery doc. This field should only be used
      +     * to define system APIs in ESF.
      +     * 
      + */ + public java.util.List + getSystemTypesBuilderList() { + return getSystemTypesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder> + getSystemTypesFieldBuilder() { + if (systemTypesBuilder_ == null) { + systemTypesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder>( + systemTypes_, + ((bitField0_ & 0x00002000) == 0x00002000), + getParentForChildren(), + isClean()); + systemTypes_ = null; + } + return systemTypesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.Service) + } + + // @@protoc_insertion_point(class_scope:google.api.Service) + private static final com.google.api.Service DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.Service(); + } + + public static com.google.api.Service getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Service parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Service(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.Service getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceOrBuilder.java new file mode 100644 index 000000000000..f3a729e886a7 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceOrBuilder.java @@ -0,0 +1,530 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/service.proto + +package com.google.api; + +public interface ServiceOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.Service) + com.google.protobuf.MessageOrBuilder { + + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +   * The version of the service configuration. The config version may
      +   * influence interpretation of the configuration, for example
      +   * determine defaults. This is documented together with applicable
      +   * options. The current default for the config version itself is `1`.
      +   * 
      + */ + boolean hasConfigVersion(); + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +   * The version of the service configuration. The config version may
      +   * influence interpretation of the configuration, for example
      +   * determine defaults. This is documented together with applicable
      +   * options. The current default for the config version itself is `1`.
      +   * 
      + */ + com.google.protobuf.UInt32Value getConfigVersion(); + /** + * optional .google.protobuf.UInt32Value config_version = 20; + * + *
      +   * The version of the service configuration. The config version may
      +   * influence interpretation of the configuration, for example
      +   * determine defaults. This is documented together with applicable
      +   * options. The current default for the config version itself is `1`.
      +   * 
      + */ + com.google.protobuf.UInt32ValueOrBuilder getConfigVersionOrBuilder(); + + /** + * optional string name = 1; + * + *
      +   * The DNS address at which this service is available,
      +   * e.g. `calendar.googleapis.com`.
      +   * 
      + */ + java.lang.String getName(); + /** + * optional string name = 1; + * + *
      +   * The DNS address at which this service is available,
      +   * e.g. `calendar.googleapis.com`.
      +   * 
      + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * optional string title = 2; + * + *
      +   * The product title associated with this service.
      +   * 
      + */ + java.lang.String getTitle(); + /** + * optional string title = 2; + * + *
      +   * The product title associated with this service.
      +   * 
      + */ + com.google.protobuf.ByteString + getTitleBytes(); + + /** + * optional string producer_project_id = 22; + * + *
      +   * The id of the Google developer project that owns the service.
      +   * Members of this project can manage the service configuration,
      +   * manage consumption of the service, etc.
      +   * 
      + */ + java.lang.String getProducerProjectId(); + /** + * optional string producer_project_id = 22; + * + *
      +   * The id of the Google developer project that owns the service.
      +   * Members of this project can manage the service configuration,
      +   * manage consumption of the service, etc.
      +   * 
      + */ + com.google.protobuf.ByteString + getProducerProjectIdBytes(); + + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +   * A list of API interfaces exported by this service. Only the `name` field
      +   * of the [google.protobuf.Api][] needs to be provided by the configuration
      +   * author, as the remaining fields will be derived from the IDL during the
      +   * normalization process. It is an error to specify an API interface here
      +   * which cannot be resolved against the associated IDL files.
      +   * 
      + */ + java.util.List + getApisList(); + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +   * A list of API interfaces exported by this service. Only the `name` field
      +   * of the [google.protobuf.Api][] needs to be provided by the configuration
      +   * author, as the remaining fields will be derived from the IDL during the
      +   * normalization process. It is an error to specify an API interface here
      +   * which cannot be resolved against the associated IDL files.
      +   * 
      + */ + com.google.protobuf.Api getApis(int index); + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +   * A list of API interfaces exported by this service. Only the `name` field
      +   * of the [google.protobuf.Api][] needs to be provided by the configuration
      +   * author, as the remaining fields will be derived from the IDL during the
      +   * normalization process. It is an error to specify an API interface here
      +   * which cannot be resolved against the associated IDL files.
      +   * 
      + */ + int getApisCount(); + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +   * A list of API interfaces exported by this service. Only the `name` field
      +   * of the [google.protobuf.Api][] needs to be provided by the configuration
      +   * author, as the remaining fields will be derived from the IDL during the
      +   * normalization process. It is an error to specify an API interface here
      +   * which cannot be resolved against the associated IDL files.
      +   * 
      + */ + java.util.List + getApisOrBuilderList(); + /** + * repeated .google.protobuf.Api apis = 3; + * + *
      +   * A list of API interfaces exported by this service. Only the `name` field
      +   * of the [google.protobuf.Api][] needs to be provided by the configuration
      +   * author, as the remaining fields will be derived from the IDL during the
      +   * normalization process. It is an error to specify an API interface here
      +   * which cannot be resolved against the associated IDL files.
      +   * 
      + */ + com.google.protobuf.ApiOrBuilder getApisOrBuilder( + int index); + + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +   * A list of all proto message types included in this API service.
      +   * Types referenced directly or indirectly by the `apis` are
      +   * automatically included.  Messages which are not referenced but
      +   * shall be included, such as types used by the `google.protobuf.Any` type,
      +   * should be listed here by name. Example:
      +   *     types:
      +   *     - name: google.protobuf.Int32
      +   * 
      + */ + java.util.List + getTypesList(); + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +   * A list of all proto message types included in this API service.
      +   * Types referenced directly or indirectly by the `apis` are
      +   * automatically included.  Messages which are not referenced but
      +   * shall be included, such as types used by the `google.protobuf.Any` type,
      +   * should be listed here by name. Example:
      +   *     types:
      +   *     - name: google.protobuf.Int32
      +   * 
      + */ + com.google.protobuf.Type getTypes(int index); + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +   * A list of all proto message types included in this API service.
      +   * Types referenced directly or indirectly by the `apis` are
      +   * automatically included.  Messages which are not referenced but
      +   * shall be included, such as types used by the `google.protobuf.Any` type,
      +   * should be listed here by name. Example:
      +   *     types:
      +   *     - name: google.protobuf.Int32
      +   * 
      + */ + int getTypesCount(); + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +   * A list of all proto message types included in this API service.
      +   * Types referenced directly or indirectly by the `apis` are
      +   * automatically included.  Messages which are not referenced but
      +   * shall be included, such as types used by the `google.protobuf.Any` type,
      +   * should be listed here by name. Example:
      +   *     types:
      +   *     - name: google.protobuf.Int32
      +   * 
      + */ + java.util.List + getTypesOrBuilderList(); + /** + * repeated .google.protobuf.Type types = 4; + * + *
      +   * A list of all proto message types included in this API service.
      +   * Types referenced directly or indirectly by the `apis` are
      +   * automatically included.  Messages which are not referenced but
      +   * shall be included, such as types used by the `google.protobuf.Any` type,
      +   * should be listed here by name. Example:
      +   *     types:
      +   *     - name: google.protobuf.Int32
      +   * 
      + */ + com.google.protobuf.TypeOrBuilder getTypesOrBuilder( + int index); + + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +   * A list of all enum types included in this API service.  Enums
      +   * referenced directly or indirectly by the `apis` are automatically
      +   * included.  Enums which are not referenced but shall be included
      +   * should be listed here by name. Example:
      +   *     enums:
      +   *     - name: google.someapi.v1.SomeEnum
      +   * 
      + */ + java.util.List + getEnumsList(); + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +   * A list of all enum types included in this API service.  Enums
      +   * referenced directly or indirectly by the `apis` are automatically
      +   * included.  Enums which are not referenced but shall be included
      +   * should be listed here by name. Example:
      +   *     enums:
      +   *     - name: google.someapi.v1.SomeEnum
      +   * 
      + */ + com.google.protobuf.Enum getEnums(int index); + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +   * A list of all enum types included in this API service.  Enums
      +   * referenced directly or indirectly by the `apis` are automatically
      +   * included.  Enums which are not referenced but shall be included
      +   * should be listed here by name. Example:
      +   *     enums:
      +   *     - name: google.someapi.v1.SomeEnum
      +   * 
      + */ + int getEnumsCount(); + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +   * A list of all enum types included in this API service.  Enums
      +   * referenced directly or indirectly by the `apis` are automatically
      +   * included.  Enums which are not referenced but shall be included
      +   * should be listed here by name. Example:
      +   *     enums:
      +   *     - name: google.someapi.v1.SomeEnum
      +   * 
      + */ + java.util.List + getEnumsOrBuilderList(); + /** + * repeated .google.protobuf.Enum enums = 5; + * + *
      +   * A list of all enum types included in this API service.  Enums
      +   * referenced directly or indirectly by the `apis` are automatically
      +   * included.  Enums which are not referenced but shall be included
      +   * should be listed here by name. Example:
      +   *     enums:
      +   *     - name: google.someapi.v1.SomeEnum
      +   * 
      + */ + com.google.protobuf.EnumOrBuilder getEnumsOrBuilder( + int index); + + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +   * Additional API documentation.
      +   * 
      + */ + boolean hasDocumentation(); + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +   * Additional API documentation.
      +   * 
      + */ + com.google.api.Documentation getDocumentation(); + /** + * optional .google.api.Documentation documentation = 6; + * + *
      +   * Additional API documentation.
      +   * 
      + */ + com.google.api.DocumentationOrBuilder getDocumentationOrBuilder(); + + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +   * API visibility configuration.
      +   * 
      + */ + boolean hasVisibility(); + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +   * API visibility configuration.
      +   * 
      + */ + com.google.api.Visibility getVisibility(); + /** + * optional .google.api.Visibility visibility = 7; + * + *
      +   * API visibility configuration.
      +   * 
      + */ + com.google.api.VisibilityOrBuilder getVisibilityOrBuilder(); + + /** + * optional .google.api.Http http = 9; + * + *
      +   * HTTP configuration.
      +   * 
      + */ + boolean hasHttp(); + /** + * optional .google.api.Http http = 9; + * + *
      +   * HTTP configuration.
      +   * 
      + */ + com.google.api.Http getHttp(); + /** + * optional .google.api.Http http = 9; + * + *
      +   * HTTP configuration.
      +   * 
      + */ + com.google.api.HttpOrBuilder getHttpOrBuilder(); + + /** + * optional .google.api.Context context = 12; + * + *
      +   * Context configuration.
      +   * 
      + */ + boolean hasContext(); + /** + * optional .google.api.Context context = 12; + * + *
      +   * Context configuration.
      +   * 
      + */ + com.google.api.Context getContext(); + /** + * optional .google.api.Context context = 12; + * + *
      +   * Context configuration.
      +   * 
      + */ + com.google.api.ContextOrBuilder getContextOrBuilder(); + + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +   * Custom error configuration.
      +   * 
      + */ + boolean hasCustomError(); + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +   * Custom error configuration.
      +   * 
      + */ + com.google.api.CustomError getCustomError(); + /** + * optional .google.api.CustomError custom_error = 16; + * + *
      +   * Custom error configuration.
      +   * 
      + */ + com.google.api.CustomErrorOrBuilder getCustomErrorOrBuilder(); + + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +   * Service attributes derived by the configuration toolchain, for
      +   * use at runtime.  Type is defined in
      +   * `//google/internal/api/derived_service.proto`.
      +   * 
      + */ + boolean hasDerivedData(); + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +   * Service attributes derived by the configuration toolchain, for
      +   * use at runtime.  Type is defined in
      +   * `//google/internal/api/derived_service.proto`.
      +   * 
      + */ + com.google.protobuf.Any getDerivedData(); + /** + * optional .google.protobuf.Any derived_data = 100; + * + *
      +   * Service attributes derived by the configuration toolchain, for
      +   * use at runtime.  Type is defined in
      +   * `//google/internal/api/derived_service.proto`.
      +   * 
      + */ + com.google.protobuf.AnyOrBuilder getDerivedDataOrBuilder(); + + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +   * A list of all proto message types included in this API service.
      +   * It serves similar purpose as [google.api.Service.types], except that
      +   * these types are not needed by user-defined APIs. Therefore, they will not
      +   * show up in the generated discovery doc. This field should only be used
      +   * to define system APIs in ESF.
      +   * 
      + */ + java.util.List + getSystemTypesList(); + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +   * A list of all proto message types included in this API service.
      +   * It serves similar purpose as [google.api.Service.types], except that
      +   * these types are not needed by user-defined APIs. Therefore, they will not
      +   * show up in the generated discovery doc. This field should only be used
      +   * to define system APIs in ESF.
      +   * 
      + */ + com.google.protobuf.Type getSystemTypes(int index); + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +   * A list of all proto message types included in this API service.
      +   * It serves similar purpose as [google.api.Service.types], except that
      +   * these types are not needed by user-defined APIs. Therefore, they will not
      +   * show up in the generated discovery doc. This field should only be used
      +   * to define system APIs in ESF.
      +   * 
      + */ + int getSystemTypesCount(); + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +   * A list of all proto message types included in this API service.
      +   * It serves similar purpose as [google.api.Service.types], except that
      +   * these types are not needed by user-defined APIs. Therefore, they will not
      +   * show up in the generated discovery doc. This field should only be used
      +   * to define system APIs in ESF.
      +   * 
      + */ + java.util.List + getSystemTypesOrBuilderList(); + /** + * repeated .google.protobuf.Type system_types = 102; + * + *
      +   * A list of all proto message types included in this API service.
      +   * It serves similar purpose as [google.api.Service.types], except that
      +   * these types are not needed by user-defined APIs. Therefore, they will not
      +   * show up in the generated discovery doc. This field should only be used
      +   * to define system APIs in ESF.
      +   * 
      + */ + com.google.protobuf.TypeOrBuilder getSystemTypesOrBuilder( + int index); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceProto.java new file mode 100644 index 000000000000..fa6c564c7644 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceProto.java @@ -0,0 +1,95 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/service.proto + +package com.google.api; + +public final class ServiceProto { + private ServiceProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_Service_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_Service_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\030google/api/service.proto\022\ngoogle.api\032\031" + + "google/protobuf/any.proto\032\031google/protob" + + "uf/api.proto\032\032google/protobuf/type.proto" + + "\032\036google/protobuf/wrappers.proto\032\034google" + + "/api/annotations.proto\032\030google/api/conte" + + "xt.proto\032\036google/api/documentation.proto" + + "\032\026google/api/error.proto\032\025google/api/htt" + + "p.proto\032\033google/api/visibility.proto\"\253\004\n" + + "\007Service\0224\n\016config_version\030\024 \001(\0132\034.googl" + + "e.protobuf.UInt32Value\022\014\n\004name\030\001 \001(\t\022\r\n\005", + "title\030\002 \001(\t\022\033\n\023producer_project_id\030\026 \001(\t" + + "\022\"\n\004apis\030\003 \003(\0132\024.google.protobuf.Api\022$\n\005" + + "types\030\004 \003(\0132\025.google.protobuf.Type\022$\n\005en" + + "ums\030\005 \003(\0132\025.google.protobuf.Enum\0220\n\rdocu" + + "mentation\030\006 \001(\0132\031.google.api.Documentati" + + "on\022*\n\nvisibility\030\007 \001(\0132\026.google.api.Visi" + + "bility\022\036\n\004http\030\t \001(\0132\020.google.api.Http\022$" + + "\n\007context\030\014 \001(\0132\023.google.api.Context\022-\n\014" + + "custom_error\030\020 \001(\0132\027.google.api.CustomEr" + + "ror\022@\n\014derived_data\030d \001(\0132\024.google.proto", + "buf.AnyB\024\372\322\344\223\002\016\022\014GOOGLE_TOOLS\022+\n\014system_" + + "types\030f \003(\0132\025.google.protobuf.TypeB \n\016co" + + "m.google.apiB\014ServiceProtoP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.AnyProto.getDescriptor(), + com.google.protobuf.ApiProto.getDescriptor(), + com.google.protobuf.TypeProto.getDescriptor(), + com.google.protobuf.WrappersProto.getDescriptor(), + com.google.api.AnnotationsProto.getDescriptor(), + com.google.api.ContextProto.getDescriptor(), + com.google.api.DocumentationProto.getDescriptor(), + com.google.api.ErrorFormatProto.getDescriptor(), + com.google.api.HttpProto.getDescriptor(), + com.google.api.VisibilityProto.getDescriptor(), + }, assigner); + internal_static_google_api_Service_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_api_Service_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_Service_descriptor, + new java.lang.String[] { "ConfigVersion", "Name", "Title", "ProducerProjectId", "Apis", "Types", "Enums", "Documentation", "Visibility", "Http", "Context", "CustomError", "DerivedData", "SystemTypes", }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.AnnotationsProto.fieldVisibility); + com.google.protobuf.Descriptors.FileDescriptor + .internalUpdateFileDescriptor(descriptor, registry); + com.google.protobuf.AnyProto.getDescriptor(); + com.google.protobuf.ApiProto.getDescriptor(); + com.google.protobuf.TypeProto.getDescriptor(); + com.google.protobuf.WrappersProto.getDescriptor(); + com.google.api.AnnotationsProto.getDescriptor(); + com.google.api.ContextProto.getDescriptor(); + com.google.api.DocumentationProto.getDescriptor(); + com.google.api.ErrorFormatProto.getDescriptor(); + com.google.api.HttpProto.getDescriptor(); + com.google.api.VisibilityProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Visibility.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Visibility.java new file mode 100644 index 000000000000..2ef3f2b0442d --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/Visibility.java @@ -0,0 +1,1370 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/visibility.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.Visibility} + * + *
      + * `Visibility` defines restrictions for the visibility of service
      + * elements.  Restrictions are specified using visibility labels
      + * (e.g., TRUSTED_TESTER) that are elsewhere linked to users and projects.
      + * User and projects can have access to more than one visibility label. The
      + * effective visibility for multiple labels is the union of each label's
      + * elements, plus any unrestricted elements. You must list any supported label
      + * combinations in `label_combinations`.
      + * If an element and its parents have no restrictions, visibility is
      + * unconditionally granted.
      + * Example:
      + *     visibility:
      + *       label_combinations:
      + *       - GOOGLE_INTERNAL, TRUSTED_TESTER
      + *       rules:
      + *       - selector: google.calendar.Calendar.EnhancedSearch
      + *         restriction: TRUSTED_TESTER
      + *       - selector: google.calendar.Calendar.Delegate
      + *         restriction: GOOGLE_INTERNAL
      + * Here, all methods are publicly visible except for the restricted methods
      + * EnhancedSearch and Delegate. In addition, since `label_combinations`
      + * lists both GOOGLE_INTERNAL and TRUSTED_TESTER, users and projects can be
      + * given access to a combined visibility with both EnhancedSearch and Delegate.
      + * 
      + */ +public final class Visibility extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.Visibility) + VisibilityOrBuilder { + // Use Visibility.newBuilder() to construct. + private Visibility(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Visibility() { + rules_ = java.util.Collections.emptyList(); + labelCombinations_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Visibility( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + rules_.add(input.readMessage(com.google.api.VisibilityRule.parser(), extensionRegistry)); + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + labelCombinations_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + labelCombinations_.add(s); + break; + } + case 26: { + com.google.protobuf.BoolValue.Builder subBuilder = null; + if (enforceRuntimeVisibility_ != null) { + subBuilder = enforceRuntimeVisibility_.toBuilder(); + } + enforceRuntimeVisibility_ = input.readMessage(com.google.protobuf.BoolValue.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(enforceRuntimeVisibility_); + enforceRuntimeVisibility_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + } + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + labelCombinations_ = labelCombinations_.getUnmodifiableView(); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.VisibilityProto.internal_static_google_api_Visibility_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.VisibilityProto.internal_static_google_api_Visibility_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Visibility.class, com.google.api.Visibility.Builder.class); + } + + private int bitField0_; + public static final int RULES_FIELD_NUMBER = 1; + private java.util.List rules_; + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +   * A list of visibility rules providing visibility configuration for
      +   * individual API elements.
      +   * 
      + */ + public java.util.List getRulesList() { + return rules_; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +   * A list of visibility rules providing visibility configuration for
      +   * individual API elements.
      +   * 
      + */ + public java.util.List + getRulesOrBuilderList() { + return rules_; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +   * A list of visibility rules providing visibility configuration for
      +   * individual API elements.
      +   * 
      + */ + public int getRulesCount() { + return rules_.size(); + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +   * A list of visibility rules providing visibility configuration for
      +   * individual API elements.
      +   * 
      + */ + public com.google.api.VisibilityRule getRules(int index) { + return rules_.get(index); + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +   * A list of visibility rules providing visibility configuration for
      +   * individual API elements.
      +   * 
      + */ + public com.google.api.VisibilityRuleOrBuilder getRulesOrBuilder( + int index) { + return rules_.get(index); + } + + public static final int LABEL_COMBINATIONS_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList labelCombinations_; + /** + * repeated string label_combinations = 2; + * + *
      +   * Lists valid label combinations for this service in comma-delimited form.
      +   * This lets users and projects see the union of these labels' elements.
      +   * Removing a label combination can be a breaking change, as clients with
      +   * access to the combination will now see non-restricted elements only.
      +   * 
      + */ + public com.google.protobuf.ProtocolStringList + getLabelCombinationsList() { + return labelCombinations_; + } + /** + * repeated string label_combinations = 2; + * + *
      +   * Lists valid label combinations for this service in comma-delimited form.
      +   * This lets users and projects see the union of these labels' elements.
      +   * Removing a label combination can be a breaking change, as clients with
      +   * access to the combination will now see non-restricted elements only.
      +   * 
      + */ + public int getLabelCombinationsCount() { + return labelCombinations_.size(); + } + /** + * repeated string label_combinations = 2; + * + *
      +   * Lists valid label combinations for this service in comma-delimited form.
      +   * This lets users and projects see the union of these labels' elements.
      +   * Removing a label combination can be a breaking change, as clients with
      +   * access to the combination will now see non-restricted elements only.
      +   * 
      + */ + public java.lang.String getLabelCombinations(int index) { + return labelCombinations_.get(index); + } + /** + * repeated string label_combinations = 2; + * + *
      +   * Lists valid label combinations for this service in comma-delimited form.
      +   * This lets users and projects see the union of these labels' elements.
      +   * Removing a label combination can be a breaking change, as clients with
      +   * access to the combination will now see non-restricted elements only.
      +   * 
      + */ + public com.google.protobuf.ByteString + getLabelCombinationsBytes(int index) { + return labelCombinations_.getByteString(index); + } + + public static final int ENFORCE_RUNTIME_VISIBILITY_FIELD_NUMBER = 3; + private com.google.protobuf.BoolValue enforceRuntimeVisibility_; + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility rules are enforced at runtime for requests to
      +   * all APIs and methods.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is false.
      +   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +   * overrides this setting for the APIs or methods asscoiated with the rule.
      +   * 
      + */ + public boolean hasEnforceRuntimeVisibility() { + return enforceRuntimeVisibility_ != null; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility rules are enforced at runtime for requests to
      +   * all APIs and methods.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is false.
      +   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +   * overrides this setting for the APIs or methods asscoiated with the rule.
      +   * 
      + */ + public com.google.protobuf.BoolValue getEnforceRuntimeVisibility() { + return enforceRuntimeVisibility_ == null ? com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility rules are enforced at runtime for requests to
      +   * all APIs and methods.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is false.
      +   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +   * overrides this setting for the APIs or methods asscoiated with the rule.
      +   * 
      + */ + public com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder() { + return getEnforceRuntimeVisibility(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < rules_.size(); i++) { + output.writeMessage(1, rules_.get(i)); + } + for (int i = 0; i < labelCombinations_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, labelCombinations_.getRaw(i)); + } + if (enforceRuntimeVisibility_ != null) { + output.writeMessage(3, getEnforceRuntimeVisibility()); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < rules_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, rules_.get(i)); + } + { + int dataSize = 0; + for (int i = 0; i < labelCombinations_.size(); i++) { + dataSize += computeStringSizeNoTag(labelCombinations_.getRaw(i)); + } + size += dataSize; + size += 1 * getLabelCombinationsList().size(); + } + if (enforceRuntimeVisibility_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getEnforceRuntimeVisibility()); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.Visibility parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Visibility parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Visibility parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.Visibility parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.Visibility parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Visibility parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.Visibility parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.Visibility parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.Visibility parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.Visibility parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.Visibility prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.Visibility} + * + *
      +   * `Visibility` defines restrictions for the visibility of service
      +   * elements.  Restrictions are specified using visibility labels
      +   * (e.g., TRUSTED_TESTER) that are elsewhere linked to users and projects.
      +   * User and projects can have access to more than one visibility label. The
      +   * effective visibility for multiple labels is the union of each label's
      +   * elements, plus any unrestricted elements. You must list any supported label
      +   * combinations in `label_combinations`.
      +   * If an element and its parents have no restrictions, visibility is
      +   * unconditionally granted.
      +   * Example:
      +   *     visibility:
      +   *       label_combinations:
      +   *       - GOOGLE_INTERNAL, TRUSTED_TESTER
      +   *       rules:
      +   *       - selector: google.calendar.Calendar.EnhancedSearch
      +   *         restriction: TRUSTED_TESTER
      +   *       - selector: google.calendar.Calendar.Delegate
      +   *         restriction: GOOGLE_INTERNAL
      +   * Here, all methods are publicly visible except for the restricted methods
      +   * EnhancedSearch and Delegate. In addition, since `label_combinations`
      +   * lists both GOOGLE_INTERNAL and TRUSTED_TESTER, users and projects can be
      +   * given access to a combined visibility with both EnhancedSearch and Delegate.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.Visibility) + com.google.api.VisibilityOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.VisibilityProto.internal_static_google_api_Visibility_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.VisibilityProto.internal_static_google_api_Visibility_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.Visibility.class, com.google.api.Visibility.Builder.class); + } + + // Construct using com.google.api.Visibility.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getRulesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + rulesBuilder_.clear(); + } + labelCombinations_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + if (enforceRuntimeVisibilityBuilder_ == null) { + enforceRuntimeVisibility_ = null; + } else { + enforceRuntimeVisibility_ = null; + enforceRuntimeVisibilityBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.VisibilityProto.internal_static_google_api_Visibility_descriptor; + } + + public com.google.api.Visibility getDefaultInstanceForType() { + return com.google.api.Visibility.getDefaultInstance(); + } + + public com.google.api.Visibility build() { + com.google.api.Visibility result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.Visibility buildPartial() { + com.google.api.Visibility result = new com.google.api.Visibility(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (rulesBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.rules_ = rules_; + } else { + result.rules_ = rulesBuilder_.build(); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + labelCombinations_ = labelCombinations_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.labelCombinations_ = labelCombinations_; + if (enforceRuntimeVisibilityBuilder_ == null) { + result.enforceRuntimeVisibility_ = enforceRuntimeVisibility_; + } else { + result.enforceRuntimeVisibility_ = enforceRuntimeVisibilityBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.Visibility) { + return mergeFrom((com.google.api.Visibility)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.Visibility other) { + if (other == com.google.api.Visibility.getDefaultInstance()) return this; + if (rulesBuilder_ == null) { + if (!other.rules_.isEmpty()) { + if (rules_.isEmpty()) { + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureRulesIsMutable(); + rules_.addAll(other.rules_); + } + onChanged(); + } + } else { + if (!other.rules_.isEmpty()) { + if (rulesBuilder_.isEmpty()) { + rulesBuilder_.dispose(); + rulesBuilder_ = null; + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000001); + rulesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getRulesFieldBuilder() : null; + } else { + rulesBuilder_.addAllMessages(other.rules_); + } + } + } + if (!other.labelCombinations_.isEmpty()) { + if (labelCombinations_.isEmpty()) { + labelCombinations_ = other.labelCombinations_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureLabelCombinationsIsMutable(); + labelCombinations_.addAll(other.labelCombinations_); + } + onChanged(); + } + if (other.hasEnforceRuntimeVisibility()) { + mergeEnforceRuntimeVisibility(other.getEnforceRuntimeVisibility()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.Visibility parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.Visibility) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List rules_ = + java.util.Collections.emptyList(); + private void ensureRulesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + rules_ = new java.util.ArrayList(rules_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.VisibilityRule, com.google.api.VisibilityRule.Builder, com.google.api.VisibilityRuleOrBuilder> rulesBuilder_; + + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public java.util.List getRulesList() { + if (rulesBuilder_ == null) { + return java.util.Collections.unmodifiableList(rules_); + } else { + return rulesBuilder_.getMessageList(); + } + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public int getRulesCount() { + if (rulesBuilder_ == null) { + return rules_.size(); + } else { + return rulesBuilder_.getCount(); + } + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public com.google.api.VisibilityRule getRules(int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); + } else { + return rulesBuilder_.getMessage(index); + } + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public Builder setRules( + int index, com.google.api.VisibilityRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.set(index, value); + onChanged(); + } else { + rulesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public Builder setRules( + int index, com.google.api.VisibilityRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.set(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public Builder addRules(com.google.api.VisibilityRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(value); + onChanged(); + } else { + rulesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public Builder addRules( + int index, com.google.api.VisibilityRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(index, value); + onChanged(); + } else { + rulesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public Builder addRules( + com.google.api.VisibilityRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public Builder addRules( + int index, com.google.api.VisibilityRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public Builder addAllRules( + java.lang.Iterable values) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, rules_); + onChanged(); + } else { + rulesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public Builder clearRules() { + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + rulesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public Builder removeRules(int index) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.remove(index); + onChanged(); + } else { + rulesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public com.google.api.VisibilityRule.Builder getRulesBuilder( + int index) { + return getRulesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public com.google.api.VisibilityRuleOrBuilder getRulesOrBuilder( + int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); } else { + return rulesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public java.util.List + getRulesOrBuilderList() { + if (rulesBuilder_ != null) { + return rulesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(rules_); + } + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public com.google.api.VisibilityRule.Builder addRulesBuilder() { + return getRulesFieldBuilder().addBuilder( + com.google.api.VisibilityRule.getDefaultInstance()); + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public com.google.api.VisibilityRule.Builder addRulesBuilder( + int index) { + return getRulesFieldBuilder().addBuilder( + index, com.google.api.VisibilityRule.getDefaultInstance()); + } + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +     * A list of visibility rules providing visibility configuration for
      +     * individual API elements.
      +     * 
      + */ + public java.util.List + getRulesBuilderList() { + return getRulesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.api.VisibilityRule, com.google.api.VisibilityRule.Builder, com.google.api.VisibilityRuleOrBuilder> + getRulesFieldBuilder() { + if (rulesBuilder_ == null) { + rulesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.api.VisibilityRule, com.google.api.VisibilityRule.Builder, com.google.api.VisibilityRuleOrBuilder>( + rules_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + rules_ = null; + } + return rulesBuilder_; + } + + private com.google.protobuf.LazyStringList labelCombinations_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureLabelCombinationsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + labelCombinations_ = new com.google.protobuf.LazyStringArrayList(labelCombinations_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated string label_combinations = 2; + * + *
      +     * Lists valid label combinations for this service in comma-delimited form.
      +     * This lets users and projects see the union of these labels' elements.
      +     * Removing a label combination can be a breaking change, as clients with
      +     * access to the combination will now see non-restricted elements only.
      +     * 
      + */ + public com.google.protobuf.ProtocolStringList + getLabelCombinationsList() { + return labelCombinations_.getUnmodifiableView(); + } + /** + * repeated string label_combinations = 2; + * + *
      +     * Lists valid label combinations for this service in comma-delimited form.
      +     * This lets users and projects see the union of these labels' elements.
      +     * Removing a label combination can be a breaking change, as clients with
      +     * access to the combination will now see non-restricted elements only.
      +     * 
      + */ + public int getLabelCombinationsCount() { + return labelCombinations_.size(); + } + /** + * repeated string label_combinations = 2; + * + *
      +     * Lists valid label combinations for this service in comma-delimited form.
      +     * This lets users and projects see the union of these labels' elements.
      +     * Removing a label combination can be a breaking change, as clients with
      +     * access to the combination will now see non-restricted elements only.
      +     * 
      + */ + public java.lang.String getLabelCombinations(int index) { + return labelCombinations_.get(index); + } + /** + * repeated string label_combinations = 2; + * + *
      +     * Lists valid label combinations for this service in comma-delimited form.
      +     * This lets users and projects see the union of these labels' elements.
      +     * Removing a label combination can be a breaking change, as clients with
      +     * access to the combination will now see non-restricted elements only.
      +     * 
      + */ + public com.google.protobuf.ByteString + getLabelCombinationsBytes(int index) { + return labelCombinations_.getByteString(index); + } + /** + * repeated string label_combinations = 2; + * + *
      +     * Lists valid label combinations for this service in comma-delimited form.
      +     * This lets users and projects see the union of these labels' elements.
      +     * Removing a label combination can be a breaking change, as clients with
      +     * access to the combination will now see non-restricted elements only.
      +     * 
      + */ + public Builder setLabelCombinations( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureLabelCombinationsIsMutable(); + labelCombinations_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string label_combinations = 2; + * + *
      +     * Lists valid label combinations for this service in comma-delimited form.
      +     * This lets users and projects see the union of these labels' elements.
      +     * Removing a label combination can be a breaking change, as clients with
      +     * access to the combination will now see non-restricted elements only.
      +     * 
      + */ + public Builder addLabelCombinations( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureLabelCombinationsIsMutable(); + labelCombinations_.add(value); + onChanged(); + return this; + } + /** + * repeated string label_combinations = 2; + * + *
      +     * Lists valid label combinations for this service in comma-delimited form.
      +     * This lets users and projects see the union of these labels' elements.
      +     * Removing a label combination can be a breaking change, as clients with
      +     * access to the combination will now see non-restricted elements only.
      +     * 
      + */ + public Builder addAllLabelCombinations( + java.lang.Iterable values) { + ensureLabelCombinationsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, labelCombinations_); + onChanged(); + return this; + } + /** + * repeated string label_combinations = 2; + * + *
      +     * Lists valid label combinations for this service in comma-delimited form.
      +     * This lets users and projects see the union of these labels' elements.
      +     * Removing a label combination can be a breaking change, as clients with
      +     * access to the combination will now see non-restricted elements only.
      +     * 
      + */ + public Builder clearLabelCombinations() { + labelCombinations_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * repeated string label_combinations = 2; + * + *
      +     * Lists valid label combinations for this service in comma-delimited form.
      +     * This lets users and projects see the union of these labels' elements.
      +     * Removing a label combination can be a breaking change, as clients with
      +     * access to the combination will now see non-restricted elements only.
      +     * 
      + */ + public Builder addLabelCombinationsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureLabelCombinationsIsMutable(); + labelCombinations_.add(value); + onChanged(); + return this; + } + + private com.google.protobuf.BoolValue enforceRuntimeVisibility_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder> enforceRuntimeVisibilityBuilder_; + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility rules are enforced at runtime for requests to
      +     * all APIs and methods.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is false.
      +     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +     * overrides this setting for the APIs or methods asscoiated with the rule.
      +     * 
      + */ + public boolean hasEnforceRuntimeVisibility() { + return enforceRuntimeVisibilityBuilder_ != null || enforceRuntimeVisibility_ != null; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility rules are enforced at runtime for requests to
      +     * all APIs and methods.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is false.
      +     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +     * overrides this setting for the APIs or methods asscoiated with the rule.
      +     * 
      + */ + public com.google.protobuf.BoolValue getEnforceRuntimeVisibility() { + if (enforceRuntimeVisibilityBuilder_ == null) { + return enforceRuntimeVisibility_ == null ? com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; + } else { + return enforceRuntimeVisibilityBuilder_.getMessage(); + } + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility rules are enforced at runtime for requests to
      +     * all APIs and methods.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is false.
      +     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +     * overrides this setting for the APIs or methods asscoiated with the rule.
      +     * 
      + */ + public Builder setEnforceRuntimeVisibility(com.google.protobuf.BoolValue value) { + if (enforceRuntimeVisibilityBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + enforceRuntimeVisibility_ = value; + onChanged(); + } else { + enforceRuntimeVisibilityBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility rules are enforced at runtime for requests to
      +     * all APIs and methods.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is false.
      +     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +     * overrides this setting for the APIs or methods asscoiated with the rule.
      +     * 
      + */ + public Builder setEnforceRuntimeVisibility( + com.google.protobuf.BoolValue.Builder builderForValue) { + if (enforceRuntimeVisibilityBuilder_ == null) { + enforceRuntimeVisibility_ = builderForValue.build(); + onChanged(); + } else { + enforceRuntimeVisibilityBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility rules are enforced at runtime for requests to
      +     * all APIs and methods.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is false.
      +     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +     * overrides this setting for the APIs or methods asscoiated with the rule.
      +     * 
      + */ + public Builder mergeEnforceRuntimeVisibility(com.google.protobuf.BoolValue value) { + if (enforceRuntimeVisibilityBuilder_ == null) { + if (enforceRuntimeVisibility_ != null) { + enforceRuntimeVisibility_ = + com.google.protobuf.BoolValue.newBuilder(enforceRuntimeVisibility_).mergeFrom(value).buildPartial(); + } else { + enforceRuntimeVisibility_ = value; + } + onChanged(); + } else { + enforceRuntimeVisibilityBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility rules are enforced at runtime for requests to
      +     * all APIs and methods.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is false.
      +     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +     * overrides this setting for the APIs or methods asscoiated with the rule.
      +     * 
      + */ + public Builder clearEnforceRuntimeVisibility() { + if (enforceRuntimeVisibilityBuilder_ == null) { + enforceRuntimeVisibility_ = null; + onChanged(); + } else { + enforceRuntimeVisibility_ = null; + enforceRuntimeVisibilityBuilder_ = null; + } + + return this; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility rules are enforced at runtime for requests to
      +     * all APIs and methods.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is false.
      +     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +     * overrides this setting for the APIs or methods asscoiated with the rule.
      +     * 
      + */ + public com.google.protobuf.BoolValue.Builder getEnforceRuntimeVisibilityBuilder() { + + onChanged(); + return getEnforceRuntimeVisibilityFieldBuilder().getBuilder(); + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility rules are enforced at runtime for requests to
      +     * all APIs and methods.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is false.
      +     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +     * overrides this setting for the APIs or methods asscoiated with the rule.
      +     * 
      + */ + public com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder() { + if (enforceRuntimeVisibilityBuilder_ != null) { + return enforceRuntimeVisibilityBuilder_.getMessageOrBuilder(); + } else { + return enforceRuntimeVisibility_ == null ? + com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; + } + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility rules are enforced at runtime for requests to
      +     * all APIs and methods.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is false.
      +     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +     * overrides this setting for the APIs or methods asscoiated with the rule.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder> + getEnforceRuntimeVisibilityFieldBuilder() { + if (enforceRuntimeVisibilityBuilder_ == null) { + enforceRuntimeVisibilityBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder>( + getEnforceRuntimeVisibility(), + getParentForChildren(), + isClean()); + enforceRuntimeVisibility_ = null; + } + return enforceRuntimeVisibilityBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.Visibility) + } + + // @@protoc_insertion_point(class_scope:google.api.Visibility) + private static final com.google.api.Visibility DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.Visibility(); + } + + public static com.google.api.Visibility getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Visibility parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Visibility(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.Visibility getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityOrBuilder.java new file mode 100644 index 000000000000..1c8cb2bca4b8 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityOrBuilder.java @@ -0,0 +1,148 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/visibility.proto + +package com.google.api; + +public interface VisibilityOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.Visibility) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +   * A list of visibility rules providing visibility configuration for
      +   * individual API elements.
      +   * 
      + */ + java.util.List + getRulesList(); + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +   * A list of visibility rules providing visibility configuration for
      +   * individual API elements.
      +   * 
      + */ + com.google.api.VisibilityRule getRules(int index); + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +   * A list of visibility rules providing visibility configuration for
      +   * individual API elements.
      +   * 
      + */ + int getRulesCount(); + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +   * A list of visibility rules providing visibility configuration for
      +   * individual API elements.
      +   * 
      + */ + java.util.List + getRulesOrBuilderList(); + /** + * repeated .google.api.VisibilityRule rules = 1; + * + *
      +   * A list of visibility rules providing visibility configuration for
      +   * individual API elements.
      +   * 
      + */ + com.google.api.VisibilityRuleOrBuilder getRulesOrBuilder( + int index); + + /** + * repeated string label_combinations = 2; + * + *
      +   * Lists valid label combinations for this service in comma-delimited form.
      +   * This lets users and projects see the union of these labels' elements.
      +   * Removing a label combination can be a breaking change, as clients with
      +   * access to the combination will now see non-restricted elements only.
      +   * 
      + */ + com.google.protobuf.ProtocolStringList + getLabelCombinationsList(); + /** + * repeated string label_combinations = 2; + * + *
      +   * Lists valid label combinations for this service in comma-delimited form.
      +   * This lets users and projects see the union of these labels' elements.
      +   * Removing a label combination can be a breaking change, as clients with
      +   * access to the combination will now see non-restricted elements only.
      +   * 
      + */ + int getLabelCombinationsCount(); + /** + * repeated string label_combinations = 2; + * + *
      +   * Lists valid label combinations for this service in comma-delimited form.
      +   * This lets users and projects see the union of these labels' elements.
      +   * Removing a label combination can be a breaking change, as clients with
      +   * access to the combination will now see non-restricted elements only.
      +   * 
      + */ + java.lang.String getLabelCombinations(int index); + /** + * repeated string label_combinations = 2; + * + *
      +   * Lists valid label combinations for this service in comma-delimited form.
      +   * This lets users and projects see the union of these labels' elements.
      +   * Removing a label combination can be a breaking change, as clients with
      +   * access to the combination will now see non-restricted elements only.
      +   * 
      + */ + com.google.protobuf.ByteString + getLabelCombinationsBytes(int index); + + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility rules are enforced at runtime for requests to
      +   * all APIs and methods.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is false.
      +   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +   * overrides this setting for the APIs or methods asscoiated with the rule.
      +   * 
      + */ + boolean hasEnforceRuntimeVisibility(); + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility rules are enforced at runtime for requests to
      +   * all APIs and methods.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is false.
      +   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +   * overrides this setting for the APIs or methods asscoiated with the rule.
      +   * 
      + */ + com.google.protobuf.BoolValue getEnforceRuntimeVisibility(); + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility rules are enforced at runtime for requests to
      +   * all APIs and methods.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is false.
      +   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      +   * overrides this setting for the APIs or methods asscoiated with the rule.
      +   * 
      + */ + com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityProto.java new file mode 100644 index 000000000000..75f797d990e2 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityProto.java @@ -0,0 +1,70 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/visibility.proto + +package com.google.api; + +public final class VisibilityProto { + private VisibilityProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_Visibility_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_Visibility_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_VisibilityRule_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_api_VisibilityRule_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\033google/api/visibility.proto\022\ngoogle.ap" + + "i\032\036google/protobuf/wrappers.proto\"\223\001\n\nVi" + + "sibility\022)\n\005rules\030\001 \003(\0132\032.google.api.Vis" + + "ibilityRule\022\032\n\022label_combinations\030\002 \003(\t\022" + + ">\n\032enforce_runtime_visibility\030\003 \001(\0132\032.go" + + "ogle.protobuf.BoolValue\"w\n\016VisibilityRul" + + "e\022\020\n\010selector\030\001 \001(\t\022\023\n\013restriction\030\002 \001(\t" + + "\022>\n\032enforce_runtime_visibility\030\003 \001(\0132\032.g" + + "oogle.protobuf.BoolValueB&\n\016com.google.a" + + "piB\017VisibilityProtoP\001\370\001\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.WrappersProto.getDescriptor(), + }, assigner); + internal_static_google_api_Visibility_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_api_Visibility_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_Visibility_descriptor, + new java.lang.String[] { "Rules", "LabelCombinations", "EnforceRuntimeVisibility", }); + internal_static_google_api_VisibilityRule_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_api_VisibilityRule_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_api_VisibilityRule_descriptor, + new java.lang.String[] { "Selector", "Restriction", "EnforceRuntimeVisibility", }); + com.google.protobuf.WrappersProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRule.java b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRule.java new file mode 100644 index 000000000000..1fcc76384b70 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRule.java @@ -0,0 +1,998 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/visibility.proto + +package com.google.api; + +/** + * Protobuf type {@code google.api.VisibilityRule} + * + *
      + * A visibility rule provides visibility configuration for an individual API
      + * element.
      + * 
      + */ +public final class VisibilityRule extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.api.VisibilityRule) + VisibilityRuleOrBuilder { + // Use VisibilityRule.newBuilder() to construct. + private VisibilityRule(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private VisibilityRule() { + selector_ = ""; + restriction_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private VisibilityRule( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + selector_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + restriction_ = s; + break; + } + case 26: { + com.google.protobuf.BoolValue.Builder subBuilder = null; + if (enforceRuntimeVisibility_ != null) { + subBuilder = enforceRuntimeVisibility_.toBuilder(); + } + enforceRuntimeVisibility_ = input.readMessage(com.google.protobuf.BoolValue.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(enforceRuntimeVisibility_); + enforceRuntimeVisibility_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.VisibilityProto.internal_static_google_api_VisibilityRule_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.VisibilityProto.internal_static_google_api_VisibilityRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.VisibilityRule.class, com.google.api.VisibilityRule.Builder.class); + } + + public static final int SELECTOR_FIELD_NUMBER = 1; + private volatile java.lang.Object selector_; + /** + * optional string selector = 1; + * + *
      +   * Selects methods, messages, fields, enums, etc. to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } + } + /** + * optional string selector = 1; + * + *
      +   * Selects methods, messages, fields, enums, etc. to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESTRICTION_FIELD_NUMBER = 2; + private volatile java.lang.Object restriction_; + /** + * optional string restriction = 2; + * + *
      +   * Lists the visibility labels for this rule. Any of the listed labels grants
      +   * visibility to the element.
      +   * If a rule has multiple labels, removing one of the labels but not all of
      +   * them can break clients.
      +   * Example:
      +   *     visibility:
      +   *       rules:
      +   *       - selector: google.calendar.Calendar.EnhancedSearch
      +   *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      +   * Removing GOOGLE_INTERNAL from this restriction will break clients that
      +   * rely on this method and only had access to it through GOOGLE_INTERNAL.
      +   * 
      + */ + public java.lang.String getRestriction() { + java.lang.Object ref = restriction_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + restriction_ = s; + return s; + } + } + /** + * optional string restriction = 2; + * + *
      +   * Lists the visibility labels for this rule. Any of the listed labels grants
      +   * visibility to the element.
      +   * If a rule has multiple labels, removing one of the labels but not all of
      +   * them can break clients.
      +   * Example:
      +   *     visibility:
      +   *       rules:
      +   *       - selector: google.calendar.Calendar.EnhancedSearch
      +   *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      +   * Removing GOOGLE_INTERNAL from this restriction will break clients that
      +   * rely on this method and only had access to it through GOOGLE_INTERNAL.
      +   * 
      + */ + public com.google.protobuf.ByteString + getRestrictionBytes() { + java.lang.Object ref = restriction_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + restriction_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ENFORCE_RUNTIME_VISIBILITY_FIELD_NUMBER = 3; + private com.google.protobuf.BoolValue enforceRuntimeVisibility_; + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility is enforced at runtime for requests to an API
      +   * method. This setting has meaning only when the selector applies to a method
      +   * or an API.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is determined by the value of
      +   * [google.api.Visibility.enforce_runtime_visibility][].
      +   * 
      + */ + public boolean hasEnforceRuntimeVisibility() { + return enforceRuntimeVisibility_ != null; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility is enforced at runtime for requests to an API
      +   * method. This setting has meaning only when the selector applies to a method
      +   * or an API.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is determined by the value of
      +   * [google.api.Visibility.enforce_runtime_visibility][].
      +   * 
      + */ + public com.google.protobuf.BoolValue getEnforceRuntimeVisibility() { + return enforceRuntimeVisibility_ == null ? com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility is enforced at runtime for requests to an API
      +   * method. This setting has meaning only when the selector applies to a method
      +   * or an API.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is determined by the value of
      +   * [google.api.Visibility.enforce_runtime_visibility][].
      +   * 
      + */ + public com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder() { + return getEnforceRuntimeVisibility(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSelectorBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, selector_); + } + if (!getRestrictionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, restriction_); + } + if (enforceRuntimeVisibility_ != null) { + output.writeMessage(3, getEnforceRuntimeVisibility()); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSelectorBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, selector_); + } + if (!getRestrictionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, restriction_); + } + if (enforceRuntimeVisibility_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getEnforceRuntimeVisibility()); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.api.VisibilityRule parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.VisibilityRule parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.VisibilityRule parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.api.VisibilityRule parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.api.VisibilityRule parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.VisibilityRule parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.api.VisibilityRule parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.api.VisibilityRule parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.api.VisibilityRule parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.api.VisibilityRule parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.api.VisibilityRule prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.api.VisibilityRule} + * + *
      +   * A visibility rule provides visibility configuration for an individual API
      +   * element.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.api.VisibilityRule) + com.google.api.VisibilityRuleOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.api.VisibilityProto.internal_static_google_api_VisibilityRule_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.VisibilityProto.internal_static_google_api_VisibilityRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.VisibilityRule.class, com.google.api.VisibilityRule.Builder.class); + } + + // Construct using com.google.api.VisibilityRule.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + selector_ = ""; + + restriction_ = ""; + + if (enforceRuntimeVisibilityBuilder_ == null) { + enforceRuntimeVisibility_ = null; + } else { + enforceRuntimeVisibility_ = null; + enforceRuntimeVisibilityBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.api.VisibilityProto.internal_static_google_api_VisibilityRule_descriptor; + } + + public com.google.api.VisibilityRule getDefaultInstanceForType() { + return com.google.api.VisibilityRule.getDefaultInstance(); + } + + public com.google.api.VisibilityRule build() { + com.google.api.VisibilityRule result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.api.VisibilityRule buildPartial() { + com.google.api.VisibilityRule result = new com.google.api.VisibilityRule(this); + result.selector_ = selector_; + result.restriction_ = restriction_; + if (enforceRuntimeVisibilityBuilder_ == null) { + result.enforceRuntimeVisibility_ = enforceRuntimeVisibility_; + } else { + result.enforceRuntimeVisibility_ = enforceRuntimeVisibilityBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.VisibilityRule) { + return mergeFrom((com.google.api.VisibilityRule)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.VisibilityRule other) { + if (other == com.google.api.VisibilityRule.getDefaultInstance()) return this; + if (!other.getSelector().isEmpty()) { + selector_ = other.selector_; + onChanged(); + } + if (!other.getRestriction().isEmpty()) { + restriction_ = other.restriction_; + onChanged(); + } + if (other.hasEnforceRuntimeVisibility()) { + mergeEnforceRuntimeVisibility(other.getEnforceRuntimeVisibility()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.api.VisibilityRule parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.api.VisibilityRule) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object selector_ = ""; + /** + * optional string selector = 1; + * + *
      +     * Selects methods, messages, fields, enums, etc. to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string selector = 1; + * + *
      +     * Selects methods, messages, fields, enums, etc. to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string selector = 1; + * + *
      +     * Selects methods, messages, fields, enums, etc. to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder setSelector( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + selector_ = value; + onChanged(); + return this; + } + /** + * optional string selector = 1; + * + *
      +     * Selects methods, messages, fields, enums, etc. to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder clearSelector() { + + selector_ = getDefaultInstance().getSelector(); + onChanged(); + return this; + } + /** + * optional string selector = 1; + * + *
      +     * Selects methods, messages, fields, enums, etc. to which this rule applies.
      +     * Refer to [selector][DocumentationRule.selector] for syntax details.
      +     * 
      + */ + public Builder setSelectorBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + selector_ = value; + onChanged(); + return this; + } + + private java.lang.Object restriction_ = ""; + /** + * optional string restriction = 2; + * + *
      +     * Lists the visibility labels for this rule. Any of the listed labels grants
      +     * visibility to the element.
      +     * If a rule has multiple labels, removing one of the labels but not all of
      +     * them can break clients.
      +     * Example:
      +     *     visibility:
      +     *       rules:
      +     *       - selector: google.calendar.Calendar.EnhancedSearch
      +     *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      +     * Removing GOOGLE_INTERNAL from this restriction will break clients that
      +     * rely on this method and only had access to it through GOOGLE_INTERNAL.
      +     * 
      + */ + public java.lang.String getRestriction() { + java.lang.Object ref = restriction_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + restriction_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string restriction = 2; + * + *
      +     * Lists the visibility labels for this rule. Any of the listed labels grants
      +     * visibility to the element.
      +     * If a rule has multiple labels, removing one of the labels but not all of
      +     * them can break clients.
      +     * Example:
      +     *     visibility:
      +     *       rules:
      +     *       - selector: google.calendar.Calendar.EnhancedSearch
      +     *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      +     * Removing GOOGLE_INTERNAL from this restriction will break clients that
      +     * rely on this method and only had access to it through GOOGLE_INTERNAL.
      +     * 
      + */ + public com.google.protobuf.ByteString + getRestrictionBytes() { + java.lang.Object ref = restriction_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + restriction_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string restriction = 2; + * + *
      +     * Lists the visibility labels for this rule. Any of the listed labels grants
      +     * visibility to the element.
      +     * If a rule has multiple labels, removing one of the labels but not all of
      +     * them can break clients.
      +     * Example:
      +     *     visibility:
      +     *       rules:
      +     *       - selector: google.calendar.Calendar.EnhancedSearch
      +     *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      +     * Removing GOOGLE_INTERNAL from this restriction will break clients that
      +     * rely on this method and only had access to it through GOOGLE_INTERNAL.
      +     * 
      + */ + public Builder setRestriction( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + restriction_ = value; + onChanged(); + return this; + } + /** + * optional string restriction = 2; + * + *
      +     * Lists the visibility labels for this rule. Any of the listed labels grants
      +     * visibility to the element.
      +     * If a rule has multiple labels, removing one of the labels but not all of
      +     * them can break clients.
      +     * Example:
      +     *     visibility:
      +     *       rules:
      +     *       - selector: google.calendar.Calendar.EnhancedSearch
      +     *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      +     * Removing GOOGLE_INTERNAL from this restriction will break clients that
      +     * rely on this method and only had access to it through GOOGLE_INTERNAL.
      +     * 
      + */ + public Builder clearRestriction() { + + restriction_ = getDefaultInstance().getRestriction(); + onChanged(); + return this; + } + /** + * optional string restriction = 2; + * + *
      +     * Lists the visibility labels for this rule. Any of the listed labels grants
      +     * visibility to the element.
      +     * If a rule has multiple labels, removing one of the labels but not all of
      +     * them can break clients.
      +     * Example:
      +     *     visibility:
      +     *       rules:
      +     *       - selector: google.calendar.Calendar.EnhancedSearch
      +     *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      +     * Removing GOOGLE_INTERNAL from this restriction will break clients that
      +     * rely on this method and only had access to it through GOOGLE_INTERNAL.
      +     * 
      + */ + public Builder setRestrictionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + restriction_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.BoolValue enforceRuntimeVisibility_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder> enforceRuntimeVisibilityBuilder_; + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility is enforced at runtime for requests to an API
      +     * method. This setting has meaning only when the selector applies to a method
      +     * or an API.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is determined by the value of
      +     * [google.api.Visibility.enforce_runtime_visibility][].
      +     * 
      + */ + public boolean hasEnforceRuntimeVisibility() { + return enforceRuntimeVisibilityBuilder_ != null || enforceRuntimeVisibility_ != null; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility is enforced at runtime for requests to an API
      +     * method. This setting has meaning only when the selector applies to a method
      +     * or an API.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is determined by the value of
      +     * [google.api.Visibility.enforce_runtime_visibility][].
      +     * 
      + */ + public com.google.protobuf.BoolValue getEnforceRuntimeVisibility() { + if (enforceRuntimeVisibilityBuilder_ == null) { + return enforceRuntimeVisibility_ == null ? com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; + } else { + return enforceRuntimeVisibilityBuilder_.getMessage(); + } + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility is enforced at runtime for requests to an API
      +     * method. This setting has meaning only when the selector applies to a method
      +     * or an API.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is determined by the value of
      +     * [google.api.Visibility.enforce_runtime_visibility][].
      +     * 
      + */ + public Builder setEnforceRuntimeVisibility(com.google.protobuf.BoolValue value) { + if (enforceRuntimeVisibilityBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + enforceRuntimeVisibility_ = value; + onChanged(); + } else { + enforceRuntimeVisibilityBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility is enforced at runtime for requests to an API
      +     * method. This setting has meaning only when the selector applies to a method
      +     * or an API.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is determined by the value of
      +     * [google.api.Visibility.enforce_runtime_visibility][].
      +     * 
      + */ + public Builder setEnforceRuntimeVisibility( + com.google.protobuf.BoolValue.Builder builderForValue) { + if (enforceRuntimeVisibilityBuilder_ == null) { + enforceRuntimeVisibility_ = builderForValue.build(); + onChanged(); + } else { + enforceRuntimeVisibilityBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility is enforced at runtime for requests to an API
      +     * method. This setting has meaning only when the selector applies to a method
      +     * or an API.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is determined by the value of
      +     * [google.api.Visibility.enforce_runtime_visibility][].
      +     * 
      + */ + public Builder mergeEnforceRuntimeVisibility(com.google.protobuf.BoolValue value) { + if (enforceRuntimeVisibilityBuilder_ == null) { + if (enforceRuntimeVisibility_ != null) { + enforceRuntimeVisibility_ = + com.google.protobuf.BoolValue.newBuilder(enforceRuntimeVisibility_).mergeFrom(value).buildPartial(); + } else { + enforceRuntimeVisibility_ = value; + } + onChanged(); + } else { + enforceRuntimeVisibilityBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility is enforced at runtime for requests to an API
      +     * method. This setting has meaning only when the selector applies to a method
      +     * or an API.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is determined by the value of
      +     * [google.api.Visibility.enforce_runtime_visibility][].
      +     * 
      + */ + public Builder clearEnforceRuntimeVisibility() { + if (enforceRuntimeVisibilityBuilder_ == null) { + enforceRuntimeVisibility_ = null; + onChanged(); + } else { + enforceRuntimeVisibility_ = null; + enforceRuntimeVisibilityBuilder_ = null; + } + + return this; + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility is enforced at runtime for requests to an API
      +     * method. This setting has meaning only when the selector applies to a method
      +     * or an API.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is determined by the value of
      +     * [google.api.Visibility.enforce_runtime_visibility][].
      +     * 
      + */ + public com.google.protobuf.BoolValue.Builder getEnforceRuntimeVisibilityBuilder() { + + onChanged(); + return getEnforceRuntimeVisibilityFieldBuilder().getBuilder(); + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility is enforced at runtime for requests to an API
      +     * method. This setting has meaning only when the selector applies to a method
      +     * or an API.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is determined by the value of
      +     * [google.api.Visibility.enforce_runtime_visibility][].
      +     * 
      + */ + public com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder() { + if (enforceRuntimeVisibilityBuilder_ != null) { + return enforceRuntimeVisibilityBuilder_.getMessageOrBuilder(); + } else { + return enforceRuntimeVisibility_ == null ? + com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; + } + } + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +     * Controls whether visibility is enforced at runtime for requests to an API
      +     * method. This setting has meaning only when the selector applies to a method
      +     * or an API.
      +     * If true, requests without method visibility will receive a
      +     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +     * the response messages. The default is determined by the value of
      +     * [google.api.Visibility.enforce_runtime_visibility][].
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder> + getEnforceRuntimeVisibilityFieldBuilder() { + if (enforceRuntimeVisibilityBuilder_ == null) { + enforceRuntimeVisibilityBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder>( + getEnforceRuntimeVisibility(), + getParentForChildren(), + isClean()); + enforceRuntimeVisibility_ = null; + } + return enforceRuntimeVisibilityBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.api.VisibilityRule) + } + + // @@protoc_insertion_point(class_scope:google.api.VisibilityRule) + private static final com.google.api.VisibilityRule DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.api.VisibilityRule(); + } + + public static com.google.api.VisibilityRule getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public VisibilityRule parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new VisibilityRule(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.api.VisibilityRule getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRuleOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRuleOrBuilder.java new file mode 100644 index 000000000000..130f46c58ada --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRuleOrBuilder.java @@ -0,0 +1,110 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/visibility.proto + +package com.google.api; + +public interface VisibilityRuleOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.api.VisibilityRule) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string selector = 1; + * + *
      +   * Selects methods, messages, fields, enums, etc. to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + java.lang.String getSelector(); + /** + * optional string selector = 1; + * + *
      +   * Selects methods, messages, fields, enums, etc. to which this rule applies.
      +   * Refer to [selector][DocumentationRule.selector] for syntax details.
      +   * 
      + */ + com.google.protobuf.ByteString + getSelectorBytes(); + + /** + * optional string restriction = 2; + * + *
      +   * Lists the visibility labels for this rule. Any of the listed labels grants
      +   * visibility to the element.
      +   * If a rule has multiple labels, removing one of the labels but not all of
      +   * them can break clients.
      +   * Example:
      +   *     visibility:
      +   *       rules:
      +   *       - selector: google.calendar.Calendar.EnhancedSearch
      +   *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      +   * Removing GOOGLE_INTERNAL from this restriction will break clients that
      +   * rely on this method and only had access to it through GOOGLE_INTERNAL.
      +   * 
      + */ + java.lang.String getRestriction(); + /** + * optional string restriction = 2; + * + *
      +   * Lists the visibility labels for this rule. Any of the listed labels grants
      +   * visibility to the element.
      +   * If a rule has multiple labels, removing one of the labels but not all of
      +   * them can break clients.
      +   * Example:
      +   *     visibility:
      +   *       rules:
      +   *       - selector: google.calendar.Calendar.EnhancedSearch
      +   *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      +   * Removing GOOGLE_INTERNAL from this restriction will break clients that
      +   * rely on this method and only had access to it through GOOGLE_INTERNAL.
      +   * 
      + */ + com.google.protobuf.ByteString + getRestrictionBytes(); + + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility is enforced at runtime for requests to an API
      +   * method. This setting has meaning only when the selector applies to a method
      +   * or an API.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is determined by the value of
      +   * [google.api.Visibility.enforce_runtime_visibility][].
      +   * 
      + */ + boolean hasEnforceRuntimeVisibility(); + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility is enforced at runtime for requests to an API
      +   * method. This setting has meaning only when the selector applies to a method
      +   * or an API.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is determined by the value of
      +   * [google.api.Visibility.enforce_runtime_visibility][].
      +   * 
      + */ + com.google.protobuf.BoolValue getEnforceRuntimeVisibility(); + /** + * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; + * + *
      +   * Controls whether visibility is enforced at runtime for requests to an API
      +   * method. This setting has meaning only when the selector applies to a method
      +   * or an API.
      +   * If true, requests without method visibility will receive a
      +   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      +   * the response messages. The default is determined by the value of
      +   * [google.api.Visibility.enforce_runtime_visibility][].
      +   * 
      + */ + com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequest.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequest.java new file mode 100644 index 000000000000..fe7f54b5b58f --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequest.java @@ -0,0 +1,476 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +/** + * Protobuf type {@code google.longrunning.CancelOperationRequest} + * + *
      + * The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
      + * 
      + */ +public final class CancelOperationRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.longrunning.CancelOperationRequest) + CancelOperationRequestOrBuilder { + // Use CancelOperationRequest.newBuilder() to construct. + private CancelOperationRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private CancelOperationRequest() { + name_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private CancelOperationRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_CancelOperationRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_CancelOperationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.CancelOperationRequest.class, com.google.longrunning.CancelOperationRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource to be cancelled.
      +   * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource to be cancelled.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.longrunning.CancelOperationRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.CancelOperationRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.CancelOperationRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.CancelOperationRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.CancelOperationRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.CancelOperationRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.longrunning.CancelOperationRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.longrunning.CancelOperationRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.longrunning.CancelOperationRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.CancelOperationRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.longrunning.CancelOperationRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.longrunning.CancelOperationRequest} + * + *
      +   * The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.longrunning.CancelOperationRequest) + com.google.longrunning.CancelOperationRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_CancelOperationRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_CancelOperationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.CancelOperationRequest.class, com.google.longrunning.CancelOperationRequest.Builder.class); + } + + // Construct using com.google.longrunning.CancelOperationRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_CancelOperationRequest_descriptor; + } + + public com.google.longrunning.CancelOperationRequest getDefaultInstanceForType() { + return com.google.longrunning.CancelOperationRequest.getDefaultInstance(); + } + + public com.google.longrunning.CancelOperationRequest build() { + com.google.longrunning.CancelOperationRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.longrunning.CancelOperationRequest buildPartial() { + com.google.longrunning.CancelOperationRequest result = new com.google.longrunning.CancelOperationRequest(this); + result.name_ = name_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.longrunning.CancelOperationRequest) { + return mergeFrom((com.google.longrunning.CancelOperationRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.longrunning.CancelOperationRequest other) { + if (other == com.google.longrunning.CancelOperationRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.longrunning.CancelOperationRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.longrunning.CancelOperationRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource to be cancelled.
      +     * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource to be cancelled.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource to be cancelled.
      +     * 
      + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource to be cancelled.
      +     * 
      + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource to be cancelled.
      +     * 
      + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.longrunning.CancelOperationRequest) + } + + // @@protoc_insertion_point(class_scope:google.longrunning.CancelOperationRequest) + private static final com.google.longrunning.CancelOperationRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.longrunning.CancelOperationRequest(); + } + + public static com.google.longrunning.CancelOperationRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public CancelOperationRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new CancelOperationRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.longrunning.CancelOperationRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequestOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequestOrBuilder.java new file mode 100644 index 000000000000..86004606c35d --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequestOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +public interface CancelOperationRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.longrunning.CancelOperationRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource to be cancelled.
      +   * 
      + */ + java.lang.String getName(); + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource to be cancelled.
      +   * 
      + */ + com.google.protobuf.ByteString + getNameBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequest.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequest.java new file mode 100644 index 000000000000..d10d1e3300aa --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequest.java @@ -0,0 +1,476 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +/** + * Protobuf type {@code google.longrunning.DeleteOperationRequest} + * + *
      + * The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
      + * 
      + */ +public final class DeleteOperationRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.longrunning.DeleteOperationRequest) + DeleteOperationRequestOrBuilder { + // Use DeleteOperationRequest.newBuilder() to construct. + private DeleteOperationRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private DeleteOperationRequest() { + name_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private DeleteOperationRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_DeleteOperationRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_DeleteOperationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.DeleteOperationRequest.class, com.google.longrunning.DeleteOperationRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource to be deleted.
      +   * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource to be deleted.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.longrunning.DeleteOperationRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.DeleteOperationRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.DeleteOperationRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.DeleteOperationRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.DeleteOperationRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.DeleteOperationRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.longrunning.DeleteOperationRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.longrunning.DeleteOperationRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.longrunning.DeleteOperationRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.DeleteOperationRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.longrunning.DeleteOperationRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.longrunning.DeleteOperationRequest} + * + *
      +   * The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.longrunning.DeleteOperationRequest) + com.google.longrunning.DeleteOperationRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_DeleteOperationRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_DeleteOperationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.DeleteOperationRequest.class, com.google.longrunning.DeleteOperationRequest.Builder.class); + } + + // Construct using com.google.longrunning.DeleteOperationRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_DeleteOperationRequest_descriptor; + } + + public com.google.longrunning.DeleteOperationRequest getDefaultInstanceForType() { + return com.google.longrunning.DeleteOperationRequest.getDefaultInstance(); + } + + public com.google.longrunning.DeleteOperationRequest build() { + com.google.longrunning.DeleteOperationRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.longrunning.DeleteOperationRequest buildPartial() { + com.google.longrunning.DeleteOperationRequest result = new com.google.longrunning.DeleteOperationRequest(this); + result.name_ = name_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.longrunning.DeleteOperationRequest) { + return mergeFrom((com.google.longrunning.DeleteOperationRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.longrunning.DeleteOperationRequest other) { + if (other == com.google.longrunning.DeleteOperationRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.longrunning.DeleteOperationRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.longrunning.DeleteOperationRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource to be deleted.
      +     * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource to be deleted.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource to be deleted.
      +     * 
      + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource to be deleted.
      +     * 
      + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource to be deleted.
      +     * 
      + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.longrunning.DeleteOperationRequest) + } + + // @@protoc_insertion_point(class_scope:google.longrunning.DeleteOperationRequest) + private static final com.google.longrunning.DeleteOperationRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.longrunning.DeleteOperationRequest(); + } + + public static com.google.longrunning.DeleteOperationRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DeleteOperationRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new DeleteOperationRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.longrunning.DeleteOperationRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequestOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequestOrBuilder.java new file mode 100644 index 000000000000..16f7c82c171a --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequestOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +public interface DeleteOperationRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.longrunning.DeleteOperationRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource to be deleted.
      +   * 
      + */ + java.lang.String getName(); + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource to be deleted.
      +   * 
      + */ + com.google.protobuf.ByteString + getNameBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequest.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequest.java new file mode 100644 index 000000000000..111563850c1a --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequest.java @@ -0,0 +1,476 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +/** + * Protobuf type {@code google.longrunning.GetOperationRequest} + * + *
      + * The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation].
      + * 
      + */ +public final class GetOperationRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.longrunning.GetOperationRequest) + GetOperationRequestOrBuilder { + // Use GetOperationRequest.newBuilder() to construct. + private GetOperationRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private GetOperationRequest() { + name_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private GetOperationRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_GetOperationRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_GetOperationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.GetOperationRequest.class, com.google.longrunning.GetOperationRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource.
      +   * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.longrunning.GetOperationRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.GetOperationRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.GetOperationRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.GetOperationRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.GetOperationRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.GetOperationRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.longrunning.GetOperationRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.longrunning.GetOperationRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.longrunning.GetOperationRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.GetOperationRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.longrunning.GetOperationRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.longrunning.GetOperationRequest} + * + *
      +   * The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation].
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.longrunning.GetOperationRequest) + com.google.longrunning.GetOperationRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_GetOperationRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_GetOperationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.GetOperationRequest.class, com.google.longrunning.GetOperationRequest.Builder.class); + } + + // Construct using com.google.longrunning.GetOperationRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_GetOperationRequest_descriptor; + } + + public com.google.longrunning.GetOperationRequest getDefaultInstanceForType() { + return com.google.longrunning.GetOperationRequest.getDefaultInstance(); + } + + public com.google.longrunning.GetOperationRequest build() { + com.google.longrunning.GetOperationRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.longrunning.GetOperationRequest buildPartial() { + com.google.longrunning.GetOperationRequest result = new com.google.longrunning.GetOperationRequest(this); + result.name_ = name_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.longrunning.GetOperationRequest) { + return mergeFrom((com.google.longrunning.GetOperationRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.longrunning.GetOperationRequest other) { + if (other == com.google.longrunning.GetOperationRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.longrunning.GetOperationRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.longrunning.GetOperationRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource.
      +     * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource.
      +     * 
      + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource.
      +     * 
      + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource.
      +     * 
      + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.longrunning.GetOperationRequest) + } + + // @@protoc_insertion_point(class_scope:google.longrunning.GetOperationRequest) + private static final com.google.longrunning.GetOperationRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.longrunning.GetOperationRequest(); + } + + public static com.google.longrunning.GetOperationRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public GetOperationRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new GetOperationRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.longrunning.GetOperationRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequestOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequestOrBuilder.java new file mode 100644 index 000000000000..099a7072cd23 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequestOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +public interface GetOperationRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.longrunning.GetOperationRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource.
      +   * 
      + */ + java.lang.String getName(); + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource.
      +   * 
      + */ + com.google.protobuf.ByteString + getNameBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequest.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequest.java new file mode 100644 index 000000000000..12a996ead622 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequest.java @@ -0,0 +1,848 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +/** + * Protobuf type {@code google.longrunning.ListOperationsRequest} + * + *
      + * The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
      + * 
      + */ +public final class ListOperationsRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.longrunning.ListOperationsRequest) + ListOperationsRequestOrBuilder { + // Use ListOperationsRequest.newBuilder() to construct. + private ListOperationsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ListOperationsRequest() { + name_ = ""; + filter_ = ""; + pageSize_ = 0; + pageToken_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ListOperationsRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + filter_ = s; + break; + } + case 16: { + + pageSize_ = input.readInt32(); + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + pageToken_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.ListOperationsRequest.class, com.google.longrunning.ListOperationsRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 4; + private volatile java.lang.Object name_; + /** + * optional string name = 4; + * + *
      +   * The name of the operation collection.
      +   * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 4; + * + *
      +   * The name of the operation collection.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FILTER_FIELD_NUMBER = 1; + private volatile java.lang.Object filter_; + /** + * optional string filter = 1; + * + *
      +   * The standard List filter.
      +   * 
      + */ + public java.lang.String getFilter() { + java.lang.Object ref = filter_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + filter_ = s; + return s; + } + } + /** + * optional string filter = 1; + * + *
      +   * The standard List filter.
      +   * 
      + */ + public com.google.protobuf.ByteString + getFilterBytes() { + java.lang.Object ref = filter_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + filter_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 2; + private int pageSize_; + /** + * optional int32 page_size = 2; + * + *
      +   * The standard List page size.
      +   * 
      + */ + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 3; + private volatile java.lang.Object pageToken_; + /** + * optional string page_token = 3; + * + *
      +   * The standard List page token.
      +   * 
      + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } + } + /** + * optional string page_token = 3; + * + *
      +   * The standard List page token.
      +   * 
      + */ + public com.google.protobuf.ByteString + getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getFilterBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, filter_); + } + if (pageSize_ != 0) { + output.writeInt32(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, pageToken_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, name_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getFilterBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, filter_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pageToken_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, name_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.longrunning.ListOperationsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.ListOperationsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.ListOperationsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.ListOperationsRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.ListOperationsRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.ListOperationsRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.longrunning.ListOperationsRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.longrunning.ListOperationsRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.longrunning.ListOperationsRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.ListOperationsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.longrunning.ListOperationsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.longrunning.ListOperationsRequest} + * + *
      +   * The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.longrunning.ListOperationsRequest) + com.google.longrunning.ListOperationsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.ListOperationsRequest.class, com.google.longrunning.ListOperationsRequest.Builder.class); + } + + // Construct using com.google.longrunning.ListOperationsRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + filter_ = ""; + + pageSize_ = 0; + + pageToken_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsRequest_descriptor; + } + + public com.google.longrunning.ListOperationsRequest getDefaultInstanceForType() { + return com.google.longrunning.ListOperationsRequest.getDefaultInstance(); + } + + public com.google.longrunning.ListOperationsRequest build() { + com.google.longrunning.ListOperationsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.longrunning.ListOperationsRequest buildPartial() { + com.google.longrunning.ListOperationsRequest result = new com.google.longrunning.ListOperationsRequest(this); + result.name_ = name_; + result.filter_ = filter_; + result.pageSize_ = pageSize_; + result.pageToken_ = pageToken_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.longrunning.ListOperationsRequest) { + return mergeFrom((com.google.longrunning.ListOperationsRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.longrunning.ListOperationsRequest other) { + if (other == com.google.longrunning.ListOperationsRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getFilter().isEmpty()) { + filter_ = other.filter_; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.longrunning.ListOperationsRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.longrunning.ListOperationsRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * optional string name = 4; + * + *
      +     * The name of the operation collection.
      +     * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string name = 4; + * + *
      +     * The name of the operation collection.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 4; + * + *
      +     * The name of the operation collection.
      +     * 
      + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 4; + * + *
      +     * The name of the operation collection.
      +     * 
      + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 4; + * + *
      +     * The name of the operation collection.
      +     * 
      + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object filter_ = ""; + /** + * optional string filter = 1; + * + *
      +     * The standard List filter.
      +     * 
      + */ + public java.lang.String getFilter() { + java.lang.Object ref = filter_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + filter_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string filter = 1; + * + *
      +     * The standard List filter.
      +     * 
      + */ + public com.google.protobuf.ByteString + getFilterBytes() { + java.lang.Object ref = filter_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + filter_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string filter = 1; + * + *
      +     * The standard List filter.
      +     * 
      + */ + public Builder setFilter( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + filter_ = value; + onChanged(); + return this; + } + /** + * optional string filter = 1; + * + *
      +     * The standard List filter.
      +     * 
      + */ + public Builder clearFilter() { + + filter_ = getDefaultInstance().getFilter(); + onChanged(); + return this; + } + /** + * optional string filter = 1; + * + *
      +     * The standard List filter.
      +     * 
      + */ + public Builder setFilterBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + filter_ = value; + onChanged(); + return this; + } + + private int pageSize_ ; + /** + * optional int32 page_size = 2; + * + *
      +     * The standard List page size.
      +     * 
      + */ + public int getPageSize() { + return pageSize_; + } + /** + * optional int32 page_size = 2; + * + *
      +     * The standard List page size.
      +     * 
      + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + onChanged(); + return this; + } + /** + * optional int32 page_size = 2; + * + *
      +     * The standard List page size.
      +     * 
      + */ + public Builder clearPageSize() { + + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + /** + * optional string page_token = 3; + * + *
      +     * The standard List page token.
      +     * 
      + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string page_token = 3; + * + *
      +     * The standard List page token.
      +     * 
      + */ + public com.google.protobuf.ByteString + getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string page_token = 3; + * + *
      +     * The standard List page token.
      +     * 
      + */ + public Builder setPageToken( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + pageToken_ = value; + onChanged(); + return this; + } + /** + * optional string page_token = 3; + * + *
      +     * The standard List page token.
      +     * 
      + */ + public Builder clearPageToken() { + + pageToken_ = getDefaultInstance().getPageToken(); + onChanged(); + return this; + } + /** + * optional string page_token = 3; + * + *
      +     * The standard List page token.
      +     * 
      + */ + public Builder setPageTokenBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + pageToken_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.longrunning.ListOperationsRequest) + } + + // @@protoc_insertion_point(class_scope:google.longrunning.ListOperationsRequest) + private static final com.google.longrunning.ListOperationsRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.longrunning.ListOperationsRequest(); + } + + public static com.google.longrunning.ListOperationsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ListOperationsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ListOperationsRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.longrunning.ListOperationsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequestOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequestOrBuilder.java new file mode 100644 index 000000000000..4d16f4b037d3 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequestOrBuilder.java @@ -0,0 +1,72 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +public interface ListOperationsRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.longrunning.ListOperationsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 4; + * + *
      +   * The name of the operation collection.
      +   * 
      + */ + java.lang.String getName(); + /** + * optional string name = 4; + * + *
      +   * The name of the operation collection.
      +   * 
      + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * optional string filter = 1; + * + *
      +   * The standard List filter.
      +   * 
      + */ + java.lang.String getFilter(); + /** + * optional string filter = 1; + * + *
      +   * The standard List filter.
      +   * 
      + */ + com.google.protobuf.ByteString + getFilterBytes(); + + /** + * optional int32 page_size = 2; + * + *
      +   * The standard List page size.
      +   * 
      + */ + int getPageSize(); + + /** + * optional string page_token = 3; + * + *
      +   * The standard List page token.
      +   * 
      + */ + java.lang.String getPageToken(); + /** + * optional string page_token = 3; + * + *
      +   * The standard List page token.
      +   * 
      + */ + com.google.protobuf.ByteString + getPageTokenBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponse.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponse.java new file mode 100644 index 000000000000..7d329933d9e6 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponse.java @@ -0,0 +1,909 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +/** + * Protobuf type {@code google.longrunning.ListOperationsResponse} + * + *
      + * The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
      + * 
      + */ +public final class ListOperationsResponse extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.longrunning.ListOperationsResponse) + ListOperationsResponseOrBuilder { + // Use ListOperationsResponse.newBuilder() to construct. + private ListOperationsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ListOperationsResponse() { + operations_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ListOperationsResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + operations_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + operations_.add(input.readMessage(com.google.longrunning.Operation.parser(), extensionRegistry)); + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + nextPageToken_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + operations_ = java.util.Collections.unmodifiableList(operations_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.ListOperationsResponse.class, com.google.longrunning.ListOperationsResponse.Builder.class); + } + + private int bitField0_; + public static final int OPERATIONS_FIELD_NUMBER = 1; + private java.util.List operations_; + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +   * A list of operations that match the specified filter in the request.
      +   * 
      + */ + public java.util.List getOperationsList() { + return operations_; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +   * A list of operations that match the specified filter in the request.
      +   * 
      + */ + public java.util.List + getOperationsOrBuilderList() { + return operations_; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +   * A list of operations that match the specified filter in the request.
      +   * 
      + */ + public int getOperationsCount() { + return operations_.size(); + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +   * A list of operations that match the specified filter in the request.
      +   * 
      + */ + public com.google.longrunning.Operation getOperations(int index) { + return operations_.get(index); + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +   * A list of operations that match the specified filter in the request.
      +   * 
      + */ + public com.google.longrunning.OperationOrBuilder getOperationsOrBuilder( + int index) { + return operations_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + private volatile java.lang.Object nextPageToken_; + /** + * optional string next_page_token = 2; + * + *
      +   * The standard List next-page token.
      +   * 
      + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } + } + /** + * optional string next_page_token = 2; + * + *
      +   * The standard List next-page token.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < operations_.size(); i++) { + output.writeMessage(1, operations_.get(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < operations_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, operations_.get(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.longrunning.ListOperationsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.ListOperationsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.ListOperationsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.ListOperationsResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.ListOperationsResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.ListOperationsResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.longrunning.ListOperationsResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.longrunning.ListOperationsResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.longrunning.ListOperationsResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.ListOperationsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.longrunning.ListOperationsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.longrunning.ListOperationsResponse} + * + *
      +   * The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.longrunning.ListOperationsResponse) + com.google.longrunning.ListOperationsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.ListOperationsResponse.class, com.google.longrunning.ListOperationsResponse.Builder.class); + } + + // Construct using com.google.longrunning.ListOperationsResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getOperationsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (operationsBuilder_ == null) { + operations_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + operationsBuilder_.clear(); + } + nextPageToken_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsResponse_descriptor; + } + + public com.google.longrunning.ListOperationsResponse getDefaultInstanceForType() { + return com.google.longrunning.ListOperationsResponse.getDefaultInstance(); + } + + public com.google.longrunning.ListOperationsResponse build() { + com.google.longrunning.ListOperationsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.longrunning.ListOperationsResponse buildPartial() { + com.google.longrunning.ListOperationsResponse result = new com.google.longrunning.ListOperationsResponse(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (operationsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + operations_ = java.util.Collections.unmodifiableList(operations_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.operations_ = operations_; + } else { + result.operations_ = operationsBuilder_.build(); + } + result.nextPageToken_ = nextPageToken_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.longrunning.ListOperationsResponse) { + return mergeFrom((com.google.longrunning.ListOperationsResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.longrunning.ListOperationsResponse other) { + if (other == com.google.longrunning.ListOperationsResponse.getDefaultInstance()) return this; + if (operationsBuilder_ == null) { + if (!other.operations_.isEmpty()) { + if (operations_.isEmpty()) { + operations_ = other.operations_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureOperationsIsMutable(); + operations_.addAll(other.operations_); + } + onChanged(); + } + } else { + if (!other.operations_.isEmpty()) { + if (operationsBuilder_.isEmpty()) { + operationsBuilder_.dispose(); + operationsBuilder_ = null; + operations_ = other.operations_; + bitField0_ = (bitField0_ & ~0x00000001); + operationsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getOperationsFieldBuilder() : null; + } else { + operationsBuilder_.addAllMessages(other.operations_); + } + } + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.longrunning.ListOperationsResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.longrunning.ListOperationsResponse) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List operations_ = + java.util.Collections.emptyList(); + private void ensureOperationsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + operations_ = new java.util.ArrayList(operations_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.longrunning.Operation, com.google.longrunning.Operation.Builder, com.google.longrunning.OperationOrBuilder> operationsBuilder_; + + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public java.util.List getOperationsList() { + if (operationsBuilder_ == null) { + return java.util.Collections.unmodifiableList(operations_); + } else { + return operationsBuilder_.getMessageList(); + } + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public int getOperationsCount() { + if (operationsBuilder_ == null) { + return operations_.size(); + } else { + return operationsBuilder_.getCount(); + } + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public com.google.longrunning.Operation getOperations(int index) { + if (operationsBuilder_ == null) { + return operations_.get(index); + } else { + return operationsBuilder_.getMessage(index); + } + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public Builder setOperations( + int index, com.google.longrunning.Operation value) { + if (operationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOperationsIsMutable(); + operations_.set(index, value); + onChanged(); + } else { + operationsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public Builder setOperations( + int index, com.google.longrunning.Operation.Builder builderForValue) { + if (operationsBuilder_ == null) { + ensureOperationsIsMutable(); + operations_.set(index, builderForValue.build()); + onChanged(); + } else { + operationsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public Builder addOperations(com.google.longrunning.Operation value) { + if (operationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOperationsIsMutable(); + operations_.add(value); + onChanged(); + } else { + operationsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public Builder addOperations( + int index, com.google.longrunning.Operation value) { + if (operationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOperationsIsMutable(); + operations_.add(index, value); + onChanged(); + } else { + operationsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public Builder addOperations( + com.google.longrunning.Operation.Builder builderForValue) { + if (operationsBuilder_ == null) { + ensureOperationsIsMutable(); + operations_.add(builderForValue.build()); + onChanged(); + } else { + operationsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public Builder addOperations( + int index, com.google.longrunning.Operation.Builder builderForValue) { + if (operationsBuilder_ == null) { + ensureOperationsIsMutable(); + operations_.add(index, builderForValue.build()); + onChanged(); + } else { + operationsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public Builder addAllOperations( + java.lang.Iterable values) { + if (operationsBuilder_ == null) { + ensureOperationsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, operations_); + onChanged(); + } else { + operationsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public Builder clearOperations() { + if (operationsBuilder_ == null) { + operations_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + operationsBuilder_.clear(); + } + return this; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public Builder removeOperations(int index) { + if (operationsBuilder_ == null) { + ensureOperationsIsMutable(); + operations_.remove(index); + onChanged(); + } else { + operationsBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public com.google.longrunning.Operation.Builder getOperationsBuilder( + int index) { + return getOperationsFieldBuilder().getBuilder(index); + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public com.google.longrunning.OperationOrBuilder getOperationsOrBuilder( + int index) { + if (operationsBuilder_ == null) { + return operations_.get(index); } else { + return operationsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public java.util.List + getOperationsOrBuilderList() { + if (operationsBuilder_ != null) { + return operationsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(operations_); + } + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public com.google.longrunning.Operation.Builder addOperationsBuilder() { + return getOperationsFieldBuilder().addBuilder( + com.google.longrunning.Operation.getDefaultInstance()); + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public com.google.longrunning.Operation.Builder addOperationsBuilder( + int index) { + return getOperationsFieldBuilder().addBuilder( + index, com.google.longrunning.Operation.getDefaultInstance()); + } + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +     * A list of operations that match the specified filter in the request.
      +     * 
      + */ + public java.util.List + getOperationsBuilderList() { + return getOperationsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.longrunning.Operation, com.google.longrunning.Operation.Builder, com.google.longrunning.OperationOrBuilder> + getOperationsFieldBuilder() { + if (operationsBuilder_ == null) { + operationsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.longrunning.Operation, com.google.longrunning.Operation.Builder, com.google.longrunning.OperationOrBuilder>( + operations_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + operations_ = null; + } + return operationsBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + /** + * optional string next_page_token = 2; + * + *
      +     * The standard List next-page token.
      +     * 
      + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string next_page_token = 2; + * + *
      +     * The standard List next-page token.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string next_page_token = 2; + * + *
      +     * The standard List next-page token.
      +     * 
      + */ + public Builder setNextPageToken( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + nextPageToken_ = value; + onChanged(); + return this; + } + /** + * optional string next_page_token = 2; + * + *
      +     * The standard List next-page token.
      +     * 
      + */ + public Builder clearNextPageToken() { + + nextPageToken_ = getDefaultInstance().getNextPageToken(); + onChanged(); + return this; + } + /** + * optional string next_page_token = 2; + * + *
      +     * The standard List next-page token.
      +     * 
      + */ + public Builder setNextPageTokenBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + nextPageToken_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.longrunning.ListOperationsResponse) + } + + // @@protoc_insertion_point(class_scope:google.longrunning.ListOperationsResponse) + private static final com.google.longrunning.ListOperationsResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.longrunning.ListOperationsResponse(); + } + + public static com.google.longrunning.ListOperationsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ListOperationsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ListOperationsResponse(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.longrunning.ListOperationsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponseOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponseOrBuilder.java new file mode 100644 index 000000000000..8e2c047294a5 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponseOrBuilder.java @@ -0,0 +1,71 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +public interface ListOperationsResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.longrunning.ListOperationsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +   * A list of operations that match the specified filter in the request.
      +   * 
      + */ + java.util.List + getOperationsList(); + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +   * A list of operations that match the specified filter in the request.
      +   * 
      + */ + com.google.longrunning.Operation getOperations(int index); + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +   * A list of operations that match the specified filter in the request.
      +   * 
      + */ + int getOperationsCount(); + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +   * A list of operations that match the specified filter in the request.
      +   * 
      + */ + java.util.List + getOperationsOrBuilderList(); + /** + * repeated .google.longrunning.Operation operations = 1; + * + *
      +   * A list of operations that match the specified filter in the request.
      +   * 
      + */ + com.google.longrunning.OperationOrBuilder getOperationsOrBuilder( + int index); + + /** + * optional string next_page_token = 2; + * + *
      +   * The standard List next-page token.
      +   * 
      + */ + java.lang.String getNextPageToken(); + /** + * optional string next_page_token = 2; + * + *
      +   * The standard List next-page token.
      +   * 
      + */ + com.google.protobuf.ByteString + getNextPageTokenBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/Operation.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/Operation.java new file mode 100644 index 000000000000..750f3a657b25 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/Operation.java @@ -0,0 +1,1383 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +/** + * Protobuf type {@code google.longrunning.Operation} + * + *
      + * This resource represents a long-running operation that is the result of a
      + * network API call.
      + * 
      + */ +public final class Operation extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.longrunning.Operation) + OperationOrBuilder { + // Use Operation.newBuilder() to construct. + private Operation(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Operation() { + name_ = ""; + done_ = false; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Operation( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: { + com.google.protobuf.Any.Builder subBuilder = null; + if (metadata_ != null) { + subBuilder = metadata_.toBuilder(); + } + metadata_ = input.readMessage(com.google.protobuf.Any.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(metadata_); + metadata_ = subBuilder.buildPartial(); + } + + break; + } + case 24: { + + done_ = input.readBool(); + break; + } + case 34: { + com.google.rpc.Status.Builder subBuilder = null; + if (resultCase_ == 4) { + subBuilder = ((com.google.rpc.Status) result_).toBuilder(); + } + result_ = + input.readMessage(com.google.rpc.Status.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((com.google.rpc.Status) result_); + result_ = subBuilder.buildPartial(); + } + resultCase_ = 4; + break; + } + case 42: { + com.google.protobuf.Any.Builder subBuilder = null; + if (resultCase_ == 5) { + subBuilder = ((com.google.protobuf.Any) result_).toBuilder(); + } + result_ = + input.readMessage(com.google.protobuf.Any.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((com.google.protobuf.Any) result_); + result_ = subBuilder.buildPartial(); + } + resultCase_ = 5; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_Operation_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_Operation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.Operation.class, com.google.longrunning.Operation.Builder.class); + } + + private int resultCase_ = 0; + private java.lang.Object result_; + public enum ResultCase + implements com.google.protobuf.Internal.EnumLite { + ERROR(4), + RESPONSE(5), + RESULT_NOT_SET(0); + private int value = 0; + private ResultCase(int value) { + this.value = value; + } + public static ResultCase valueOf(int value) { + switch (value) { + case 4: return ERROR; + case 5: return RESPONSE; + case 0: return RESULT_NOT_SET; + default: throw new java.lang.IllegalArgumentException( + "Value is undefined for this oneof enum."); + } + } + public int getNumber() { + return this.value; + } + }; + + public ResultCase + getResultCase() { + return ResultCase.valueOf( + resultCase_); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource, which is only unique within the same
      +   * service that originally returns it.
      +   * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource, which is only unique within the same
      +   * service that originally returns it.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int METADATA_FIELD_NUMBER = 2; + private com.google.protobuf.Any metadata_; + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +   * Some service-specific metadata associated with the operation.  It typically
      +   * contains progress information and common metadata such as create time.
      +   * Some services may not provide such metadata.  Any method that returns a
      +   * long-running operation should document the metadata type, if any.
      +   * 
      + */ + public boolean hasMetadata() { + return metadata_ != null; + } + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +   * Some service-specific metadata associated with the operation.  It typically
      +   * contains progress information and common metadata such as create time.
      +   * Some services may not provide such metadata.  Any method that returns a
      +   * long-running operation should document the metadata type, if any.
      +   * 
      + */ + public com.google.protobuf.Any getMetadata() { + return metadata_ == null ? com.google.protobuf.Any.getDefaultInstance() : metadata_; + } + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +   * Some service-specific metadata associated with the operation.  It typically
      +   * contains progress information and common metadata such as create time.
      +   * Some services may not provide such metadata.  Any method that returns a
      +   * long-running operation should document the metadata type, if any.
      +   * 
      + */ + public com.google.protobuf.AnyOrBuilder getMetadataOrBuilder() { + return getMetadata(); + } + + public static final int DONE_FIELD_NUMBER = 3; + private boolean done_; + /** + * optional bool done = 3; + * + *
      +   * If the value is false, it means the operation is still in progress.
      +   * If true, the operation is completed and the `result` is available.
      +   * 
      + */ + public boolean getDone() { + return done_; + } + + public static final int ERROR_FIELD_NUMBER = 4; + /** + * optional .google.rpc.Status error = 4; + * + *
      +   * The error result of the operation in case of failure.
      +   * 
      + */ + public com.google.rpc.Status getError() { + if (resultCase_ == 4) { + return (com.google.rpc.Status) result_; + } + return com.google.rpc.Status.getDefaultInstance(); + } + /** + * optional .google.rpc.Status error = 4; + * + *
      +   * The error result of the operation in case of failure.
      +   * 
      + */ + public com.google.rpc.StatusOrBuilder getErrorOrBuilder() { + if (resultCase_ == 4) { + return (com.google.rpc.Status) result_; + } + return com.google.rpc.Status.getDefaultInstance(); + } + + public static final int RESPONSE_FIELD_NUMBER = 5; + /** + * optional .google.protobuf.Any response = 5; + * + *
      +   * The normal response of the operation in case of success.  If the original
      +   * method returns no data on success, such as `Delete`, the response will be
      +   * `google.protobuf.Empty`.  If the original method is standard
      +   * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +   * methods, the response should have the type `XxxResponse`, where `Xxx`
      +   * is the original method name.  For example, if the original method name
      +   * is `TakeSnapshot()`, the inferred response type will be
      +   * `TakeSnapshotResponse`.
      +   * 
      + */ + public com.google.protobuf.Any getResponse() { + if (resultCase_ == 5) { + return (com.google.protobuf.Any) result_; + } + return com.google.protobuf.Any.getDefaultInstance(); + } + /** + * optional .google.protobuf.Any response = 5; + * + *
      +   * The normal response of the operation in case of success.  If the original
      +   * method returns no data on success, such as `Delete`, the response will be
      +   * `google.protobuf.Empty`.  If the original method is standard
      +   * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +   * methods, the response should have the type `XxxResponse`, where `Xxx`
      +   * is the original method name.  For example, if the original method name
      +   * is `TakeSnapshot()`, the inferred response type will be
      +   * `TakeSnapshotResponse`.
      +   * 
      + */ + public com.google.protobuf.AnyOrBuilder getResponseOrBuilder() { + if (resultCase_ == 5) { + return (com.google.protobuf.Any) result_; + } + return com.google.protobuf.Any.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (metadata_ != null) { + output.writeMessage(2, getMetadata()); + } + if (done_ != false) { + output.writeBool(3, done_); + } + if (resultCase_ == 4) { + output.writeMessage(4, (com.google.rpc.Status) result_); + } + if (resultCase_ == 5) { + output.writeMessage(5, (com.google.protobuf.Any) result_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (metadata_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getMetadata()); + } + if (done_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, done_); + } + if (resultCase_ == 4) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, (com.google.rpc.Status) result_); + } + if (resultCase_ == 5) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, (com.google.protobuf.Any) result_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.longrunning.Operation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.Operation parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.Operation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.longrunning.Operation parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.longrunning.Operation parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.Operation parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.longrunning.Operation parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.longrunning.Operation parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.longrunning.Operation parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.longrunning.Operation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.longrunning.Operation prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.longrunning.Operation} + * + *
      +   * This resource represents a long-running operation that is the result of a
      +   * network API call.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.longrunning.Operation) + com.google.longrunning.OperationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_Operation_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_Operation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.longrunning.Operation.class, com.google.longrunning.Operation.Builder.class); + } + + // Construct using com.google.longrunning.Operation.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + if (metadataBuilder_ == null) { + metadata_ = null; + } else { + metadata_ = null; + metadataBuilder_ = null; + } + done_ = false; + + resultCase_ = 0; + result_ = null; + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.longrunning.OperationsProto.internal_static_google_longrunning_Operation_descriptor; + } + + public com.google.longrunning.Operation getDefaultInstanceForType() { + return com.google.longrunning.Operation.getDefaultInstance(); + } + + public com.google.longrunning.Operation build() { + com.google.longrunning.Operation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.longrunning.Operation buildPartial() { + com.google.longrunning.Operation result = new com.google.longrunning.Operation(this); + result.name_ = name_; + if (metadataBuilder_ == null) { + result.metadata_ = metadata_; + } else { + result.metadata_ = metadataBuilder_.build(); + } + result.done_ = done_; + if (resultCase_ == 4) { + if (errorBuilder_ == null) { + result.result_ = result_; + } else { + result.result_ = errorBuilder_.build(); + } + } + if (resultCase_ == 5) { + if (responseBuilder_ == null) { + result.result_ = result_; + } else { + result.result_ = responseBuilder_.build(); + } + } + result.resultCase_ = resultCase_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.longrunning.Operation) { + return mergeFrom((com.google.longrunning.Operation)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.longrunning.Operation other) { + if (other == com.google.longrunning.Operation.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.hasMetadata()) { + mergeMetadata(other.getMetadata()); + } + if (other.getDone() != false) { + setDone(other.getDone()); + } + switch (other.getResultCase()) { + case ERROR: { + mergeError(other.getError()); + break; + } + case RESPONSE: { + mergeResponse(other.getResponse()); + break; + } + case RESULT_NOT_SET: { + break; + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.longrunning.Operation parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.longrunning.Operation) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int resultCase_ = 0; + private java.lang.Object result_; + public ResultCase + getResultCase() { + return ResultCase.valueOf( + resultCase_); + } + + public Builder clearResult() { + resultCase_ = 0; + result_ = null; + onChanged(); + return this; + } + + + private java.lang.Object name_ = ""; + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource, which is only unique within the same
      +     * service that originally returns it.
      +     * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource, which is only unique within the same
      +     * service that originally returns it.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource, which is only unique within the same
      +     * service that originally returns it.
      +     * 
      + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource, which is only unique within the same
      +     * service that originally returns it.
      +     * 
      + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the operation resource, which is only unique within the same
      +     * service that originally returns it.
      +     * 
      + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.Any metadata_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> metadataBuilder_; + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +     * Some service-specific metadata associated with the operation.  It typically
      +     * contains progress information and common metadata such as create time.
      +     * Some services may not provide such metadata.  Any method that returns a
      +     * long-running operation should document the metadata type, if any.
      +     * 
      + */ + public boolean hasMetadata() { + return metadataBuilder_ != null || metadata_ != null; + } + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +     * Some service-specific metadata associated with the operation.  It typically
      +     * contains progress information and common metadata such as create time.
      +     * Some services may not provide such metadata.  Any method that returns a
      +     * long-running operation should document the metadata type, if any.
      +     * 
      + */ + public com.google.protobuf.Any getMetadata() { + if (metadataBuilder_ == null) { + return metadata_ == null ? com.google.protobuf.Any.getDefaultInstance() : metadata_; + } else { + return metadataBuilder_.getMessage(); + } + } + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +     * Some service-specific metadata associated with the operation.  It typically
      +     * contains progress information and common metadata such as create time.
      +     * Some services may not provide such metadata.  Any method that returns a
      +     * long-running operation should document the metadata type, if any.
      +     * 
      + */ + public Builder setMetadata(com.google.protobuf.Any value) { + if (metadataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + metadata_ = value; + onChanged(); + } else { + metadataBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +     * Some service-specific metadata associated with the operation.  It typically
      +     * contains progress information and common metadata such as create time.
      +     * Some services may not provide such metadata.  Any method that returns a
      +     * long-running operation should document the metadata type, if any.
      +     * 
      + */ + public Builder setMetadata( + com.google.protobuf.Any.Builder builderForValue) { + if (metadataBuilder_ == null) { + metadata_ = builderForValue.build(); + onChanged(); + } else { + metadataBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +     * Some service-specific metadata associated with the operation.  It typically
      +     * contains progress information and common metadata such as create time.
      +     * Some services may not provide such metadata.  Any method that returns a
      +     * long-running operation should document the metadata type, if any.
      +     * 
      + */ + public Builder mergeMetadata(com.google.protobuf.Any value) { + if (metadataBuilder_ == null) { + if (metadata_ != null) { + metadata_ = + com.google.protobuf.Any.newBuilder(metadata_).mergeFrom(value).buildPartial(); + } else { + metadata_ = value; + } + onChanged(); + } else { + metadataBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +     * Some service-specific metadata associated with the operation.  It typically
      +     * contains progress information and common metadata such as create time.
      +     * Some services may not provide such metadata.  Any method that returns a
      +     * long-running operation should document the metadata type, if any.
      +     * 
      + */ + public Builder clearMetadata() { + if (metadataBuilder_ == null) { + metadata_ = null; + onChanged(); + } else { + metadata_ = null; + metadataBuilder_ = null; + } + + return this; + } + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +     * Some service-specific metadata associated with the operation.  It typically
      +     * contains progress information and common metadata such as create time.
      +     * Some services may not provide such metadata.  Any method that returns a
      +     * long-running operation should document the metadata type, if any.
      +     * 
      + */ + public com.google.protobuf.Any.Builder getMetadataBuilder() { + + onChanged(); + return getMetadataFieldBuilder().getBuilder(); + } + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +     * Some service-specific metadata associated with the operation.  It typically
      +     * contains progress information and common metadata such as create time.
      +     * Some services may not provide such metadata.  Any method that returns a
      +     * long-running operation should document the metadata type, if any.
      +     * 
      + */ + public com.google.protobuf.AnyOrBuilder getMetadataOrBuilder() { + if (metadataBuilder_ != null) { + return metadataBuilder_.getMessageOrBuilder(); + } else { + return metadata_ == null ? + com.google.protobuf.Any.getDefaultInstance() : metadata_; + } + } + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +     * Some service-specific metadata associated with the operation.  It typically
      +     * contains progress information and common metadata such as create time.
      +     * Some services may not provide such metadata.  Any method that returns a
      +     * long-running operation should document the metadata type, if any.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> + getMetadataFieldBuilder() { + if (metadataBuilder_ == null) { + metadataBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>( + getMetadata(), + getParentForChildren(), + isClean()); + metadata_ = null; + } + return metadataBuilder_; + } + + private boolean done_ ; + /** + * optional bool done = 3; + * + *
      +     * If the value is false, it means the operation is still in progress.
      +     * If true, the operation is completed and the `result` is available.
      +     * 
      + */ + public boolean getDone() { + return done_; + } + /** + * optional bool done = 3; + * + *
      +     * If the value is false, it means the operation is still in progress.
      +     * If true, the operation is completed and the `result` is available.
      +     * 
      + */ + public Builder setDone(boolean value) { + + done_ = value; + onChanged(); + return this; + } + /** + * optional bool done = 3; + * + *
      +     * If the value is false, it means the operation is still in progress.
      +     * If true, the operation is completed and the `result` is available.
      +     * 
      + */ + public Builder clearDone() { + + done_ = false; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> errorBuilder_; + /** + * optional .google.rpc.Status error = 4; + * + *
      +     * The error result of the operation in case of failure.
      +     * 
      + */ + public com.google.rpc.Status getError() { + if (errorBuilder_ == null) { + if (resultCase_ == 4) { + return (com.google.rpc.Status) result_; + } + return com.google.rpc.Status.getDefaultInstance(); + } else { + if (resultCase_ == 4) { + return errorBuilder_.getMessage(); + } + return com.google.rpc.Status.getDefaultInstance(); + } + } + /** + * optional .google.rpc.Status error = 4; + * + *
      +     * The error result of the operation in case of failure.
      +     * 
      + */ + public Builder setError(com.google.rpc.Status value) { + if (errorBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + result_ = value; + onChanged(); + } else { + errorBuilder_.setMessage(value); + } + resultCase_ = 4; + return this; + } + /** + * optional .google.rpc.Status error = 4; + * + *
      +     * The error result of the operation in case of failure.
      +     * 
      + */ + public Builder setError( + com.google.rpc.Status.Builder builderForValue) { + if (errorBuilder_ == null) { + result_ = builderForValue.build(); + onChanged(); + } else { + errorBuilder_.setMessage(builderForValue.build()); + } + resultCase_ = 4; + return this; + } + /** + * optional .google.rpc.Status error = 4; + * + *
      +     * The error result of the operation in case of failure.
      +     * 
      + */ + public Builder mergeError(com.google.rpc.Status value) { + if (errorBuilder_ == null) { + if (resultCase_ == 4 && + result_ != com.google.rpc.Status.getDefaultInstance()) { + result_ = com.google.rpc.Status.newBuilder((com.google.rpc.Status) result_) + .mergeFrom(value).buildPartial(); + } else { + result_ = value; + } + onChanged(); + } else { + if (resultCase_ == 4) { + errorBuilder_.mergeFrom(value); + } + errorBuilder_.setMessage(value); + } + resultCase_ = 4; + return this; + } + /** + * optional .google.rpc.Status error = 4; + * + *
      +     * The error result of the operation in case of failure.
      +     * 
      + */ + public Builder clearError() { + if (errorBuilder_ == null) { + if (resultCase_ == 4) { + resultCase_ = 0; + result_ = null; + onChanged(); + } + } else { + if (resultCase_ == 4) { + resultCase_ = 0; + result_ = null; + } + errorBuilder_.clear(); + } + return this; + } + /** + * optional .google.rpc.Status error = 4; + * + *
      +     * The error result of the operation in case of failure.
      +     * 
      + */ + public com.google.rpc.Status.Builder getErrorBuilder() { + return getErrorFieldBuilder().getBuilder(); + } + /** + * optional .google.rpc.Status error = 4; + * + *
      +     * The error result of the operation in case of failure.
      +     * 
      + */ + public com.google.rpc.StatusOrBuilder getErrorOrBuilder() { + if ((resultCase_ == 4) && (errorBuilder_ != null)) { + return errorBuilder_.getMessageOrBuilder(); + } else { + if (resultCase_ == 4) { + return (com.google.rpc.Status) result_; + } + return com.google.rpc.Status.getDefaultInstance(); + } + } + /** + * optional .google.rpc.Status error = 4; + * + *
      +     * The error result of the operation in case of failure.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> + getErrorFieldBuilder() { + if (errorBuilder_ == null) { + if (!(resultCase_ == 4)) { + result_ = com.google.rpc.Status.getDefaultInstance(); + } + errorBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder>( + (com.google.rpc.Status) result_, + getParentForChildren(), + isClean()); + result_ = null; + } + resultCase_ = 4; + onChanged();; + return errorBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> responseBuilder_; + /** + * optional .google.protobuf.Any response = 5; + * + *
      +     * The normal response of the operation in case of success.  If the original
      +     * method returns no data on success, such as `Delete`, the response will be
      +     * `google.protobuf.Empty`.  If the original method is standard
      +     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +     * methods, the response should have the type `XxxResponse`, where `Xxx`
      +     * is the original method name.  For example, if the original method name
      +     * is `TakeSnapshot()`, the inferred response type will be
      +     * `TakeSnapshotResponse`.
      +     * 
      + */ + public com.google.protobuf.Any getResponse() { + if (responseBuilder_ == null) { + if (resultCase_ == 5) { + return (com.google.protobuf.Any) result_; + } + return com.google.protobuf.Any.getDefaultInstance(); + } else { + if (resultCase_ == 5) { + return responseBuilder_.getMessage(); + } + return com.google.protobuf.Any.getDefaultInstance(); + } + } + /** + * optional .google.protobuf.Any response = 5; + * + *
      +     * The normal response of the operation in case of success.  If the original
      +     * method returns no data on success, such as `Delete`, the response will be
      +     * `google.protobuf.Empty`.  If the original method is standard
      +     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +     * methods, the response should have the type `XxxResponse`, where `Xxx`
      +     * is the original method name.  For example, if the original method name
      +     * is `TakeSnapshot()`, the inferred response type will be
      +     * `TakeSnapshotResponse`.
      +     * 
      + */ + public Builder setResponse(com.google.protobuf.Any value) { + if (responseBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + result_ = value; + onChanged(); + } else { + responseBuilder_.setMessage(value); + } + resultCase_ = 5; + return this; + } + /** + * optional .google.protobuf.Any response = 5; + * + *
      +     * The normal response of the operation in case of success.  If the original
      +     * method returns no data on success, such as `Delete`, the response will be
      +     * `google.protobuf.Empty`.  If the original method is standard
      +     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +     * methods, the response should have the type `XxxResponse`, where `Xxx`
      +     * is the original method name.  For example, if the original method name
      +     * is `TakeSnapshot()`, the inferred response type will be
      +     * `TakeSnapshotResponse`.
      +     * 
      + */ + public Builder setResponse( + com.google.protobuf.Any.Builder builderForValue) { + if (responseBuilder_ == null) { + result_ = builderForValue.build(); + onChanged(); + } else { + responseBuilder_.setMessage(builderForValue.build()); + } + resultCase_ = 5; + return this; + } + /** + * optional .google.protobuf.Any response = 5; + * + *
      +     * The normal response of the operation in case of success.  If the original
      +     * method returns no data on success, such as `Delete`, the response will be
      +     * `google.protobuf.Empty`.  If the original method is standard
      +     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +     * methods, the response should have the type `XxxResponse`, where `Xxx`
      +     * is the original method name.  For example, if the original method name
      +     * is `TakeSnapshot()`, the inferred response type will be
      +     * `TakeSnapshotResponse`.
      +     * 
      + */ + public Builder mergeResponse(com.google.protobuf.Any value) { + if (responseBuilder_ == null) { + if (resultCase_ == 5 && + result_ != com.google.protobuf.Any.getDefaultInstance()) { + result_ = com.google.protobuf.Any.newBuilder((com.google.protobuf.Any) result_) + .mergeFrom(value).buildPartial(); + } else { + result_ = value; + } + onChanged(); + } else { + if (resultCase_ == 5) { + responseBuilder_.mergeFrom(value); + } + responseBuilder_.setMessage(value); + } + resultCase_ = 5; + return this; + } + /** + * optional .google.protobuf.Any response = 5; + * + *
      +     * The normal response of the operation in case of success.  If the original
      +     * method returns no data on success, such as `Delete`, the response will be
      +     * `google.protobuf.Empty`.  If the original method is standard
      +     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +     * methods, the response should have the type `XxxResponse`, where `Xxx`
      +     * is the original method name.  For example, if the original method name
      +     * is `TakeSnapshot()`, the inferred response type will be
      +     * `TakeSnapshotResponse`.
      +     * 
      + */ + public Builder clearResponse() { + if (responseBuilder_ == null) { + if (resultCase_ == 5) { + resultCase_ = 0; + result_ = null; + onChanged(); + } + } else { + if (resultCase_ == 5) { + resultCase_ = 0; + result_ = null; + } + responseBuilder_.clear(); + } + return this; + } + /** + * optional .google.protobuf.Any response = 5; + * + *
      +     * The normal response of the operation in case of success.  If the original
      +     * method returns no data on success, such as `Delete`, the response will be
      +     * `google.protobuf.Empty`.  If the original method is standard
      +     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +     * methods, the response should have the type `XxxResponse`, where `Xxx`
      +     * is the original method name.  For example, if the original method name
      +     * is `TakeSnapshot()`, the inferred response type will be
      +     * `TakeSnapshotResponse`.
      +     * 
      + */ + public com.google.protobuf.Any.Builder getResponseBuilder() { + return getResponseFieldBuilder().getBuilder(); + } + /** + * optional .google.protobuf.Any response = 5; + * + *
      +     * The normal response of the operation in case of success.  If the original
      +     * method returns no data on success, such as `Delete`, the response will be
      +     * `google.protobuf.Empty`.  If the original method is standard
      +     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +     * methods, the response should have the type `XxxResponse`, where `Xxx`
      +     * is the original method name.  For example, if the original method name
      +     * is `TakeSnapshot()`, the inferred response type will be
      +     * `TakeSnapshotResponse`.
      +     * 
      + */ + public com.google.protobuf.AnyOrBuilder getResponseOrBuilder() { + if ((resultCase_ == 5) && (responseBuilder_ != null)) { + return responseBuilder_.getMessageOrBuilder(); + } else { + if (resultCase_ == 5) { + return (com.google.protobuf.Any) result_; + } + return com.google.protobuf.Any.getDefaultInstance(); + } + } + /** + * optional .google.protobuf.Any response = 5; + * + *
      +     * The normal response of the operation in case of success.  If the original
      +     * method returns no data on success, such as `Delete`, the response will be
      +     * `google.protobuf.Empty`.  If the original method is standard
      +     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +     * methods, the response should have the type `XxxResponse`, where `Xxx`
      +     * is the original method name.  For example, if the original method name
      +     * is `TakeSnapshot()`, the inferred response type will be
      +     * `TakeSnapshotResponse`.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> + getResponseFieldBuilder() { + if (responseBuilder_ == null) { + if (!(resultCase_ == 5)) { + result_ = com.google.protobuf.Any.getDefaultInstance(); + } + responseBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>( + (com.google.protobuf.Any) result_, + getParentForChildren(), + isClean()); + result_ = null; + } + resultCase_ = 5; + onChanged();; + return responseBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.longrunning.Operation) + } + + // @@protoc_insertion_point(class_scope:google.longrunning.Operation) + private static final com.google.longrunning.Operation DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.longrunning.Operation(); + } + + public static com.google.longrunning.Operation getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Operation parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Operation(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.longrunning.Operation getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationOrBuilder.java new file mode 100644 index 000000000000..8366f5d21f3e --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationOrBuilder.java @@ -0,0 +1,123 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +public interface OperationOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.longrunning.Operation) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource, which is only unique within the same
      +   * service that originally returns it.
      +   * 
      + */ + java.lang.String getName(); + /** + * optional string name = 1; + * + *
      +   * The name of the operation resource, which is only unique within the same
      +   * service that originally returns it.
      +   * 
      + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +   * Some service-specific metadata associated with the operation.  It typically
      +   * contains progress information and common metadata such as create time.
      +   * Some services may not provide such metadata.  Any method that returns a
      +   * long-running operation should document the metadata type, if any.
      +   * 
      + */ + boolean hasMetadata(); + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +   * Some service-specific metadata associated with the operation.  It typically
      +   * contains progress information and common metadata such as create time.
      +   * Some services may not provide such metadata.  Any method that returns a
      +   * long-running operation should document the metadata type, if any.
      +   * 
      + */ + com.google.protobuf.Any getMetadata(); + /** + * optional .google.protobuf.Any metadata = 2; + * + *
      +   * Some service-specific metadata associated with the operation.  It typically
      +   * contains progress information and common metadata such as create time.
      +   * Some services may not provide such metadata.  Any method that returns a
      +   * long-running operation should document the metadata type, if any.
      +   * 
      + */ + com.google.protobuf.AnyOrBuilder getMetadataOrBuilder(); + + /** + * optional bool done = 3; + * + *
      +   * If the value is false, it means the operation is still in progress.
      +   * If true, the operation is completed and the `result` is available.
      +   * 
      + */ + boolean getDone(); + + /** + * optional .google.rpc.Status error = 4; + * + *
      +   * The error result of the operation in case of failure.
      +   * 
      + */ + com.google.rpc.Status getError(); + /** + * optional .google.rpc.Status error = 4; + * + *
      +   * The error result of the operation in case of failure.
      +   * 
      + */ + com.google.rpc.StatusOrBuilder getErrorOrBuilder(); + + /** + * optional .google.protobuf.Any response = 5; + * + *
      +   * The normal response of the operation in case of success.  If the original
      +   * method returns no data on success, such as `Delete`, the response will be
      +   * `google.protobuf.Empty`.  If the original method is standard
      +   * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +   * methods, the response should have the type `XxxResponse`, where `Xxx`
      +   * is the original method name.  For example, if the original method name
      +   * is `TakeSnapshot()`, the inferred response type will be
      +   * `TakeSnapshotResponse`.
      +   * 
      + */ + com.google.protobuf.Any getResponse(); + /** + * optional .google.protobuf.Any response = 5; + * + *
      +   * The normal response of the operation in case of success.  If the original
      +   * method returns no data on success, such as `Delete`, the response will be
      +   * `google.protobuf.Empty`.  If the original method is standard
      +   * `Get`/`Create`/`Update`, the response should be the resource.  For other
      +   * methods, the response should have the type `XxxResponse`, where `Xxx`
      +   * is the original method name.  For example, if the original method name
      +   * is `TakeSnapshot()`, the inferred response type will be
      +   * `TakeSnapshotResponse`.
      +   * 
      + */ + com.google.protobuf.AnyOrBuilder getResponseOrBuilder(); + + public com.google.longrunning.Operation.ResultCase getResultCase(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsGrpc.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsGrpc.java new file mode 100644 index 000000000000..0c1c82a52874 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsGrpc.java @@ -0,0 +1,306 @@ +package com.google.longrunning; + +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; + +@javax.annotation.Generated("by gRPC proto compiler") +public class OperationsGrpc { + + private OperationsGrpc() {} + + public static final String SERVICE_NAME = "google.longrunning.Operations"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_GET_OPERATION = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.longrunning.Operations", "GetOperation"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.GetOperationRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.Operation.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_LIST_OPERATIONS = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.longrunning.Operations", "ListOperations"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.ListOperationsRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.ListOperationsResponse.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_CANCEL_OPERATION = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.longrunning.Operations", "CancelOperation"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.CancelOperationRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_DELETE_OPERATION = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.longrunning.Operations", "DeleteOperation"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.DeleteOperationRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); + + public static OperationsStub newStub(io.grpc.Channel channel) { + return new OperationsStub(channel); + } + + public static OperationsBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new OperationsBlockingStub(channel); + } + + public static OperationsFutureStub newFutureStub( + io.grpc.Channel channel) { + return new OperationsFutureStub(channel); + } + + public static interface Operations { + + public void getOperation(com.google.longrunning.GetOperationRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void listOperations(com.google.longrunning.ListOperationsRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void cancelOperation(com.google.longrunning.CancelOperationRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void deleteOperation(com.google.longrunning.DeleteOperationRequest request, + io.grpc.stub.StreamObserver responseObserver); + } + + public static interface OperationsBlockingClient { + + public com.google.longrunning.Operation getOperation(com.google.longrunning.GetOperationRequest request); + + public com.google.longrunning.ListOperationsResponse listOperations(com.google.longrunning.ListOperationsRequest request); + + public com.google.protobuf.Empty cancelOperation(com.google.longrunning.CancelOperationRequest request); + + public com.google.protobuf.Empty deleteOperation(com.google.longrunning.DeleteOperationRequest request); + } + + public static interface OperationsFutureClient { + + public com.google.common.util.concurrent.ListenableFuture getOperation( + com.google.longrunning.GetOperationRequest request); + + public com.google.common.util.concurrent.ListenableFuture listOperations( + com.google.longrunning.ListOperationsRequest request); + + public com.google.common.util.concurrent.ListenableFuture cancelOperation( + com.google.longrunning.CancelOperationRequest request); + + public com.google.common.util.concurrent.ListenableFuture deleteOperation( + com.google.longrunning.DeleteOperationRequest request); + } + + public static class OperationsStub extends io.grpc.stub.AbstractStub + implements Operations { + private OperationsStub(io.grpc.Channel channel) { + super(channel); + } + + private OperationsStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected OperationsStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new OperationsStub(channel, callOptions); + } + + @java.lang.Override + public void getOperation(com.google.longrunning.GetOperationRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_GET_OPERATION, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void listOperations(com.google.longrunning.ListOperationsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_LIST_OPERATIONS, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void cancelOperation(com.google.longrunning.CancelOperationRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_CANCEL_OPERATION, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void deleteOperation(com.google.longrunning.DeleteOperationRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_DELETE_OPERATION, getCallOptions()), request, responseObserver); + } + } + + public static class OperationsBlockingStub extends io.grpc.stub.AbstractStub + implements OperationsBlockingClient { + private OperationsBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private OperationsBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected OperationsBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new OperationsBlockingStub(channel, callOptions); + } + + @java.lang.Override + public com.google.longrunning.Operation getOperation(com.google.longrunning.GetOperationRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_GET_OPERATION, getCallOptions()), request); + } + + @java.lang.Override + public com.google.longrunning.ListOperationsResponse listOperations(com.google.longrunning.ListOperationsRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_LIST_OPERATIONS, getCallOptions()), request); + } + + @java.lang.Override + public com.google.protobuf.Empty cancelOperation(com.google.longrunning.CancelOperationRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_CANCEL_OPERATION, getCallOptions()), request); + } + + @java.lang.Override + public com.google.protobuf.Empty deleteOperation(com.google.longrunning.DeleteOperationRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_DELETE_OPERATION, getCallOptions()), request); + } + } + + public static class OperationsFutureStub extends io.grpc.stub.AbstractStub + implements OperationsFutureClient { + private OperationsFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private OperationsFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected OperationsFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new OperationsFutureStub(channel, callOptions); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture getOperation( + com.google.longrunning.GetOperationRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_GET_OPERATION, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture listOperations( + com.google.longrunning.ListOperationsRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_LIST_OPERATIONS, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture cancelOperation( + com.google.longrunning.CancelOperationRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_CANCEL_OPERATION, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture deleteOperation( + com.google.longrunning.DeleteOperationRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_DELETE_OPERATION, getCallOptions()), request); + } + } + + public static io.grpc.ServerServiceDefinition bindService( + final Operations serviceImpl) { + return io.grpc.ServerServiceDefinition.builder(SERVICE_NAME) + .addMethod( + METHOD_GET_OPERATION, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.longrunning.GetOperationRequest, + com.google.longrunning.Operation>() { + @java.lang.Override + public void invoke( + com.google.longrunning.GetOperationRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.getOperation(request, responseObserver); + } + })) + .addMethod( + METHOD_LIST_OPERATIONS, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.longrunning.ListOperationsRequest, + com.google.longrunning.ListOperationsResponse>() { + @java.lang.Override + public void invoke( + com.google.longrunning.ListOperationsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.listOperations(request, responseObserver); + } + })) + .addMethod( + METHOD_CANCEL_OPERATION, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.longrunning.CancelOperationRequest, + com.google.protobuf.Empty>() { + @java.lang.Override + public void invoke( + com.google.longrunning.CancelOperationRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.cancelOperation(request, responseObserver); + } + })) + .addMethod( + METHOD_DELETE_OPERATION, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.longrunning.DeleteOperationRequest, + com.google.protobuf.Empty>() { + @java.lang.Override + public void invoke( + com.google.longrunning.DeleteOperationRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.deleteOperation(request, responseObserver); + } + })).build(); + } +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsProto.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsProto.java new file mode 100644 index 000000000000..462e611fba19 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsProto.java @@ -0,0 +1,146 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/longrunning/operations.proto + +package com.google.longrunning; + +public final class OperationsProto { + private OperationsProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_longrunning_Operation_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_longrunning_Operation_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_longrunning_GetOperationRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_longrunning_GetOperationRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_longrunning_ListOperationsRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_longrunning_ListOperationsRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_longrunning_ListOperationsResponse_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_longrunning_ListOperationsResponse_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_longrunning_CancelOperationRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_longrunning_CancelOperationRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_longrunning_DeleteOperationRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_longrunning_DeleteOperationRequest_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n#google/longrunning/operations.proto\022\022g" + + "oogle.longrunning\032\034google/api/annotation" + + "s.proto\032\031google/protobuf/any.proto\032\033goog" + + "le/protobuf/empty.proto\032\027google/rpc/stat" + + "us.proto\"\250\001\n\tOperation\022\014\n\004name\030\001 \001(\t\022&\n\010" + + "metadata\030\002 \001(\0132\024.google.protobuf.Any\022\014\n\004" + + "done\030\003 \001(\010\022#\n\005error\030\004 \001(\0132\022.google.rpc.S" + + "tatusH\000\022(\n\010response\030\005 \001(\0132\024.google.proto" + + "buf.AnyH\000B\010\n\006result\"#\n\023GetOperationReque" + + "st\022\014\n\004name\030\001 \001(\t\"\\\n\025ListOperationsReques", + "t\022\014\n\004name\030\004 \001(\t\022\016\n\006filter\030\001 \001(\t\022\021\n\tpage_" + + "size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\"d\n\026ListOp" + + "erationsResponse\0221\n\noperations\030\001 \003(\0132\035.g" + + "oogle.longrunning.Operation\022\027\n\017next_page" + + "_token\030\002 \001(\t\"&\n\026CancelOperationRequest\022\014" + + "\n\004name\030\001 \001(\t\"&\n\026DeleteOperationRequest\022\014" + + "\n\004name\030\001 \001(\t2\214\004\n\nOperations\022x\n\014GetOperat" + + "ion\022\'.google.longrunning.GetOperationReq" + + "uest\032\035.google.longrunning.Operation\" \202\323\344" + + "\223\002\032\022\030/v1/{name=operations/**}\022\206\001\n\016ListOp", + "erations\022).google.longrunning.ListOperat" + + "ionsRequest\032*.google.longrunning.ListOpe" + + "rationsResponse\"\035\202\323\344\223\002\027\022\025/v1/{name=opera" + + "tions}\022\201\001\n\017CancelOperation\022*.google.long" + + "running.CancelOperationRequest\032\026.google." + + "protobuf.Empty\"*\202\323\344\223\002$\"\037/v1/{name=operat" + + "ions/**}:cancel:\001*\022w\n\017DeleteOperation\022*." + + "google.longrunning.DeleteOperationReques" + + "t\032\026.google.protobuf.Empty\" \202\323\344\223\002\032*\030/v1/{" + + "name=operations/**}B+\n\026com.google.longru", + "nningB\017OperationsProtoP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + com.google.protobuf.AnyProto.getDescriptor(), + com.google.protobuf.EmptyProto.getDescriptor(), + com.google.rpc.StatusProto.getDescriptor(), + }, assigner); + internal_static_google_longrunning_Operation_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_longrunning_Operation_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_longrunning_Operation_descriptor, + new java.lang.String[] { "Name", "Metadata", "Done", "Error", "Response", "Result", }); + internal_static_google_longrunning_GetOperationRequest_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_longrunning_GetOperationRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_longrunning_GetOperationRequest_descriptor, + new java.lang.String[] { "Name", }); + internal_static_google_longrunning_ListOperationsRequest_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_longrunning_ListOperationsRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_longrunning_ListOperationsRequest_descriptor, + new java.lang.String[] { "Name", "Filter", "PageSize", "PageToken", }); + internal_static_google_longrunning_ListOperationsResponse_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_longrunning_ListOperationsResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_longrunning_ListOperationsResponse_descriptor, + new java.lang.String[] { "Operations", "NextPageToken", }); + internal_static_google_longrunning_CancelOperationRequest_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_longrunning_CancelOperationRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_longrunning_CancelOperationRequest_descriptor, + new java.lang.String[] { "Name", }); + internal_static_google_longrunning_DeleteOperationRequest_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_longrunning_DeleteOperationRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_longrunning_DeleteOperationRequest_descriptor, + new java.lang.String[] { "Name", }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.AnnotationsProto.http); + com.google.protobuf.Descriptors.FileDescriptor + .internalUpdateFileDescriptor(descriptor, registry); + com.google.api.AnnotationsProto.getDescriptor(); + com.google.protobuf.AnyProto.getDescriptor(); + com.google.protobuf.EmptyProto.getDescriptor(); + com.google.rpc.StatusProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequest.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequest.java new file mode 100644 index 000000000000..acb0dc65019d --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequest.java @@ -0,0 +1,1437 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +/** + * Protobuf type {@code google.rpc.BadRequest} + * + *
      + * Describes violations in a client request. This error type focuses on the
      + * syntactic aspects of the request.
      + * 
      + */ +public final class BadRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.BadRequest) + BadRequestOrBuilder { + // Use BadRequest.newBuilder() to construct. + private BadRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private BadRequest() { + fieldViolations_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private BadRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + fieldViolations_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + fieldViolations_.add(input.readMessage(com.google.rpc.BadRequest.FieldViolation.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + fieldViolations_ = java.util.Collections.unmodifiableList(fieldViolations_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.BadRequest.class, com.google.rpc.BadRequest.Builder.class); + } + + public interface FieldViolationOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.BadRequest.FieldViolation) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string field = 1; + * + *
      +     * A path leading to a field in the request body. The value will be a
      +     * sequence of dot-separated identifiers that identify a protocol buffer
      +     * field. E.g., "violations.field" would identify this field.
      +     * 
      + */ + java.lang.String getField(); + /** + * optional string field = 1; + * + *
      +     * A path leading to a field in the request body. The value will be a
      +     * sequence of dot-separated identifiers that identify a protocol buffer
      +     * field. E.g., "violations.field" would identify this field.
      +     * 
      + */ + com.google.protobuf.ByteString + getFieldBytes(); + + /** + * optional string description = 2; + * + *
      +     * A description of why the request element is bad.
      +     * 
      + */ + java.lang.String getDescription(); + /** + * optional string description = 2; + * + *
      +     * A description of why the request element is bad.
      +     * 
      + */ + com.google.protobuf.ByteString + getDescriptionBytes(); + } + /** + * Protobuf type {@code google.rpc.BadRequest.FieldViolation} + * + *
      +   * A message type used to describe a single bad request field.
      +   * 
      + */ + public static final class FieldViolation extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.BadRequest.FieldViolation) + FieldViolationOrBuilder { + // Use FieldViolation.newBuilder() to construct. + private FieldViolation(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private FieldViolation() { + field_ = ""; + description_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private FieldViolation( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + field_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + description_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_FieldViolation_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_FieldViolation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.BadRequest.FieldViolation.class, com.google.rpc.BadRequest.FieldViolation.Builder.class); + } + + public static final int FIELD_FIELD_NUMBER = 1; + private volatile java.lang.Object field_; + /** + * optional string field = 1; + * + *
      +     * A path leading to a field in the request body. The value will be a
      +     * sequence of dot-separated identifiers that identify a protocol buffer
      +     * field. E.g., "violations.field" would identify this field.
      +     * 
      + */ + public java.lang.String getField() { + java.lang.Object ref = field_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + field_ = s; + return s; + } + } + /** + * optional string field = 1; + * + *
      +     * A path leading to a field in the request body. The value will be a
      +     * sequence of dot-separated identifiers that identify a protocol buffer
      +     * field. E.g., "violations.field" would identify this field.
      +     * 
      + */ + public com.google.protobuf.ByteString + getFieldBytes() { + java.lang.Object ref = field_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + field_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DESCRIPTION_FIELD_NUMBER = 2; + private volatile java.lang.Object description_; + /** + * optional string description = 2; + * + *
      +     * A description of why the request element is bad.
      +     * 
      + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } + } + /** + * optional string description = 2; + * + *
      +     * A description of why the request element is bad.
      +     * 
      + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getFieldBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, field_); + } + if (!getDescriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, description_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getFieldBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, field_); + } + if (!getDescriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, description_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.BadRequest.FieldViolation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.BadRequest.FieldViolation parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.BadRequest.FieldViolation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.BadRequest.FieldViolation parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.BadRequest.FieldViolation parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.BadRequest.FieldViolation parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.BadRequest.FieldViolation parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.BadRequest.FieldViolation parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.BadRequest.FieldViolation parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.BadRequest.FieldViolation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.BadRequest.FieldViolation prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.BadRequest.FieldViolation} + * + *
      +     * A message type used to describe a single bad request field.
      +     * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.BadRequest.FieldViolation) + com.google.rpc.BadRequest.FieldViolationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_FieldViolation_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_FieldViolation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.BadRequest.FieldViolation.class, com.google.rpc.BadRequest.FieldViolation.Builder.class); + } + + // Construct using com.google.rpc.BadRequest.FieldViolation.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + field_ = ""; + + description_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_FieldViolation_descriptor; + } + + public com.google.rpc.BadRequest.FieldViolation getDefaultInstanceForType() { + return com.google.rpc.BadRequest.FieldViolation.getDefaultInstance(); + } + + public com.google.rpc.BadRequest.FieldViolation build() { + com.google.rpc.BadRequest.FieldViolation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.BadRequest.FieldViolation buildPartial() { + com.google.rpc.BadRequest.FieldViolation result = new com.google.rpc.BadRequest.FieldViolation(this); + result.field_ = field_; + result.description_ = description_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.BadRequest.FieldViolation) { + return mergeFrom((com.google.rpc.BadRequest.FieldViolation)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.BadRequest.FieldViolation other) { + if (other == com.google.rpc.BadRequest.FieldViolation.getDefaultInstance()) return this; + if (!other.getField().isEmpty()) { + field_ = other.field_; + onChanged(); + } + if (!other.getDescription().isEmpty()) { + description_ = other.description_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.BadRequest.FieldViolation parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.BadRequest.FieldViolation) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object field_ = ""; + /** + * optional string field = 1; + * + *
      +       * A path leading to a field in the request body. The value will be a
      +       * sequence of dot-separated identifiers that identify a protocol buffer
      +       * field. E.g., "violations.field" would identify this field.
      +       * 
      + */ + public java.lang.String getField() { + java.lang.Object ref = field_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + field_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string field = 1; + * + *
      +       * A path leading to a field in the request body. The value will be a
      +       * sequence of dot-separated identifiers that identify a protocol buffer
      +       * field. E.g., "violations.field" would identify this field.
      +       * 
      + */ + public com.google.protobuf.ByteString + getFieldBytes() { + java.lang.Object ref = field_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + field_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string field = 1; + * + *
      +       * A path leading to a field in the request body. The value will be a
      +       * sequence of dot-separated identifiers that identify a protocol buffer
      +       * field. E.g., "violations.field" would identify this field.
      +       * 
      + */ + public Builder setField( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + field_ = value; + onChanged(); + return this; + } + /** + * optional string field = 1; + * + *
      +       * A path leading to a field in the request body. The value will be a
      +       * sequence of dot-separated identifiers that identify a protocol buffer
      +       * field. E.g., "violations.field" would identify this field.
      +       * 
      + */ + public Builder clearField() { + + field_ = getDefaultInstance().getField(); + onChanged(); + return this; + } + /** + * optional string field = 1; + * + *
      +       * A path leading to a field in the request body. The value will be a
      +       * sequence of dot-separated identifiers that identify a protocol buffer
      +       * field. E.g., "violations.field" would identify this field.
      +       * 
      + */ + public Builder setFieldBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + field_ = value; + onChanged(); + return this; + } + + private java.lang.Object description_ = ""; + /** + * optional string description = 2; + * + *
      +       * A description of why the request element is bad.
      +       * 
      + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string description = 2; + * + *
      +       * A description of why the request element is bad.
      +       * 
      + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string description = 2; + * + *
      +       * A description of why the request element is bad.
      +       * 
      + */ + public Builder setDescription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + description_ = value; + onChanged(); + return this; + } + /** + * optional string description = 2; + * + *
      +       * A description of why the request element is bad.
      +       * 
      + */ + public Builder clearDescription() { + + description_ = getDefaultInstance().getDescription(); + onChanged(); + return this; + } + /** + * optional string description = 2; + * + *
      +       * A description of why the request element is bad.
      +       * 
      + */ + public Builder setDescriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + description_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.BadRequest.FieldViolation) + } + + // @@protoc_insertion_point(class_scope:google.rpc.BadRequest.FieldViolation) + private static final com.google.rpc.BadRequest.FieldViolation DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.BadRequest.FieldViolation(); + } + + public static com.google.rpc.BadRequest.FieldViolation getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public FieldViolation parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new FieldViolation(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.BadRequest.FieldViolation getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int FIELD_VIOLATIONS_FIELD_NUMBER = 1; + private java.util.List fieldViolations_; + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +   * Describes all violations in a client request.
      +   * 
      + */ + public java.util.List getFieldViolationsList() { + return fieldViolations_; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +   * Describes all violations in a client request.
      +   * 
      + */ + public java.util.List + getFieldViolationsOrBuilderList() { + return fieldViolations_; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +   * Describes all violations in a client request.
      +   * 
      + */ + public int getFieldViolationsCount() { + return fieldViolations_.size(); + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +   * Describes all violations in a client request.
      +   * 
      + */ + public com.google.rpc.BadRequest.FieldViolation getFieldViolations(int index) { + return fieldViolations_.get(index); + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +   * Describes all violations in a client request.
      +   * 
      + */ + public com.google.rpc.BadRequest.FieldViolationOrBuilder getFieldViolationsOrBuilder( + int index) { + return fieldViolations_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < fieldViolations_.size(); i++) { + output.writeMessage(1, fieldViolations_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < fieldViolations_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, fieldViolations_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.BadRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.BadRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.BadRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.BadRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.BadRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.BadRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.BadRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.BadRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.BadRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.BadRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.BadRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.BadRequest} + * + *
      +   * Describes violations in a client request. This error type focuses on the
      +   * syntactic aspects of the request.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.BadRequest) + com.google.rpc.BadRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.BadRequest.class, com.google.rpc.BadRequest.Builder.class); + } + + // Construct using com.google.rpc.BadRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getFieldViolationsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (fieldViolationsBuilder_ == null) { + fieldViolations_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + fieldViolationsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_descriptor; + } + + public com.google.rpc.BadRequest getDefaultInstanceForType() { + return com.google.rpc.BadRequest.getDefaultInstance(); + } + + public com.google.rpc.BadRequest build() { + com.google.rpc.BadRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.BadRequest buildPartial() { + com.google.rpc.BadRequest result = new com.google.rpc.BadRequest(this); + int from_bitField0_ = bitField0_; + if (fieldViolationsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + fieldViolations_ = java.util.Collections.unmodifiableList(fieldViolations_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.fieldViolations_ = fieldViolations_; + } else { + result.fieldViolations_ = fieldViolationsBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.BadRequest) { + return mergeFrom((com.google.rpc.BadRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.BadRequest other) { + if (other == com.google.rpc.BadRequest.getDefaultInstance()) return this; + if (fieldViolationsBuilder_ == null) { + if (!other.fieldViolations_.isEmpty()) { + if (fieldViolations_.isEmpty()) { + fieldViolations_ = other.fieldViolations_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureFieldViolationsIsMutable(); + fieldViolations_.addAll(other.fieldViolations_); + } + onChanged(); + } + } else { + if (!other.fieldViolations_.isEmpty()) { + if (fieldViolationsBuilder_.isEmpty()) { + fieldViolationsBuilder_.dispose(); + fieldViolationsBuilder_ = null; + fieldViolations_ = other.fieldViolations_; + bitField0_ = (bitField0_ & ~0x00000001); + fieldViolationsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getFieldViolationsFieldBuilder() : null; + } else { + fieldViolationsBuilder_.addAllMessages(other.fieldViolations_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.BadRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.BadRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List fieldViolations_ = + java.util.Collections.emptyList(); + private void ensureFieldViolationsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + fieldViolations_ = new java.util.ArrayList(fieldViolations_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.BadRequest.FieldViolation, com.google.rpc.BadRequest.FieldViolation.Builder, com.google.rpc.BadRequest.FieldViolationOrBuilder> fieldViolationsBuilder_; + + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public java.util.List getFieldViolationsList() { + if (fieldViolationsBuilder_ == null) { + return java.util.Collections.unmodifiableList(fieldViolations_); + } else { + return fieldViolationsBuilder_.getMessageList(); + } + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public int getFieldViolationsCount() { + if (fieldViolationsBuilder_ == null) { + return fieldViolations_.size(); + } else { + return fieldViolationsBuilder_.getCount(); + } + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public com.google.rpc.BadRequest.FieldViolation getFieldViolations(int index) { + if (fieldViolationsBuilder_ == null) { + return fieldViolations_.get(index); + } else { + return fieldViolationsBuilder_.getMessage(index); + } + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public Builder setFieldViolations( + int index, com.google.rpc.BadRequest.FieldViolation value) { + if (fieldViolationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldViolationsIsMutable(); + fieldViolations_.set(index, value); + onChanged(); + } else { + fieldViolationsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public Builder setFieldViolations( + int index, com.google.rpc.BadRequest.FieldViolation.Builder builderForValue) { + if (fieldViolationsBuilder_ == null) { + ensureFieldViolationsIsMutable(); + fieldViolations_.set(index, builderForValue.build()); + onChanged(); + } else { + fieldViolationsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public Builder addFieldViolations(com.google.rpc.BadRequest.FieldViolation value) { + if (fieldViolationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldViolationsIsMutable(); + fieldViolations_.add(value); + onChanged(); + } else { + fieldViolationsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public Builder addFieldViolations( + int index, com.google.rpc.BadRequest.FieldViolation value) { + if (fieldViolationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldViolationsIsMutable(); + fieldViolations_.add(index, value); + onChanged(); + } else { + fieldViolationsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public Builder addFieldViolations( + com.google.rpc.BadRequest.FieldViolation.Builder builderForValue) { + if (fieldViolationsBuilder_ == null) { + ensureFieldViolationsIsMutable(); + fieldViolations_.add(builderForValue.build()); + onChanged(); + } else { + fieldViolationsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public Builder addFieldViolations( + int index, com.google.rpc.BadRequest.FieldViolation.Builder builderForValue) { + if (fieldViolationsBuilder_ == null) { + ensureFieldViolationsIsMutable(); + fieldViolations_.add(index, builderForValue.build()); + onChanged(); + } else { + fieldViolationsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public Builder addAllFieldViolations( + java.lang.Iterable values) { + if (fieldViolationsBuilder_ == null) { + ensureFieldViolationsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, fieldViolations_); + onChanged(); + } else { + fieldViolationsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public Builder clearFieldViolations() { + if (fieldViolationsBuilder_ == null) { + fieldViolations_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + fieldViolationsBuilder_.clear(); + } + return this; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public Builder removeFieldViolations(int index) { + if (fieldViolationsBuilder_ == null) { + ensureFieldViolationsIsMutable(); + fieldViolations_.remove(index); + onChanged(); + } else { + fieldViolationsBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public com.google.rpc.BadRequest.FieldViolation.Builder getFieldViolationsBuilder( + int index) { + return getFieldViolationsFieldBuilder().getBuilder(index); + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public com.google.rpc.BadRequest.FieldViolationOrBuilder getFieldViolationsOrBuilder( + int index) { + if (fieldViolationsBuilder_ == null) { + return fieldViolations_.get(index); } else { + return fieldViolationsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public java.util.List + getFieldViolationsOrBuilderList() { + if (fieldViolationsBuilder_ != null) { + return fieldViolationsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(fieldViolations_); + } + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public com.google.rpc.BadRequest.FieldViolation.Builder addFieldViolationsBuilder() { + return getFieldViolationsFieldBuilder().addBuilder( + com.google.rpc.BadRequest.FieldViolation.getDefaultInstance()); + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public com.google.rpc.BadRequest.FieldViolation.Builder addFieldViolationsBuilder( + int index) { + return getFieldViolationsFieldBuilder().addBuilder( + index, com.google.rpc.BadRequest.FieldViolation.getDefaultInstance()); + } + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +     * Describes all violations in a client request.
      +     * 
      + */ + public java.util.List + getFieldViolationsBuilderList() { + return getFieldViolationsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.BadRequest.FieldViolation, com.google.rpc.BadRequest.FieldViolation.Builder, com.google.rpc.BadRequest.FieldViolationOrBuilder> + getFieldViolationsFieldBuilder() { + if (fieldViolationsBuilder_ == null) { + fieldViolationsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.BadRequest.FieldViolation, com.google.rpc.BadRequest.FieldViolation.Builder, com.google.rpc.BadRequest.FieldViolationOrBuilder>( + fieldViolations_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + fieldViolations_ = null; + } + return fieldViolationsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.BadRequest) + } + + // @@protoc_insertion_point(class_scope:google.rpc.BadRequest) + private static final com.google.rpc.BadRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.BadRequest(); + } + + public static com.google.rpc.BadRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public BadRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new BadRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.BadRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequestOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequestOrBuilder.java new file mode 100644 index 000000000000..6363fe8b9a0e --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequestOrBuilder.java @@ -0,0 +1,53 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +public interface BadRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.BadRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +   * Describes all violations in a client request.
      +   * 
      + */ + java.util.List + getFieldViolationsList(); + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +   * Describes all violations in a client request.
      +   * 
      + */ + com.google.rpc.BadRequest.FieldViolation getFieldViolations(int index); + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +   * Describes all violations in a client request.
      +   * 
      + */ + int getFieldViolationsCount(); + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +   * Describes all violations in a client request.
      +   * 
      + */ + java.util.List + getFieldViolationsOrBuilderList(); + /** + * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; + * + *
      +   * Describes all violations in a client request.
      +   * 
      + */ + com.google.rpc.BadRequest.FieldViolationOrBuilder getFieldViolationsOrBuilder( + int index); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/Code.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/Code.java new file mode 100644 index 000000000000..3fcbad557708 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/Code.java @@ -0,0 +1,543 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/code.proto + +package com.google.rpc; + +/** + * Protobuf enum {@code google.rpc.Code} + * + *
      + * The canonical error codes for Google APIs.
      + * Warnings:
      + * -   Do not change any numeric assignments.
      + * -   Changes to this list should be made only if there is a compelling
      + *     need that can't be satisfied in another way.
      + * Sometimes multiple error codes may apply.  Services should return
      + * the most specific error code that applies.  For example, prefer
      + * `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply.
      + * Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`.
      + * 
      + */ +public enum Code + implements com.google.protobuf.ProtocolMessageEnum { + /** + * OK = 0; + * + *
      +   * Not an error; returned on success
      +   * HTTP Mapping: 200 OK
      +   * 
      + */ + OK(0, 0), + /** + * CANCELLED = 1; + * + *
      +   * The operation was cancelled, typically by the caller.
      +   * HTTP Mapping: 499 Client Closed Request
      +   * 
      + */ + CANCELLED(1, 1), + /** + * UNKNOWN = 2; + * + *
      +   * Unknown error.  For example, this error may be returned when
      +   * a `Status` value received from another address space belongs to
      +   * an error space that is not known in this address space.  Also
      +   * errors raised by APIs that do not return enough error information
      +   * may be converted to this error.
      +   * HTTP Mapping: 500 Internal Server Error
      +   * 
      + */ + UNKNOWN(2, 2), + /** + * INVALID_ARGUMENT = 3; + * + *
      +   * The client specified an invalid argument.  Note that this differs
      +   * from `FAILED_PRECONDITION`.  `INVALID_ARGUMENT` indicates arguments
      +   * that are problematic regardless of the state of the system
      +   * (e.g., a malformed file name).
      +   * HTTP Mapping: 400 Bad Request
      +   * 
      + */ + INVALID_ARGUMENT(3, 3), + /** + * DEADLINE_EXCEEDED = 4; + * + *
      +   * The deadline expired before the operation could complete. For operations
      +   * that change the state of the system, this error may be returned
      +   * even if the operation has completed successfully.  For example, a
      +   * successful response from a server could have been delayed long
      +   * enough for the deadline to expire.
      +   * HTTP Mapping: 504 Gateway Timeout
      +   * 
      + */ + DEADLINE_EXCEEDED(4, 4), + /** + * NOT_FOUND = 5; + * + *
      +   * Some requested entity (e.g., file or directory) was not found.
      +   * For privacy reasons, this code *might* be returned when the client
      +   * does not have the access rights to the entity.
      +   * HTTP Mapping: 404 Not Found
      +   * 
      + */ + NOT_FOUND(5, 5), + /** + * ALREADY_EXISTS = 6; + * + *
      +   * The entity that a client attempted to create (e.g., file or directory)
      +   * already exists.
      +   * HTTP Mapping: 409 Conflict
      +   * 
      + */ + ALREADY_EXISTS(6, 6), + /** + * PERMISSION_DENIED = 7; + * + *
      +   * The caller does not have permission to execute the specified
      +   * operation. `PERMISSION_DENIED` must not be used for rejections
      +   * caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
      +   * instead for those errors). `PERMISSION_DENIED` must not be
      +   * used if the caller can not be identified (use `UNAUTHENTICATED`
      +   * instead for those errors).
      +   * HTTP Mapping: 403 Forbidden
      +   * 
      + */ + PERMISSION_DENIED(7, 7), + /** + * UNAUTHENTICATED = 16; + * + *
      +   * The request does not have valid authentication credentials for the
      +   * operation.
      +   * HTTP Mapping: 401 Unauthorized
      +   * 
      + */ + UNAUTHENTICATED(8, 16), + /** + * RESOURCE_EXHAUSTED = 8; + * + *
      +   * Some resource has been exhausted, perhaps a per-user quota, or
      +   * perhaps the entire file system is out of space.
      +   * HTTP Mapping: 429 Too Many Requests
      +   * 
      + */ + RESOURCE_EXHAUSTED(9, 8), + /** + * FAILED_PRECONDITION = 9; + * + *
      +   * The operation was rejected because the system is not in a state
      +   * required for the operation's execution.  For example, the directory
      +   * to be deleted is non-empty, an rmdir operation is applied to
      +   * a non-directory, etc.
      +   * Service implementors can use the following guidelines to decide
      +   * between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
      +   *  (a) Use `UNAVAILABLE` if the client can retry just the failing call.
      +   *  (b) Use `ABORTED` if the client should retry at a higher level
      +   *      (e.g., restarting a read-modify-write sequence).
      +   *  (c) Use `FAILED_PRECONDITION` if the client should not retry until
      +   *      the system state has been explicitly fixed.  E.g., if an "rmdir"
      +   *      fails because the directory is non-empty, `FAILED_PRECONDITION`
      +   *      should be returned since the client should not retry unless
      +   *      the files are deleted from the directory.
      +   *  (d) Use `FAILED_PRECONDITION` if the client performs conditional
      +   *      REST Get/Update/Delete on a resource and the resource on the
      +   *      server does not match the condition. E.g., conflicting
      +   *      read-modify-write on the same resource.
      +   * HTTP Mapping: 400 Bad Request
      +   * NOTE: HTTP spec says `412 Precondition Failed` should be used only if
      +   * the request contains Etag-related headers. So if the server does see
      +   * Etag-related headers in the request, it may choose to return 412
      +   * instead of 400 for this error code.
      +   * 
      + */ + FAILED_PRECONDITION(10, 9), + /** + * ABORTED = 10; + * + *
      +   * The operation was aborted, typically due to a concurrency issue such as
      +   * a sequencer check failure or transaction abort.
      +   * See the guidelines above for deciding between `FAILED_PRECONDITION`,
      +   * `ABORTED`, and `UNAVAILABLE`.
      +   * HTTP Mapping: 409 Conflict
      +   * 
      + */ + ABORTED(11, 10), + /** + * OUT_OF_RANGE = 11; + * + *
      +   * The operation was attempted past the valid range.  E.g., seeking or
      +   * reading past end-of-file.
      +   * Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
      +   * be fixed if the system state changes. For example, a 32-bit file
      +   * system will generate `INVALID_ARGUMENT` if asked to read at an
      +   * offset that is not in the range [0,2^32-1], but it will generate
      +   * `OUT_OF_RANGE` if asked to read from an offset past the current
      +   * file size.
      +   * There is a fair bit of overlap between `FAILED_PRECONDITION` and
      +   * `OUT_OF_RANGE`.  We recommend using `OUT_OF_RANGE` (the more specific
      +   * error) when it applies so that callers who are iterating through
      +   * a space can easily look for an `OUT_OF_RANGE` error to detect when
      +   * they are done.
      +   * HTTP Mapping: 400 Bad Request
      +   * 
      + */ + OUT_OF_RANGE(12, 11), + /** + * UNIMPLEMENTED = 12; + * + *
      +   * The operation is not implemented or is not supported/enabled in this
      +   * service.
      +   * HTTP Mapping: 501 Not Implemented
      +   * 
      + */ + UNIMPLEMENTED(13, 12), + /** + * INTERNAL = 13; + * + *
      +   * Internal errors.  This means that some invariants expected by the
      +   * underlying system have been broken.  This error code is reserved
      +   * for serious errors.
      +   * HTTP Mapping: 500 Internal Server Error
      +   * 
      + */ + INTERNAL(14, 13), + /** + * UNAVAILABLE = 14; + * + *
      +   * The service is currently unavailable.  This is most likely a
      +   * transient condition, which can be corrected by retrying with
      +   * a backoff.
      +   * See the guidelines above for deciding between `FAILED_PRECONDITION`,
      +   * `ABORTED`, and `UNAVAILABLE`.
      +   * HTTP Mapping: 503 Service Unavailable
      +   * 
      + */ + UNAVAILABLE(15, 14), + /** + * DATA_LOSS = 15; + * + *
      +   * Unrecoverable data loss or corruption.
      +   * HTTP Mapping: 500 Internal Server Error
      +   * 
      + */ + DATA_LOSS(16, 15), + UNRECOGNIZED(-1, -1), + ; + + /** + * OK = 0; + * + *
      +   * Not an error; returned on success
      +   * HTTP Mapping: 200 OK
      +   * 
      + */ + public static final int OK_VALUE = 0; + /** + * CANCELLED = 1; + * + *
      +   * The operation was cancelled, typically by the caller.
      +   * HTTP Mapping: 499 Client Closed Request
      +   * 
      + */ + public static final int CANCELLED_VALUE = 1; + /** + * UNKNOWN = 2; + * + *
      +   * Unknown error.  For example, this error may be returned when
      +   * a `Status` value received from another address space belongs to
      +   * an error space that is not known in this address space.  Also
      +   * errors raised by APIs that do not return enough error information
      +   * may be converted to this error.
      +   * HTTP Mapping: 500 Internal Server Error
      +   * 
      + */ + public static final int UNKNOWN_VALUE = 2; + /** + * INVALID_ARGUMENT = 3; + * + *
      +   * The client specified an invalid argument.  Note that this differs
      +   * from `FAILED_PRECONDITION`.  `INVALID_ARGUMENT` indicates arguments
      +   * that are problematic regardless of the state of the system
      +   * (e.g., a malformed file name).
      +   * HTTP Mapping: 400 Bad Request
      +   * 
      + */ + public static final int INVALID_ARGUMENT_VALUE = 3; + /** + * DEADLINE_EXCEEDED = 4; + * + *
      +   * The deadline expired before the operation could complete. For operations
      +   * that change the state of the system, this error may be returned
      +   * even if the operation has completed successfully.  For example, a
      +   * successful response from a server could have been delayed long
      +   * enough for the deadline to expire.
      +   * HTTP Mapping: 504 Gateway Timeout
      +   * 
      + */ + public static final int DEADLINE_EXCEEDED_VALUE = 4; + /** + * NOT_FOUND = 5; + * + *
      +   * Some requested entity (e.g., file or directory) was not found.
      +   * For privacy reasons, this code *might* be returned when the client
      +   * does not have the access rights to the entity.
      +   * HTTP Mapping: 404 Not Found
      +   * 
      + */ + public static final int NOT_FOUND_VALUE = 5; + /** + * ALREADY_EXISTS = 6; + * + *
      +   * The entity that a client attempted to create (e.g., file or directory)
      +   * already exists.
      +   * HTTP Mapping: 409 Conflict
      +   * 
      + */ + public static final int ALREADY_EXISTS_VALUE = 6; + /** + * PERMISSION_DENIED = 7; + * + *
      +   * The caller does not have permission to execute the specified
      +   * operation. `PERMISSION_DENIED` must not be used for rejections
      +   * caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
      +   * instead for those errors). `PERMISSION_DENIED` must not be
      +   * used if the caller can not be identified (use `UNAUTHENTICATED`
      +   * instead for those errors).
      +   * HTTP Mapping: 403 Forbidden
      +   * 
      + */ + public static final int PERMISSION_DENIED_VALUE = 7; + /** + * UNAUTHENTICATED = 16; + * + *
      +   * The request does not have valid authentication credentials for the
      +   * operation.
      +   * HTTP Mapping: 401 Unauthorized
      +   * 
      + */ + public static final int UNAUTHENTICATED_VALUE = 16; + /** + * RESOURCE_EXHAUSTED = 8; + * + *
      +   * Some resource has been exhausted, perhaps a per-user quota, or
      +   * perhaps the entire file system is out of space.
      +   * HTTP Mapping: 429 Too Many Requests
      +   * 
      + */ + public static final int RESOURCE_EXHAUSTED_VALUE = 8; + /** + * FAILED_PRECONDITION = 9; + * + *
      +   * The operation was rejected because the system is not in a state
      +   * required for the operation's execution.  For example, the directory
      +   * to be deleted is non-empty, an rmdir operation is applied to
      +   * a non-directory, etc.
      +   * Service implementors can use the following guidelines to decide
      +   * between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
      +   *  (a) Use `UNAVAILABLE` if the client can retry just the failing call.
      +   *  (b) Use `ABORTED` if the client should retry at a higher level
      +   *      (e.g., restarting a read-modify-write sequence).
      +   *  (c) Use `FAILED_PRECONDITION` if the client should not retry until
      +   *      the system state has been explicitly fixed.  E.g., if an "rmdir"
      +   *      fails because the directory is non-empty, `FAILED_PRECONDITION`
      +   *      should be returned since the client should not retry unless
      +   *      the files are deleted from the directory.
      +   *  (d) Use `FAILED_PRECONDITION` if the client performs conditional
      +   *      REST Get/Update/Delete on a resource and the resource on the
      +   *      server does not match the condition. E.g., conflicting
      +   *      read-modify-write on the same resource.
      +   * HTTP Mapping: 400 Bad Request
      +   * NOTE: HTTP spec says `412 Precondition Failed` should be used only if
      +   * the request contains Etag-related headers. So if the server does see
      +   * Etag-related headers in the request, it may choose to return 412
      +   * instead of 400 for this error code.
      +   * 
      + */ + public static final int FAILED_PRECONDITION_VALUE = 9; + /** + * ABORTED = 10; + * + *
      +   * The operation was aborted, typically due to a concurrency issue such as
      +   * a sequencer check failure or transaction abort.
      +   * See the guidelines above for deciding between `FAILED_PRECONDITION`,
      +   * `ABORTED`, and `UNAVAILABLE`.
      +   * HTTP Mapping: 409 Conflict
      +   * 
      + */ + public static final int ABORTED_VALUE = 10; + /** + * OUT_OF_RANGE = 11; + * + *
      +   * The operation was attempted past the valid range.  E.g., seeking or
      +   * reading past end-of-file.
      +   * Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
      +   * be fixed if the system state changes. For example, a 32-bit file
      +   * system will generate `INVALID_ARGUMENT` if asked to read at an
      +   * offset that is not in the range [0,2^32-1], but it will generate
      +   * `OUT_OF_RANGE` if asked to read from an offset past the current
      +   * file size.
      +   * There is a fair bit of overlap between `FAILED_PRECONDITION` and
      +   * `OUT_OF_RANGE`.  We recommend using `OUT_OF_RANGE` (the more specific
      +   * error) when it applies so that callers who are iterating through
      +   * a space can easily look for an `OUT_OF_RANGE` error to detect when
      +   * they are done.
      +   * HTTP Mapping: 400 Bad Request
      +   * 
      + */ + public static final int OUT_OF_RANGE_VALUE = 11; + /** + * UNIMPLEMENTED = 12; + * + *
      +   * The operation is not implemented or is not supported/enabled in this
      +   * service.
      +   * HTTP Mapping: 501 Not Implemented
      +   * 
      + */ + public static final int UNIMPLEMENTED_VALUE = 12; + /** + * INTERNAL = 13; + * + *
      +   * Internal errors.  This means that some invariants expected by the
      +   * underlying system have been broken.  This error code is reserved
      +   * for serious errors.
      +   * HTTP Mapping: 500 Internal Server Error
      +   * 
      + */ + public static final int INTERNAL_VALUE = 13; + /** + * UNAVAILABLE = 14; + * + *
      +   * The service is currently unavailable.  This is most likely a
      +   * transient condition, which can be corrected by retrying with
      +   * a backoff.
      +   * See the guidelines above for deciding between `FAILED_PRECONDITION`,
      +   * `ABORTED`, and `UNAVAILABLE`.
      +   * HTTP Mapping: 503 Service Unavailable
      +   * 
      + */ + public static final int UNAVAILABLE_VALUE = 14; + /** + * DATA_LOSS = 15; + * + *
      +   * Unrecoverable data loss or corruption.
      +   * HTTP Mapping: 500 Internal Server Error
      +   * 
      + */ + public static final int DATA_LOSS_VALUE = 15; + + + public final int getNumber() { + if (index == -1) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + public static Code valueOf(int value) { + switch (value) { + case 0: return OK; + case 1: return CANCELLED; + case 2: return UNKNOWN; + case 3: return INVALID_ARGUMENT; + case 4: return DEADLINE_EXCEEDED; + case 5: return NOT_FOUND; + case 6: return ALREADY_EXISTS; + case 7: return PERMISSION_DENIED; + case 16: return UNAUTHENTICATED; + case 8: return RESOURCE_EXHAUSTED; + case 9: return FAILED_PRECONDITION; + case 10: return ABORTED; + case 11: return OUT_OF_RANGE; + case 12: return UNIMPLEMENTED; + case 13: return INTERNAL; + case 14: return UNAVAILABLE; + case 15: return DATA_LOSS; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + Code> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Code findValueByNumber(int number) { + return Code.valueOf(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(index); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return com.google.rpc.CodeProto.getDescriptor() + .getEnumTypes().get(0); + } + + private static final Code[] VALUES = values(); + + public static Code valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int index; + private final int value; + + private Code(int index, int value) { + this.index = index; + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.rpc.Code) +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/CodeProto.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/CodeProto.java new file mode 100644 index 000000000000..95dc036ed327 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/CodeProto.java @@ -0,0 +1,46 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/code.proto + +package com.google.rpc; + +public final class CodeProto { + private CodeProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\025google/rpc/code.proto\022\ngoogle.rpc*\267\002\n\004" + + "Code\022\006\n\002OK\020\000\022\r\n\tCANCELLED\020\001\022\013\n\007UNKNOWN\020\002" + + "\022\024\n\020INVALID_ARGUMENT\020\003\022\025\n\021DEADLINE_EXCEE" + + "DED\020\004\022\r\n\tNOT_FOUND\020\005\022\022\n\016ALREADY_EXISTS\020\006" + + "\022\025\n\021PERMISSION_DENIED\020\007\022\023\n\017UNAUTHENTICAT" + + "ED\020\020\022\026\n\022RESOURCE_EXHAUSTED\020\010\022\027\n\023FAILED_P" + + "RECONDITION\020\t\022\013\n\007ABORTED\020\n\022\020\n\014OUT_OF_RAN" + + "GE\020\013\022\021\n\rUNIMPLEMENTED\020\014\022\014\n\010INTERNAL\020\r\022\017\n" + + "\013UNAVAILABLE\020\016\022\r\n\tDATA_LOSS\020\017B\035\n\016com.goo" + + "gle.rpcB\tCodeProtoP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfo.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfo.java new file mode 100644 index 000000000000..74550a10502d --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfo.java @@ -0,0 +1,697 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +/** + * Protobuf type {@code google.rpc.DebugInfo} + * + *
      + * Describes additional debugging info.
      + * 
      + */ +public final class DebugInfo extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.DebugInfo) + DebugInfoOrBuilder { + // Use DebugInfo.newBuilder() to construct. + private DebugInfo(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private DebugInfo() { + stackEntries_ = com.google.protobuf.LazyStringArrayList.EMPTY; + detail_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private DebugInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + stackEntries_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + stackEntries_.add(s); + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + detail_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + stackEntries_ = stackEntries_.getUnmodifiableView(); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_DebugInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_DebugInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.DebugInfo.class, com.google.rpc.DebugInfo.Builder.class); + } + + private int bitField0_; + public static final int STACK_ENTRIES_FIELD_NUMBER = 1; + private com.google.protobuf.LazyStringList stackEntries_; + /** + * repeated string stack_entries = 1; + * + *
      +   * The stack trace entries indicating where the error occurred.
      +   * 
      + */ + public com.google.protobuf.ProtocolStringList + getStackEntriesList() { + return stackEntries_; + } + /** + * repeated string stack_entries = 1; + * + *
      +   * The stack trace entries indicating where the error occurred.
      +   * 
      + */ + public int getStackEntriesCount() { + return stackEntries_.size(); + } + /** + * repeated string stack_entries = 1; + * + *
      +   * The stack trace entries indicating where the error occurred.
      +   * 
      + */ + public java.lang.String getStackEntries(int index) { + return stackEntries_.get(index); + } + /** + * repeated string stack_entries = 1; + * + *
      +   * The stack trace entries indicating where the error occurred.
      +   * 
      + */ + public com.google.protobuf.ByteString + getStackEntriesBytes(int index) { + return stackEntries_.getByteString(index); + } + + public static final int DETAIL_FIELD_NUMBER = 2; + private volatile java.lang.Object detail_; + /** + * optional string detail = 2; + * + *
      +   * Additional debugging information provided by the server.
      +   * 
      + */ + public java.lang.String getDetail() { + java.lang.Object ref = detail_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + detail_ = s; + return s; + } + } + /** + * optional string detail = 2; + * + *
      +   * Additional debugging information provided by the server.
      +   * 
      + */ + public com.google.protobuf.ByteString + getDetailBytes() { + java.lang.Object ref = detail_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + detail_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < stackEntries_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, stackEntries_.getRaw(i)); + } + if (!getDetailBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, detail_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < stackEntries_.size(); i++) { + dataSize += computeStringSizeNoTag(stackEntries_.getRaw(i)); + } + size += dataSize; + size += 1 * getStackEntriesList().size(); + } + if (!getDetailBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, detail_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.DebugInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.DebugInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.DebugInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.DebugInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.DebugInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.DebugInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.DebugInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.DebugInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.DebugInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.DebugInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.DebugInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.DebugInfo} + * + *
      +   * Describes additional debugging info.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.DebugInfo) + com.google.rpc.DebugInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_DebugInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_DebugInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.DebugInfo.class, com.google.rpc.DebugInfo.Builder.class); + } + + // Construct using com.google.rpc.DebugInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + stackEntries_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + detail_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_DebugInfo_descriptor; + } + + public com.google.rpc.DebugInfo getDefaultInstanceForType() { + return com.google.rpc.DebugInfo.getDefaultInstance(); + } + + public com.google.rpc.DebugInfo build() { + com.google.rpc.DebugInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.DebugInfo buildPartial() { + com.google.rpc.DebugInfo result = new com.google.rpc.DebugInfo(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + stackEntries_ = stackEntries_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.stackEntries_ = stackEntries_; + result.detail_ = detail_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.DebugInfo) { + return mergeFrom((com.google.rpc.DebugInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.DebugInfo other) { + if (other == com.google.rpc.DebugInfo.getDefaultInstance()) return this; + if (!other.stackEntries_.isEmpty()) { + if (stackEntries_.isEmpty()) { + stackEntries_ = other.stackEntries_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureStackEntriesIsMutable(); + stackEntries_.addAll(other.stackEntries_); + } + onChanged(); + } + if (!other.getDetail().isEmpty()) { + detail_ = other.detail_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.DebugInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.DebugInfo) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.LazyStringList stackEntries_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureStackEntriesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + stackEntries_ = new com.google.protobuf.LazyStringArrayList(stackEntries_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated string stack_entries = 1; + * + *
      +     * The stack trace entries indicating where the error occurred.
      +     * 
      + */ + public com.google.protobuf.ProtocolStringList + getStackEntriesList() { + return stackEntries_.getUnmodifiableView(); + } + /** + * repeated string stack_entries = 1; + * + *
      +     * The stack trace entries indicating where the error occurred.
      +     * 
      + */ + public int getStackEntriesCount() { + return stackEntries_.size(); + } + /** + * repeated string stack_entries = 1; + * + *
      +     * The stack trace entries indicating where the error occurred.
      +     * 
      + */ + public java.lang.String getStackEntries(int index) { + return stackEntries_.get(index); + } + /** + * repeated string stack_entries = 1; + * + *
      +     * The stack trace entries indicating where the error occurred.
      +     * 
      + */ + public com.google.protobuf.ByteString + getStackEntriesBytes(int index) { + return stackEntries_.getByteString(index); + } + /** + * repeated string stack_entries = 1; + * + *
      +     * The stack trace entries indicating where the error occurred.
      +     * 
      + */ + public Builder setStackEntries( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureStackEntriesIsMutable(); + stackEntries_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string stack_entries = 1; + * + *
      +     * The stack trace entries indicating where the error occurred.
      +     * 
      + */ + public Builder addStackEntries( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureStackEntriesIsMutable(); + stackEntries_.add(value); + onChanged(); + return this; + } + /** + * repeated string stack_entries = 1; + * + *
      +     * The stack trace entries indicating where the error occurred.
      +     * 
      + */ + public Builder addAllStackEntries( + java.lang.Iterable values) { + ensureStackEntriesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, stackEntries_); + onChanged(); + return this; + } + /** + * repeated string stack_entries = 1; + * + *
      +     * The stack trace entries indicating where the error occurred.
      +     * 
      + */ + public Builder clearStackEntries() { + stackEntries_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * repeated string stack_entries = 1; + * + *
      +     * The stack trace entries indicating where the error occurred.
      +     * 
      + */ + public Builder addStackEntriesBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureStackEntriesIsMutable(); + stackEntries_.add(value); + onChanged(); + return this; + } + + private java.lang.Object detail_ = ""; + /** + * optional string detail = 2; + * + *
      +     * Additional debugging information provided by the server.
      +     * 
      + */ + public java.lang.String getDetail() { + java.lang.Object ref = detail_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + detail_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string detail = 2; + * + *
      +     * Additional debugging information provided by the server.
      +     * 
      + */ + public com.google.protobuf.ByteString + getDetailBytes() { + java.lang.Object ref = detail_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + detail_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string detail = 2; + * + *
      +     * Additional debugging information provided by the server.
      +     * 
      + */ + public Builder setDetail( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + detail_ = value; + onChanged(); + return this; + } + /** + * optional string detail = 2; + * + *
      +     * Additional debugging information provided by the server.
      +     * 
      + */ + public Builder clearDetail() { + + detail_ = getDefaultInstance().getDetail(); + onChanged(); + return this; + } + /** + * optional string detail = 2; + * + *
      +     * Additional debugging information provided by the server.
      +     * 
      + */ + public Builder setDetailBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + detail_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.DebugInfo) + } + + // @@protoc_insertion_point(class_scope:google.rpc.DebugInfo) + private static final com.google.rpc.DebugInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.DebugInfo(); + } + + public static com.google.rpc.DebugInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DebugInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new DebugInfo(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.DebugInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfoOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfoOrBuilder.java new file mode 100644 index 000000000000..25d0e498747a --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfoOrBuilder.java @@ -0,0 +1,62 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +public interface DebugInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.DebugInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated string stack_entries = 1; + * + *
      +   * The stack trace entries indicating where the error occurred.
      +   * 
      + */ + com.google.protobuf.ProtocolStringList + getStackEntriesList(); + /** + * repeated string stack_entries = 1; + * + *
      +   * The stack trace entries indicating where the error occurred.
      +   * 
      + */ + int getStackEntriesCount(); + /** + * repeated string stack_entries = 1; + * + *
      +   * The stack trace entries indicating where the error occurred.
      +   * 
      + */ + java.lang.String getStackEntries(int index); + /** + * repeated string stack_entries = 1; + * + *
      +   * The stack trace entries indicating where the error occurred.
      +   * 
      + */ + com.google.protobuf.ByteString + getStackEntriesBytes(int index); + + /** + * optional string detail = 2; + * + *
      +   * Additional debugging information provided by the server.
      +   * 
      + */ + java.lang.String getDetail(); + /** + * optional string detail = 2; + * + *
      +   * Additional debugging information provided by the server.
      +   * 
      + */ + com.google.protobuf.ByteString + getDetailBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/ErrorDetailsProto.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/ErrorDetailsProto.java new file mode 100644 index 000000000000..1760e0a1d4bf --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/ErrorDetailsProto.java @@ -0,0 +1,167 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +public final class ErrorDetailsProto { + private ErrorDetailsProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_RetryInfo_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_RetryInfo_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_DebugInfo_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_DebugInfo_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_QuotaFailure_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_QuotaFailure_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_QuotaFailure_Violation_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_QuotaFailure_Violation_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_BadRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_BadRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_BadRequest_FieldViolation_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_BadRequest_FieldViolation_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_RequestInfo_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_RequestInfo_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_ResourceInfo_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_ResourceInfo_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_Help_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_Help_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_Help_Link_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_Help_Link_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\036google/rpc/error_details.proto\022\ngoogle" + + ".rpc\032\036google/protobuf/duration.proto\";\n\t" + + "RetryInfo\022.\n\013retry_delay\030\001 \001(\0132\031.google." + + "protobuf.Duration\"2\n\tDebugInfo\022\025\n\rstack_" + + "entries\030\001 \003(\t\022\016\n\006detail\030\002 \001(\t\"y\n\014QuotaFa" + + "ilure\0226\n\nviolations\030\001 \003(\0132\".google.rpc.Q" + + "uotaFailure.Violation\0321\n\tViolation\022\017\n\007su" + + "bject\030\001 \001(\t\022\023\n\013description\030\002 \001(\t\"\203\001\n\nBad" + + "Request\022?\n\020field_violations\030\001 \003(\0132%.goog" + + "le.rpc.BadRequest.FieldViolation\0324\n\016Fiel", + "dViolation\022\r\n\005field\030\001 \001(\t\022\023\n\013description" + + "\030\002 \001(\t\"7\n\013RequestInfo\022\022\n\nrequest_id\030\001 \001(" + + "\t\022\024\n\014serving_data\030\002 \001(\t\"`\n\014ResourceInfo\022" + + "\025\n\rresource_type\030\001 \001(\t\022\025\n\rresource_name\030" + + "\002 \001(\t\022\r\n\005owner\030\003 \001(\t\022\023\n\013description\030\004 \001(" + + "\t\"V\n\004Help\022$\n\005links\030\001 \003(\0132\025.google.rpc.He" + + "lp.Link\032(\n\004Link\022\023\n\013description\030\001 \001(\t\022\013\n\003" + + "url\030\002 \001(\tB%\n\016com.google.rpcB\021ErrorDetail" + + "sProtoP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.DurationProto.getDescriptor(), + }, assigner); + internal_static_google_rpc_RetryInfo_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_rpc_RetryInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_RetryInfo_descriptor, + new java.lang.String[] { "RetryDelay", }); + internal_static_google_rpc_DebugInfo_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_rpc_DebugInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_DebugInfo_descriptor, + new java.lang.String[] { "StackEntries", "Detail", }); + internal_static_google_rpc_QuotaFailure_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_rpc_QuotaFailure_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_QuotaFailure_descriptor, + new java.lang.String[] { "Violations", }); + internal_static_google_rpc_QuotaFailure_Violation_descriptor = + internal_static_google_rpc_QuotaFailure_descriptor.getNestedTypes().get(0); + internal_static_google_rpc_QuotaFailure_Violation_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_QuotaFailure_Violation_descriptor, + new java.lang.String[] { "Subject", "Description", }); + internal_static_google_rpc_BadRequest_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_rpc_BadRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_BadRequest_descriptor, + new java.lang.String[] { "FieldViolations", }); + internal_static_google_rpc_BadRequest_FieldViolation_descriptor = + internal_static_google_rpc_BadRequest_descriptor.getNestedTypes().get(0); + internal_static_google_rpc_BadRequest_FieldViolation_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_BadRequest_FieldViolation_descriptor, + new java.lang.String[] { "Field", "Description", }); + internal_static_google_rpc_RequestInfo_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_rpc_RequestInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_RequestInfo_descriptor, + new java.lang.String[] { "RequestId", "ServingData", }); + internal_static_google_rpc_ResourceInfo_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_rpc_ResourceInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_ResourceInfo_descriptor, + new java.lang.String[] { "ResourceType", "ResourceName", "Owner", "Description", }); + internal_static_google_rpc_Help_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_google_rpc_Help_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_Help_descriptor, + new java.lang.String[] { "Links", }); + internal_static_google_rpc_Help_Link_descriptor = + internal_static_google_rpc_Help_descriptor.getNestedTypes().get(0); + internal_static_google_rpc_Help_Link_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_Help_Link_descriptor, + new java.lang.String[] { "Description", "Url", }); + com.google.protobuf.DurationProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/Help.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/Help.java new file mode 100644 index 000000000000..92fe066f6f78 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/Help.java @@ -0,0 +1,1423 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +/** + * Protobuf type {@code google.rpc.Help} + * + *
      + * Provides links to documentation or for performing an out of band action.
      + * For example, if a quota check failed with an error indicating the calling
      + * project hasn't enabled the accessed service, this can contain a URL pointing
      + * directly to the right place in the developer console to flip the bit.
      + * 
      + */ +public final class Help extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.Help) + HelpOrBuilder { + // Use Help.newBuilder() to construct. + private Help(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Help() { + links_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Help( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + links_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + links_.add(input.readMessage(com.google.rpc.Help.Link.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + links_ = java.util.Collections.unmodifiableList(links_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.Help.class, com.google.rpc.Help.Builder.class); + } + + public interface LinkOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.Help.Link) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string description = 1; + * + *
      +     * Describes what the link offers.
      +     * 
      + */ + java.lang.String getDescription(); + /** + * optional string description = 1; + * + *
      +     * Describes what the link offers.
      +     * 
      + */ + com.google.protobuf.ByteString + getDescriptionBytes(); + + /** + * optional string url = 2; + * + *
      +     * The URL of the link.
      +     * 
      + */ + java.lang.String getUrl(); + /** + * optional string url = 2; + * + *
      +     * The URL of the link.
      +     * 
      + */ + com.google.protobuf.ByteString + getUrlBytes(); + } + /** + * Protobuf type {@code google.rpc.Help.Link} + * + *
      +   * Describes a URL link.
      +   * 
      + */ + public static final class Link extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.Help.Link) + LinkOrBuilder { + // Use Link.newBuilder() to construct. + private Link(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Link() { + description_ = ""; + url_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Link( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + description_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + url_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_Link_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_Link_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.Help.Link.class, com.google.rpc.Help.Link.Builder.class); + } + + public static final int DESCRIPTION_FIELD_NUMBER = 1; + private volatile java.lang.Object description_; + /** + * optional string description = 1; + * + *
      +     * Describes what the link offers.
      +     * 
      + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } + } + /** + * optional string description = 1; + * + *
      +     * Describes what the link offers.
      +     * 
      + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int URL_FIELD_NUMBER = 2; + private volatile java.lang.Object url_; + /** + * optional string url = 2; + * + *
      +     * The URL of the link.
      +     * 
      + */ + public java.lang.String getUrl() { + java.lang.Object ref = url_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + url_ = s; + return s; + } + } + /** + * optional string url = 2; + * + *
      +     * The URL of the link.
      +     * 
      + */ + public com.google.protobuf.ByteString + getUrlBytes() { + java.lang.Object ref = url_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getDescriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, description_); + } + if (!getUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, url_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getDescriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, description_); + } + if (!getUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, url_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.Help.Link parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.Help.Link parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.Help.Link parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.Help.Link parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.Help.Link parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.Help.Link parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.Help.Link parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.Help.Link parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.Help.Link parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.Help.Link parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.Help.Link prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.Help.Link} + * + *
      +     * Describes a URL link.
      +     * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.Help.Link) + com.google.rpc.Help.LinkOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_Link_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_Link_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.Help.Link.class, com.google.rpc.Help.Link.Builder.class); + } + + // Construct using com.google.rpc.Help.Link.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + description_ = ""; + + url_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_Link_descriptor; + } + + public com.google.rpc.Help.Link getDefaultInstanceForType() { + return com.google.rpc.Help.Link.getDefaultInstance(); + } + + public com.google.rpc.Help.Link build() { + com.google.rpc.Help.Link result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.Help.Link buildPartial() { + com.google.rpc.Help.Link result = new com.google.rpc.Help.Link(this); + result.description_ = description_; + result.url_ = url_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.Help.Link) { + return mergeFrom((com.google.rpc.Help.Link)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.Help.Link other) { + if (other == com.google.rpc.Help.Link.getDefaultInstance()) return this; + if (!other.getDescription().isEmpty()) { + description_ = other.description_; + onChanged(); + } + if (!other.getUrl().isEmpty()) { + url_ = other.url_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.Help.Link parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.Help.Link) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object description_ = ""; + /** + * optional string description = 1; + * + *
      +       * Describes what the link offers.
      +       * 
      + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string description = 1; + * + *
      +       * Describes what the link offers.
      +       * 
      + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string description = 1; + * + *
      +       * Describes what the link offers.
      +       * 
      + */ + public Builder setDescription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + description_ = value; + onChanged(); + return this; + } + /** + * optional string description = 1; + * + *
      +       * Describes what the link offers.
      +       * 
      + */ + public Builder clearDescription() { + + description_ = getDefaultInstance().getDescription(); + onChanged(); + return this; + } + /** + * optional string description = 1; + * + *
      +       * Describes what the link offers.
      +       * 
      + */ + public Builder setDescriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + description_ = value; + onChanged(); + return this; + } + + private java.lang.Object url_ = ""; + /** + * optional string url = 2; + * + *
      +       * The URL of the link.
      +       * 
      + */ + public java.lang.String getUrl() { + java.lang.Object ref = url_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + url_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string url = 2; + * + *
      +       * The URL of the link.
      +       * 
      + */ + public com.google.protobuf.ByteString + getUrlBytes() { + java.lang.Object ref = url_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + url_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string url = 2; + * + *
      +       * The URL of the link.
      +       * 
      + */ + public Builder setUrl( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + url_ = value; + onChanged(); + return this; + } + /** + * optional string url = 2; + * + *
      +       * The URL of the link.
      +       * 
      + */ + public Builder clearUrl() { + + url_ = getDefaultInstance().getUrl(); + onChanged(); + return this; + } + /** + * optional string url = 2; + * + *
      +       * The URL of the link.
      +       * 
      + */ + public Builder setUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + url_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.Help.Link) + } + + // @@protoc_insertion_point(class_scope:google.rpc.Help.Link) + private static final com.google.rpc.Help.Link DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.Help.Link(); + } + + public static com.google.rpc.Help.Link getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Link parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Link(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.Help.Link getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int LINKS_FIELD_NUMBER = 1; + private java.util.List links_; + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +   * URL(s) pointing to additional information on handling the current error.
      +   * 
      + */ + public java.util.List getLinksList() { + return links_; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +   * URL(s) pointing to additional information on handling the current error.
      +   * 
      + */ + public java.util.List + getLinksOrBuilderList() { + return links_; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +   * URL(s) pointing to additional information on handling the current error.
      +   * 
      + */ + public int getLinksCount() { + return links_.size(); + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +   * URL(s) pointing to additional information on handling the current error.
      +   * 
      + */ + public com.google.rpc.Help.Link getLinks(int index) { + return links_.get(index); + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +   * URL(s) pointing to additional information on handling the current error.
      +   * 
      + */ + public com.google.rpc.Help.LinkOrBuilder getLinksOrBuilder( + int index) { + return links_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < links_.size(); i++) { + output.writeMessage(1, links_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < links_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, links_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.Help parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.Help parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.Help parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.Help parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.Help parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.Help parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.Help parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.Help parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.Help parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.Help parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.Help prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.Help} + * + *
      +   * Provides links to documentation or for performing an out of band action.
      +   * For example, if a quota check failed with an error indicating the calling
      +   * project hasn't enabled the accessed service, this can contain a URL pointing
      +   * directly to the right place in the developer console to flip the bit.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.Help) + com.google.rpc.HelpOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.Help.class, com.google.rpc.Help.Builder.class); + } + + // Construct using com.google.rpc.Help.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getLinksFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (linksBuilder_ == null) { + links_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + linksBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_descriptor; + } + + public com.google.rpc.Help getDefaultInstanceForType() { + return com.google.rpc.Help.getDefaultInstance(); + } + + public com.google.rpc.Help build() { + com.google.rpc.Help result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.Help buildPartial() { + com.google.rpc.Help result = new com.google.rpc.Help(this); + int from_bitField0_ = bitField0_; + if (linksBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + links_ = java.util.Collections.unmodifiableList(links_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.links_ = links_; + } else { + result.links_ = linksBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.Help) { + return mergeFrom((com.google.rpc.Help)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.Help other) { + if (other == com.google.rpc.Help.getDefaultInstance()) return this; + if (linksBuilder_ == null) { + if (!other.links_.isEmpty()) { + if (links_.isEmpty()) { + links_ = other.links_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureLinksIsMutable(); + links_.addAll(other.links_); + } + onChanged(); + } + } else { + if (!other.links_.isEmpty()) { + if (linksBuilder_.isEmpty()) { + linksBuilder_.dispose(); + linksBuilder_ = null; + links_ = other.links_; + bitField0_ = (bitField0_ & ~0x00000001); + linksBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getLinksFieldBuilder() : null; + } else { + linksBuilder_.addAllMessages(other.links_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.Help parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.Help) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List links_ = + java.util.Collections.emptyList(); + private void ensureLinksIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + links_ = new java.util.ArrayList(links_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.Help.Link, com.google.rpc.Help.Link.Builder, com.google.rpc.Help.LinkOrBuilder> linksBuilder_; + + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public java.util.List getLinksList() { + if (linksBuilder_ == null) { + return java.util.Collections.unmodifiableList(links_); + } else { + return linksBuilder_.getMessageList(); + } + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public int getLinksCount() { + if (linksBuilder_ == null) { + return links_.size(); + } else { + return linksBuilder_.getCount(); + } + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public com.google.rpc.Help.Link getLinks(int index) { + if (linksBuilder_ == null) { + return links_.get(index); + } else { + return linksBuilder_.getMessage(index); + } + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public Builder setLinks( + int index, com.google.rpc.Help.Link value) { + if (linksBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLinksIsMutable(); + links_.set(index, value); + onChanged(); + } else { + linksBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public Builder setLinks( + int index, com.google.rpc.Help.Link.Builder builderForValue) { + if (linksBuilder_ == null) { + ensureLinksIsMutable(); + links_.set(index, builderForValue.build()); + onChanged(); + } else { + linksBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public Builder addLinks(com.google.rpc.Help.Link value) { + if (linksBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLinksIsMutable(); + links_.add(value); + onChanged(); + } else { + linksBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public Builder addLinks( + int index, com.google.rpc.Help.Link value) { + if (linksBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLinksIsMutable(); + links_.add(index, value); + onChanged(); + } else { + linksBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public Builder addLinks( + com.google.rpc.Help.Link.Builder builderForValue) { + if (linksBuilder_ == null) { + ensureLinksIsMutable(); + links_.add(builderForValue.build()); + onChanged(); + } else { + linksBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public Builder addLinks( + int index, com.google.rpc.Help.Link.Builder builderForValue) { + if (linksBuilder_ == null) { + ensureLinksIsMutable(); + links_.add(index, builderForValue.build()); + onChanged(); + } else { + linksBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public Builder addAllLinks( + java.lang.Iterable values) { + if (linksBuilder_ == null) { + ensureLinksIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, links_); + onChanged(); + } else { + linksBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public Builder clearLinks() { + if (linksBuilder_ == null) { + links_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + linksBuilder_.clear(); + } + return this; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public Builder removeLinks(int index) { + if (linksBuilder_ == null) { + ensureLinksIsMutable(); + links_.remove(index); + onChanged(); + } else { + linksBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public com.google.rpc.Help.Link.Builder getLinksBuilder( + int index) { + return getLinksFieldBuilder().getBuilder(index); + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public com.google.rpc.Help.LinkOrBuilder getLinksOrBuilder( + int index) { + if (linksBuilder_ == null) { + return links_.get(index); } else { + return linksBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public java.util.List + getLinksOrBuilderList() { + if (linksBuilder_ != null) { + return linksBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(links_); + } + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public com.google.rpc.Help.Link.Builder addLinksBuilder() { + return getLinksFieldBuilder().addBuilder( + com.google.rpc.Help.Link.getDefaultInstance()); + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public com.google.rpc.Help.Link.Builder addLinksBuilder( + int index) { + return getLinksFieldBuilder().addBuilder( + index, com.google.rpc.Help.Link.getDefaultInstance()); + } + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +     * URL(s) pointing to additional information on handling the current error.
      +     * 
      + */ + public java.util.List + getLinksBuilderList() { + return getLinksFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.Help.Link, com.google.rpc.Help.Link.Builder, com.google.rpc.Help.LinkOrBuilder> + getLinksFieldBuilder() { + if (linksBuilder_ == null) { + linksBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.Help.Link, com.google.rpc.Help.Link.Builder, com.google.rpc.Help.LinkOrBuilder>( + links_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + links_ = null; + } + return linksBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.Help) + } + + // @@protoc_insertion_point(class_scope:google.rpc.Help) + private static final com.google.rpc.Help DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.Help(); + } + + public static com.google.rpc.Help getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Help parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Help(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.Help getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/HelpOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/HelpOrBuilder.java new file mode 100644 index 000000000000..ffaca8109020 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/HelpOrBuilder.java @@ -0,0 +1,53 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +public interface HelpOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.Help) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +   * URL(s) pointing to additional information on handling the current error.
      +   * 
      + */ + java.util.List + getLinksList(); + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +   * URL(s) pointing to additional information on handling the current error.
      +   * 
      + */ + com.google.rpc.Help.Link getLinks(int index); + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +   * URL(s) pointing to additional information on handling the current error.
      +   * 
      + */ + int getLinksCount(); + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +   * URL(s) pointing to additional information on handling the current error.
      +   * 
      + */ + java.util.List + getLinksOrBuilderList(); + /** + * repeated .google.rpc.Help.Link links = 1; + * + *
      +   * URL(s) pointing to additional information on handling the current error.
      +   * 
      + */ + com.google.rpc.Help.LinkOrBuilder getLinksOrBuilder( + int index); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailure.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailure.java new file mode 100644 index 000000000000..3051a2773fbb --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailure.java @@ -0,0 +1,1498 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +/** + * Protobuf type {@code google.rpc.QuotaFailure} + * + *
      + * Describes how a quota check failed.
      + * For example if a daily limit was exceeded for the calling project,
      + * a service could respond with a QuotaFailure detail containing the project
      + * id and the description of the quota limit that was exceeded.  If the
      + * calling project hasn't enabled the service in the developer console, then
      + * a service could respond with the project id and set `service_disabled`
      + * to true.
      + * Also see RetryDetail and Help types for other details about handling a
      + * quota failure.
      + * 
      + */ +public final class QuotaFailure extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.QuotaFailure) + QuotaFailureOrBuilder { + // Use QuotaFailure.newBuilder() to construct. + private QuotaFailure(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private QuotaFailure() { + violations_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private QuotaFailure( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + violations_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + violations_.add(input.readMessage(com.google.rpc.QuotaFailure.Violation.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + violations_ = java.util.Collections.unmodifiableList(violations_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.QuotaFailure.class, com.google.rpc.QuotaFailure.Builder.class); + } + + public interface ViolationOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.QuotaFailure.Violation) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string subject = 1; + * + *
      +     * The subject on which the quota check failed.
      +     * For example, "clientip:<ip address of client>" or "project:<Google
      +     * developer project id>".
      +     * 
      + */ + java.lang.String getSubject(); + /** + * optional string subject = 1; + * + *
      +     * The subject on which the quota check failed.
      +     * For example, "clientip:<ip address of client>" or "project:<Google
      +     * developer project id>".
      +     * 
      + */ + com.google.protobuf.ByteString + getSubjectBytes(); + + /** + * optional string description = 2; + * + *
      +     * A description of how the quota check failed. Clients can use this
      +     * description to find more about the quota configuration in the service's
      +     * public documentation, or find the relevant quota limit to adjust through
      +     * developer console.
      +     * For example: "Service disabled" or "Daily Limit for read operations
      +     * exceeded".
      +     * 
      + */ + java.lang.String getDescription(); + /** + * optional string description = 2; + * + *
      +     * A description of how the quota check failed. Clients can use this
      +     * description to find more about the quota configuration in the service's
      +     * public documentation, or find the relevant quota limit to adjust through
      +     * developer console.
      +     * For example: "Service disabled" or "Daily Limit for read operations
      +     * exceeded".
      +     * 
      + */ + com.google.protobuf.ByteString + getDescriptionBytes(); + } + /** + * Protobuf type {@code google.rpc.QuotaFailure.Violation} + * + *
      +   * A message type used to describe a single quota violation.  For example, a
      +   * daily quota or a custom quota that was exceeded.
      +   * 
      + */ + public static final class Violation extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.QuotaFailure.Violation) + ViolationOrBuilder { + // Use Violation.newBuilder() to construct. + private Violation(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Violation() { + subject_ = ""; + description_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Violation( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + subject_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + description_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_Violation_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_Violation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.QuotaFailure.Violation.class, com.google.rpc.QuotaFailure.Violation.Builder.class); + } + + public static final int SUBJECT_FIELD_NUMBER = 1; + private volatile java.lang.Object subject_; + /** + * optional string subject = 1; + * + *
      +     * The subject on which the quota check failed.
      +     * For example, "clientip:<ip address of client>" or "project:<Google
      +     * developer project id>".
      +     * 
      + */ + public java.lang.String getSubject() { + java.lang.Object ref = subject_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subject_ = s; + return s; + } + } + /** + * optional string subject = 1; + * + *
      +     * The subject on which the quota check failed.
      +     * For example, "clientip:<ip address of client>" or "project:<Google
      +     * developer project id>".
      +     * 
      + */ + public com.google.protobuf.ByteString + getSubjectBytes() { + java.lang.Object ref = subject_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subject_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DESCRIPTION_FIELD_NUMBER = 2; + private volatile java.lang.Object description_; + /** + * optional string description = 2; + * + *
      +     * A description of how the quota check failed. Clients can use this
      +     * description to find more about the quota configuration in the service's
      +     * public documentation, or find the relevant quota limit to adjust through
      +     * developer console.
      +     * For example: "Service disabled" or "Daily Limit for read operations
      +     * exceeded".
      +     * 
      + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } + } + /** + * optional string description = 2; + * + *
      +     * A description of how the quota check failed. Clients can use this
      +     * description to find more about the quota configuration in the service's
      +     * public documentation, or find the relevant quota limit to adjust through
      +     * developer console.
      +     * For example: "Service disabled" or "Daily Limit for read operations
      +     * exceeded".
      +     * 
      + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSubjectBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, subject_); + } + if (!getDescriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, description_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSubjectBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subject_); + } + if (!getDescriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, description_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.QuotaFailure.Violation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.QuotaFailure.Violation parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.QuotaFailure.Violation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.QuotaFailure.Violation parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.QuotaFailure.Violation parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.QuotaFailure.Violation parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.QuotaFailure.Violation parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.QuotaFailure.Violation parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.QuotaFailure.Violation parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.QuotaFailure.Violation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.QuotaFailure.Violation prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.QuotaFailure.Violation} + * + *
      +     * A message type used to describe a single quota violation.  For example, a
      +     * daily quota or a custom quota that was exceeded.
      +     * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.QuotaFailure.Violation) + com.google.rpc.QuotaFailure.ViolationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_Violation_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_Violation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.QuotaFailure.Violation.class, com.google.rpc.QuotaFailure.Violation.Builder.class); + } + + // Construct using com.google.rpc.QuotaFailure.Violation.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + subject_ = ""; + + description_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_Violation_descriptor; + } + + public com.google.rpc.QuotaFailure.Violation getDefaultInstanceForType() { + return com.google.rpc.QuotaFailure.Violation.getDefaultInstance(); + } + + public com.google.rpc.QuotaFailure.Violation build() { + com.google.rpc.QuotaFailure.Violation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.QuotaFailure.Violation buildPartial() { + com.google.rpc.QuotaFailure.Violation result = new com.google.rpc.QuotaFailure.Violation(this); + result.subject_ = subject_; + result.description_ = description_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.QuotaFailure.Violation) { + return mergeFrom((com.google.rpc.QuotaFailure.Violation)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.QuotaFailure.Violation other) { + if (other == com.google.rpc.QuotaFailure.Violation.getDefaultInstance()) return this; + if (!other.getSubject().isEmpty()) { + subject_ = other.subject_; + onChanged(); + } + if (!other.getDescription().isEmpty()) { + description_ = other.description_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.QuotaFailure.Violation parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.QuotaFailure.Violation) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object subject_ = ""; + /** + * optional string subject = 1; + * + *
      +       * The subject on which the quota check failed.
      +       * For example, "clientip:<ip address of client>" or "project:<Google
      +       * developer project id>".
      +       * 
      + */ + public java.lang.String getSubject() { + java.lang.Object ref = subject_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subject_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string subject = 1; + * + *
      +       * The subject on which the quota check failed.
      +       * For example, "clientip:<ip address of client>" or "project:<Google
      +       * developer project id>".
      +       * 
      + */ + public com.google.protobuf.ByteString + getSubjectBytes() { + java.lang.Object ref = subject_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subject_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string subject = 1; + * + *
      +       * The subject on which the quota check failed.
      +       * For example, "clientip:<ip address of client>" or "project:<Google
      +       * developer project id>".
      +       * 
      + */ + public Builder setSubject( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + subject_ = value; + onChanged(); + return this; + } + /** + * optional string subject = 1; + * + *
      +       * The subject on which the quota check failed.
      +       * For example, "clientip:<ip address of client>" or "project:<Google
      +       * developer project id>".
      +       * 
      + */ + public Builder clearSubject() { + + subject_ = getDefaultInstance().getSubject(); + onChanged(); + return this; + } + /** + * optional string subject = 1; + * + *
      +       * The subject on which the quota check failed.
      +       * For example, "clientip:<ip address of client>" or "project:<Google
      +       * developer project id>".
      +       * 
      + */ + public Builder setSubjectBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + subject_ = value; + onChanged(); + return this; + } + + private java.lang.Object description_ = ""; + /** + * optional string description = 2; + * + *
      +       * A description of how the quota check failed. Clients can use this
      +       * description to find more about the quota configuration in the service's
      +       * public documentation, or find the relevant quota limit to adjust through
      +       * developer console.
      +       * For example: "Service disabled" or "Daily Limit for read operations
      +       * exceeded".
      +       * 
      + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string description = 2; + * + *
      +       * A description of how the quota check failed. Clients can use this
      +       * description to find more about the quota configuration in the service's
      +       * public documentation, or find the relevant quota limit to adjust through
      +       * developer console.
      +       * For example: "Service disabled" or "Daily Limit for read operations
      +       * exceeded".
      +       * 
      + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string description = 2; + * + *
      +       * A description of how the quota check failed. Clients can use this
      +       * description to find more about the quota configuration in the service's
      +       * public documentation, or find the relevant quota limit to adjust through
      +       * developer console.
      +       * For example: "Service disabled" or "Daily Limit for read operations
      +       * exceeded".
      +       * 
      + */ + public Builder setDescription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + description_ = value; + onChanged(); + return this; + } + /** + * optional string description = 2; + * + *
      +       * A description of how the quota check failed. Clients can use this
      +       * description to find more about the quota configuration in the service's
      +       * public documentation, or find the relevant quota limit to adjust through
      +       * developer console.
      +       * For example: "Service disabled" or "Daily Limit for read operations
      +       * exceeded".
      +       * 
      + */ + public Builder clearDescription() { + + description_ = getDefaultInstance().getDescription(); + onChanged(); + return this; + } + /** + * optional string description = 2; + * + *
      +       * A description of how the quota check failed. Clients can use this
      +       * description to find more about the quota configuration in the service's
      +       * public documentation, or find the relevant quota limit to adjust through
      +       * developer console.
      +       * For example: "Service disabled" or "Daily Limit for read operations
      +       * exceeded".
      +       * 
      + */ + public Builder setDescriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + description_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.QuotaFailure.Violation) + } + + // @@protoc_insertion_point(class_scope:google.rpc.QuotaFailure.Violation) + private static final com.google.rpc.QuotaFailure.Violation DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.QuotaFailure.Violation(); + } + + public static com.google.rpc.QuotaFailure.Violation getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Violation parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Violation(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.QuotaFailure.Violation getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int VIOLATIONS_FIELD_NUMBER = 1; + private java.util.List violations_; + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +   * Describes all quota violations.
      +   * 
      + */ + public java.util.List getViolationsList() { + return violations_; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +   * Describes all quota violations.
      +   * 
      + */ + public java.util.List + getViolationsOrBuilderList() { + return violations_; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +   * Describes all quota violations.
      +   * 
      + */ + public int getViolationsCount() { + return violations_.size(); + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +   * Describes all quota violations.
      +   * 
      + */ + public com.google.rpc.QuotaFailure.Violation getViolations(int index) { + return violations_.get(index); + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +   * Describes all quota violations.
      +   * 
      + */ + public com.google.rpc.QuotaFailure.ViolationOrBuilder getViolationsOrBuilder( + int index) { + return violations_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < violations_.size(); i++) { + output.writeMessage(1, violations_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < violations_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, violations_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.QuotaFailure parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.QuotaFailure parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.QuotaFailure parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.QuotaFailure parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.QuotaFailure parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.QuotaFailure parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.QuotaFailure parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.QuotaFailure parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.QuotaFailure parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.QuotaFailure parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.QuotaFailure prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.QuotaFailure} + * + *
      +   * Describes how a quota check failed.
      +   * For example if a daily limit was exceeded for the calling project,
      +   * a service could respond with a QuotaFailure detail containing the project
      +   * id and the description of the quota limit that was exceeded.  If the
      +   * calling project hasn't enabled the service in the developer console, then
      +   * a service could respond with the project id and set `service_disabled`
      +   * to true.
      +   * Also see RetryDetail and Help types for other details about handling a
      +   * quota failure.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.QuotaFailure) + com.google.rpc.QuotaFailureOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.QuotaFailure.class, com.google.rpc.QuotaFailure.Builder.class); + } + + // Construct using com.google.rpc.QuotaFailure.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getViolationsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (violationsBuilder_ == null) { + violations_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + violationsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_descriptor; + } + + public com.google.rpc.QuotaFailure getDefaultInstanceForType() { + return com.google.rpc.QuotaFailure.getDefaultInstance(); + } + + public com.google.rpc.QuotaFailure build() { + com.google.rpc.QuotaFailure result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.QuotaFailure buildPartial() { + com.google.rpc.QuotaFailure result = new com.google.rpc.QuotaFailure(this); + int from_bitField0_ = bitField0_; + if (violationsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + violations_ = java.util.Collections.unmodifiableList(violations_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.violations_ = violations_; + } else { + result.violations_ = violationsBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.QuotaFailure) { + return mergeFrom((com.google.rpc.QuotaFailure)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.QuotaFailure other) { + if (other == com.google.rpc.QuotaFailure.getDefaultInstance()) return this; + if (violationsBuilder_ == null) { + if (!other.violations_.isEmpty()) { + if (violations_.isEmpty()) { + violations_ = other.violations_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureViolationsIsMutable(); + violations_.addAll(other.violations_); + } + onChanged(); + } + } else { + if (!other.violations_.isEmpty()) { + if (violationsBuilder_.isEmpty()) { + violationsBuilder_.dispose(); + violationsBuilder_ = null; + violations_ = other.violations_; + bitField0_ = (bitField0_ & ~0x00000001); + violationsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getViolationsFieldBuilder() : null; + } else { + violationsBuilder_.addAllMessages(other.violations_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.QuotaFailure parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.QuotaFailure) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List violations_ = + java.util.Collections.emptyList(); + private void ensureViolationsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + violations_ = new java.util.ArrayList(violations_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.QuotaFailure.Violation, com.google.rpc.QuotaFailure.Violation.Builder, com.google.rpc.QuotaFailure.ViolationOrBuilder> violationsBuilder_; + + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public java.util.List getViolationsList() { + if (violationsBuilder_ == null) { + return java.util.Collections.unmodifiableList(violations_); + } else { + return violationsBuilder_.getMessageList(); + } + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public int getViolationsCount() { + if (violationsBuilder_ == null) { + return violations_.size(); + } else { + return violationsBuilder_.getCount(); + } + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public com.google.rpc.QuotaFailure.Violation getViolations(int index) { + if (violationsBuilder_ == null) { + return violations_.get(index); + } else { + return violationsBuilder_.getMessage(index); + } + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public Builder setViolations( + int index, com.google.rpc.QuotaFailure.Violation value) { + if (violationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureViolationsIsMutable(); + violations_.set(index, value); + onChanged(); + } else { + violationsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public Builder setViolations( + int index, com.google.rpc.QuotaFailure.Violation.Builder builderForValue) { + if (violationsBuilder_ == null) { + ensureViolationsIsMutable(); + violations_.set(index, builderForValue.build()); + onChanged(); + } else { + violationsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public Builder addViolations(com.google.rpc.QuotaFailure.Violation value) { + if (violationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureViolationsIsMutable(); + violations_.add(value); + onChanged(); + } else { + violationsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public Builder addViolations( + int index, com.google.rpc.QuotaFailure.Violation value) { + if (violationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureViolationsIsMutable(); + violations_.add(index, value); + onChanged(); + } else { + violationsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public Builder addViolations( + com.google.rpc.QuotaFailure.Violation.Builder builderForValue) { + if (violationsBuilder_ == null) { + ensureViolationsIsMutable(); + violations_.add(builderForValue.build()); + onChanged(); + } else { + violationsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public Builder addViolations( + int index, com.google.rpc.QuotaFailure.Violation.Builder builderForValue) { + if (violationsBuilder_ == null) { + ensureViolationsIsMutable(); + violations_.add(index, builderForValue.build()); + onChanged(); + } else { + violationsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public Builder addAllViolations( + java.lang.Iterable values) { + if (violationsBuilder_ == null) { + ensureViolationsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, violations_); + onChanged(); + } else { + violationsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public Builder clearViolations() { + if (violationsBuilder_ == null) { + violations_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + violationsBuilder_.clear(); + } + return this; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public Builder removeViolations(int index) { + if (violationsBuilder_ == null) { + ensureViolationsIsMutable(); + violations_.remove(index); + onChanged(); + } else { + violationsBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public com.google.rpc.QuotaFailure.Violation.Builder getViolationsBuilder( + int index) { + return getViolationsFieldBuilder().getBuilder(index); + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public com.google.rpc.QuotaFailure.ViolationOrBuilder getViolationsOrBuilder( + int index) { + if (violationsBuilder_ == null) { + return violations_.get(index); } else { + return violationsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public java.util.List + getViolationsOrBuilderList() { + if (violationsBuilder_ != null) { + return violationsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(violations_); + } + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public com.google.rpc.QuotaFailure.Violation.Builder addViolationsBuilder() { + return getViolationsFieldBuilder().addBuilder( + com.google.rpc.QuotaFailure.Violation.getDefaultInstance()); + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public com.google.rpc.QuotaFailure.Violation.Builder addViolationsBuilder( + int index) { + return getViolationsFieldBuilder().addBuilder( + index, com.google.rpc.QuotaFailure.Violation.getDefaultInstance()); + } + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +     * Describes all quota violations.
      +     * 
      + */ + public java.util.List + getViolationsBuilderList() { + return getViolationsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.QuotaFailure.Violation, com.google.rpc.QuotaFailure.Violation.Builder, com.google.rpc.QuotaFailure.ViolationOrBuilder> + getViolationsFieldBuilder() { + if (violationsBuilder_ == null) { + violationsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.QuotaFailure.Violation, com.google.rpc.QuotaFailure.Violation.Builder, com.google.rpc.QuotaFailure.ViolationOrBuilder>( + violations_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + violations_ = null; + } + return violationsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.QuotaFailure) + } + + // @@protoc_insertion_point(class_scope:google.rpc.QuotaFailure) + private static final com.google.rpc.QuotaFailure DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.QuotaFailure(); + } + + public static com.google.rpc.QuotaFailure getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public QuotaFailure parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new QuotaFailure(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.QuotaFailure getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailureOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailureOrBuilder.java new file mode 100644 index 000000000000..e586659760de --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailureOrBuilder.java @@ -0,0 +1,53 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +public interface QuotaFailureOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.QuotaFailure) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +   * Describes all quota violations.
      +   * 
      + */ + java.util.List + getViolationsList(); + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +   * Describes all quota violations.
      +   * 
      + */ + com.google.rpc.QuotaFailure.Violation getViolations(int index); + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +   * Describes all quota violations.
      +   * 
      + */ + int getViolationsCount(); + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +   * Describes all quota violations.
      +   * 
      + */ + java.util.List + getViolationsOrBuilderList(); + /** + * repeated .google.rpc.QuotaFailure.Violation violations = 1; + * + *
      +   * Describes all quota violations.
      +   * 
      + */ + com.google.rpc.QuotaFailure.ViolationOrBuilder getViolationsOrBuilder( + int index); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfo.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfo.java new file mode 100644 index 000000000000..1654fd4aaab8 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfo.java @@ -0,0 +1,643 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +/** + * Protobuf type {@code google.rpc.RequestInfo} + * + *
      + * Contains metadata about the request that clients can attach when filing a bug
      + * or providing other forms of feedback.
      + * 
      + */ +public final class RequestInfo extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.RequestInfo) + RequestInfoOrBuilder { + // Use RequestInfo.newBuilder() to construct. + private RequestInfo(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private RequestInfo() { + requestId_ = ""; + servingData_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private RequestInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + requestId_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + servingData_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RequestInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RequestInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.RequestInfo.class, com.google.rpc.RequestInfo.Builder.class); + } + + public static final int REQUEST_ID_FIELD_NUMBER = 1; + private volatile java.lang.Object requestId_; + /** + * optional string request_id = 1; + * + *
      +   * An opaque string that should only be interpreted by the service generating
      +   * it. For example, it can be used to identify requests in the service's logs.
      +   * 
      + */ + public java.lang.String getRequestId() { + java.lang.Object ref = requestId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + requestId_ = s; + return s; + } + } + /** + * optional string request_id = 1; + * + *
      +   * An opaque string that should only be interpreted by the service generating
      +   * it. For example, it can be used to identify requests in the service's logs.
      +   * 
      + */ + public com.google.protobuf.ByteString + getRequestIdBytes() { + java.lang.Object ref = requestId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + requestId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SERVING_DATA_FIELD_NUMBER = 2; + private volatile java.lang.Object servingData_; + /** + * optional string serving_data = 2; + * + *
      +   * Any data that was used to serve this request. For example, an encrypted
      +   * stack trace that can be sent back to the service provider for debugging.
      +   * 
      + */ + public java.lang.String getServingData() { + java.lang.Object ref = servingData_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + servingData_ = s; + return s; + } + } + /** + * optional string serving_data = 2; + * + *
      +   * Any data that was used to serve this request. For example, an encrypted
      +   * stack trace that can be sent back to the service provider for debugging.
      +   * 
      + */ + public com.google.protobuf.ByteString + getServingDataBytes() { + java.lang.Object ref = servingData_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + servingData_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getRequestIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, requestId_); + } + if (!getServingDataBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, servingData_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getRequestIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, requestId_); + } + if (!getServingDataBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, servingData_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.RequestInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.RequestInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.RequestInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.RequestInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.RequestInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.RequestInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.RequestInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.RequestInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.RequestInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.RequestInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.RequestInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.RequestInfo} + * + *
      +   * Contains metadata about the request that clients can attach when filing a bug
      +   * or providing other forms of feedback.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.RequestInfo) + com.google.rpc.RequestInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RequestInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RequestInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.RequestInfo.class, com.google.rpc.RequestInfo.Builder.class); + } + + // Construct using com.google.rpc.RequestInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + requestId_ = ""; + + servingData_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RequestInfo_descriptor; + } + + public com.google.rpc.RequestInfo getDefaultInstanceForType() { + return com.google.rpc.RequestInfo.getDefaultInstance(); + } + + public com.google.rpc.RequestInfo build() { + com.google.rpc.RequestInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.RequestInfo buildPartial() { + com.google.rpc.RequestInfo result = new com.google.rpc.RequestInfo(this); + result.requestId_ = requestId_; + result.servingData_ = servingData_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.RequestInfo) { + return mergeFrom((com.google.rpc.RequestInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.RequestInfo other) { + if (other == com.google.rpc.RequestInfo.getDefaultInstance()) return this; + if (!other.getRequestId().isEmpty()) { + requestId_ = other.requestId_; + onChanged(); + } + if (!other.getServingData().isEmpty()) { + servingData_ = other.servingData_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.RequestInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.RequestInfo) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object requestId_ = ""; + /** + * optional string request_id = 1; + * + *
      +     * An opaque string that should only be interpreted by the service generating
      +     * it. For example, it can be used to identify requests in the service's logs.
      +     * 
      + */ + public java.lang.String getRequestId() { + java.lang.Object ref = requestId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + requestId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string request_id = 1; + * + *
      +     * An opaque string that should only be interpreted by the service generating
      +     * it. For example, it can be used to identify requests in the service's logs.
      +     * 
      + */ + public com.google.protobuf.ByteString + getRequestIdBytes() { + java.lang.Object ref = requestId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + requestId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string request_id = 1; + * + *
      +     * An opaque string that should only be interpreted by the service generating
      +     * it. For example, it can be used to identify requests in the service's logs.
      +     * 
      + */ + public Builder setRequestId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + requestId_ = value; + onChanged(); + return this; + } + /** + * optional string request_id = 1; + * + *
      +     * An opaque string that should only be interpreted by the service generating
      +     * it. For example, it can be used to identify requests in the service's logs.
      +     * 
      + */ + public Builder clearRequestId() { + + requestId_ = getDefaultInstance().getRequestId(); + onChanged(); + return this; + } + /** + * optional string request_id = 1; + * + *
      +     * An opaque string that should only be interpreted by the service generating
      +     * it. For example, it can be used to identify requests in the service's logs.
      +     * 
      + */ + public Builder setRequestIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + requestId_ = value; + onChanged(); + return this; + } + + private java.lang.Object servingData_ = ""; + /** + * optional string serving_data = 2; + * + *
      +     * Any data that was used to serve this request. For example, an encrypted
      +     * stack trace that can be sent back to the service provider for debugging.
      +     * 
      + */ + public java.lang.String getServingData() { + java.lang.Object ref = servingData_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + servingData_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string serving_data = 2; + * + *
      +     * Any data that was used to serve this request. For example, an encrypted
      +     * stack trace that can be sent back to the service provider for debugging.
      +     * 
      + */ + public com.google.protobuf.ByteString + getServingDataBytes() { + java.lang.Object ref = servingData_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + servingData_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string serving_data = 2; + * + *
      +     * Any data that was used to serve this request. For example, an encrypted
      +     * stack trace that can be sent back to the service provider for debugging.
      +     * 
      + */ + public Builder setServingData( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + servingData_ = value; + onChanged(); + return this; + } + /** + * optional string serving_data = 2; + * + *
      +     * Any data that was used to serve this request. For example, an encrypted
      +     * stack trace that can be sent back to the service provider for debugging.
      +     * 
      + */ + public Builder clearServingData() { + + servingData_ = getDefaultInstance().getServingData(); + onChanged(); + return this; + } + /** + * optional string serving_data = 2; + * + *
      +     * Any data that was used to serve this request. For example, an encrypted
      +     * stack trace that can be sent back to the service provider for debugging.
      +     * 
      + */ + public Builder setServingDataBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + servingData_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.RequestInfo) + } + + // @@protoc_insertion_point(class_scope:google.rpc.RequestInfo) + private static final com.google.rpc.RequestInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.RequestInfo(); + } + + public static com.google.rpc.RequestInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public RequestInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new RequestInfo(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.RequestInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfoOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfoOrBuilder.java new file mode 100644 index 000000000000..94ad03b0f1c9 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfoOrBuilder.java @@ -0,0 +1,49 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +public interface RequestInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.RequestInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string request_id = 1; + * + *
      +   * An opaque string that should only be interpreted by the service generating
      +   * it. For example, it can be used to identify requests in the service's logs.
      +   * 
      + */ + java.lang.String getRequestId(); + /** + * optional string request_id = 1; + * + *
      +   * An opaque string that should only be interpreted by the service generating
      +   * it. For example, it can be used to identify requests in the service's logs.
      +   * 
      + */ + com.google.protobuf.ByteString + getRequestIdBytes(); + + /** + * optional string serving_data = 2; + * + *
      +   * Any data that was used to serve this request. For example, an encrypted
      +   * stack trace that can be sent back to the service provider for debugging.
      +   * 
      + */ + java.lang.String getServingData(); + /** + * optional string serving_data = 2; + * + *
      +   * Any data that was used to serve this request. For example, an encrypted
      +   * stack trace that can be sent back to the service provider for debugging.
      +   * 
      + */ + com.google.protobuf.ByteString + getServingDataBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfo.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfo.java new file mode 100644 index 000000000000..9e69a569483e --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfo.java @@ -0,0 +1,985 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +/** + * Protobuf type {@code google.rpc.ResourceInfo} + * + *
      + * Describes the resource that is being accessed.
      + * 
      + */ +public final class ResourceInfo extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.ResourceInfo) + ResourceInfoOrBuilder { + // Use ResourceInfo.newBuilder() to construct. + private ResourceInfo(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ResourceInfo() { + resourceType_ = ""; + resourceName_ = ""; + owner_ = ""; + description_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ResourceInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + resourceType_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + resourceName_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + owner_ = s; + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + + description_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_ResourceInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_ResourceInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.ResourceInfo.class, com.google.rpc.ResourceInfo.Builder.class); + } + + public static final int RESOURCE_TYPE_FIELD_NUMBER = 1; + private volatile java.lang.Object resourceType_; + /** + * optional string resource_type = 1; + * + *
      +   * A name for the type of resource being accessed, e.g. "sql table",
      +   * "cloud storage bucket", "file", "Google calendar"; or the type URL
      +   * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      +   * 
      + */ + public java.lang.String getResourceType() { + java.lang.Object ref = resourceType_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + resourceType_ = s; + return s; + } + } + /** + * optional string resource_type = 1; + * + *
      +   * A name for the type of resource being accessed, e.g. "sql table",
      +   * "cloud storage bucket", "file", "Google calendar"; or the type URL
      +   * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      +   * 
      + */ + public com.google.protobuf.ByteString + getResourceTypeBytes() { + java.lang.Object ref = resourceType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + resourceType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESOURCE_NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object resourceName_; + /** + * optional string resource_name = 2; + * + *
      +   * The name of the resource being accessed.  For example, a shared calendar
      +   * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      +   * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      +   * 
      + */ + public java.lang.String getResourceName() { + java.lang.Object ref = resourceName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + resourceName_ = s; + return s; + } + } + /** + * optional string resource_name = 2; + * + *
      +   * The name of the resource being accessed.  For example, a shared calendar
      +   * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      +   * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      +   * 
      + */ + public com.google.protobuf.ByteString + getResourceNameBytes() { + java.lang.Object ref = resourceName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + resourceName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int OWNER_FIELD_NUMBER = 3; + private volatile java.lang.Object owner_; + /** + * optional string owner = 3; + * + *
      +   * The owner of the resource (optional).
      +   * For example, "user:<owner email>" or "project:<Google developer project
      +   * id>".
      +   * 
      + */ + public java.lang.String getOwner() { + java.lang.Object ref = owner_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + owner_ = s; + return s; + } + } + /** + * optional string owner = 3; + * + *
      +   * The owner of the resource (optional).
      +   * For example, "user:<owner email>" or "project:<Google developer project
      +   * id>".
      +   * 
      + */ + public com.google.protobuf.ByteString + getOwnerBytes() { + java.lang.Object ref = owner_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + owner_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DESCRIPTION_FIELD_NUMBER = 4; + private volatile java.lang.Object description_; + /** + * optional string description = 4; + * + *
      +   * Describes what error is encountered when accessing this resource.
      +   * For example, updating a cloud project may require the `writer` permission
      +   * on the developer console project.
      +   * 
      + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } + } + /** + * optional string description = 4; + * + *
      +   * Describes what error is encountered when accessing this resource.
      +   * For example, updating a cloud project may require the `writer` permission
      +   * on the developer console project.
      +   * 
      + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getResourceTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, resourceType_); + } + if (!getResourceNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, resourceName_); + } + if (!getOwnerBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, owner_); + } + if (!getDescriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, description_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getResourceTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, resourceType_); + } + if (!getResourceNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, resourceName_); + } + if (!getOwnerBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, owner_); + } + if (!getDescriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, description_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.ResourceInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.ResourceInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.ResourceInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.ResourceInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.ResourceInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.ResourceInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.ResourceInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.ResourceInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.ResourceInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.ResourceInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.ResourceInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.ResourceInfo} + * + *
      +   * Describes the resource that is being accessed.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.ResourceInfo) + com.google.rpc.ResourceInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_ResourceInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_ResourceInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.ResourceInfo.class, com.google.rpc.ResourceInfo.Builder.class); + } + + // Construct using com.google.rpc.ResourceInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + resourceType_ = ""; + + resourceName_ = ""; + + owner_ = ""; + + description_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_ResourceInfo_descriptor; + } + + public com.google.rpc.ResourceInfo getDefaultInstanceForType() { + return com.google.rpc.ResourceInfo.getDefaultInstance(); + } + + public com.google.rpc.ResourceInfo build() { + com.google.rpc.ResourceInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.ResourceInfo buildPartial() { + com.google.rpc.ResourceInfo result = new com.google.rpc.ResourceInfo(this); + result.resourceType_ = resourceType_; + result.resourceName_ = resourceName_; + result.owner_ = owner_; + result.description_ = description_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.ResourceInfo) { + return mergeFrom((com.google.rpc.ResourceInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.ResourceInfo other) { + if (other == com.google.rpc.ResourceInfo.getDefaultInstance()) return this; + if (!other.getResourceType().isEmpty()) { + resourceType_ = other.resourceType_; + onChanged(); + } + if (!other.getResourceName().isEmpty()) { + resourceName_ = other.resourceName_; + onChanged(); + } + if (!other.getOwner().isEmpty()) { + owner_ = other.owner_; + onChanged(); + } + if (!other.getDescription().isEmpty()) { + description_ = other.description_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.ResourceInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.ResourceInfo) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object resourceType_ = ""; + /** + * optional string resource_type = 1; + * + *
      +     * A name for the type of resource being accessed, e.g. "sql table",
      +     * "cloud storage bucket", "file", "Google calendar"; or the type URL
      +     * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      +     * 
      + */ + public java.lang.String getResourceType() { + java.lang.Object ref = resourceType_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + resourceType_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string resource_type = 1; + * + *
      +     * A name for the type of resource being accessed, e.g. "sql table",
      +     * "cloud storage bucket", "file", "Google calendar"; or the type URL
      +     * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      +     * 
      + */ + public com.google.protobuf.ByteString + getResourceTypeBytes() { + java.lang.Object ref = resourceType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + resourceType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string resource_type = 1; + * + *
      +     * A name for the type of resource being accessed, e.g. "sql table",
      +     * "cloud storage bucket", "file", "Google calendar"; or the type URL
      +     * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      +     * 
      + */ + public Builder setResourceType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + resourceType_ = value; + onChanged(); + return this; + } + /** + * optional string resource_type = 1; + * + *
      +     * A name for the type of resource being accessed, e.g. "sql table",
      +     * "cloud storage bucket", "file", "Google calendar"; or the type URL
      +     * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      +     * 
      + */ + public Builder clearResourceType() { + + resourceType_ = getDefaultInstance().getResourceType(); + onChanged(); + return this; + } + /** + * optional string resource_type = 1; + * + *
      +     * A name for the type of resource being accessed, e.g. "sql table",
      +     * "cloud storage bucket", "file", "Google calendar"; or the type URL
      +     * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      +     * 
      + */ + public Builder setResourceTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + resourceType_ = value; + onChanged(); + return this; + } + + private java.lang.Object resourceName_ = ""; + /** + * optional string resource_name = 2; + * + *
      +     * The name of the resource being accessed.  For example, a shared calendar
      +     * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      +     * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      +     * 
      + */ + public java.lang.String getResourceName() { + java.lang.Object ref = resourceName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + resourceName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string resource_name = 2; + * + *
      +     * The name of the resource being accessed.  For example, a shared calendar
      +     * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      +     * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      +     * 
      + */ + public com.google.protobuf.ByteString + getResourceNameBytes() { + java.lang.Object ref = resourceName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + resourceName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string resource_name = 2; + * + *
      +     * The name of the resource being accessed.  For example, a shared calendar
      +     * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      +     * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      +     * 
      + */ + public Builder setResourceName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + resourceName_ = value; + onChanged(); + return this; + } + /** + * optional string resource_name = 2; + * + *
      +     * The name of the resource being accessed.  For example, a shared calendar
      +     * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      +     * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      +     * 
      + */ + public Builder clearResourceName() { + + resourceName_ = getDefaultInstance().getResourceName(); + onChanged(); + return this; + } + /** + * optional string resource_name = 2; + * + *
      +     * The name of the resource being accessed.  For example, a shared calendar
      +     * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      +     * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      +     * 
      + */ + public Builder setResourceNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + resourceName_ = value; + onChanged(); + return this; + } + + private java.lang.Object owner_ = ""; + /** + * optional string owner = 3; + * + *
      +     * The owner of the resource (optional).
      +     * For example, "user:<owner email>" or "project:<Google developer project
      +     * id>".
      +     * 
      + */ + public java.lang.String getOwner() { + java.lang.Object ref = owner_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + owner_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string owner = 3; + * + *
      +     * The owner of the resource (optional).
      +     * For example, "user:<owner email>" or "project:<Google developer project
      +     * id>".
      +     * 
      + */ + public com.google.protobuf.ByteString + getOwnerBytes() { + java.lang.Object ref = owner_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + owner_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string owner = 3; + * + *
      +     * The owner of the resource (optional).
      +     * For example, "user:<owner email>" or "project:<Google developer project
      +     * id>".
      +     * 
      + */ + public Builder setOwner( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + owner_ = value; + onChanged(); + return this; + } + /** + * optional string owner = 3; + * + *
      +     * The owner of the resource (optional).
      +     * For example, "user:<owner email>" or "project:<Google developer project
      +     * id>".
      +     * 
      + */ + public Builder clearOwner() { + + owner_ = getDefaultInstance().getOwner(); + onChanged(); + return this; + } + /** + * optional string owner = 3; + * + *
      +     * The owner of the resource (optional).
      +     * For example, "user:<owner email>" or "project:<Google developer project
      +     * id>".
      +     * 
      + */ + public Builder setOwnerBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + owner_ = value; + onChanged(); + return this; + } + + private java.lang.Object description_ = ""; + /** + * optional string description = 4; + * + *
      +     * Describes what error is encountered when accessing this resource.
      +     * For example, updating a cloud project may require the `writer` permission
      +     * on the developer console project.
      +     * 
      + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string description = 4; + * + *
      +     * Describes what error is encountered when accessing this resource.
      +     * For example, updating a cloud project may require the `writer` permission
      +     * on the developer console project.
      +     * 
      + */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string description = 4; + * + *
      +     * Describes what error is encountered when accessing this resource.
      +     * For example, updating a cloud project may require the `writer` permission
      +     * on the developer console project.
      +     * 
      + */ + public Builder setDescription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + description_ = value; + onChanged(); + return this; + } + /** + * optional string description = 4; + * + *
      +     * Describes what error is encountered when accessing this resource.
      +     * For example, updating a cloud project may require the `writer` permission
      +     * on the developer console project.
      +     * 
      + */ + public Builder clearDescription() { + + description_ = getDefaultInstance().getDescription(); + onChanged(); + return this; + } + /** + * optional string description = 4; + * + *
      +     * Describes what error is encountered when accessing this resource.
      +     * For example, updating a cloud project may require the `writer` permission
      +     * on the developer console project.
      +     * 
      + */ + public Builder setDescriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + description_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.ResourceInfo) + } + + // @@protoc_insertion_point(class_scope:google.rpc.ResourceInfo) + private static final com.google.rpc.ResourceInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.ResourceInfo(); + } + + public static com.google.rpc.ResourceInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ResourceInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ResourceInfo(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.ResourceInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfoOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfoOrBuilder.java new file mode 100644 index 000000000000..5c48486c13a8 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfoOrBuilder.java @@ -0,0 +1,97 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +public interface ResourceInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.ResourceInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string resource_type = 1; + * + *
      +   * A name for the type of resource being accessed, e.g. "sql table",
      +   * "cloud storage bucket", "file", "Google calendar"; or the type URL
      +   * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      +   * 
      + */ + java.lang.String getResourceType(); + /** + * optional string resource_type = 1; + * + *
      +   * A name for the type of resource being accessed, e.g. "sql table",
      +   * "cloud storage bucket", "file", "Google calendar"; or the type URL
      +   * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      +   * 
      + */ + com.google.protobuf.ByteString + getResourceTypeBytes(); + + /** + * optional string resource_name = 2; + * + *
      +   * The name of the resource being accessed.  For example, a shared calendar
      +   * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      +   * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      +   * 
      + */ + java.lang.String getResourceName(); + /** + * optional string resource_name = 2; + * + *
      +   * The name of the resource being accessed.  For example, a shared calendar
      +   * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      +   * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      +   * 
      + */ + com.google.protobuf.ByteString + getResourceNameBytes(); + + /** + * optional string owner = 3; + * + *
      +   * The owner of the resource (optional).
      +   * For example, "user:<owner email>" or "project:<Google developer project
      +   * id>".
      +   * 
      + */ + java.lang.String getOwner(); + /** + * optional string owner = 3; + * + *
      +   * The owner of the resource (optional).
      +   * For example, "user:<owner email>" or "project:<Google developer project
      +   * id>".
      +   * 
      + */ + com.google.protobuf.ByteString + getOwnerBytes(); + + /** + * optional string description = 4; + * + *
      +   * Describes what error is encountered when accessing this resource.
      +   * For example, updating a cloud project may require the `writer` permission
      +   * on the developer console project.
      +   * 
      + */ + java.lang.String getDescription(); + /** + * optional string description = 4; + * + *
      +   * Describes what error is encountered when accessing this resource.
      +   * For example, updating a cloud project may require the `writer` permission
      +   * on the developer console project.
      +   * 
      + */ + com.google.protobuf.ByteString + getDescriptionBytes(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfo.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfo.java new file mode 100644 index 000000000000..8da5185492bd --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfo.java @@ -0,0 +1,565 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +/** + * Protobuf type {@code google.rpc.RetryInfo} + * + *
      + * Describes when the clients can retry a failed request. Clients could ignore
      + * the recommendation here or retry when this information is missing from error
      + * responses.
      + * It's always recommended that clients should use exponential backoff when
      + * retrying.
      + * Clients should wait until `retry_delay` amount of time has passed since
      + * receiving the error response before retrying.  If retrying requests also
      + * fail, clients should use an exponential backoff scheme to gradually increase
      + * the delay between retries based on `retry_delay`, until either a maximum
      + * number of retires have been reached or a maximum retry delay cap has been
      + * reached.
      + * 
      + */ +public final class RetryInfo extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.RetryInfo) + RetryInfoOrBuilder { + // Use RetryInfo.newBuilder() to construct. + private RetryInfo(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private RetryInfo() { + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private RetryInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + com.google.protobuf.Duration.Builder subBuilder = null; + if (retryDelay_ != null) { + subBuilder = retryDelay_.toBuilder(); + } + retryDelay_ = input.readMessage(com.google.protobuf.Duration.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(retryDelay_); + retryDelay_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RetryInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RetryInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.RetryInfo.class, com.google.rpc.RetryInfo.Builder.class); + } + + public static final int RETRY_DELAY_FIELD_NUMBER = 1; + private com.google.protobuf.Duration retryDelay_; + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +   * Clients should wait at least this long between retrying the same request.
      +   * 
      + */ + public boolean hasRetryDelay() { + return retryDelay_ != null; + } + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +   * Clients should wait at least this long between retrying the same request.
      +   * 
      + */ + public com.google.protobuf.Duration getRetryDelay() { + return retryDelay_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retryDelay_; + } + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +   * Clients should wait at least this long between retrying the same request.
      +   * 
      + */ + public com.google.protobuf.DurationOrBuilder getRetryDelayOrBuilder() { + return getRetryDelay(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (retryDelay_ != null) { + output.writeMessage(1, getRetryDelay()); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (retryDelay_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getRetryDelay()); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.RetryInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.RetryInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.RetryInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.RetryInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.RetryInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.RetryInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.RetryInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.RetryInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.RetryInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.RetryInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.RetryInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.RetryInfo} + * + *
      +   * Describes when the clients can retry a failed request. Clients could ignore
      +   * the recommendation here or retry when this information is missing from error
      +   * responses.
      +   * It's always recommended that clients should use exponential backoff when
      +   * retrying.
      +   * Clients should wait until `retry_delay` amount of time has passed since
      +   * receiving the error response before retrying.  If retrying requests also
      +   * fail, clients should use an exponential backoff scheme to gradually increase
      +   * the delay between retries based on `retry_delay`, until either a maximum
      +   * number of retires have been reached or a maximum retry delay cap has been
      +   * reached.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.RetryInfo) + com.google.rpc.RetryInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RetryInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RetryInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.RetryInfo.class, com.google.rpc.RetryInfo.Builder.class); + } + + // Construct using com.google.rpc.RetryInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (retryDelayBuilder_ == null) { + retryDelay_ = null; + } else { + retryDelay_ = null; + retryDelayBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RetryInfo_descriptor; + } + + public com.google.rpc.RetryInfo getDefaultInstanceForType() { + return com.google.rpc.RetryInfo.getDefaultInstance(); + } + + public com.google.rpc.RetryInfo build() { + com.google.rpc.RetryInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.RetryInfo buildPartial() { + com.google.rpc.RetryInfo result = new com.google.rpc.RetryInfo(this); + if (retryDelayBuilder_ == null) { + result.retryDelay_ = retryDelay_; + } else { + result.retryDelay_ = retryDelayBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.RetryInfo) { + return mergeFrom((com.google.rpc.RetryInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.RetryInfo other) { + if (other == com.google.rpc.RetryInfo.getDefaultInstance()) return this; + if (other.hasRetryDelay()) { + mergeRetryDelay(other.getRetryDelay()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.RetryInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.RetryInfo) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.Duration retryDelay_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, com.google.protobuf.Duration.Builder, com.google.protobuf.DurationOrBuilder> retryDelayBuilder_; + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +     * Clients should wait at least this long between retrying the same request.
      +     * 
      + */ + public boolean hasRetryDelay() { + return retryDelayBuilder_ != null || retryDelay_ != null; + } + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +     * Clients should wait at least this long between retrying the same request.
      +     * 
      + */ + public com.google.protobuf.Duration getRetryDelay() { + if (retryDelayBuilder_ == null) { + return retryDelay_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retryDelay_; + } else { + return retryDelayBuilder_.getMessage(); + } + } + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +     * Clients should wait at least this long between retrying the same request.
      +     * 
      + */ + public Builder setRetryDelay(com.google.protobuf.Duration value) { + if (retryDelayBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + retryDelay_ = value; + onChanged(); + } else { + retryDelayBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +     * Clients should wait at least this long between retrying the same request.
      +     * 
      + */ + public Builder setRetryDelay( + com.google.protobuf.Duration.Builder builderForValue) { + if (retryDelayBuilder_ == null) { + retryDelay_ = builderForValue.build(); + onChanged(); + } else { + retryDelayBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +     * Clients should wait at least this long between retrying the same request.
      +     * 
      + */ + public Builder mergeRetryDelay(com.google.protobuf.Duration value) { + if (retryDelayBuilder_ == null) { + if (retryDelay_ != null) { + retryDelay_ = + com.google.protobuf.Duration.newBuilder(retryDelay_).mergeFrom(value).buildPartial(); + } else { + retryDelay_ = value; + } + onChanged(); + } else { + retryDelayBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +     * Clients should wait at least this long between retrying the same request.
      +     * 
      + */ + public Builder clearRetryDelay() { + if (retryDelayBuilder_ == null) { + retryDelay_ = null; + onChanged(); + } else { + retryDelay_ = null; + retryDelayBuilder_ = null; + } + + return this; + } + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +     * Clients should wait at least this long between retrying the same request.
      +     * 
      + */ + public com.google.protobuf.Duration.Builder getRetryDelayBuilder() { + + onChanged(); + return getRetryDelayFieldBuilder().getBuilder(); + } + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +     * Clients should wait at least this long between retrying the same request.
      +     * 
      + */ + public com.google.protobuf.DurationOrBuilder getRetryDelayOrBuilder() { + if (retryDelayBuilder_ != null) { + return retryDelayBuilder_.getMessageOrBuilder(); + } else { + return retryDelay_ == null ? + com.google.protobuf.Duration.getDefaultInstance() : retryDelay_; + } + } + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +     * Clients should wait at least this long between retrying the same request.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, com.google.protobuf.Duration.Builder, com.google.protobuf.DurationOrBuilder> + getRetryDelayFieldBuilder() { + if (retryDelayBuilder_ == null) { + retryDelayBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, com.google.protobuf.Duration.Builder, com.google.protobuf.DurationOrBuilder>( + getRetryDelay(), + getParentForChildren(), + isClean()); + retryDelay_ = null; + } + return retryDelayBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.RetryInfo) + } + + // @@protoc_insertion_point(class_scope:google.rpc.RetryInfo) + private static final com.google.rpc.RetryInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.RetryInfo(); + } + + public static com.google.rpc.RetryInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public RetryInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new RetryInfo(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.RetryInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfoOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfoOrBuilder.java new file mode 100644 index 000000000000..f4b347a1d04e --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfoOrBuilder.java @@ -0,0 +1,34 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/error_details.proto + +package com.google.rpc; + +public interface RetryInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.RetryInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +   * Clients should wait at least this long between retrying the same request.
      +   * 
      + */ + boolean hasRetryDelay(); + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +   * Clients should wait at least this long between retrying the same request.
      +   * 
      + */ + com.google.protobuf.Duration getRetryDelay(); + /** + * optional .google.protobuf.Duration retry_delay = 1; + * + *
      +   * Clients should wait at least this long between retrying the same request.
      +   * 
      + */ + com.google.protobuf.DurationOrBuilder getRetryDelayOrBuilder(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/Status.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/Status.java new file mode 100644 index 000000000000..be0c3a54ec64 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/Status.java @@ -0,0 +1,1092 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/status.proto + +package com.google.rpc; + +/** + * Protobuf type {@code google.rpc.Status} + * + *
      + * The `Status` type defines a logical error model that is suitable for different
      + * programming environments, including REST APIs and RPC APIs. It is used by
      + * [gRPC](https://github.com/grpc). The error model is designed to be:
      + * - Simple to use and understand for most users
      + * - Flexible enough to meet unexpected needs
      + * # Overview
      + * The `Status` message contains three pieces of data: error code, error message,
      + * and error details. The error code should be an enum value of
      + * [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed.  The
      + * error message should be a developer-facing English message that helps
      + * developers *understand* and *resolve* the error. If a localized user-facing
      + * error message is needed, put the localized message in the error details or
      + * localize it in the client. The optional error details may contain arbitrary
      + * information about the error. There is a predefined set of error detail types
      + * in the package `google.rpc` which can be used for common error conditions.
      + * # Language mapping
      + * The `Status` message is the logical representation of the error model, but it
      + * is not necessarily the actual wire format. When the `Status` message is
      + * exposed in different client libraries and different wire protocols, it can be
      + * mapped differently. For example, it will likely be mapped to some exceptions
      + * in Java, but more likely mapped to some error codes in C.
      + * # Other uses
      + * The error model and the `Status` message can be used in a variety of
      + * environments, either with or without APIs, to provide a
      + * consistent developer experience across different environments.
      + * Example uses of this error model include:
      + * - Partial errors. If a service needs to return partial errors to the client,
      + *     it may embed the `Status` in the normal response to indicate the partial
      + *     errors.
      + * - Workflow errors. A typical workflow has multiple steps. Each step may
      + *     have a `Status` message for error reporting purpose.
      + * - Batch operations. If a client uses batch request and batch response, the
      + *     `Status` message should be used directly inside batch response, one for
      + *     each error sub-response.
      + * - Asynchronous operations. If an API call embeds asynchronous operation
      + *     results in its response, the status of those operations should be
      + *     represented directly using the `Status` message.
      + * - Logging. If some API errors are stored in logs, the message `Status` could
      + *     be used directly after any stripping needed for security/privacy reasons.
      + * 
      + */ +public final class Status extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.rpc.Status) + StatusOrBuilder { + // Use Status.newBuilder() to construct. + private Status(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Status() { + code_ = 0; + message_ = ""; + details_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Status( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + code_ = input.readInt32(); + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + details_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + details_.add(input.readMessage(com.google.protobuf.Any.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + details_ = java.util.Collections.unmodifiableList(details_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.StatusProto.internal_static_google_rpc_Status_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.StatusProto.internal_static_google_rpc_Status_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.Status.class, com.google.rpc.Status.Builder.class); + } + + private int bitField0_; + public static final int CODE_FIELD_NUMBER = 1; + private int code_; + /** + * optional int32 code = 1; + * + *
      +   * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
      +   * 
      + */ + public int getCode() { + return code_; + } + + public static final int MESSAGE_FIELD_NUMBER = 2; + private volatile java.lang.Object message_; + /** + * optional string message = 2; + * + *
      +   * A developer-facing error message, which should be in English. Any
      +   * user-facing error message should be localized and sent in the
      +   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      +   * 
      + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + * optional string message = 2; + * + *
      +   * A developer-facing error message, which should be in English. Any
      +   * user-facing error message should be localized and sent in the
      +   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      +   * 
      + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DETAILS_FIELD_NUMBER = 3; + private java.util.List details_; + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +   * A list of messages that carry the error details.  There will be a
      +   * common set of message types for APIs to use.
      +   * 
      + */ + public java.util.List getDetailsList() { + return details_; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +   * A list of messages that carry the error details.  There will be a
      +   * common set of message types for APIs to use.
      +   * 
      + */ + public java.util.List + getDetailsOrBuilderList() { + return details_; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +   * A list of messages that carry the error details.  There will be a
      +   * common set of message types for APIs to use.
      +   * 
      + */ + public int getDetailsCount() { + return details_.size(); + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +   * A list of messages that carry the error details.  There will be a
      +   * common set of message types for APIs to use.
      +   * 
      + */ + public com.google.protobuf.Any getDetails(int index) { + return details_.get(index); + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +   * A list of messages that carry the error details.  There will be a
      +   * common set of message types for APIs to use.
      +   * 
      + */ + public com.google.protobuf.AnyOrBuilder getDetailsOrBuilder( + int index) { + return details_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (code_ != 0) { + output.writeInt32(1, code_); + } + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, message_); + } + for (int i = 0; i < details_.size(); i++) { + output.writeMessage(3, details_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (code_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, code_); + } + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, message_); + } + for (int i = 0; i < details_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, details_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.rpc.Status parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.Status parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.Status parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.rpc.Status parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.rpc.Status parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.Status parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.rpc.Status parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.rpc.Status parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.rpc.Status parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.rpc.Status parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.rpc.Status prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.rpc.Status} + * + *
      +   * The `Status` type defines a logical error model that is suitable for different
      +   * programming environments, including REST APIs and RPC APIs. It is used by
      +   * [gRPC](https://github.com/grpc). The error model is designed to be:
      +   * - Simple to use and understand for most users
      +   * - Flexible enough to meet unexpected needs
      +   * # Overview
      +   * The `Status` message contains three pieces of data: error code, error message,
      +   * and error details. The error code should be an enum value of
      +   * [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed.  The
      +   * error message should be a developer-facing English message that helps
      +   * developers *understand* and *resolve* the error. If a localized user-facing
      +   * error message is needed, put the localized message in the error details or
      +   * localize it in the client. The optional error details may contain arbitrary
      +   * information about the error. There is a predefined set of error detail types
      +   * in the package `google.rpc` which can be used for common error conditions.
      +   * # Language mapping
      +   * The `Status` message is the logical representation of the error model, but it
      +   * is not necessarily the actual wire format. When the `Status` message is
      +   * exposed in different client libraries and different wire protocols, it can be
      +   * mapped differently. For example, it will likely be mapped to some exceptions
      +   * in Java, but more likely mapped to some error codes in C.
      +   * # Other uses
      +   * The error model and the `Status` message can be used in a variety of
      +   * environments, either with or without APIs, to provide a
      +   * consistent developer experience across different environments.
      +   * Example uses of this error model include:
      +   * - Partial errors. If a service needs to return partial errors to the client,
      +   *     it may embed the `Status` in the normal response to indicate the partial
      +   *     errors.
      +   * - Workflow errors. A typical workflow has multiple steps. Each step may
      +   *     have a `Status` message for error reporting purpose.
      +   * - Batch operations. If a client uses batch request and batch response, the
      +   *     `Status` message should be used directly inside batch response, one for
      +   *     each error sub-response.
      +   * - Asynchronous operations. If an API call embeds asynchronous operation
      +   *     results in its response, the status of those operations should be
      +   *     represented directly using the `Status` message.
      +   * - Logging. If some API errors are stored in logs, the message `Status` could
      +   *     be used directly after any stripping needed for security/privacy reasons.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.rpc.Status) + com.google.rpc.StatusOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.rpc.StatusProto.internal_static_google_rpc_Status_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.rpc.StatusProto.internal_static_google_rpc_Status_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.rpc.Status.class, com.google.rpc.Status.Builder.class); + } + + // Construct using com.google.rpc.Status.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getDetailsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + code_ = 0; + + message_ = ""; + + if (detailsBuilder_ == null) { + details_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + detailsBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.rpc.StatusProto.internal_static_google_rpc_Status_descriptor; + } + + public com.google.rpc.Status getDefaultInstanceForType() { + return com.google.rpc.Status.getDefaultInstance(); + } + + public com.google.rpc.Status build() { + com.google.rpc.Status result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.rpc.Status buildPartial() { + com.google.rpc.Status result = new com.google.rpc.Status(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.code_ = code_; + result.message_ = message_; + if (detailsBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + details_ = java.util.Collections.unmodifiableList(details_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.details_ = details_; + } else { + result.details_ = detailsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.rpc.Status) { + return mergeFrom((com.google.rpc.Status)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.rpc.Status other) { + if (other == com.google.rpc.Status.getDefaultInstance()) return this; + if (other.getCode() != 0) { + setCode(other.getCode()); + } + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + if (detailsBuilder_ == null) { + if (!other.details_.isEmpty()) { + if (details_.isEmpty()) { + details_ = other.details_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureDetailsIsMutable(); + details_.addAll(other.details_); + } + onChanged(); + } + } else { + if (!other.details_.isEmpty()) { + if (detailsBuilder_.isEmpty()) { + detailsBuilder_.dispose(); + detailsBuilder_ = null; + details_ = other.details_; + bitField0_ = (bitField0_ & ~0x00000004); + detailsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getDetailsFieldBuilder() : null; + } else { + detailsBuilder_.addAllMessages(other.details_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.rpc.Status parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.rpc.Status) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private int code_ ; + /** + * optional int32 code = 1; + * + *
      +     * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
      +     * 
      + */ + public int getCode() { + return code_; + } + /** + * optional int32 code = 1; + * + *
      +     * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
      +     * 
      + */ + public Builder setCode(int value) { + + code_ = value; + onChanged(); + return this; + } + /** + * optional int32 code = 1; + * + *
      +     * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
      +     * 
      + */ + public Builder clearCode() { + + code_ = 0; + onChanged(); + return this; + } + + private java.lang.Object message_ = ""; + /** + * optional string message = 2; + * + *
      +     * A developer-facing error message, which should be in English. Any
      +     * user-facing error message should be localized and sent in the
      +     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      +     * 
      + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string message = 2; + * + *
      +     * A developer-facing error message, which should be in English. Any
      +     * user-facing error message should be localized and sent in the
      +     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      +     * 
      + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string message = 2; + * + *
      +     * A developer-facing error message, which should be in English. Any
      +     * user-facing error message should be localized and sent in the
      +     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      +     * 
      + */ + public Builder setMessage( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + * optional string message = 2; + * + *
      +     * A developer-facing error message, which should be in English. Any
      +     * user-facing error message should be localized and sent in the
      +     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      +     * 
      + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + * optional string message = 2; + * + *
      +     * A developer-facing error message, which should be in English. Any
      +     * user-facing error message should be localized and sent in the
      +     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      +     * 
      + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + + private java.util.List details_ = + java.util.Collections.emptyList(); + private void ensureDetailsIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + details_ = new java.util.ArrayList(details_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> detailsBuilder_; + + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public java.util.List getDetailsList() { + if (detailsBuilder_ == null) { + return java.util.Collections.unmodifiableList(details_); + } else { + return detailsBuilder_.getMessageList(); + } + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public int getDetailsCount() { + if (detailsBuilder_ == null) { + return details_.size(); + } else { + return detailsBuilder_.getCount(); + } + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public com.google.protobuf.Any getDetails(int index) { + if (detailsBuilder_ == null) { + return details_.get(index); + } else { + return detailsBuilder_.getMessage(index); + } + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public Builder setDetails( + int index, com.google.protobuf.Any value) { + if (detailsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDetailsIsMutable(); + details_.set(index, value); + onChanged(); + } else { + detailsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public Builder setDetails( + int index, com.google.protobuf.Any.Builder builderForValue) { + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + details_.set(index, builderForValue.build()); + onChanged(); + } else { + detailsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public Builder addDetails(com.google.protobuf.Any value) { + if (detailsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDetailsIsMutable(); + details_.add(value); + onChanged(); + } else { + detailsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public Builder addDetails( + int index, com.google.protobuf.Any value) { + if (detailsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDetailsIsMutable(); + details_.add(index, value); + onChanged(); + } else { + detailsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public Builder addDetails( + com.google.protobuf.Any.Builder builderForValue) { + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + details_.add(builderForValue.build()); + onChanged(); + } else { + detailsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public Builder addDetails( + int index, com.google.protobuf.Any.Builder builderForValue) { + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + details_.add(index, builderForValue.build()); + onChanged(); + } else { + detailsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public Builder addAllDetails( + java.lang.Iterable values) { + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, details_); + onChanged(); + } else { + detailsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public Builder clearDetails() { + if (detailsBuilder_ == null) { + details_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + detailsBuilder_.clear(); + } + return this; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public Builder removeDetails(int index) { + if (detailsBuilder_ == null) { + ensureDetailsIsMutable(); + details_.remove(index); + onChanged(); + } else { + detailsBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public com.google.protobuf.Any.Builder getDetailsBuilder( + int index) { + return getDetailsFieldBuilder().getBuilder(index); + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public com.google.protobuf.AnyOrBuilder getDetailsOrBuilder( + int index) { + if (detailsBuilder_ == null) { + return details_.get(index); } else { + return detailsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public java.util.List + getDetailsOrBuilderList() { + if (detailsBuilder_ != null) { + return detailsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(details_); + } + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public com.google.protobuf.Any.Builder addDetailsBuilder() { + return getDetailsFieldBuilder().addBuilder( + com.google.protobuf.Any.getDefaultInstance()); + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public com.google.protobuf.Any.Builder addDetailsBuilder( + int index) { + return getDetailsFieldBuilder().addBuilder( + index, com.google.protobuf.Any.getDefaultInstance()); + } + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +     * A list of messages that carry the error details.  There will be a
      +     * common set of message types for APIs to use.
      +     * 
      + */ + public java.util.List + getDetailsBuilderList() { + return getDetailsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> + getDetailsFieldBuilder() { + if (detailsBuilder_ == null) { + detailsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>( + details_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + details_ = null; + } + return detailsBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.rpc.Status) + } + + // @@protoc_insertion_point(class_scope:google.rpc.Status) + private static final com.google.rpc.Status DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.rpc.Status(); + } + + public static com.google.rpc.Status getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Status parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Status(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.rpc.Status getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusOrBuilder.java new file mode 100644 index 000000000000..d34e7133da6a --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusOrBuilder.java @@ -0,0 +1,89 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/status.proto + +package com.google.rpc; + +public interface StatusOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.rpc.Status) + com.google.protobuf.MessageOrBuilder { + + /** + * optional int32 code = 1; + * + *
      +   * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
      +   * 
      + */ + int getCode(); + + /** + * optional string message = 2; + * + *
      +   * A developer-facing error message, which should be in English. Any
      +   * user-facing error message should be localized and sent in the
      +   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      +   * 
      + */ + java.lang.String getMessage(); + /** + * optional string message = 2; + * + *
      +   * A developer-facing error message, which should be in English. Any
      +   * user-facing error message should be localized and sent in the
      +   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      +   * 
      + */ + com.google.protobuf.ByteString + getMessageBytes(); + + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +   * A list of messages that carry the error details.  There will be a
      +   * common set of message types for APIs to use.
      +   * 
      + */ + java.util.List + getDetailsList(); + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +   * A list of messages that carry the error details.  There will be a
      +   * common set of message types for APIs to use.
      +   * 
      + */ + com.google.protobuf.Any getDetails(int index); + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +   * A list of messages that carry the error details.  There will be a
      +   * common set of message types for APIs to use.
      +   * 
      + */ + int getDetailsCount(); + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +   * A list of messages that carry the error details.  There will be a
      +   * common set of message types for APIs to use.
      +   * 
      + */ + java.util.List + getDetailsOrBuilderList(); + /** + * repeated .google.protobuf.Any details = 3; + * + *
      +   * A list of messages that carry the error details.  There will be a
      +   * common set of message types for APIs to use.
      +   * 
      + */ + com.google.protobuf.AnyOrBuilder getDetailsOrBuilder( + int index); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusProto.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusProto.java new file mode 100644 index 000000000000..46c87a712b3f --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusProto.java @@ -0,0 +1,54 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/rpc/status.proto + +package com.google.rpc; + +public final class StatusProto { + private StatusProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_rpc_Status_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_rpc_Status_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\027google/rpc/status.proto\022\ngoogle.rpc\032\031g" + + "oogle/protobuf/any.proto\"N\n\006Status\022\014\n\004co" + + "de\030\001 \001(\005\022\017\n\007message\030\002 \001(\t\022%\n\007details\030\003 \003" + + "(\0132\024.google.protobuf.AnyB\037\n\016com.google.r" + + "pcB\013StatusProtoP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.AnyProto.getDescriptor(), + }, assigner); + internal_static_google_rpc_Status_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_rpc_Status_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_rpc_Status_descriptor, + new java.lang.String[] { "Code", "Message", "Details", }); + com.google.protobuf.AnyProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/Color.java b/gcloud-java-gax/generated/src/main/java/com/google/type/Color.java new file mode 100644 index 000000000000..a4d6c9f79529 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/Color.java @@ -0,0 +1,1047 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/color.proto + +package com.google.type; + +/** + * Protobuf type {@code google.type.Color} + * + *
      + * Represents a color in the RGBA color space. This representation is designed
      + * for simplicity of conversion to/from color representations in various
      + * languages over compactness; for example, the fields of this representation
      + * can be trivially provided to the constructor of "java.awt.Color" in Java; it
      + * can also be trivially provided to UIColor's "+colorWithRed:green:blue:alpha"
      + * method in iOS; and, with just a little work, it can be easily formatted into
      + * a CSS "rgba()" string in JavaScript, as well. Here are some examples:
      + * Example (Java):
      + *      import com.google.type.Color;
      + *      // ...
      + *      public static java.awt.Color fromProto(Color protocolor) {
      + *        float alpha = protocolor.hasAlpha()
      + *            ? protocolor.getAlpha().getValue()
      + *            : 1.0;
      + *        return new java.awt.Color(
      + *            protocolor.getRed(),
      + *            protocolor.getGreen(),
      + *            protocolor.getBlue(),
      + *            alpha);
      + *      }
      + *      public static Color toProto(java.awt.Color color) {
      + *        float red = (float) color.getRed();
      + *        float green = (float) color.getGreen();
      + *        float blue = (float) color.getBlue();
      + *        float denominator = 255.0;
      + *        Color.Builder resultBuilder =
      + *            Color
      + *                .newBuilder()
      + *                .setRed(red / denominator)
      + *                .setGreen(green / denominator)
      + *                .setBlue(blue / denominator);
      + *        int alpha = color.getAlpha();
      + *        if (alpha != 255) {
      + *          result.setAlpha(
      + *              FloatValue
      + *                  .newBuilder()
      + *                  .setValue(((float) alpha) / denominator)
      + *                  .build());
      + *        }
      + *        return resultBuilder.build();
      + *      }
      + *      // ...
      + * Example (iOS / Obj-C):
      + *      // ...
      + *      static UIColor* fromProto(Color* protocolor) {
      + *         float red = [protocolor red];
      + *         float green = [protocolor green];
      + *         float blue = [protocolor blue];
      + *         FloatValue* alpha_wrapper = [protocolor alpha];
      + *         float alpha = 1.0;
      + *         if (alpha_wrapper != nil) {
      + *           alpha = [alpha_wrapper value];
      + *         }
      + *         return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
      + *      }
      + *      static Color* toProto(UIColor* color) {
      + *          CGFloat red, green, blue, alpha;
      + *          if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
      + *            return nil;
      + *          }
      + *          Color* result = [Color alloc] init];
      + *          [result setRed:red];
      + *          [result setGreen:green];
      + *          [result setBlue:blue];
      + *          if (alpha <= 0.9999) {
      + *            [result setAlpha:floatWrapperWithValue(alpha)];
      + *          }
      + *          [result autorelease];
      + *          return result;
      + *     }
      + *     // ...
      + *  Example (JavaScript):
      + *     // ...
      + *     var protoToCssColor = function(rgb_color) {
      + *        var redFrac = rgb_color.red || 0.0;
      + *        var greenFrac = rgb_color.green || 0.0;
      + *        var blueFrac = rgb_color.blue || 0.0;
      + *        var red = Math.floor(redFrac * 255);
      + *        var green = Math.floor(greenFrac * 255);
      + *        var blue = Math.floor(blueFrac * 255);
      + *        if (!('alpha' in rgb_color)) {
      + *           return rgbToCssColor_(red, green, blue);
      + *        }
      + *        var alphaFrac = rgb_color.alpha.value || 0.0;
      + *        var rgbParams = [red, green, blue].join(',');
      + *        return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
      + *     };
      + *     var rgbToCssColor_ = function(red, green, blue) {
      + *       var rgbNumber = new Number((red << 16) | (green << 8) | blue);
      + *       var hexString = rgbNumber.toString(16);
      + *       var missingZeros = 6 - hexString.length;
      + *       var resultBuilder = ['#'];
      + *       for (var i = 0; i < missingZeros; i++) {
      + *          resultBuilder.push('0');
      + *       }
      + *       resultBuilder.push(hexString);
      + *       return resultBuilder.join('');
      + *     };
      + *     // ...
      + * 
      + */ +public final class Color extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.type.Color) + ColorOrBuilder { + // Use Color.newBuilder() to construct. + private Color(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Color() { + red_ = 0F; + green_ = 0F; + blue_ = 0F; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Color( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 13: { + + red_ = input.readFloat(); + break; + } + case 21: { + + green_ = input.readFloat(); + break; + } + case 29: { + + blue_ = input.readFloat(); + break; + } + case 34: { + com.google.protobuf.FloatValue.Builder subBuilder = null; + if (alpha_ != null) { + subBuilder = alpha_.toBuilder(); + } + alpha_ = input.readMessage(com.google.protobuf.FloatValue.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(alpha_); + alpha_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.type.ColorProto.internal_static_google_type_Color_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.type.ColorProto.internal_static_google_type_Color_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.type.Color.class, com.google.type.Color.Builder.class); + } + + public static final int RED_FIELD_NUMBER = 1; + private float red_; + /** + * optional float red = 1; + * + *
      +   * The amount of red in the color as a value in the interval [0, 1].
      +   * 
      + */ + public float getRed() { + return red_; + } + + public static final int GREEN_FIELD_NUMBER = 2; + private float green_; + /** + * optional float green = 2; + * + *
      +   * The amount of green in the color as a value in the interval [0, 1].
      +   * 
      + */ + public float getGreen() { + return green_; + } + + public static final int BLUE_FIELD_NUMBER = 3; + private float blue_; + /** + * optional float blue = 3; + * + *
      +   * The amount of blue in the color as a value in the interval [0, 1].
      +   * 
      + */ + public float getBlue() { + return blue_; + } + + public static final int ALPHA_FIELD_NUMBER = 4; + private com.google.protobuf.FloatValue alpha_; + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +   * The fraction of this color that should be applied to the pixel. That is,
      +   * the final pixel color is defined by the equation:
      +   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +   * This means that a value of 1.0 corresponds to a solid color, whereas
      +   * a value of 0.0 corresponds to a completely transparent color. This
      +   * uses a wrapper message rather than a simple float scalar so that it is
      +   * possible to distinguish between a default value and the value being unset.
      +   * If omitted, this color object is to be rendered as a solid color
      +   * (as if the alpha value had been explicitly given with a value of 1.0).
      +   * 
      + */ + public boolean hasAlpha() { + return alpha_ != null; + } + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +   * The fraction of this color that should be applied to the pixel. That is,
      +   * the final pixel color is defined by the equation:
      +   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +   * This means that a value of 1.0 corresponds to a solid color, whereas
      +   * a value of 0.0 corresponds to a completely transparent color. This
      +   * uses a wrapper message rather than a simple float scalar so that it is
      +   * possible to distinguish between a default value and the value being unset.
      +   * If omitted, this color object is to be rendered as a solid color
      +   * (as if the alpha value had been explicitly given with a value of 1.0).
      +   * 
      + */ + public com.google.protobuf.FloatValue getAlpha() { + return alpha_ == null ? com.google.protobuf.FloatValue.getDefaultInstance() : alpha_; + } + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +   * The fraction of this color that should be applied to the pixel. That is,
      +   * the final pixel color is defined by the equation:
      +   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +   * This means that a value of 1.0 corresponds to a solid color, whereas
      +   * a value of 0.0 corresponds to a completely transparent color. This
      +   * uses a wrapper message rather than a simple float scalar so that it is
      +   * possible to distinguish between a default value and the value being unset.
      +   * If omitted, this color object is to be rendered as a solid color
      +   * (as if the alpha value had been explicitly given with a value of 1.0).
      +   * 
      + */ + public com.google.protobuf.FloatValueOrBuilder getAlphaOrBuilder() { + return getAlpha(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (red_ != 0F) { + output.writeFloat(1, red_); + } + if (green_ != 0F) { + output.writeFloat(2, green_); + } + if (blue_ != 0F) { + output.writeFloat(3, blue_); + } + if (alpha_ != null) { + output.writeMessage(4, getAlpha()); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (red_ != 0F) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(1, red_); + } + if (green_ != 0F) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(2, green_); + } + if (blue_ != 0F) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(3, blue_); + } + if (alpha_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getAlpha()); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.type.Color parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.type.Color parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.type.Color parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.type.Color parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.type.Color parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.type.Color parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.type.Color parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.type.Color parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.type.Color parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.type.Color parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.type.Color prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.type.Color} + * + *
      +   * Represents a color in the RGBA color space. This representation is designed
      +   * for simplicity of conversion to/from color representations in various
      +   * languages over compactness; for example, the fields of this representation
      +   * can be trivially provided to the constructor of "java.awt.Color" in Java; it
      +   * can also be trivially provided to UIColor's "+colorWithRed:green:blue:alpha"
      +   * method in iOS; and, with just a little work, it can be easily formatted into
      +   * a CSS "rgba()" string in JavaScript, as well. Here are some examples:
      +   * Example (Java):
      +   *      import com.google.type.Color;
      +   *      // ...
      +   *      public static java.awt.Color fromProto(Color protocolor) {
      +   *        float alpha = protocolor.hasAlpha()
      +   *            ? protocolor.getAlpha().getValue()
      +   *            : 1.0;
      +   *        return new java.awt.Color(
      +   *            protocolor.getRed(),
      +   *            protocolor.getGreen(),
      +   *            protocolor.getBlue(),
      +   *            alpha);
      +   *      }
      +   *      public static Color toProto(java.awt.Color color) {
      +   *        float red = (float) color.getRed();
      +   *        float green = (float) color.getGreen();
      +   *        float blue = (float) color.getBlue();
      +   *        float denominator = 255.0;
      +   *        Color.Builder resultBuilder =
      +   *            Color
      +   *                .newBuilder()
      +   *                .setRed(red / denominator)
      +   *                .setGreen(green / denominator)
      +   *                .setBlue(blue / denominator);
      +   *        int alpha = color.getAlpha();
      +   *        if (alpha != 255) {
      +   *          result.setAlpha(
      +   *              FloatValue
      +   *                  .newBuilder()
      +   *                  .setValue(((float) alpha) / denominator)
      +   *                  .build());
      +   *        }
      +   *        return resultBuilder.build();
      +   *      }
      +   *      // ...
      +   * Example (iOS / Obj-C):
      +   *      // ...
      +   *      static UIColor* fromProto(Color* protocolor) {
      +   *         float red = [protocolor red];
      +   *         float green = [protocolor green];
      +   *         float blue = [protocolor blue];
      +   *         FloatValue* alpha_wrapper = [protocolor alpha];
      +   *         float alpha = 1.0;
      +   *         if (alpha_wrapper != nil) {
      +   *           alpha = [alpha_wrapper value];
      +   *         }
      +   *         return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
      +   *      }
      +   *      static Color* toProto(UIColor* color) {
      +   *          CGFloat red, green, blue, alpha;
      +   *          if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
      +   *            return nil;
      +   *          }
      +   *          Color* result = [Color alloc] init];
      +   *          [result setRed:red];
      +   *          [result setGreen:green];
      +   *          [result setBlue:blue];
      +   *          if (alpha <= 0.9999) {
      +   *            [result setAlpha:floatWrapperWithValue(alpha)];
      +   *          }
      +   *          [result autorelease];
      +   *          return result;
      +   *     }
      +   *     // ...
      +   *  Example (JavaScript):
      +   *     // ...
      +   *     var protoToCssColor = function(rgb_color) {
      +   *        var redFrac = rgb_color.red || 0.0;
      +   *        var greenFrac = rgb_color.green || 0.0;
      +   *        var blueFrac = rgb_color.blue || 0.0;
      +   *        var red = Math.floor(redFrac * 255);
      +   *        var green = Math.floor(greenFrac * 255);
      +   *        var blue = Math.floor(blueFrac * 255);
      +   *        if (!('alpha' in rgb_color)) {
      +   *           return rgbToCssColor_(red, green, blue);
      +   *        }
      +   *        var alphaFrac = rgb_color.alpha.value || 0.0;
      +   *        var rgbParams = [red, green, blue].join(',');
      +   *        return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
      +   *     };
      +   *     var rgbToCssColor_ = function(red, green, blue) {
      +   *       var rgbNumber = new Number((red << 16) | (green << 8) | blue);
      +   *       var hexString = rgbNumber.toString(16);
      +   *       var missingZeros = 6 - hexString.length;
      +   *       var resultBuilder = ['#'];
      +   *       for (var i = 0; i < missingZeros; i++) {
      +   *          resultBuilder.push('0');
      +   *       }
      +   *       resultBuilder.push(hexString);
      +   *       return resultBuilder.join('');
      +   *     };
      +   *     // ...
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.type.Color) + com.google.type.ColorOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.type.ColorProto.internal_static_google_type_Color_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.type.ColorProto.internal_static_google_type_Color_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.type.Color.class, com.google.type.Color.Builder.class); + } + + // Construct using com.google.type.Color.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + red_ = 0F; + + green_ = 0F; + + blue_ = 0F; + + if (alphaBuilder_ == null) { + alpha_ = null; + } else { + alpha_ = null; + alphaBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.type.ColorProto.internal_static_google_type_Color_descriptor; + } + + public com.google.type.Color getDefaultInstanceForType() { + return com.google.type.Color.getDefaultInstance(); + } + + public com.google.type.Color build() { + com.google.type.Color result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.type.Color buildPartial() { + com.google.type.Color result = new com.google.type.Color(this); + result.red_ = red_; + result.green_ = green_; + result.blue_ = blue_; + if (alphaBuilder_ == null) { + result.alpha_ = alpha_; + } else { + result.alpha_ = alphaBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.type.Color) { + return mergeFrom((com.google.type.Color)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.type.Color other) { + if (other == com.google.type.Color.getDefaultInstance()) return this; + if (other.getRed() != 0F) { + setRed(other.getRed()); + } + if (other.getGreen() != 0F) { + setGreen(other.getGreen()); + } + if (other.getBlue() != 0F) { + setBlue(other.getBlue()); + } + if (other.hasAlpha()) { + mergeAlpha(other.getAlpha()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.type.Color parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.type.Color) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private float red_ ; + /** + * optional float red = 1; + * + *
      +     * The amount of red in the color as a value in the interval [0, 1].
      +     * 
      + */ + public float getRed() { + return red_; + } + /** + * optional float red = 1; + * + *
      +     * The amount of red in the color as a value in the interval [0, 1].
      +     * 
      + */ + public Builder setRed(float value) { + + red_ = value; + onChanged(); + return this; + } + /** + * optional float red = 1; + * + *
      +     * The amount of red in the color as a value in the interval [0, 1].
      +     * 
      + */ + public Builder clearRed() { + + red_ = 0F; + onChanged(); + return this; + } + + private float green_ ; + /** + * optional float green = 2; + * + *
      +     * The amount of green in the color as a value in the interval [0, 1].
      +     * 
      + */ + public float getGreen() { + return green_; + } + /** + * optional float green = 2; + * + *
      +     * The amount of green in the color as a value in the interval [0, 1].
      +     * 
      + */ + public Builder setGreen(float value) { + + green_ = value; + onChanged(); + return this; + } + /** + * optional float green = 2; + * + *
      +     * The amount of green in the color as a value in the interval [0, 1].
      +     * 
      + */ + public Builder clearGreen() { + + green_ = 0F; + onChanged(); + return this; + } + + private float blue_ ; + /** + * optional float blue = 3; + * + *
      +     * The amount of blue in the color as a value in the interval [0, 1].
      +     * 
      + */ + public float getBlue() { + return blue_; + } + /** + * optional float blue = 3; + * + *
      +     * The amount of blue in the color as a value in the interval [0, 1].
      +     * 
      + */ + public Builder setBlue(float value) { + + blue_ = value; + onChanged(); + return this; + } + /** + * optional float blue = 3; + * + *
      +     * The amount of blue in the color as a value in the interval [0, 1].
      +     * 
      + */ + public Builder clearBlue() { + + blue_ = 0F; + onChanged(); + return this; + } + + private com.google.protobuf.FloatValue alpha_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FloatValue, com.google.protobuf.FloatValue.Builder, com.google.protobuf.FloatValueOrBuilder> alphaBuilder_; + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +     * The fraction of this color that should be applied to the pixel. That is,
      +     * the final pixel color is defined by the equation:
      +     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +     * This means that a value of 1.0 corresponds to a solid color, whereas
      +     * a value of 0.0 corresponds to a completely transparent color. This
      +     * uses a wrapper message rather than a simple float scalar so that it is
      +     * possible to distinguish between a default value and the value being unset.
      +     * If omitted, this color object is to be rendered as a solid color
      +     * (as if the alpha value had been explicitly given with a value of 1.0).
      +     * 
      + */ + public boolean hasAlpha() { + return alphaBuilder_ != null || alpha_ != null; + } + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +     * The fraction of this color that should be applied to the pixel. That is,
      +     * the final pixel color is defined by the equation:
      +     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +     * This means that a value of 1.0 corresponds to a solid color, whereas
      +     * a value of 0.0 corresponds to a completely transparent color. This
      +     * uses a wrapper message rather than a simple float scalar so that it is
      +     * possible to distinguish between a default value and the value being unset.
      +     * If omitted, this color object is to be rendered as a solid color
      +     * (as if the alpha value had been explicitly given with a value of 1.0).
      +     * 
      + */ + public com.google.protobuf.FloatValue getAlpha() { + if (alphaBuilder_ == null) { + return alpha_ == null ? com.google.protobuf.FloatValue.getDefaultInstance() : alpha_; + } else { + return alphaBuilder_.getMessage(); + } + } + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +     * The fraction of this color that should be applied to the pixel. That is,
      +     * the final pixel color is defined by the equation:
      +     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +     * This means that a value of 1.0 corresponds to a solid color, whereas
      +     * a value of 0.0 corresponds to a completely transparent color. This
      +     * uses a wrapper message rather than a simple float scalar so that it is
      +     * possible to distinguish between a default value and the value being unset.
      +     * If omitted, this color object is to be rendered as a solid color
      +     * (as if the alpha value had been explicitly given with a value of 1.0).
      +     * 
      + */ + public Builder setAlpha(com.google.protobuf.FloatValue value) { + if (alphaBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + alpha_ = value; + onChanged(); + } else { + alphaBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +     * The fraction of this color that should be applied to the pixel. That is,
      +     * the final pixel color is defined by the equation:
      +     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +     * This means that a value of 1.0 corresponds to a solid color, whereas
      +     * a value of 0.0 corresponds to a completely transparent color. This
      +     * uses a wrapper message rather than a simple float scalar so that it is
      +     * possible to distinguish between a default value and the value being unset.
      +     * If omitted, this color object is to be rendered as a solid color
      +     * (as if the alpha value had been explicitly given with a value of 1.0).
      +     * 
      + */ + public Builder setAlpha( + com.google.protobuf.FloatValue.Builder builderForValue) { + if (alphaBuilder_ == null) { + alpha_ = builderForValue.build(); + onChanged(); + } else { + alphaBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +     * The fraction of this color that should be applied to the pixel. That is,
      +     * the final pixel color is defined by the equation:
      +     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +     * This means that a value of 1.0 corresponds to a solid color, whereas
      +     * a value of 0.0 corresponds to a completely transparent color. This
      +     * uses a wrapper message rather than a simple float scalar so that it is
      +     * possible to distinguish between a default value and the value being unset.
      +     * If omitted, this color object is to be rendered as a solid color
      +     * (as if the alpha value had been explicitly given with a value of 1.0).
      +     * 
      + */ + public Builder mergeAlpha(com.google.protobuf.FloatValue value) { + if (alphaBuilder_ == null) { + if (alpha_ != null) { + alpha_ = + com.google.protobuf.FloatValue.newBuilder(alpha_).mergeFrom(value).buildPartial(); + } else { + alpha_ = value; + } + onChanged(); + } else { + alphaBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +     * The fraction of this color that should be applied to the pixel. That is,
      +     * the final pixel color is defined by the equation:
      +     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +     * This means that a value of 1.0 corresponds to a solid color, whereas
      +     * a value of 0.0 corresponds to a completely transparent color. This
      +     * uses a wrapper message rather than a simple float scalar so that it is
      +     * possible to distinguish between a default value and the value being unset.
      +     * If omitted, this color object is to be rendered as a solid color
      +     * (as if the alpha value had been explicitly given with a value of 1.0).
      +     * 
      + */ + public Builder clearAlpha() { + if (alphaBuilder_ == null) { + alpha_ = null; + onChanged(); + } else { + alpha_ = null; + alphaBuilder_ = null; + } + + return this; + } + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +     * The fraction of this color that should be applied to the pixel. That is,
      +     * the final pixel color is defined by the equation:
      +     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +     * This means that a value of 1.0 corresponds to a solid color, whereas
      +     * a value of 0.0 corresponds to a completely transparent color. This
      +     * uses a wrapper message rather than a simple float scalar so that it is
      +     * possible to distinguish between a default value and the value being unset.
      +     * If omitted, this color object is to be rendered as a solid color
      +     * (as if the alpha value had been explicitly given with a value of 1.0).
      +     * 
      + */ + public com.google.protobuf.FloatValue.Builder getAlphaBuilder() { + + onChanged(); + return getAlphaFieldBuilder().getBuilder(); + } + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +     * The fraction of this color that should be applied to the pixel. That is,
      +     * the final pixel color is defined by the equation:
      +     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +     * This means that a value of 1.0 corresponds to a solid color, whereas
      +     * a value of 0.0 corresponds to a completely transparent color. This
      +     * uses a wrapper message rather than a simple float scalar so that it is
      +     * possible to distinguish between a default value and the value being unset.
      +     * If omitted, this color object is to be rendered as a solid color
      +     * (as if the alpha value had been explicitly given with a value of 1.0).
      +     * 
      + */ + public com.google.protobuf.FloatValueOrBuilder getAlphaOrBuilder() { + if (alphaBuilder_ != null) { + return alphaBuilder_.getMessageOrBuilder(); + } else { + return alpha_ == null ? + com.google.protobuf.FloatValue.getDefaultInstance() : alpha_; + } + } + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +     * The fraction of this color that should be applied to the pixel. That is,
      +     * the final pixel color is defined by the equation:
      +     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +     * This means that a value of 1.0 corresponds to a solid color, whereas
      +     * a value of 0.0 corresponds to a completely transparent color. This
      +     * uses a wrapper message rather than a simple float scalar so that it is
      +     * possible to distinguish between a default value and the value being unset.
      +     * If omitted, this color object is to be rendered as a solid color
      +     * (as if the alpha value had been explicitly given with a value of 1.0).
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FloatValue, com.google.protobuf.FloatValue.Builder, com.google.protobuf.FloatValueOrBuilder> + getAlphaFieldBuilder() { + if (alphaBuilder_ == null) { + alphaBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FloatValue, com.google.protobuf.FloatValue.Builder, com.google.protobuf.FloatValueOrBuilder>( + getAlpha(), + getParentForChildren(), + isClean()); + alpha_ = null; + } + return alphaBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.type.Color) + } + + // @@protoc_insertion_point(class_scope:google.type.Color) + private static final com.google.type.Color DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.type.Color(); + } + + public static com.google.type.Color getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Color parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Color(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.type.Color getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/ColorOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/type/ColorOrBuilder.java new file mode 100644 index 000000000000..d6c1ea1ed3fd --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/ColorOrBuilder.java @@ -0,0 +1,85 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/color.proto + +package com.google.type; + +public interface ColorOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.type.Color) + com.google.protobuf.MessageOrBuilder { + + /** + * optional float red = 1; + * + *
      +   * The amount of red in the color as a value in the interval [0, 1].
      +   * 
      + */ + float getRed(); + + /** + * optional float green = 2; + * + *
      +   * The amount of green in the color as a value in the interval [0, 1].
      +   * 
      + */ + float getGreen(); + + /** + * optional float blue = 3; + * + *
      +   * The amount of blue in the color as a value in the interval [0, 1].
      +   * 
      + */ + float getBlue(); + + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +   * The fraction of this color that should be applied to the pixel. That is,
      +   * the final pixel color is defined by the equation:
      +   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +   * This means that a value of 1.0 corresponds to a solid color, whereas
      +   * a value of 0.0 corresponds to a completely transparent color. This
      +   * uses a wrapper message rather than a simple float scalar so that it is
      +   * possible to distinguish between a default value and the value being unset.
      +   * If omitted, this color object is to be rendered as a solid color
      +   * (as if the alpha value had been explicitly given with a value of 1.0).
      +   * 
      + */ + boolean hasAlpha(); + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +   * The fraction of this color that should be applied to the pixel. That is,
      +   * the final pixel color is defined by the equation:
      +   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +   * This means that a value of 1.0 corresponds to a solid color, whereas
      +   * a value of 0.0 corresponds to a completely transparent color. This
      +   * uses a wrapper message rather than a simple float scalar so that it is
      +   * possible to distinguish between a default value and the value being unset.
      +   * If omitted, this color object is to be rendered as a solid color
      +   * (as if the alpha value had been explicitly given with a value of 1.0).
      +   * 
      + */ + com.google.protobuf.FloatValue getAlpha(); + /** + * optional .google.protobuf.FloatValue alpha = 4; + * + *
      +   * The fraction of this color that should be applied to the pixel. That is,
      +   * the final pixel color is defined by the equation:
      +   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      +   * This means that a value of 1.0 corresponds to a solid color, whereas
      +   * a value of 0.0 corresponds to a completely transparent color. This
      +   * uses a wrapper message rather than a simple float scalar so that it is
      +   * possible to distinguish between a default value and the value being unset.
      +   * If omitted, this color object is to be rendered as a solid color
      +   * (as if the alpha value had been explicitly given with a value of 1.0).
      +   * 
      + */ + com.google.protobuf.FloatValueOrBuilder getAlphaOrBuilder(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/ColorProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/ColorProto.java new file mode 100644 index 000000000000..7706183802ed --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/ColorProto.java @@ -0,0 +1,55 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/color.proto + +package com.google.type; + +public final class ColorProto { + private ColorProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_type_Color_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_type_Color_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\027google/type/color.proto\022\013google.type\032\036" + + "google/protobuf/wrappers.proto\"]\n\005Color\022" + + "\013\n\003red\030\001 \001(\002\022\r\n\005green\030\002 \001(\002\022\014\n\004blue\030\003 \001(" + + "\002\022*\n\005alpha\030\004 \001(\0132\033.google.protobuf.Float" + + "ValueB\037\n\017com.google.typeB\nColorProtoP\001b\006" + + "proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.WrappersProto.getDescriptor(), + }, assigner); + internal_static_google_type_Color_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_type_Color_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_type_Color_descriptor, + new java.lang.String[] { "Red", "Green", "Blue", "Alpha", }); + com.google.protobuf.WrappersProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/Date.java b/gcloud-java-gax/generated/src/main/java/com/google/type/Date.java new file mode 100644 index 000000000000..b4a06c47f778 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/Date.java @@ -0,0 +1,593 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/date.proto + +package com.google.type; + +/** + * Protobuf type {@code google.type.Date} + * + *
      + * Represents a whole calendar date, e.g. date of birth. The time of day and
      + * time zone are either specified elsewhere or are not significant. The date
      + * is relative to the Proleptic Gregorian Calendar. The day may be 0 to
      + * represent a year and month where the day is not significant, e.g. credit card
      + * expiration date. The year may be 0 to represent a month and day independent
      + * of year, e.g. anniversary date. Related types are [google.type.TimeOfDay][google.type.TimeOfDay]
      + * and [google.protobuf.Timestamp][google.protobuf.Timestamp].
      + * 
      + */ +public final class Date extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.type.Date) + DateOrBuilder { + // Use Date.newBuilder() to construct. + private Date(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Date() { + year_ = 0; + month_ = 0; + day_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Date( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + year_ = input.readInt32(); + break; + } + case 16: { + + month_ = input.readInt32(); + break; + } + case 24: { + + day_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.type.DateProto.internal_static_google_type_Date_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.type.DateProto.internal_static_google_type_Date_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.type.Date.class, com.google.type.Date.Builder.class); + } + + public static final int YEAR_FIELD_NUMBER = 1; + private int year_; + /** + * optional int32 year = 1; + * + *
      +   * Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
      +   * a year.
      +   * 
      + */ + public int getYear() { + return year_; + } + + public static final int MONTH_FIELD_NUMBER = 2; + private int month_; + /** + * optional int32 month = 2; + * + *
      +   * Month of year of date. Must be from 1 to 12.
      +   * 
      + */ + public int getMonth() { + return month_; + } + + public static final int DAY_FIELD_NUMBER = 3; + private int day_; + /** + * optional int32 day = 3; + * + *
      +   * Day of month. Must be from 1 to 31 and valid for the year and month, or 0
      +   * if specifying a year/month where the day is not sigificant.
      +   * 
      + */ + public int getDay() { + return day_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (year_ != 0) { + output.writeInt32(1, year_); + } + if (month_ != 0) { + output.writeInt32(2, month_); + } + if (day_ != 0) { + output.writeInt32(3, day_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (year_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, year_); + } + if (month_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, month_); + } + if (day_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, day_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.type.Date)) { + return super.equals(obj); + } + com.google.type.Date other = (com.google.type.Date) obj; + + boolean result = true; + result = result && (getYear() + == other.getYear()); + result = result && (getMonth() + == other.getMonth()); + result = result && (getDay() + == other.getDay()); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = (37 * hash) + YEAR_FIELD_NUMBER; + hash = (53 * hash) + getYear(); + hash = (37 * hash) + MONTH_FIELD_NUMBER; + hash = (53 * hash) + getMonth(); + hash = (37 * hash) + DAY_FIELD_NUMBER; + hash = (53 * hash) + getDay(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.type.Date parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.type.Date parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.type.Date parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.type.Date parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.type.Date parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.type.Date parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.type.Date parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.type.Date parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.type.Date parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.type.Date parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.type.Date prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.type.Date} + * + *
      +   * Represents a whole calendar date, e.g. date of birth. The time of day and
      +   * time zone are either specified elsewhere or are not significant. The date
      +   * is relative to the Proleptic Gregorian Calendar. The day may be 0 to
      +   * represent a year and month where the day is not significant, e.g. credit card
      +   * expiration date. The year may be 0 to represent a month and day independent
      +   * of year, e.g. anniversary date. Related types are [google.type.TimeOfDay][google.type.TimeOfDay]
      +   * and [google.protobuf.Timestamp][google.protobuf.Timestamp].
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.type.Date) + com.google.type.DateOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.type.DateProto.internal_static_google_type_Date_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.type.DateProto.internal_static_google_type_Date_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.type.Date.class, com.google.type.Date.Builder.class); + } + + // Construct using com.google.type.Date.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + year_ = 0; + + month_ = 0; + + day_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.type.DateProto.internal_static_google_type_Date_descriptor; + } + + public com.google.type.Date getDefaultInstanceForType() { + return com.google.type.Date.getDefaultInstance(); + } + + public com.google.type.Date build() { + com.google.type.Date result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.type.Date buildPartial() { + com.google.type.Date result = new com.google.type.Date(this); + result.year_ = year_; + result.month_ = month_; + result.day_ = day_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.type.Date) { + return mergeFrom((com.google.type.Date)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.type.Date other) { + if (other == com.google.type.Date.getDefaultInstance()) return this; + if (other.getYear() != 0) { + setYear(other.getYear()); + } + if (other.getMonth() != 0) { + setMonth(other.getMonth()); + } + if (other.getDay() != 0) { + setDay(other.getDay()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.type.Date parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.type.Date) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int year_ ; + /** + * optional int32 year = 1; + * + *
      +     * Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
      +     * a year.
      +     * 
      + */ + public int getYear() { + return year_; + } + /** + * optional int32 year = 1; + * + *
      +     * Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
      +     * a year.
      +     * 
      + */ + public Builder setYear(int value) { + + year_ = value; + onChanged(); + return this; + } + /** + * optional int32 year = 1; + * + *
      +     * Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
      +     * a year.
      +     * 
      + */ + public Builder clearYear() { + + year_ = 0; + onChanged(); + return this; + } + + private int month_ ; + /** + * optional int32 month = 2; + * + *
      +     * Month of year of date. Must be from 1 to 12.
      +     * 
      + */ + public int getMonth() { + return month_; + } + /** + * optional int32 month = 2; + * + *
      +     * Month of year of date. Must be from 1 to 12.
      +     * 
      + */ + public Builder setMonth(int value) { + + month_ = value; + onChanged(); + return this; + } + /** + * optional int32 month = 2; + * + *
      +     * Month of year of date. Must be from 1 to 12.
      +     * 
      + */ + public Builder clearMonth() { + + month_ = 0; + onChanged(); + return this; + } + + private int day_ ; + /** + * optional int32 day = 3; + * + *
      +     * Day of month. Must be from 1 to 31 and valid for the year and month, or 0
      +     * if specifying a year/month where the day is not sigificant.
      +     * 
      + */ + public int getDay() { + return day_; + } + /** + * optional int32 day = 3; + * + *
      +     * Day of month. Must be from 1 to 31 and valid for the year and month, or 0
      +     * if specifying a year/month where the day is not sigificant.
      +     * 
      + */ + public Builder setDay(int value) { + + day_ = value; + onChanged(); + return this; + } + /** + * optional int32 day = 3; + * + *
      +     * Day of month. Must be from 1 to 31 and valid for the year and month, or 0
      +     * if specifying a year/month where the day is not sigificant.
      +     * 
      + */ + public Builder clearDay() { + + day_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.type.Date) + } + + // @@protoc_insertion_point(class_scope:google.type.Date) + private static final com.google.type.Date DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.type.Date(); + } + + public static com.google.type.Date getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Date parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Date(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.type.Date getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/DateOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/type/DateOrBuilder.java new file mode 100644 index 000000000000..adf3a03af627 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/DateOrBuilder.java @@ -0,0 +1,38 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/date.proto + +package com.google.type; + +public interface DateOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.type.Date) + com.google.protobuf.MessageOrBuilder { + + /** + * optional int32 year = 1; + * + *
      +   * Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
      +   * a year.
      +   * 
      + */ + int getYear(); + + /** + * optional int32 month = 2; + * + *
      +   * Month of year of date. Must be from 1 to 12.
      +   * 
      + */ + int getMonth(); + + /** + * optional int32 day = 3; + * + *
      +   * Day of month. Must be from 1 to 31 and valid for the year and month, or 0
      +   * if specifying a year/month where the day is not sigificant.
      +   * 
      + */ + int getDay(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/DateProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/DateProto.java new file mode 100644 index 000000000000..2ddd35383cd5 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/DateProto.java @@ -0,0 +1,51 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/date.proto + +package com.google.type; + +public final class DateProto { + private DateProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_type_Date_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_type_Date_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\026google/type/date.proto\022\013google.type\"0\n" + + "\004Date\022\014\n\004year\030\001 \001(\005\022\r\n\005month\030\002 \001(\005\022\013\n\003da" + + "y\030\003 \001(\005B!\n\017com.google.typeB\tDateProtoP\001\240" + + "\001\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_google_type_Date_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_type_Date_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_type_Date_descriptor, + new java.lang.String[] { "Year", "Month", "Day", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeek.java b/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeek.java new file mode 100644 index 000000000000..06df59326e8c --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeek.java @@ -0,0 +1,220 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/dayofweek.proto + +package com.google.type; + +/** + * Protobuf enum {@code google.type.DayOfWeek} + * + *
      + * Represents a day of week.
      + * 
      + */ +public enum DayOfWeek + implements com.google.protobuf.ProtocolMessageEnum { + /** + * DAY_OF_WEEK_UNSPECIFIED = 0; + * + *
      +   * The unspecified day-of-week.
      +   * 
      + */ + DAY_OF_WEEK_UNSPECIFIED(0, 0), + /** + * MONDAY = 1; + * + *
      +   * The day-of-week of Monday.
      +   * 
      + */ + MONDAY(1, 1), + /** + * TUESDAY = 2; + * + *
      +   * The day-of-week of Tuesday.
      +   * 
      + */ + TUESDAY(2, 2), + /** + * WEDNESDAY = 3; + * + *
      +   * The day-of-week of Wednesday.
      +   * 
      + */ + WEDNESDAY(3, 3), + /** + * THURSDAY = 4; + * + *
      +   * The day-of-week of Thursday.
      +   * 
      + */ + THURSDAY(4, 4), + /** + * FRIDAY = 5; + * + *
      +   * The day-of-week of Friday.
      +   * 
      + */ + FRIDAY(5, 5), + /** + * SATURDAY = 6; + * + *
      +   * The day-of-week of Saturday.
      +   * 
      + */ + SATURDAY(6, 6), + /** + * SUNDAY = 7; + * + *
      +   * The day-of-week of Sunday.
      +   * 
      + */ + SUNDAY(7, 7), + UNRECOGNIZED(-1, -1), + ; + + /** + * DAY_OF_WEEK_UNSPECIFIED = 0; + * + *
      +   * The unspecified day-of-week.
      +   * 
      + */ + public static final int DAY_OF_WEEK_UNSPECIFIED_VALUE = 0; + /** + * MONDAY = 1; + * + *
      +   * The day-of-week of Monday.
      +   * 
      + */ + public static final int MONDAY_VALUE = 1; + /** + * TUESDAY = 2; + * + *
      +   * The day-of-week of Tuesday.
      +   * 
      + */ + public static final int TUESDAY_VALUE = 2; + /** + * WEDNESDAY = 3; + * + *
      +   * The day-of-week of Wednesday.
      +   * 
      + */ + public static final int WEDNESDAY_VALUE = 3; + /** + * THURSDAY = 4; + * + *
      +   * The day-of-week of Thursday.
      +   * 
      + */ + public static final int THURSDAY_VALUE = 4; + /** + * FRIDAY = 5; + * + *
      +   * The day-of-week of Friday.
      +   * 
      + */ + public static final int FRIDAY_VALUE = 5; + /** + * SATURDAY = 6; + * + *
      +   * The day-of-week of Saturday.
      +   * 
      + */ + public static final int SATURDAY_VALUE = 6; + /** + * SUNDAY = 7; + * + *
      +   * The day-of-week of Sunday.
      +   * 
      + */ + public static final int SUNDAY_VALUE = 7; + + + public final int getNumber() { + if (index == -1) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + public static DayOfWeek valueOf(int value) { + switch (value) { + case 0: return DAY_OF_WEEK_UNSPECIFIED; + case 1: return MONDAY; + case 2: return TUESDAY; + case 3: return WEDNESDAY; + case 4: return THURSDAY; + case 5: return FRIDAY; + case 6: return SATURDAY; + case 7: return SUNDAY; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + DayOfWeek> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public DayOfWeek findValueByNumber(int number) { + return DayOfWeek.valueOf(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(index); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return com.google.type.DayOfWeekProto.getDescriptor() + .getEnumTypes().get(0); + } + + private static final DayOfWeek[] VALUES = values(); + + public static DayOfWeek valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int index; + private final int value; + + private DayOfWeek(int index, int value) { + this.index = index; + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.type.DayOfWeek) +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeekProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeekProto.java new file mode 100644 index 000000000000..8fc4a373d4c7 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeekProto.java @@ -0,0 +1,42 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/dayofweek.proto + +package com.google.type; + +public final class DayOfWeekProto { + private DayOfWeekProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\033google/type/dayofweek.proto\022\013google.ty" + + "pe*\204\001\n\tDayOfWeek\022\033\n\027DAY_OF_WEEK_UNSPECIF" + + "IED\020\000\022\n\n\006MONDAY\020\001\022\013\n\007TUESDAY\020\002\022\r\n\tWEDNES" + + "DAY\020\003\022\014\n\010THURSDAY\020\004\022\n\n\006FRIDAY\020\005\022\014\n\010SATUR" + + "DAY\020\006\022\n\n\006SUNDAY\020\007B&\n\017com.google.typeB\016Da" + + "yOfWeekProtoP\001\240\001\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/LatLng.java b/gcloud-java-gax/generated/src/main/java/com/google/type/LatLng.java new file mode 100644 index 000000000000..a01d4f50b3db --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/LatLng.java @@ -0,0 +1,513 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/latlng.proto + +package com.google.type; + +/** + * Protobuf type {@code google.type.LatLng} + * + *
      + * An object representing a latitude/longitude pair. This is expressed as a pair
      + * of doubles representing degrees latitude and degrees longitude. Unless
      + * specified otherwise, this must conform to the
      + * <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
      + * standard</a>. Values must be within normalized ranges.
      + * 
      + */ +public final class LatLng extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.type.LatLng) + LatLngOrBuilder { + // Use LatLng.newBuilder() to construct. + private LatLng(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private LatLng() { + latitude_ = 0D; + longitude_ = 0D; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private LatLng( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 9: { + + latitude_ = input.readDouble(); + break; + } + case 17: { + + longitude_ = input.readDouble(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.type.LatLngProto.internal_static_google_type_LatLng_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.type.LatLngProto.internal_static_google_type_LatLng_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.type.LatLng.class, com.google.type.LatLng.Builder.class); + } + + public static final int LATITUDE_FIELD_NUMBER = 1; + private double latitude_; + /** + * optional double latitude = 1; + * + *
      +   * The latitude in degrees. It must be in the range [-90.0, +90.0].
      +   * 
      + */ + public double getLatitude() { + return latitude_; + } + + public static final int LONGITUDE_FIELD_NUMBER = 2; + private double longitude_; + /** + * optional double longitude = 2; + * + *
      +   * The longitude in degrees. It must be in the range [-180.0, +180.0].
      +   * 
      + */ + public double getLongitude() { + return longitude_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (latitude_ != 0D) { + output.writeDouble(1, latitude_); + } + if (longitude_ != 0D) { + output.writeDouble(2, longitude_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (latitude_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(1, latitude_); + } + if (longitude_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(2, longitude_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.type.LatLng)) { + return super.equals(obj); + } + com.google.type.LatLng other = (com.google.type.LatLng) obj; + + boolean result = true; + result = result && ( + java.lang.Double.doubleToLongBits(getLatitude()) + == java.lang.Double.doubleToLongBits( + other.getLatitude())); + result = result && ( + java.lang.Double.doubleToLongBits(getLongitude()) + == java.lang.Double.doubleToLongBits( + other.getLongitude())); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = (37 * hash) + LATITUDE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getLatitude())); + hash = (37 * hash) + LONGITUDE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getLongitude())); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.type.LatLng parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.type.LatLng parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.type.LatLng parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.type.LatLng parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.type.LatLng parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.type.LatLng parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.type.LatLng parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.type.LatLng parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.type.LatLng parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.type.LatLng parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.type.LatLng prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.type.LatLng} + * + *
      +   * An object representing a latitude/longitude pair. This is expressed as a pair
      +   * of doubles representing degrees latitude and degrees longitude. Unless
      +   * specified otherwise, this must conform to the
      +   * <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
      +   * standard</a>. Values must be within normalized ranges.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.type.LatLng) + com.google.type.LatLngOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.type.LatLngProto.internal_static_google_type_LatLng_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.type.LatLngProto.internal_static_google_type_LatLng_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.type.LatLng.class, com.google.type.LatLng.Builder.class); + } + + // Construct using com.google.type.LatLng.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + latitude_ = 0D; + + longitude_ = 0D; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.type.LatLngProto.internal_static_google_type_LatLng_descriptor; + } + + public com.google.type.LatLng getDefaultInstanceForType() { + return com.google.type.LatLng.getDefaultInstance(); + } + + public com.google.type.LatLng build() { + com.google.type.LatLng result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.type.LatLng buildPartial() { + com.google.type.LatLng result = new com.google.type.LatLng(this); + result.latitude_ = latitude_; + result.longitude_ = longitude_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.type.LatLng) { + return mergeFrom((com.google.type.LatLng)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.type.LatLng other) { + if (other == com.google.type.LatLng.getDefaultInstance()) return this; + if (other.getLatitude() != 0D) { + setLatitude(other.getLatitude()); + } + if (other.getLongitude() != 0D) { + setLongitude(other.getLongitude()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.type.LatLng parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.type.LatLng) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private double latitude_ ; + /** + * optional double latitude = 1; + * + *
      +     * The latitude in degrees. It must be in the range [-90.0, +90.0].
      +     * 
      + */ + public double getLatitude() { + return latitude_; + } + /** + * optional double latitude = 1; + * + *
      +     * The latitude in degrees. It must be in the range [-90.0, +90.0].
      +     * 
      + */ + public Builder setLatitude(double value) { + + latitude_ = value; + onChanged(); + return this; + } + /** + * optional double latitude = 1; + * + *
      +     * The latitude in degrees. It must be in the range [-90.0, +90.0].
      +     * 
      + */ + public Builder clearLatitude() { + + latitude_ = 0D; + onChanged(); + return this; + } + + private double longitude_ ; + /** + * optional double longitude = 2; + * + *
      +     * The longitude in degrees. It must be in the range [-180.0, +180.0].
      +     * 
      + */ + public double getLongitude() { + return longitude_; + } + /** + * optional double longitude = 2; + * + *
      +     * The longitude in degrees. It must be in the range [-180.0, +180.0].
      +     * 
      + */ + public Builder setLongitude(double value) { + + longitude_ = value; + onChanged(); + return this; + } + /** + * optional double longitude = 2; + * + *
      +     * The longitude in degrees. It must be in the range [-180.0, +180.0].
      +     * 
      + */ + public Builder clearLongitude() { + + longitude_ = 0D; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.type.LatLng) + } + + // @@protoc_insertion_point(class_scope:google.type.LatLng) + private static final com.google.type.LatLng DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.type.LatLng(); + } + + public static com.google.type.LatLng getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public LatLng parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new LatLng(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.type.LatLng getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngOrBuilder.java new file mode 100644 index 000000000000..a068aedf045d --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/latlng.proto + +package com.google.type; + +public interface LatLngOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.type.LatLng) + com.google.protobuf.MessageOrBuilder { + + /** + * optional double latitude = 1; + * + *
      +   * The latitude in degrees. It must be in the range [-90.0, +90.0].
      +   * 
      + */ + double getLatitude(); + + /** + * optional double longitude = 2; + * + *
      +   * The longitude in degrees. It must be in the range [-180.0, +180.0].
      +   * 
      + */ + double getLongitude(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngProto.java new file mode 100644 index 000000000000..35b63fce9cda --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngProto.java @@ -0,0 +1,51 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/latlng.proto + +package com.google.type; + +public final class LatLngProto { + private LatLngProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_type_LatLng_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_type_LatLng_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\030google/type/latlng.proto\022\013google.type\"" + + "-\n\006LatLng\022\020\n\010latitude\030\001 \001(\001\022\021\n\tlongitude" + + "\030\002 \001(\001B#\n\017com.google.typeB\013LatLngProtoP\001" + + "\240\001\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_google_type_LatLng_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_type_LatLng_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_type_LatLng_descriptor, + new java.lang.String[] { "Latitude", "Longitude", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/Money.java b/gcloud-java-gax/generated/src/main/java/com/google/type/Money.java new file mode 100644 index 000000000000..18025d34fe87 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/Money.java @@ -0,0 +1,640 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/money.proto + +package com.google.type; + +/** + * Protobuf type {@code google.type.Money} + * + *
      + * Represents an amount of money with its currency type.
      + * 
      + */ +public final class Money extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.type.Money) + MoneyOrBuilder { + // Use Money.newBuilder() to construct. + private Money(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Money() { + currencyCode_ = ""; + units_ = 0L; + nanos_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Money( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + currencyCode_ = s; + break; + } + case 16: { + + units_ = input.readInt64(); + break; + } + case 24: { + + nanos_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.type.MoneyProto.internal_static_google_type_Money_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.type.MoneyProto.internal_static_google_type_Money_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.type.Money.class, com.google.type.Money.Builder.class); + } + + public static final int CURRENCY_CODE_FIELD_NUMBER = 1; + private volatile java.lang.Object currencyCode_; + /** + * optional string currency_code = 1; + * + *
      +   * The 3-letter currency code defined in ISO 4217.
      +   * 
      + */ + public java.lang.String getCurrencyCode() { + java.lang.Object ref = currencyCode_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + currencyCode_ = s; + return s; + } + } + /** + * optional string currency_code = 1; + * + *
      +   * The 3-letter currency code defined in ISO 4217.
      +   * 
      + */ + public com.google.protobuf.ByteString + getCurrencyCodeBytes() { + java.lang.Object ref = currencyCode_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + currencyCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int UNITS_FIELD_NUMBER = 2; + private long units_; + /** + * optional int64 units = 2; + * + *
      +   * The whole units of the amount.
      +   * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
      +   * 
      + */ + public long getUnits() { + return units_; + } + + public static final int NANOS_FIELD_NUMBER = 3; + private int nanos_; + /** + * optional int32 nanos = 3; + * + *
      +   * Number of nano (10^-9) units of the amount.
      +   * The value must be between -999,999,999 and +999,999,999 inclusive.
      +   * If `units` is positive, `nanos` must be positive or zero.
      +   * If `units` is zero, `nanos` can be positive, zero, or negative.
      +   * If `units` is negative, `nanos` must be negative or zero.
      +   * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
      +   * 
      + */ + public int getNanos() { + return nanos_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getCurrencyCodeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, currencyCode_); + } + if (units_ != 0L) { + output.writeInt64(2, units_); + } + if (nanos_ != 0) { + output.writeInt32(3, nanos_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getCurrencyCodeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, currencyCode_); + } + if (units_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, units_); + } + if (nanos_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, nanos_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.type.Money parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.type.Money parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.type.Money parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.type.Money parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.type.Money parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.type.Money parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.type.Money parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.type.Money parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.type.Money parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.type.Money parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.type.Money prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.type.Money} + * + *
      +   * Represents an amount of money with its currency type.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.type.Money) + com.google.type.MoneyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.type.MoneyProto.internal_static_google_type_Money_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.type.MoneyProto.internal_static_google_type_Money_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.type.Money.class, com.google.type.Money.Builder.class); + } + + // Construct using com.google.type.Money.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + currencyCode_ = ""; + + units_ = 0L; + + nanos_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.type.MoneyProto.internal_static_google_type_Money_descriptor; + } + + public com.google.type.Money getDefaultInstanceForType() { + return com.google.type.Money.getDefaultInstance(); + } + + public com.google.type.Money build() { + com.google.type.Money result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.type.Money buildPartial() { + com.google.type.Money result = new com.google.type.Money(this); + result.currencyCode_ = currencyCode_; + result.units_ = units_; + result.nanos_ = nanos_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.type.Money) { + return mergeFrom((com.google.type.Money)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.type.Money other) { + if (other == com.google.type.Money.getDefaultInstance()) return this; + if (!other.getCurrencyCode().isEmpty()) { + currencyCode_ = other.currencyCode_; + onChanged(); + } + if (other.getUnits() != 0L) { + setUnits(other.getUnits()); + } + if (other.getNanos() != 0) { + setNanos(other.getNanos()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.type.Money parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.type.Money) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object currencyCode_ = ""; + /** + * optional string currency_code = 1; + * + *
      +     * The 3-letter currency code defined in ISO 4217.
      +     * 
      + */ + public java.lang.String getCurrencyCode() { + java.lang.Object ref = currencyCode_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + currencyCode_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string currency_code = 1; + * + *
      +     * The 3-letter currency code defined in ISO 4217.
      +     * 
      + */ + public com.google.protobuf.ByteString + getCurrencyCodeBytes() { + java.lang.Object ref = currencyCode_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + currencyCode_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string currency_code = 1; + * + *
      +     * The 3-letter currency code defined in ISO 4217.
      +     * 
      + */ + public Builder setCurrencyCode( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + currencyCode_ = value; + onChanged(); + return this; + } + /** + * optional string currency_code = 1; + * + *
      +     * The 3-letter currency code defined in ISO 4217.
      +     * 
      + */ + public Builder clearCurrencyCode() { + + currencyCode_ = getDefaultInstance().getCurrencyCode(); + onChanged(); + return this; + } + /** + * optional string currency_code = 1; + * + *
      +     * The 3-letter currency code defined in ISO 4217.
      +     * 
      + */ + public Builder setCurrencyCodeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + currencyCode_ = value; + onChanged(); + return this; + } + + private long units_ ; + /** + * optional int64 units = 2; + * + *
      +     * The whole units of the amount.
      +     * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
      +     * 
      + */ + public long getUnits() { + return units_; + } + /** + * optional int64 units = 2; + * + *
      +     * The whole units of the amount.
      +     * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
      +     * 
      + */ + public Builder setUnits(long value) { + + units_ = value; + onChanged(); + return this; + } + /** + * optional int64 units = 2; + * + *
      +     * The whole units of the amount.
      +     * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
      +     * 
      + */ + public Builder clearUnits() { + + units_ = 0L; + onChanged(); + return this; + } + + private int nanos_ ; + /** + * optional int32 nanos = 3; + * + *
      +     * Number of nano (10^-9) units of the amount.
      +     * The value must be between -999,999,999 and +999,999,999 inclusive.
      +     * If `units` is positive, `nanos` must be positive or zero.
      +     * If `units` is zero, `nanos` can be positive, zero, or negative.
      +     * If `units` is negative, `nanos` must be negative or zero.
      +     * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
      +     * 
      + */ + public int getNanos() { + return nanos_; + } + /** + * optional int32 nanos = 3; + * + *
      +     * Number of nano (10^-9) units of the amount.
      +     * The value must be between -999,999,999 and +999,999,999 inclusive.
      +     * If `units` is positive, `nanos` must be positive or zero.
      +     * If `units` is zero, `nanos` can be positive, zero, or negative.
      +     * If `units` is negative, `nanos` must be negative or zero.
      +     * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
      +     * 
      + */ + public Builder setNanos(int value) { + + nanos_ = value; + onChanged(); + return this; + } + /** + * optional int32 nanos = 3; + * + *
      +     * Number of nano (10^-9) units of the amount.
      +     * The value must be between -999,999,999 and +999,999,999 inclusive.
      +     * If `units` is positive, `nanos` must be positive or zero.
      +     * If `units` is zero, `nanos` can be positive, zero, or negative.
      +     * If `units` is negative, `nanos` must be negative or zero.
      +     * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
      +     * 
      + */ + public Builder clearNanos() { + + nanos_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.type.Money) + } + + // @@protoc_insertion_point(class_scope:google.type.Money) + private static final com.google.type.Money DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.type.Money(); + } + + public static com.google.type.Money getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Money parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Money(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.type.Money getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyOrBuilder.java new file mode 100644 index 000000000000..88567eecfba8 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyOrBuilder.java @@ -0,0 +1,51 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/money.proto + +package com.google.type; + +public interface MoneyOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.type.Money) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string currency_code = 1; + * + *
      +   * The 3-letter currency code defined in ISO 4217.
      +   * 
      + */ + java.lang.String getCurrencyCode(); + /** + * optional string currency_code = 1; + * + *
      +   * The 3-letter currency code defined in ISO 4217.
      +   * 
      + */ + com.google.protobuf.ByteString + getCurrencyCodeBytes(); + + /** + * optional int64 units = 2; + * + *
      +   * The whole units of the amount.
      +   * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
      +   * 
      + */ + long getUnits(); + + /** + * optional int32 nanos = 3; + * + *
      +   * Number of nano (10^-9) units of the amount.
      +   * The value must be between -999,999,999 and +999,999,999 inclusive.
      +   * If `units` is positive, `nanos` must be positive or zero.
      +   * If `units` is zero, `nanos` can be positive, zero, or negative.
      +   * If `units` is negative, `nanos` must be negative or zero.
      +   * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
      +   * 
      + */ + int getNanos(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyProto.java new file mode 100644 index 000000000000..4c5f0abec619 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyProto.java @@ -0,0 +1,51 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/money.proto + +package com.google.type; + +public final class MoneyProto { + private MoneyProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_type_Money_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_type_Money_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\027google/type/money.proto\022\013google.type\"<" + + "\n\005Money\022\025\n\rcurrency_code\030\001 \001(\t\022\r\n\005units\030" + + "\002 \001(\003\022\r\n\005nanos\030\003 \001(\005B\037\n\017com.google.typeB" + + "\nMoneyProtoP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_google_type_Money_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_type_Money_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_type_Money_descriptor, + new java.lang.String[] { "CurrencyCode", "Units", "Nanos", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDay.java b/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDay.java new file mode 100644 index 000000000000..494356df0c58 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDay.java @@ -0,0 +1,659 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/timeofday.proto + +package com.google.type; + +/** + * Protobuf type {@code google.type.TimeOfDay} + * + *
      + * Represents a time of day. The date and time zone are either not significant
      + * or are specified elsewhere. An API may chose to allow leap seconds. Related
      + * types are [google.type.Date][google.type.Date] and [google.protobuf.Timestamp][google.protobuf.Timestamp].
      + * 
      + */ +public final class TimeOfDay extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.type.TimeOfDay) + TimeOfDayOrBuilder { + // Use TimeOfDay.newBuilder() to construct. + private TimeOfDay(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private TimeOfDay() { + hours_ = 0; + minutes_ = 0; + seconds_ = 0; + nanos_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private TimeOfDay( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + hours_ = input.readInt32(); + break; + } + case 16: { + + minutes_ = input.readInt32(); + break; + } + case 24: { + + seconds_ = input.readInt32(); + break; + } + case 32: { + + nanos_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.type.TimeOfDayProto.internal_static_google_type_TimeOfDay_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.type.TimeOfDayProto.internal_static_google_type_TimeOfDay_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.type.TimeOfDay.class, com.google.type.TimeOfDay.Builder.class); + } + + public static final int HOURS_FIELD_NUMBER = 1; + private int hours_; + /** + * optional int32 hours = 1; + * + *
      +   * Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
      +   * to allow the value "24:00:00" for scenarios like business closing time.
      +   * 
      + */ + public int getHours() { + return hours_; + } + + public static final int MINUTES_FIELD_NUMBER = 2; + private int minutes_; + /** + * optional int32 minutes = 2; + * + *
      +   * Minutes of hour of day. Must be from 0 to 59.
      +   * 
      + */ + public int getMinutes() { + return minutes_; + } + + public static final int SECONDS_FIELD_NUMBER = 3; + private int seconds_; + /** + * optional int32 seconds = 3; + * + *
      +   * Seconds of minutes of the time. Must normally be from 0 to 59. An API may
      +   * allow the value 60 if it allows leap-seconds.
      +   * 
      + */ + public int getSeconds() { + return seconds_; + } + + public static final int NANOS_FIELD_NUMBER = 4; + private int nanos_; + /** + * optional int32 nanos = 4; + * + *
      +   * Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
      +   * 
      + */ + public int getNanos() { + return nanos_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (hours_ != 0) { + output.writeInt32(1, hours_); + } + if (minutes_ != 0) { + output.writeInt32(2, minutes_); + } + if (seconds_ != 0) { + output.writeInt32(3, seconds_); + } + if (nanos_ != 0) { + output.writeInt32(4, nanos_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (hours_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, hours_); + } + if (minutes_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, minutes_); + } + if (seconds_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, seconds_); + } + if (nanos_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(4, nanos_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.type.TimeOfDay)) { + return super.equals(obj); + } + com.google.type.TimeOfDay other = (com.google.type.TimeOfDay) obj; + + boolean result = true; + result = result && (getHours() + == other.getHours()); + result = result && (getMinutes() + == other.getMinutes()); + result = result && (getSeconds() + == other.getSeconds()); + result = result && (getNanos() + == other.getNanos()); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = (37 * hash) + HOURS_FIELD_NUMBER; + hash = (53 * hash) + getHours(); + hash = (37 * hash) + MINUTES_FIELD_NUMBER; + hash = (53 * hash) + getMinutes(); + hash = (37 * hash) + SECONDS_FIELD_NUMBER; + hash = (53 * hash) + getSeconds(); + hash = (37 * hash) + NANOS_FIELD_NUMBER; + hash = (53 * hash) + getNanos(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.type.TimeOfDay parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.type.TimeOfDay parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.type.TimeOfDay parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.type.TimeOfDay parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.type.TimeOfDay parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.type.TimeOfDay parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.type.TimeOfDay parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.type.TimeOfDay parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.type.TimeOfDay parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.type.TimeOfDay parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.type.TimeOfDay prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.type.TimeOfDay} + * + *
      +   * Represents a time of day. The date and time zone are either not significant
      +   * or are specified elsewhere. An API may chose to allow leap seconds. Related
      +   * types are [google.type.Date][google.type.Date] and [google.protobuf.Timestamp][google.protobuf.Timestamp].
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.type.TimeOfDay) + com.google.type.TimeOfDayOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.type.TimeOfDayProto.internal_static_google_type_TimeOfDay_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.type.TimeOfDayProto.internal_static_google_type_TimeOfDay_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.type.TimeOfDay.class, com.google.type.TimeOfDay.Builder.class); + } + + // Construct using com.google.type.TimeOfDay.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + hours_ = 0; + + minutes_ = 0; + + seconds_ = 0; + + nanos_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.type.TimeOfDayProto.internal_static_google_type_TimeOfDay_descriptor; + } + + public com.google.type.TimeOfDay getDefaultInstanceForType() { + return com.google.type.TimeOfDay.getDefaultInstance(); + } + + public com.google.type.TimeOfDay build() { + com.google.type.TimeOfDay result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.type.TimeOfDay buildPartial() { + com.google.type.TimeOfDay result = new com.google.type.TimeOfDay(this); + result.hours_ = hours_; + result.minutes_ = minutes_; + result.seconds_ = seconds_; + result.nanos_ = nanos_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.type.TimeOfDay) { + return mergeFrom((com.google.type.TimeOfDay)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.type.TimeOfDay other) { + if (other == com.google.type.TimeOfDay.getDefaultInstance()) return this; + if (other.getHours() != 0) { + setHours(other.getHours()); + } + if (other.getMinutes() != 0) { + setMinutes(other.getMinutes()); + } + if (other.getSeconds() != 0) { + setSeconds(other.getSeconds()); + } + if (other.getNanos() != 0) { + setNanos(other.getNanos()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.type.TimeOfDay parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.type.TimeOfDay) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int hours_ ; + /** + * optional int32 hours = 1; + * + *
      +     * Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
      +     * to allow the value "24:00:00" for scenarios like business closing time.
      +     * 
      + */ + public int getHours() { + return hours_; + } + /** + * optional int32 hours = 1; + * + *
      +     * Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
      +     * to allow the value "24:00:00" for scenarios like business closing time.
      +     * 
      + */ + public Builder setHours(int value) { + + hours_ = value; + onChanged(); + return this; + } + /** + * optional int32 hours = 1; + * + *
      +     * Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
      +     * to allow the value "24:00:00" for scenarios like business closing time.
      +     * 
      + */ + public Builder clearHours() { + + hours_ = 0; + onChanged(); + return this; + } + + private int minutes_ ; + /** + * optional int32 minutes = 2; + * + *
      +     * Minutes of hour of day. Must be from 0 to 59.
      +     * 
      + */ + public int getMinutes() { + return minutes_; + } + /** + * optional int32 minutes = 2; + * + *
      +     * Minutes of hour of day. Must be from 0 to 59.
      +     * 
      + */ + public Builder setMinutes(int value) { + + minutes_ = value; + onChanged(); + return this; + } + /** + * optional int32 minutes = 2; + * + *
      +     * Minutes of hour of day. Must be from 0 to 59.
      +     * 
      + */ + public Builder clearMinutes() { + + minutes_ = 0; + onChanged(); + return this; + } + + private int seconds_ ; + /** + * optional int32 seconds = 3; + * + *
      +     * Seconds of minutes of the time. Must normally be from 0 to 59. An API may
      +     * allow the value 60 if it allows leap-seconds.
      +     * 
      + */ + public int getSeconds() { + return seconds_; + } + /** + * optional int32 seconds = 3; + * + *
      +     * Seconds of minutes of the time. Must normally be from 0 to 59. An API may
      +     * allow the value 60 if it allows leap-seconds.
      +     * 
      + */ + public Builder setSeconds(int value) { + + seconds_ = value; + onChanged(); + return this; + } + /** + * optional int32 seconds = 3; + * + *
      +     * Seconds of minutes of the time. Must normally be from 0 to 59. An API may
      +     * allow the value 60 if it allows leap-seconds.
      +     * 
      + */ + public Builder clearSeconds() { + + seconds_ = 0; + onChanged(); + return this; + } + + private int nanos_ ; + /** + * optional int32 nanos = 4; + * + *
      +     * Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
      +     * 
      + */ + public int getNanos() { + return nanos_; + } + /** + * optional int32 nanos = 4; + * + *
      +     * Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
      +     * 
      + */ + public Builder setNanos(int value) { + + nanos_ = value; + onChanged(); + return this; + } + /** + * optional int32 nanos = 4; + * + *
      +     * Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
      +     * 
      + */ + public Builder clearNanos() { + + nanos_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.type.TimeOfDay) + } + + // @@protoc_insertion_point(class_scope:google.type.TimeOfDay) + private static final com.google.type.TimeOfDay DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.type.TimeOfDay(); + } + + public static com.google.type.TimeOfDay getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public TimeOfDay parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new TimeOfDay(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.type.TimeOfDay getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayOrBuilder.java new file mode 100644 index 000000000000..d1eda79b5fb0 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayOrBuilder.java @@ -0,0 +1,47 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/timeofday.proto + +package com.google.type; + +public interface TimeOfDayOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.type.TimeOfDay) + com.google.protobuf.MessageOrBuilder { + + /** + * optional int32 hours = 1; + * + *
      +   * Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
      +   * to allow the value "24:00:00" for scenarios like business closing time.
      +   * 
      + */ + int getHours(); + + /** + * optional int32 minutes = 2; + * + *
      +   * Minutes of hour of day. Must be from 0 to 59.
      +   * 
      + */ + int getMinutes(); + + /** + * optional int32 seconds = 3; + * + *
      +   * Seconds of minutes of the time. Must normally be from 0 to 59. An API may
      +   * allow the value 60 if it allows leap-seconds.
      +   * 
      + */ + int getSeconds(); + + /** + * optional int32 nanos = 4; + * + *
      +   * Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
      +   * 
      + */ + int getNanos(); +} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayProto.java new file mode 100644 index 000000000000..e995fee5b778 --- /dev/null +++ b/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayProto.java @@ -0,0 +1,52 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/type/timeofday.proto + +package com.google.type; + +public final class TimeOfDayProto { + private TimeOfDayProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_type_TimeOfDay_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_type_TimeOfDay_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\033google/type/timeofday.proto\022\013google.ty" + + "pe\"K\n\tTimeOfDay\022\r\n\005hours\030\001 \001(\005\022\017\n\007minute" + + "s\030\002 \001(\005\022\017\n\007seconds\030\003 \001(\005\022\r\n\005nanos\030\004 \001(\005B" + + "&\n\017com.google.typeB\016TimeOfDayProtoP\001\240\001\001b" + + "\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_google_type_TimeOfDay_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_type_TimeOfDay_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_type_TimeOfDay_descriptor, + new java.lang.String[] { "Hours", "Minutes", "Seconds", "Nanos", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-gax/pom.xml b/gcloud-java-gax/pom.xml new file mode 100644 index 000000000000..d170baf4b9b7 --- /dev/null +++ b/gcloud-java-gax/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + com.google.gcloud + gcloud-java-gax + jar + GCloud Api Extensions + + GCloud Api Extensions + + + com.google.gcloud + gcloud-java-pom + 0.0.7-SNAPSHOT + + + + io.grpc + grpc-all + 0.9.0 + + + com.google.auto.value + auto-value + 1.1 + + + junit + junit + 4.12 + test + + + org.mockito + mockito-core + 1.10.19 + test + + + com.google.truth + truth + 0.27 + test + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + generate-sources + add-source + + + src/generated/main + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.2 + + + attach-javadocs + + jar + + + -Xdoclint:none + + + + + + + From 24229075b2bbd4d4002a33714ba403f6361f7544 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Mon, 2 Nov 2015 10:40:06 -0800 Subject: [PATCH 171/203] Updating README.md to latest form --- gcloud-java-gax/README.md | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/gcloud-java-gax/README.md b/gcloud-java-gax/README.md index fe478991b1e7..d3dfbdde1ca8 100644 --- a/gcloud-java-gax/README.md +++ b/gcloud-java-gax/README.md @@ -1,16 +1,14 @@ -Google Cloud Java Client -========================== +Google Cloud Java Client -- GAX +========================================= -Java idiomatic client for [Google Cloud Platform][cloud-platform] services. +This module provides common functionality required by service-specific modules of this library. [![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) +[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-gax.svg)](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-gax.svg) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) -- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs) -- [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html) - -This module provides common functionality and is required by the other service specific modules. +- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/package-summary.html) Quickstart ---------- @@ -19,10 +17,15 @@ Add this to your pom.xml file com.google.gcloud gcloud-java-gax - 0.0.6 + 0.0.10 ``` +Java Versions +------------- + +Java 7 or above is required for using this client. + Contributing ------------ @@ -30,11 +33,6 @@ Contributions to this library are always welcome and highly encouraged. See [CONTRIBUTING] for more information on how to get started. -Java Versions -------------- - -Java 7 or above is required for using this client. - Versioning ---------- From ee1bb32dfa10884a3da8b0571f0387f63f06977c Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Mon, 2 Nov 2015 12:54:36 -0800 Subject: [PATCH 172/203] Updating version and installation module --- gcloud-java-gax/pom.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcloud-java-gax/pom.xml b/gcloud-java-gax/pom.xml index d170baf4b9b7..78d852313b77 100644 --- a/gcloud-java-gax/pom.xml +++ b/gcloud-java-gax/pom.xml @@ -11,8 +11,11 @@ com.google.gcloud gcloud-java-pom - 0.0.7-SNAPSHOT - + 0.0.11-SNAPSHOT + + + gcloud-java-gax + io.grpc From d0d48899f1d6f773ff84e65c69aace30d67dd290 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Mon, 2 Nov 2015 17:29:10 -0800 Subject: [PATCH 173/203] Adding GAX classes --- gcloud-java-gax/pom.xml | 2 +- .../java/io/gapi/gax/grpc/ApiCallable.java | 409 ++++++++ .../io/gapi/gax/grpc/CallableDescriptor.java | 76 ++ .../io/gapi/gax/grpc/CompoundClientCall.java | 78 ++ .../io/gapi/gax/grpc/FollowedByCallable.java | 146 +++ .../java/io/gapi/gax/grpc/PageDescriptor.java | 62 ++ .../gapi/gax/grpc/PageStreamingCallable.java | 185 ++++ .../io/gapi/gax/grpc/RetryingCallable.java | 197 ++++ .../io/gapi/gax/grpc/ServiceApiSettings.java | 119 +++ .../gapi/gax/grpc/TransformingCallable.java | 171 ++++ .../java/io/gapi/gax/internal/ApiUtils.java | 110 +++ .../io/gapi/gax/protobuf/PathTemplate.java | 880 ++++++++++++++++++ .../io/gapi/gax/protobuf/ResourceName.java | 275 ++++++ .../gax/protobuf/ValidationException.java | 63 ++ .../io/gapi/gax/grpc/ApiCallableTest.java | 250 +++++ .../gapi/gax/protobuf/PathTemplateTest.java | 168 ++++ .../gapi/gax/protobuf/ResourceNameTest.java | 25 + 17 files changed, 3215 insertions(+), 1 deletion(-) create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CallableDescriptor.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CompoundClientCall.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/FollowedByCallable.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageDescriptor.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageStreamingCallable.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/RetryingCallable.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/TransformingCallable.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ResourceName.java create mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ValidationException.java create mode 100644 gcloud-java-gax/src/test/java/io/gapi/gax/grpc/ApiCallableTest.java create mode 100644 gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/PathTemplateTest.java create mode 100644 gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/ResourceNameTest.java diff --git a/gcloud-java-gax/pom.xml b/gcloud-java-gax/pom.xml index 78d852313b77..83bd92f49f3e 100644 --- a/gcloud-java-gax/pom.xml +++ b/gcloud-java-gax/pom.xml @@ -58,7 +58,7 @@ add-source - src/generated/main + generated/src/main diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java new file mode 100644 index 000000000000..edaa0885d46f --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java @@ -0,0 +1,409 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.grpc; + +import com.google.common.util.concurrent.ListenableFuture; + +import io.grpc.CallOptions; +import io.grpc.Channel; +import io.grpc.ClientCall; +import io.grpc.ExperimentalApi; +import io.grpc.MethodDescriptor; +import io.grpc.MethodDescriptor.MethodType; +import io.grpc.StatusException; +import io.grpc.stub.ClientCalls; +import io.grpc.stub.StreamObserver; + +import java.util.Iterator; +import java.util.concurrent.Executor; + +import javax.annotation.Nullable; + +/** + * A callable is an object which represents one or more rpc calls. Various operators on callables + * produce new callables, representing common API programming patterns. Callables can be used to + * directly operate against an api, or to efficiently implement wrappers for apis which add + * additional functionality and processing. + * + *

      Technically, callables are a factory for grpc {@link ClientCall} objects, and can be executed + * by methods of the {@link ClientCalls} class. They also provide shortcuts for direct execution of + * the callable instance. + */ +@ExperimentalApi +public abstract class ApiCallable { + + // TODO(wrwg): Support interceptors and method/call option configurations. + // TODO(wrwg): gather more feedback whether the overload with java.util.Concurrent hurts that + // much that we want to rename this into ClientCallable or such. + + // Subclass Contract + // ================= + + /** + * Creates a new GRPC call from this callable. A channel may or may not be provided. + * If a channel is not provided, the callable must be bound to a channel. + */ + public abstract ClientCall newCall(@Nullable Channel channel); + + /** + * Return a descriptor for this callable, or null if none available. + */ + @Nullable public CallableDescriptor getDescriptor() { + return null; + } + + /** + * Gets the channel bound to this callable, or null, if none is bound to it. + */ + @Nullable public Channel getBoundChannel() { + return null; + } + + // Binding Callables + // ================= + + /** + * Returns a callable which is bound to the given channel. Operations on the result can + * omit the channel. If a channel is provided anyway, it overrides the bound channel. + */ + public ApiCallable bind(final Channel boundChannel) { + return new ApiCallable() { + @Override + public ClientCall newCall(@Nullable Channel channel) { + if (channel == null) { + // If the caller does not provide a channel, we use the bound one. + channel = boundChannel; + } + return ApiCallable.this.newCall(channel); + } + + @Override + @Nullable + public CallableDescriptor getDescriptor() { + return ApiCallable.this.getDescriptor(); + } + + @Override + @Nullable + public Channel getBoundChannel() { + return boundChannel; + } + }; + } + + // Running Callables + // ================= + + private void requireMethodType(MethodType type) { + MethodType actualType = getDescriptor() != null + ? getDescriptor().getMethodDescriptor().getType() : null; + if (actualType == null || actualType == MethodType.UNKNOWN || actualType.equals(type)) { + return; + } + throw new IllegalArgumentException(String.format( + "Requested method type '%s' differs from actual type '%s'", type, actualType)); + } + + /** + * Convenience method to run a unary callable synchronously. If no channel is provided, + * the callable must be bound to one. + */ + public ResponseT call(@Nullable Channel channel, RequestT request) { + requireMethodType(MethodType.UNARY); + return ClientCalls.blockingUnaryCall(newCall(channel), request); + } + + /** + * Convenience method to run a unary callable synchronously, without channel. Requires a callable + * which is bound to a channel. + */ + public ResponseT call(RequestT request) { + return call(null, request); + } + + /** + * Convenience method to run a unary callable asynchronously. If no channel is provided, + * the callable must be bound to one. + */ + public void asyncCall(@Nullable Channel channel, RequestT request, + StreamObserver responseObserver) { + requireMethodType(MethodType.UNARY); + ClientCalls.asyncUnaryCall(newCall(channel), request, responseObserver); + } + + /** + * Convenience method to run a unary callable asynchronously, without channel. Requires a callable + * which is bound to a channel. + */ + public void asyncCall(RequestT request, StreamObserver responseObserver) { + asyncCall(null, request, responseObserver); + } + + /** + * Convenience method to run a unary callable returning a future. If no channel is provided, + * the callable must be bound to one. + */ + public ListenableFuture futureCall(@Nullable Channel channel, RequestT request) { + requireMethodType(MethodType.UNARY); + return ClientCalls.futureUnaryCall(newCall(channel), request); + } + + /** + * Convenience method to run a unary callable returning a future, without a channel. Requires a + * callable which is bound to a channel. + */ + public ListenableFuture futureCall(RequestT request) { + return futureCall(null, request); + } + + /** + * Convenience method for a blocking server streaming call. If no channel is provided, + * the callable must be bound to one. + * + *

      Returns an iterable for the responses. Note the returned iterable can be used only once. + * Returning an Iterator would be more precise, but iterators cannot be used in Java for loops. + */ + public Iterable iterableResponseStreamCall(@Nullable Channel channel, + RequestT request) { + requireMethodType(MethodType.SERVER_STREAMING); + final Iterator result = + ClientCalls.blockingServerStreamingCall(newCall(channel), request); + return new Iterable() { + @Override + public Iterator iterator() { + return result; + } + }; + } + + /** + * Convenience method for a blocking server streaming call, without a channel. Requires a + * callable which is bound to a channel. + * + *

      Returns an iterable for the responses. Note the returned iterable can be used only once. + * Returning an Iterator would be more precise, but iterators cannot be used in Java for loops. + */ + public Iterable iterableResponseStreamCall(RequestT request) { + return iterableResponseStreamCall(null, request); + } + + // Creation + // ======== + + /** + * Returns a callable which executes the described method. + * + *

      +   *  Response response = Callable.create(SerivceGrpc.CONFIG.myMethod).call(channel, request);
      +   * 
      + */ + public static ApiCallable + create(MethodDescriptor descriptor) { + return create(CallableDescriptor.create(descriptor)); + } + + /** + * Returns a callable which executes the method described by a {@link CallableDescriptor}. + */ + public static ApiCallable + create(final CallableDescriptor descriptor) { + return new ApiCallable() { + @Override public ClientCall newCall(Channel channel) { + if (channel == null) { + throw new IllegalStateException(String.format( + "unbound callable for method '%s' requires a channel for execution", + descriptor.getMethodDescriptor().getFullMethodName())); + } + return channel.newCall(descriptor.getMethodDescriptor(), CallOptions.DEFAULT); + } + + @Override public CallableDescriptor getDescriptor() { + return descriptor; + } + + @Override public String toString() { + return descriptor.getMethodDescriptor().getFullMethodName(); + } + }; + } + + /** + * Returns a callable which executes the given function asynchronously on each provided + * input. The supplied executor is used for creating tasks for each input. Example: + * + *
      +   *  Callable.Transformer<RequestT, ResponseT> transformer = ...;
      +   *  Response response = Callable.create(transformer, executor).call(channel, request);
      +   * 
      + */ + public static ApiCallable + create(Transformer transformer, Executor executor) { + return new TransformingCallable(transformer, executor); + } + + + /** + * Returns a callable which executes the given function immediately on each provided input. + * Similar as {@link #create(Transformer, Executor)} but does not operate asynchronously and does + * not require an executor. + * + *

      Note that the callable returned by this method does not respect flow control. Some + * operations applied to it may deadlock because of this. However, it is safe to use this + * callable in the context of a {@link #followedBy(ApiCallable)} operation, which is the major + * use cases for transformers. But if you use a transformer to simulate a real rpc + * you should use {@link #create(Transformer, Executor)} instead. + */ + public static ApiCallable + create(Transformer transformer) { + return new TransformingCallable(transformer, null); + } + + /** + * Interface for a transformer. It can throw a {@link StatusException} to indicate an error. + */ + public interface Transformer { + ResponseT apply(RequestT request) throws StatusException; + } + + /** + * Returns a callable which echos its input. + */ + public static ApiCallable + identity() { + return new TransformingCallable(new Transformer() { + @Override public RequestT apply(RequestT request) throws StatusException { + return request; + } + }, null); + } + + /** + * Returns a callable which always returns the given constant. + */ + public static ApiCallable + constant(final ResponseT result) { + return new TransformingCallable(new Transformer() { + @Override public ResponseT apply(RequestT request) throws StatusException { + return result; + } + }, null); + } + + // Followed-By + // =========== + + /** + * Returns a callable which forwards the responses from this callable as requests into the other + * callable. Works both for unary and streaming operands. Example: + * + *

      +   * String bookName = ...;
      +   * Callable.Transformer<Book, GetAuthorRequest> bookToGetAuthorRequest = ...;
      +   * Author response =
      +   *     Callable.create(LibraryGrpc.CONFIG.getBook)
      +   *             .followedBy(Callable.create(bookToGetAuthorRequest))
      +   *             .followedBy(Callable.create(LibraryGrpc.CONFIG.getAuthor))
      +   *             .call(channel, new GetBookRequest().setName(bookName).build());
      +   * 
      + * + *

      For streaming calls, each output of the first callable will be forwarded to the second + * one as it arrives, allowing for streaming pipelines. + */ + public ApiCallable + followedBy(ApiCallable callable) { + return new FollowedByCallable(this, callable); + } + + // Retrying + // ======== + + /** + * Returns a callable which retries using exponential back-off on transient errors. Example: + * + *

      +   * Response response = Callable.create(METHOD).retrying().call(channel, request);
      +   * 
      + * + *

      The call will be retried if and only if the returned status code is {@code UNAVAILABLE}. + * + *

      No output will be produced until the underlying callable has succeeded. Applied to compound + * callables, this can be used to implement simple transactions supposed the underlying callables + * are either side-effect free or idempotent. + * + *

      Note that the retry callable requires to buffer all inputs and outputs of the underlying + * callable, and should be used with care when applied to streaming calls. + */ + public ApiCallable retrying() { + return new RetryingCallable(this); + } + + // Page Streaming + // ============== + + /** + * Returns a callable which streams the resources obtained from a series of calls to a method + * implementing the pagination pattern. Example: + * + *

      +   *  for (Resource resource :
      +   *       Callable.create(listBooksDescriptor)
      +   *               .pageStreaming(pageDescriptor)
      +   *               .iterableResponseStreamCall(channel, request)) {
      +   *    doSomething(resource);
      +   *  }
      +   *
      + * + *

      The returned stream does not buffer results; if it is traversed again, the API will be + * called again. + */ + public ApiCallable + pageStreaming(PageDescriptor pageDescriptor) { + return new PageStreamingCallable(this, pageDescriptor); + } + + /** + * Returns a callable which behaves the same as {@link #pageStreaming(PageDescriptor)}, with + * the page descriptor attempted to derive from the callable descriptor. + * + * @throws IllegalArgumentException if a page descriptor is not derivable. + */ + public ApiCallable + pageStreaming(Class resourceType) { + PageDescriptor pageDescriptor = + getDescriptor() != null ? getDescriptor().getPageDescriptor(resourceType) : null; + if (pageDescriptor == null) { + throw new IllegalArgumentException(String.format( + "cannot derive page descriptor for '%s'", this)); + } + return pageStreaming(pageDescriptor); + } +} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CallableDescriptor.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CallableDescriptor.java new file mode 100644 index 000000000000..b2c3a6952e32 --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CallableDescriptor.java @@ -0,0 +1,76 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.grpc; + +import com.google.common.base.Preconditions; + +import io.grpc.ExperimentalApi; +import io.grpc.MethodDescriptor; + +import javax.annotation.Nullable; + +/** + * Describes meta data for a {@link ApiCallable}. + */ +@ExperimentalApi +class CallableDescriptor { + + /** + * Constructs a descriptor from grpc descriptor. + */ + public static CallableDescriptor + create(MethodDescriptor grpcDescriptor) { + return new CallableDescriptor(grpcDescriptor); + } + + private final MethodDescriptor descriptor; + + private CallableDescriptor(MethodDescriptor descriptor) { + this.descriptor = Preconditions.checkNotNull(descriptor); + } + + /** + * Returns the grpc method descriptor. + */ + public MethodDescriptor getMethodDescriptor() { + return descriptor; + } + + /** + * Returns a page descriptor if one is derivable from the callable descriptor, null if not. + * By default, this returns null, but sub-classes may override this. + */ + @Nullable public PageDescriptor + getPageDescriptor(@SuppressWarnings("unused") Class resourceType) { + return null; + } +} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CompoundClientCall.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CompoundClientCall.java new file mode 100644 index 000000000000..99b8aaa35fbd --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CompoundClientCall.java @@ -0,0 +1,78 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.grpc; + +import io.grpc.ClientCall; +import io.grpc.Metadata; +import io.grpc.Status; + +/** + * A helper to implement compound calls which is used for the implementation of other callables in + * this package. This allows to have the listener and call types being implemented from one class, + * which is not possible out-of-the-box because {@link ClientCall} is a class, not an interface. + * (Note that in Java8 ClientCall could be an interface, because it does not has instance data.) + */ +abstract class CompoundClientCall + extends ClientCall { + + private final InnerListener listener = new InnerListener(); + + void onHeaders(@SuppressWarnings("unused") Metadata headers) { + // We typically ignore response headers in compound calls. + } + + abstract void onMessage(InnerResT message); + + abstract void onClose(Status status, Metadata trailers); + + final ClientCall.Listener listener() { + return listener; + } + + class InnerListener extends ClientCall.Listener { + + @Override + public void onHeaders(Metadata headers) { + CompoundClientCall.this.onHeaders(headers); + } + + @Override + public void onMessage(InnerResT message) { + CompoundClientCall.this.onMessage(message); + } + + @Override + public void onClose(Status status, Metadata trailers) { + CompoundClientCall.this.onClose(status, trailers); + } + } +} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/FollowedByCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/FollowedByCallable.java new file mode 100644 index 000000000000..3fe019153c15 --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/FollowedByCallable.java @@ -0,0 +1,146 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.grpc; + +import io.grpc.Channel; +import io.grpc.ClientCall; +import io.grpc.Metadata; +import io.grpc.Status; + +import javax.annotation.Nullable; + +/** + * Helper type for the implementation of {@link ApiCallable} methods. Please see there first for the + * specification of what this is doing. This class is concerned with the how. + * + *

      Implements the followedBy callable, which executes two callables in parallel, piping output + * from the first to the second. + */ +class FollowedByCallable extends ApiCallable { + + private final ApiCallable first; + private final ApiCallable second; + + FollowedByCallable(ApiCallable first, ApiCallable second) { + this.first = first; + this.second = second; + } + + @Override + public String toString() { + return String.format("followedBy(%s, %s)", first, second); + } + + @Override + @Nullable + public Channel getBoundChannel() { + // Inherit a bound channel from operands. + Channel channel = first.getBoundChannel(); + if (channel != null) { + return channel; + } + return second.getBoundChannel(); + } + + @Override + public ClientCall newCall(Channel channel) { + return new FollowedByCall(channel); + } + + /** + * Both calls are started in parallel, and the output from the first is immediately piped as input + * into the second. As we don't know the required input for the second call, we request all output + * from the first as soon as some output for the composite is requested. + */ + private class FollowedByCall extends CompoundClientCall { + + private Channel channel; + private ClientCall firstCall; + private ClientCall secondCall; + private ClientCall.Listener listener; + + private FollowedByCall(Channel channel) { + this.channel = channel; + } + + @Override + public void start(ClientCall.Listener listener, Metadata headers) { + this.listener = listener; + this.firstCall = first.newCall(channel); + this.secondCall = second.newCall(channel); + + // This instance's listener will receive output from the first call. + this.firstCall.start(this.listener(), headers); + + // The ForwardingCallable listener will receive output from the second call. + this.secondCall.start(listener, headers); + } + + @Override + public void request(int numMessages) { + // We don't know how much inputs the second call needs, so we request all what is available. + firstCall.request(Integer.MAX_VALUE); + secondCall.request(numMessages); + } + + @Override + public void cancel() { + firstCall.cancel(); + secondCall.cancel(); + } + + @Override + public void sendMessage(RequestT message) { + firstCall.sendMessage(message); + } + + @Override + public void halfClose() { + firstCall.halfClose(); + } + + @Override + public void onMessage(InterT message) { + secondCall.sendMessage(message); + } + + @Override + public void onClose(Status status, Metadata trailers) { + if (status.isOk()) { + secondCall.halfClose(); + return; + } + secondCall.cancel(); + listener.onClose(status, trailers); + } + } +} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageDescriptor.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageDescriptor.java new file mode 100644 index 000000000000..b8f47957e9db --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageDescriptor.java @@ -0,0 +1,62 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.grpc; + +import io.grpc.ExperimentalApi; + +/** + * An interface which describes the paging pattern. + */ +@ExperimentalApi +public interface PageDescriptor { + + /** + * Delivers the empty page token. + */ + Object emptyToken(); + + /** + * Injects a page token into the request. + */ + RequestT injectToken(RequestT payload, Object token); + + /** + * Extracts the next token from the response. Returns the empty token if there are + * no more pages. + */ + Object extractNextToken(ResponseT payload); + + /** + * Extracts an iterable of resources from the response. + */ + Iterable extractResources(ResponseT payload); +} \ No newline at end of file diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageStreamingCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageStreamingCallable.java new file mode 100644 index 000000000000..d864ec4fc562 --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageStreamingCallable.java @@ -0,0 +1,185 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.grpc; + +import com.google.common.base.Preconditions; + +import io.grpc.Channel; +import io.grpc.ClientCall; +import io.grpc.Metadata; +import io.grpc.Status; + +import java.util.concurrent.Semaphore; + +import javax.annotation.Nullable; + +/** + * Helper type for the implementation of {@link ApiCallable} methods. Please see there first for the + * specification of what this is doing. This class is concerned with the how. + * + *

      Implementation of the pageStreaming callable. + */ +class PageStreamingCallable extends ApiCallable { + + private final ApiCallable callable; + private final PageDescriptor pageDescriptor; + + + PageStreamingCallable(ApiCallable callable, + PageDescriptor pageDescriptor) { + this.callable = Preconditions.checkNotNull(callable); + this.pageDescriptor = Preconditions.checkNotNull(pageDescriptor); + } + + @Override public String toString() { + return String.format("pageStreaming(%s)", callable.toString()); + } + + @Override + @Nullable + public Channel getBoundChannel() { + return callable.getBoundChannel(); + } + + @Override + public ClientCall newCall(Channel channel) { + return new PageStreamingCall(channel); + } + + /** + * Class which handles both the call logic for the callable and listens to page call responses. + * + *

      The implementation uses a semaphore to handle flow control, since the callable level flow + * control via request() doesn't map 1:1 to the page call flow control. The semaphore holds at any + * time the number of requested messages on callable level. Blocking on the semaphore happens + * exclusively in onMessage() calls for pages. Apart of the first page call which is scheduled at + * the time the caller half-closes, all future page calls will be triggered from onMessage() as + * well. This avoids thread safety issues, assuming the ClientCall concurrency contract. + */ + private class PageStreamingCall extends CompoundClientCall { + + private final Channel channel; + private ClientCall.Listener outerListener; + private Metadata headers; + private RequestT request; + private Semaphore requestedSemaphore = new Semaphore(0); + private ClientCall currentCall; + private Object nextPageToken = pageDescriptor.emptyToken(); + private boolean sentClose; + + private PageStreamingCall(Channel channel) { + this.channel = channel; + } + + @Override + public void start(ClientCall.Listener responseListener, Metadata headers) { + this.outerListener = responseListener; + this.headers = headers; + currentCall = callable.newCall(channel); + currentCall.start(listener(), headers); + } + + @Override + public void request(int numMessages) { + requestedSemaphore.release(numMessages); + } + + @Override + public void sendMessage(RequestT request) { + Preconditions.checkState(this.request == null); + this.request = request; + } + + @Override + public void halfClose() { + // Trigger the call for the first page. + requestNextPage(); + } + + @Override + public void cancel() { + currentCall.cancel(); + if (!sentClose) { + outerListener.onClose(Status.CANCELLED, new Metadata()); + } + } + + @SuppressWarnings("unchecked") + private void requestNextPage() { + currentCall.request(1); + currentCall.sendMessage(pageDescriptor.injectToken(request, nextPageToken)); + currentCall.halfClose(); + } + + @Override + public void onMessage(ResponseT response) { + // Extract the token for the next page. If empty, there are no more pages, + // and we set the token to null. + Object token = pageDescriptor.extractNextToken(response); + nextPageToken = token.equals(pageDescriptor.emptyToken()) ? null : token; + + // Deliver as much resources as have been requested. This may block via + // our semaphore, and while we are delivering, more requests may come in. + for (ResourceT resource : pageDescriptor.extractResources(response)) { + try { + requestedSemaphore.acquire(); + } catch (InterruptedException e) { + outerListener.onClose(Status.fromThrowable(e), new Metadata()); + sentClose = true; + currentCall.cancel(); + return; + } + outerListener.onMessage(resource); + } + + // If there is a next page, create a new call and request it. + if (nextPageToken != null) { + currentCall = callable.newCall(channel); + currentCall.start(listener(), headers); + requestNextPage(); + } else { + outerListener.onClose(Status.OK, new Metadata()); + sentClose = true; + } + } + + @Override + public void onClose(Status status, Metadata trailers) { + if (!status.isOk()) { + // If there is an error, propagate it. Otherwise let onMessage determine how to continue. + outerListener.onClose(status, trailers); + sentClose = true; + } + } + } +} + diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/RetryingCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/RetryingCallable.java new file mode 100644 index 000000000000..d476890c85e9 --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/RetryingCallable.java @@ -0,0 +1,197 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.grpc; + +import com.google.common.base.Throwables; +import com.google.common.collect.Lists; + +import io.grpc.Channel; +import io.grpc.ClientCall; +import io.grpc.Metadata; +import io.grpc.Status; + +import java.util.List; +import java.util.Random; + +import javax.annotation.Nullable; + +/** + * Helper type for the implementation of {@link ApiCallable} methods. Please see there first for the + * specification of what this is doing. This class is concerned with the how. + * + *

      Implementation of the retrying callable. + */ +class RetryingCallable extends ApiCallable { + + // TODO(wgg): make the parameters below configurable. They are currently taken from + // http://en.wikipedia.org/wiki/Exponential_backoff. + + private static final int SLOT_TIME_MILLIS = 2; + private static final int TRUNCATE_AFTER = 10; + private static final int MAX_ATTEMPTS = 16; + private static final Random randomGenerator = new Random(0); + + private final ApiCallable callable; + + RetryingCallable(ApiCallable callable) { + this.callable = callable; + } + + @Override public String toString() { + return String.format("retrying(%s)", callable.toString()); + } + + @Override + @Nullable + public CallableDescriptor getDescriptor() { + return callable.getDescriptor(); + } + + @Override + @Nullable + public Channel getBoundChannel() { + return callable.getBoundChannel(); + } + + @Override public ClientCall newCall(Channel channel) { + return new RetryingCall(channel); + } + + private static boolean canRetry(Status status) { + return status.getCode() == Status.Code.UNAVAILABLE; + } + + /** + * Class implementing the call for retry. + * + *

      This remembers all actions from the caller in order to replay the call if needed. No output + * will be produced until the call has successfully ended. Thus this call requires full buffering + * of inputs and outputs, + */ + private class RetryingCall extends CompoundClientCall { + + private final Channel channel; + private ClientCall.Listener listener; + private int requested; + private Metadata requestHeaders; + private final List requestPayloads = Lists.newArrayList(); + private final List responsePayloads = Lists.newArrayList(); + private Metadata responseHeaders; + private int attempt; + private ClientCall currentCall; + + private RetryingCall(Channel channel) { + this.channel = channel; + } + + @Override + public void start(ClientCall.Listener listener, Metadata headers) { + this.listener = listener; + requestHeaders = headers; + currentCall = callable.newCall(channel); + currentCall.start(listener(), headers); + } + + @Override + public void request(int numMessages) { + requested += numMessages; + currentCall.request(numMessages); + } + + @Override + public void cancel() { + currentCall.cancel(); + } + + @Override + public void halfClose() { + currentCall.halfClose(); + } + + @Override + public void sendMessage(RequestT message) { + requestPayloads.add(message); + currentCall.sendMessage(message); + } + + @Override + public void onHeaders(Metadata headers) { + responseHeaders = headers; + } + + @Override + void onMessage(ResponseT message) { + responsePayloads.add(message); + } + + @Override + public void onClose(Status status, Metadata trailers) { + if (status.isOk() || !canRetry(status) || attempt >= MAX_ATTEMPTS) { + // Call succeeded or failed non-transiently or failed too often; feed underlying listener + // with the result. + if (status.isOk()) { + if (responseHeaders != null) { + listener.onHeaders(responseHeaders); + } + for (ResponseT response : responsePayloads) { + listener.onMessage(response); + } + } + listener.onClose(status, trailers); + return; + } + + // Sleep using duration calculated by exponential backoff algorithm. + attempt++; + int slots = 1 << (attempt - 1 > TRUNCATE_AFTER ? TRUNCATE_AFTER : attempt - 1); + int slot = randomGenerator.nextInt(slots); + if (slot > 0) { + try { + Thread.sleep(SLOT_TIME_MILLIS * slot); + } catch (InterruptedException e) { + throw Throwables.propagate(e); + } + } + + // Start call again. + responseHeaders = null; + responsePayloads.clear(); + currentCall = callable.newCall(channel); + currentCall.start(listener(), requestHeaders); + currentCall.request(requested); + for (RequestT request : requestPayloads) { + currentCall.sendMessage(request); + } + currentCall.halfClose(); + } + } +} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java new file mode 100644 index 000000000000..485d4794d917 --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java @@ -0,0 +1,119 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.grpc; + +import com.google.auth.Credentials; + +import io.grpc.ManagedChannel; + +public class ServiceApiSettings { + private boolean isIdempotentRetrying; + + private Credentials credentials; + + private String servicePath; + private int port; + + private ManagedChannel channel; + + public ServiceApiSettings() { + isIdempotentRetrying = true; + credentials = null; + servicePath = null; + port = 0; + } + + /** + * Set to true in order to have the service retry all idempotent methods, + * set to false otherwise. The default is true. This setting generally translates to + * doing retries for calls which perform gets, deletes, and updates, but not calls which + * perform creates. + */ + public ServiceApiSettings setIsIdempotentRetrying(boolean isIdempotentRetrying) { + this.isIdempotentRetrying = isIdempotentRetrying; + return this; + } + + public boolean getIsIdempotentRetrying() { + return isIdempotentRetrying; + } + + /** + * Sets the credentials to use in order to call the service. The default is to acquire + * the credentials using GoogleCredentials.getApplicationDefault(). + */ + public ServiceApiSettings setCredentials(Credentials credentials) { + this.credentials = credentials; + return this; + } + + public Credentials getCredentials() { + return credentials; + } + + /** + * The path used to reach the service. + */ + public ServiceApiSettings setServicePath(String servicePath) { + this.servicePath = servicePath; + return this; + } + + public String getServicePath() { + return servicePath; + } + + /** + * The port used to reach the service. + */ + public ServiceApiSettings setPort(int port) { + this.port = port; + return this; + } + + public int getPort() { + return port; + } + + /** + * An instance of ManagedChannel; shutdown will be called on this channel when + * the instance of LoggingServiceApi is shut down. + */ + public ServiceApiSettings setChannel(ManagedChannel channel) { + this.channel = channel; + return this; + } + + public ManagedChannel getChannel() { + return channel; + } +} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/TransformingCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/TransformingCallable.java new file mode 100644 index 000000000000..507194a50688 --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/TransformingCallable.java @@ -0,0 +1,171 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.grpc; + +import com.google.common.base.Preconditions; +import com.google.common.base.Throwables; + +import io.grpc.Channel; +import io.grpc.ClientCall; +import io.grpc.Metadata; +import io.grpc.Status; +import io.grpc.StatusException; +import io.grpc.internal.SerializingExecutor; + +import java.util.concurrent.Executor; +import java.util.concurrent.Semaphore; + +import javax.annotation.Nullable; + +/** + * Helper type for the implementation of {@link ApiCallable} methods. Please see there first for the + * specification of what this is doing. This class is concerned with the how. + * + *

      Implements the transform callable, which executes a function to produce a stream of responses + * from a stream of requests. + */ +class TransformingCallable extends ApiCallable { + + private final Transformer transformer; + @Nullable private final Executor executor; + + TransformingCallable(Transformer transformer, + Executor executor) { + this.transformer = Preconditions.checkNotNull(transformer); + this.executor = executor; + } + + @Override + public String toString() { + return "transforming(...)"; + } + + @Override + public ClientCall newCall(Channel channel) { + return new TransformCall(); + } + + /** + * Implements the transforming call. If an executor is provided, delivery of results will + * happen asynchronously and flow control is respected. If not, results will be delivered + * to the listener immediately on sendMessage(). This violates the ClientCall contract as + * methods on Call are supposed to be non-blocking, whereas methods on Listener can block. + * In most practical cases, this should not matter (see also high-level documentation in + * Callable). + * + *

      Note that this class does not need to be thread-safe since (a) the contract for + * ClientCall does not require thread-safeness (b) we use a SerializingExecutor for + * asynchronous callbacks which is guaranteed to run not more than one thread. + */ + private class TransformCall extends ClientCall { + + private final SerializingExecutor callExecutor = + executor == null ? null : new SerializingExecutor(executor); + private final Semaphore semaphore = new Semaphore(0); + private ClientCall.Listener listener; + private boolean sentClose; + + @Override + public void start(ClientCall.Listener listener, Metadata headers) { + this.listener = listener; + } + + @Override + public void request(int numMessages) { + if (callExecutor != null) { + semaphore.release(numMessages); + } + } + + @Override + public void cancel() { + if (!sentClose) { + listener.onClose(Status.CANCELLED, new Metadata()); + sentClose = true; + } + } + + @Override + public void sendMessage(final RequestT message) { + if (callExecutor == null) { + doSend(message); + return; + } + callExecutor.execute(new Runnable() { + @Override public void run() { + try { + semaphore.acquire(); + doSend(message); + } catch (Throwable t) { + cancel(); + throw Throwables.propagate(t); + } + } + }); + } + + @SuppressWarnings("deprecation") // e.getStatus() + private void doSend(RequestT message) { + try { + listener.onMessage(transformer.apply(message)); + } catch (StatusException e) { + sentClose = true; + listener.onClose(e.getStatus(), new Metadata()); + } catch (Throwable t) { + // TODO(wgg): should we throw anything else here, or catch like below? Catching might + // be an issue for debugging. + sentClose = true; + listener.onClose(Status.fromThrowable(t), new Metadata()); + } + } + + @Override + public void halfClose() { + if (callExecutor == null) { + doClose(); + return; + } + callExecutor.execute(new Runnable() { + @Override public void run() { + doClose(); + } + }); + } + + private void doClose() { + if (!sentClose) { + sentClose = true; + listener.onClose(Status.OK, new Metadata()); + } + } + } +} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java b/gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java new file mode 100644 index 000000000000..6673726f761e --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java @@ -0,0 +1,110 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.internal; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.Executors; + +import com.google.auth.oauth2.GoogleCredentials; +import com.google.common.collect.Lists; + +import io.gapi.gax.grpc.ApiCallable; +import io.gapi.gax.grpc.ServiceApiSettings; +import io.grpc.ClientInterceptor; +import io.grpc.ManagedChannel; +import io.grpc.auth.ClientAuthInterceptor; +import io.grpc.netty.NegotiationType; +import io.grpc.netty.NettyChannelBuilder; + +public class ApiUtils { + + // TODO(wgg): make this configurable + private static final int AUTH_THREADS = 4; + + public static ApiCallable prepareIdempotentCallable( + ApiCallable callable, ServiceApiSettings settings) { + ApiCallable theCallable = callable; + if (settings.getIsIdempotentRetrying()) { + theCallable = theCallable.retrying(); + } + return theCallable; + } + + /** + * Creates a channel for the given path, address and port. + */ + public static ManagedChannel createChannel(String address, int port, Collection scopes) + throws IOException { + List interceptors = Lists.newArrayList(); + //TODO: MIGRATION interceptors.add(ChannelFactory.authorityInterceptor(address)); + + GoogleCredentials credentials = GoogleCredentials.getApplicationDefault(); + if (credentials.createScopedRequired()) { + credentials = credentials.createScoped(scopes); + } + interceptors.add(new ClientAuthInterceptor(credentials, + Executors.newFixedThreadPool(AUTH_THREADS))); + + return NettyChannelBuilder + .forAddress(address, port) + .negotiationType(NegotiationType.TLS) + .intercept(interceptors) + .build(); + } + + public static ServiceApiSettings settingsWithChannels(ServiceApiSettings settings, + String defaultServicePath, int defaultServicePort, String scopes[]) throws IOException { + ManagedChannel channel = settings.getChannel(); + + if (channel == null) { + String servicePath = defaultServicePath; + if (settings.getServicePath() != null) { + servicePath = settings.getServicePath(); + } + + int port = defaultServicePort; + if (settings.getPort() != 0) { + port = settings.getPort(); + } + + List scopeList = Arrays.asList(scopes); + channel = ApiUtils.createChannel(servicePath, port, scopeList); + } + + return new ServiceApiSettings() + .setChannel(channel) + .setIsIdempotentRetrying(settings.getIsIdempotentRetrying()); + } +} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java new file mode 100644 index 000000000000..c1a000d438a2 --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java @@ -0,0 +1,880 @@ +package io.gapi.gax.protobuf; + +import com.google.auto.value.AutoValue; +import com.google.common.annotations.Beta; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.annotation.Nullable; + +/** + * Represents a path template. + * + *

      Templates use the syntax of the API platform; see the protobuf of {@link HttpRule} for + * details. A template consists of a sequence of literals, wildcards, and variable bindings, + * where each binding can have a sub-path. A string representation can be parsed into an + * instance of {@link PathTemplate}, which can then be used to perform matching and instantiation. + * + *

      Matching and instantiation deals with unescaping and escaping using URL encoding rules. For + * example, if a template variable for a single segment is instantiated with a string like + * {@code "a/b"}, the slash will be escaped to {@code "%2f"}. (Note that slash will not be escaped + * for a multiple-segment variable, but other characters will). The literals in the template + * itself are not escaped automatically, and must be already URL encoded. + * + *

      Here is an example for a template using simple variables: + *

      + *   PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}");
      + *   assert template.match("v2/shelves"} == false
      + *   Map<String, String> values = template.match("v1/shelves/s1/books/b1");
      + *   assert values.equals(ImmutableMap.of("shelf", s1", "book", "b1");
      + *   assert template.instantiate(values).equals("v1/shelves/s1/books/b1");
      + * 
      + * + * Templates can use variables which match sub-paths. Example: + *
      + *   PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}"};
      + *   assert template.match("v1/shelves/books/b1") == null;
      + *   assert template.match("v1/shelves/s1/books/b1")
      + *                  .equals(ImmutableMap.of("name", "shelves/s1/books/b1"));
      + * 
      + * + * Path templates can also be used with only wildcards. Each wildcard is associated + * with an implicit variable {@code $n}, where n is the zero-based position of the + * wildcard. Example: + *
      + *   PathTemplate template = PathTemplate.create("shelves/*/books/*"};
      + *   assert template.match("shelves/books/b1") == null;
      + *   Map<String, String> values = template.match("v1/shelves/s1/books/b1");
      + *   assert values.equals(ImmutableMap.of("$0", s1", "$1", "b1");
      + * 
      + * + * Paths input to matching can use URL relative syntax to indicate a host name by prefixing the + * host name, as in {@code //somewhere.io/some/path}. The host name is matched into the special + * variable {@link #HOSTNAME_VAR}. Patterns are agnostic about host names, and the same pattern + * can be used for URL relative syntax and simple path syntax: + *
      + *   PathTemplate template = PathTemplate.create("shelves/*"};
      + *   assert template.match("//somewhere.io/shelves/s1")
      + *                  .equals(ImmutableMap.of(PathTemplate.HOSTNAME_VAR, "//somewhere.io",
      + *                                          "$0", "s1"));
      + *   assert template.match("shelves/s1")
      + *                  .equals(ImmutableMap.of("$0", "s1"));
      + * 
      + * + * For the representation of a resource name see {@link ResourceName}, which is based + * on path templates. + */ +@Beta +public class PathTemplate { + + /** + * A constant identifying the special variable used for endpoint bindings in + * the result of {@link #matchFromFullName(String)}. + */ + public static final String HOSTNAME_VAR = "$hostname"; + + // A regexp to match a custom verb at the end of a path. + private static final Pattern CUSTOM_VERB_PATTERN = Pattern.compile(":([^/*}{=]+)$"); + + // A splitter on slash. + private static final Splitter SLASH_SPLITTER = Splitter.on('/').trimResults(); + + // Helper Types + // ============ + + /** + * Specifies a path segment kind. + */ + enum SegmentKind { + /** A literal path segment. */ + LITERAL, + + /** A custom verb. Can only appear at the end of path. */ + CUSTOM_VERB, + + /** A simple wildcard ('*'). */ + WILDCARD, + + /** A path wildcard ('**'). */ + PATH_WILDCARD, + + /** A field binding start. */ + BINDING, + + /** A field binding end. */ + END_BINDING, + } + + /** + * Specifies a path segment. + */ + @AutoValue + abstract static class Segment { + + /** + * A constant for the WILDCARD segment. + */ + private static final Segment WILDCARD = create(SegmentKind.WILDCARD, "*"); + + /** + * A constant for the PATH_WILDCARD segment. + */ + private static final Segment PATH_WILDCARD = create(SegmentKind.PATH_WILDCARD, "**"); + + /** + * A constant for the END_BINDING segment. + */ + private static final Segment END_BINDING = create(SegmentKind.END_BINDING, ""); + + /** + * Creates a segment of given kind and value. + */ + private static Segment create(SegmentKind kind, String value) { + return new AutoValue_PathTemplate_Segment(kind, value); + } + + /** + * The path segment kind. + */ + abstract SegmentKind kind(); + + /** + * The value for the segment. For literals, custom verbs, and wildcards, this reflects the value + * as it appears in the template. For bindings, this represents the variable of the binding. + */ + abstract String value(); + + /** + * Returns true of this segment is one of the wildcards, + */ + boolean isAnyWildcard() { + return kind() == SegmentKind.WILDCARD || kind() == SegmentKind.PATH_WILDCARD; + } + + String separator() { + switch (kind()) { + case CUSTOM_VERB: + return ":"; + case END_BINDING: + return ""; + default: + return "/"; + } + } + } + + /** + * Creates a path template from a string. The string must satisfy the syntax + * of path templates of the API platform; see {@link HttpRule}'s proto source. + * + * @throws ValidationException if there are errors while parsing the template. + */ + public static PathTemplate create(String template) { + return new PathTemplate(parseTemplate(template)); + } + + // Instance State and Methods + // ========================== + + // List of segments of this template. + private final ImmutableList segments; + + // Map from variable names to bindings in the template. + private final ImmutableMap bindings; + + private PathTemplate(Iterable segments) { + this.segments = ImmutableList.copyOf(segments); + if (this.segments.isEmpty()) { + throw new ValidationException("template cannot be empty."); + } + Map bindings = Maps.newLinkedHashMap(); + for (Segment seg : this.segments) { + if (seg.kind() == SegmentKind.BINDING) { + if (bindings.containsKey(seg.value())) { + throw new ValidationException("Duplicate binding '%s'", seg.value()); + } + bindings.put(seg.value(), seg); + } + } + this.bindings = ImmutableMap.copyOf(bindings); + } + + /** + * Returns the set of variable names used in the template. + */ + public Set vars() { + return bindings.keySet(); + } + + /** + * Returns a template for the parent of this template. + * + * @throws ValidationException if the template has no parent. + */ + public PathTemplate parentTemplate() { + int i = segments.size(); + Segment seg = segments.get(--i); + if (seg.kind() == SegmentKind.END_BINDING) { + while (i > 0 && segments.get(--i).kind() != SegmentKind.BINDING) {} + } + if (i == 0) { + throw new ValidationException("template does not have a parent"); + } + return new PathTemplate(segments.subList(0, i)); + } + + /** + * Returns a template where all variable bindings have been replaced by wildcards, but + * which is equivalent regards matching to this one. + */ + public PathTemplate withoutVars() { + StringBuilder result = new StringBuilder(); + ListIterator iterator = segments.listIterator(); + boolean start = true; + while (iterator.hasNext()) { + Segment seg = iterator.next(); + switch (seg.kind()) { + case BINDING: + case END_BINDING: + break; + default: + if (!start) { + result.append(seg.separator()); + } else { + start = false; + } + result.append(seg.value()); + } + } + return create(result.toString()); + } + + /** + * Returns a path template for the sub-path of the given variable. Example: + * + *
      +   *   PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}");
      +   *   assert template.subTemplate("name").toString().equals("shelves/*/books/*");
      +   * 
      + * + * The returned template will never have named variables, but only wildcards, which are + * dealt with in matching and instantiation using '$n'-variables. See the documentation of + * {@link #match(String)} and {@link #instantiate(Map)}, respectively. + * + *

      For a variable which has no sub-path, this returns a path template with a single wildcard + * ('*'). + * + * @throws ValidationException if the variable does not exist in the template. + */ + public PathTemplate subTemplate(String varName) { + List sub = Lists.newArrayList(); + boolean inBinding = false; + for (Segment seg : segments) { + if (seg.kind() == SegmentKind.BINDING && seg.value().equals(varName)) { + inBinding = true; + } else if (inBinding) { + if (seg.kind() == SegmentKind.END_BINDING) { + return PathTemplate.create(toSyntax(sub, true)); + } else { + sub.add(seg); + } + } + } + throw new ValidationException("Variable '%s' is undefined in template '%s'", + varName, this.toRawString()); + } + + /** + * Returns true of this template ends with a literal. + */ + public boolean endsWithLiteral() { + return segments.get(segments.size() - 1).kind() == SegmentKind.LITERAL; + } + + /** + * Returns true of this template ends with a custom verb. + */ + public boolean endsWithCustomVerb() { + return segments.get(segments.size() - 1).kind() == SegmentKind.CUSTOM_VERB; + } + + /** + * Creates a resource name from this template and a path. + * + * @throws ValidationException if the path does not match the template. + */ + public ResourceName parse(String path) { + return ResourceName.create(this, path); + } + + /** + * Returns the name of a singleton variable used by this template. If the template does not + * contain a single variable, returns null. + */ + @Nullable + public String singleVar() { + if (bindings.size() == 1) { + return bindings.entrySet().iterator().next().getKey(); + } + return null; + } + + // Template Matching + // ================= + + /** + * Returns true if the template matches the path. + */ + public boolean matches(String path) { + return match(path) != null; + } + + /** + * Matches the path, returning a map from variable names to matched values. All matched values + * will be properly unescaped using URL encoding rules. If the path does not match the template, + * null is returned. + * + * If the path starts with '//', the first segment will be interpreted as a host name and stored + * in the variable {@link #HOSTNAME_VAR}. + * + *

      See the {@link PathTemplate} class documentation for examples. + * + *

      For free wildcards in the template, the matching process creates variables named '$n', + * where 'n' is the wildcard's position in the template (starting at n=0). For example: + * + *

      +   *   PathTemplate template = PathTemplate.create("shelves/*/books/*");
      +   *   assert template.match("shelves/s1/books/b2")
      +   *              .equals(ImmutableMap.of("$0", "s1", "$1", "b1"));
      +   *   assert template.match("//somewhere.io/shelves/s1/books/b2")
      +   *              .equals(ImmutableMap.of(HOSTNAME_VAR, "//somewhere.io", "$0", "s1", "$1", "b1"));
      +   * 
      + * + * All matched values will be properly unescaped using URL encoding rules. + */ + @Nullable + public ImmutableMap match(String path) { + return match(path, false); + } + + /** + * Matches the path, where the first segment is interpreted as the host name regardless of + * whether it starts with '//' or not. Example: + * + *
      +   *   assert template("{name=shelves/*}").matchFromFullName("somewhere.io/shelves/s1")
      +   *            .equals(ImmutableMap.of(HOSTNAME_VAR, "somewhere.io", "name", "shelves/s1"));
      +   * 
      + */ + @Nullable + public ImmutableMap matchFromFullName(String path) { + return match(path, true); + } + + // Matches a path. + private ImmutableMap match(String path, boolean forceHostName) { + // Quick check for trailing custom verb. + Segment last = segments.get(segments.size() - 1); + if (last.kind() == SegmentKind.CUSTOM_VERB) { + Matcher matcher = CUSTOM_VERB_PATTERN.matcher(path); + if (!matcher.find() || !decodeUrl(matcher.group(1)).equals(last.value())) { + return null; + } + path = path.substring(0, matcher.start(0)); + } + + // Do full match. + boolean withHostName = path.startsWith("//"); + if (withHostName) { + path = path.substring(2); + } + List input = SLASH_SPLITTER.splitToList(path); + int inPos = 0; + Map values = Maps.newLinkedHashMap(); + if (withHostName || forceHostName) { + if (input.isEmpty()) { + return null; + } + String hostName = input.get(inPos++); + if (withHostName) { + // Put the // back, so we can distinguish this case from forceHostName. + hostName = "//" + hostName; + } + values.put(HOSTNAME_VAR, hostName); + } + if (!match(input, inPos, segments, 0, values)) { + return null; + } + return ImmutableMap.copyOf(values); + } + + // Tries to match the input based on the segments at given positions. Returns a boolean + // indicating whether the match was successful. + private static boolean match(List input, int inPos, List segments, int segPos, + Map values) { + String currentVar = null; + while (segPos < segments.size()) { + Segment seg = segments.get(segPos++); + switch (seg.kind()) { + case END_BINDING: + // End current variable binding scope. + currentVar = null; + continue; + case BINDING: + // Start variable binding scope. + currentVar = seg.value(); + continue; + default: + if (inPos >= input.size()) { + // End of input + return false; + } + // Check literal match. + String next = decodeUrl(input.get(inPos++)); + if (seg.kind() == SegmentKind.LITERAL) { + if (!seg.value().equals(next)) { + // Literal does not match. + return false; + } + } + if (currentVar != null) { + // Create or extend current match + String current = values.get(currentVar); + if (current == null) { + values.put(currentVar, next); + } else { + values.put(currentVar, current + "/" + next); + } + } + if (seg.kind() == SegmentKind.PATH_WILDCARD) { + // Compute the number of additional input the ** can consume. This + // is possible because we restrict patterns to have only one **. + int segsToMatch = 0; + for (int i = segPos; i < segments.size(); i++) { + switch (segments.get(i).kind()) { + case BINDING: + case END_BINDING: + // skip + continue; + default: + segsToMatch++; + } + } + int available = (input.size() - inPos) - segsToMatch; + while (available-- > 0) { + values.put(currentVar, values.get(currentVar) + "/" + decodeUrl(input.get(inPos++))); + } + } + } + } + return inPos == input.size(); + } + + // Template Instantiation + // ====================== + + /** + * Instantiate the template based on the given variable assignment. Performs proper + * URL escaping of variable assignments. + * + *

      Note that free wildcards in the template must have bindings of '$n' variables, where + * 'n' is the position of the wildcard (starting at 0). See the documentation of + * {@link #match(String)} for details. + * + * @throws ValidationException if a variable occurs in the template without a binding. + */ + public String instantiate(Map values) { + return instantiate(values, false); + } + + /** + * Shortcut for {@link #instantiate(Map)} with a vararg parameter for keys and values. + */ + public String instantiate(String... keysAndValues) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + for (int i = 0; i < keysAndValues.length; i += 2) { + builder.put(keysAndValues[i], keysAndValues[i + 1]); + } + return instantiate(builder.build()); + } + + /** + * Same like {@link #instantiate(Map)} but allows for unbound variables, which are + * substituted using their original syntax. Example: + * + *

      +   *   PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}");
      +   *   assert template.instantiatePartial(ImmutableMap.of("shelf", "s1"))
      +   *             .equals("v1/shelves/s1/books/{book}");
      +   * 
      + * + * The result of this call can be used to create a new template. + */ + public String instantiatePartial(Map values) { + return instantiate(values, true); + } + + private String instantiate(Map values, boolean allowPartial) { + StringBuilder result = new StringBuilder(); + if (values.containsKey(HOSTNAME_VAR)) { + result.append(values.get(HOSTNAME_VAR)); + result.append('/'); + } + boolean continueLast = true; // Whether to not append separator + boolean skip = false; // Whether we are substituting a binding and segments shall be skipped. + ListIterator iterator = segments.listIterator(); + while (iterator.hasNext()) { + Segment seg = iterator.next(); + if (!skip && !continueLast) { + result.append(seg.separator()); + } + continueLast = false; + switch (seg.kind()) { + case BINDING: + String var = seg.value(); + String value = values.get(seg.value()); + if (value == null) { + if (!allowPartial) { + throw new ValidationException("Unbound variable '%s'. Bindings: %s", + var, values); + } + // Append pattern to output + if (var.startsWith("$")) { + // Eliminate positional variable. + result.append(iterator.next().value()); + iterator.next(); + continue; + } + result.append('{'); + result.append(seg.value()); + result.append('='); + continueLast = true; + continue; + } + Segment next = iterator.next(); + Segment nextNext = iterator.next(); + boolean pathEscape = next.kind() == SegmentKind.PATH_WILDCARD + || nextNext.kind() != SegmentKind.END_BINDING; + restore(iterator, iterator.nextIndex() - 2); + if (!pathEscape) { + result.append(encodeUrl(value)); + } else { + // For a path wildcard or path of length greater 1, split the value and escape + // every sub-segment. + boolean first = true; + for (String subSeg : SLASH_SPLITTER.split(value)) { + if (!first) { + result.append('/'); + } + first = false; + result.append(encodeUrl(subSeg)); + } + } + skip = true; + continue; + case END_BINDING: + if (!skip) { + result.append('}'); + } + skip = false; + continue; + default: + if (!skip) { + result.append(seg.value()); + } + } + } + return result.toString(); + } + + // Positional Matching and Instantiation + // ===================================== + + /** + * Instantiates the template from the given positional parameters. The template must not be build + * from named bindings, but only contain wildcards. Each parameter position corresponds to a + * wildcard of the according position in the template. + */ + public String encode(String... values) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + int i = 0; + for (String value : values) { + builder.put("$" + i++, value); + } + // We will get an error if there are named bindings which are not reached by values. + return instantiate(builder.build()); + } + + /** + * Matches the template into a list of positional values. The template must not be build from + * named bindings, but only contain wildcards. For each wildcard in the template, a value + * is returned at corresponding position in the list. + */ + public List decode(String path) { + Map match = match(path); + if (match == null) { + throw new IllegalArgumentException(String.format("template '%s' does not match '%s'", + this, path)); + } + List result = Lists.newArrayList(); + for (Map.Entry entry : match.entrySet()) { + String key = entry.getKey(); + if (!key.startsWith("$")) { + throw new IllegalArgumentException("template must not contain named bindings"); + } + int i = Integer.parseInt(key.substring(1)); + while (result.size() <= i) { + result.add(""); + } + result.set(i, entry.getValue()); + } + return ImmutableList.copyOf(result); + } + + // Template Parsing + // ================ + + private static ImmutableList parseTemplate(String template) { + // Skip useless leading slash. + if (template.startsWith("/")) { + template = template.substring(1); + } + + // Extract trailing custom verb. + Matcher matcher = CUSTOM_VERB_PATTERN.matcher(template); + String customVerb = null; + if (matcher.find()) { + customVerb = matcher.group(1); + template = template.substring(0, matcher.start(0)); + } + + ImmutableList.Builder builder = ImmutableList.builder(); + String varName = null; + int freeWildcardCounter = 0; + int pathWildCardBound = 0; + + for (String seg : Splitter.on('/').trimResults().split(template)) { + // If segment starts with '{', a binding group starts. + boolean bindingStarts = seg.startsWith("{"); + boolean implicitWildcard = false; + if (bindingStarts) { + if (varName != null) { + throw new ValidationException("parse error: nested binding in '%s'", template); + } + seg = seg.substring(1); + + int i = seg.indexOf('='); + if (i <= 0) { + // Possibly looking at something like "{name}" with implicit wildcard. + if (seg.endsWith("}")) { + // Remember to add an implicit wildcard later. + implicitWildcard = true; + varName = seg.substring(0, seg.length() - 1).trim(); + seg = seg.substring(seg.length() - 1).trim(); + } else { + throw new ValidationException("parse error: invalid binding syntax in '%s'", template); + } + } else { + // Looking at something like "{name=wildcard}". + varName = seg.substring(0, i).trim(); + seg = seg.substring(i + 1).trim(); + } + builder.add(Segment.create(SegmentKind.BINDING, varName)); + } + + // If segment ends with '}', a binding group ends. Remove the brace and remember. + boolean bindingEnds = seg.endsWith("}"); + if (bindingEnds) { + seg = seg.substring(0, seg.length() - 1).trim(); + } + + // Process the segment, after stripping off "{name=.." and "..}". + switch (seg) { + case "**": + case "*": + if ("**".equals(seg)) { + pathWildCardBound++; + } + Segment wildcard = seg.length() == 2 ? Segment.PATH_WILDCARD : Segment.WILDCARD; + if (varName == null) { + // Not in a binding, turn wildcard into implicit binding. + // "*" => "{$n=*}" + builder.add(Segment.create(SegmentKind.BINDING, "$" + freeWildcardCounter)); + freeWildcardCounter++; + builder.add(wildcard); + builder.add(Segment.END_BINDING); + } else { + builder.add(wildcard); + } + break; + case "": + if (!bindingEnds) { + throw new ValidationException("parse error: empty segment not allowed in '%s'", + template); + } + // If the wildcard is implicit, seg will be empty. Just continue. + break; + default: + builder.add(Segment.create(SegmentKind.LITERAL, seg)); + } + + // End a binding. + if (bindingEnds) { + // Reset varName to null for next binding. + varName = null; + + if (implicitWildcard) { + // Looking at something like "{var}". Insert an implicit wildcard, as it is the same + // as "{var=*}". + builder.add(Segment.WILDCARD); + } + builder.add(Segment.END_BINDING); + } + + if (pathWildCardBound > 1) { + // Report restriction on number of '**' in the pattern. There can be only one, which + // enables non-backtracking based matching. + throw new ValidationException( + "parse error: pattern must not contain more than one path wildcard ('**') in '%s'", + template); + } + + } + + if (customVerb != null) { + builder.add(Segment.create(SegmentKind.CUSTOM_VERB, customVerb)); + } + return builder.build(); + } + + // Helpers + // ======= + + private static String encodeUrl(String text) { + try { + return URLEncoder.encode(text, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new ValidationException("UTF-8 encoding is not supported on this platform"); + } + } + + private static String decodeUrl(String url) { + try { + return URLDecoder.decode(url, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new ValidationException("UTF-8 encoding is not supported on this platform"); + } + } + + // Checks for the given segments kind. On success, consumes them. Otherwise leaves + // the list iterator in its state. + private static boolean peek(ListIterator segments, SegmentKind... kinds) { + int start = segments.nextIndex(); + boolean success = false; + for (SegmentKind kind : kinds) { + if (!segments.hasNext() || segments.next().kind() != kind) { + success = false; + break; + } + } + if (success) { + return true; + } + restore(segments, start); + return false; + } + + // Restores a list iterator back to a given index. + private static void restore(ListIterator segments, int index) { + while (segments.nextIndex() > index) { + segments.previous(); + } + } + + // Equality and String Conversion + // ============================== + + /** + * Returns a pretty version of the template as a string. + */ + @Override + public String toString() { + return toSyntax(segments, true); + } + + /** + * Returns a raw version of the template as a string. This renders the template in its + * internal, normalized form. + */ + public String toRawString() { + return toSyntax(segments, false); + } + + private static String toSyntax(List segments, boolean pretty) { + StringBuilder result = new StringBuilder(); + boolean continueLast = true; // if true, no slash is appended. + ListIterator iterator = segments.listIterator(); + while (iterator.hasNext()) { + Segment seg = iterator.next(); + if (!continueLast) { + result.append(seg.separator()); + } + continueLast = false; + switch (seg.kind()) { + case BINDING: + if (pretty && seg.value().startsWith("$")) { + // Remove the internal binding. + seg = iterator.next(); // Consume wildcard + result.append(seg.value()); + iterator.next(); // Consume END_BINDING + continue; + } + result.append('{'); + result.append(seg.value()); + if (pretty && peek(iterator, SegmentKind.WILDCARD, SegmentKind.END_BINDING)) { + // Reduce {name=*} to {name}. + result.append('}'); + continue; + } + result.append('='); + continueLast = true; + continue; + case END_BINDING: + result.append('}'); + continue; + default: + result.append(seg.value()); + continue; + } + } + return result.toString(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof PathTemplate)) { + return false; + } + PathTemplate other = (PathTemplate) obj; + return Objects.equals(segments, other.segments); + } + + @Override + public int hashCode() { + return segments.hashCode(); + } +} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ResourceName.java b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ResourceName.java new file mode 100644 index 000000000000..5eea8509ff44 --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ResourceName.java @@ -0,0 +1,275 @@ +package io.gapi.gax.protobuf; + +import com.google.common.annotations.Beta; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; + +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nullable; + +/** + * Class for representing and working with resource names. + * + *

      A resource name is represented by {@link PathTemplate}, an assignment to variables in + * the template, and an optional endpoint. The {@code ResourceName} class implements + * the map interface (unmodifiable) to work with the variable assignments, and has methods + * to reproduce the string representation of the name, to construct new names, and to dereference + * names into resources. + * + *

      As a resource name essentially represents a match of a path template against a string, it + * can be also used for other purposes than naming resources. However, not all provided methods + * may make sense in all applications. + * + *

      Usage examples: + * + *

      + *   PathTemplate template = PathTemplate.create("shelves/*/books/*");
      + *   ResourceName resourceName = ResourceName.create(template, "shelves/s1/books/b1");
      + *   assert resourceName.get("$1").equals("b1");
      + *   assert resourceName.parentName().toString().equals("shelves/s1/books");
      + * 
      + */ +@Beta +public class ResourceName implements Map { + + // ResourceName Resolver + // ===================== + + /** + * Represents a resource name resolver which can be registered with this class. + */ + public interface Resolver { + /** + * Resolves the resource name into a resource by calling the underlying API. + */ + T resolve(Class resourceType, ResourceName name, @Nullable String version); + } + + // The registered resource name resolver. + // TODO(wgg): its a bit spooky to have this static global. Think of ways to + // configure this from the outside instead if programmatically (e.g. java properties). + private static volatile Resolver resourceNameResolver = new Resolver() { + @Override + public T resolve(Class resourceType, ResourceName name, String version) { + throw new IllegalStateException( + "No resource name resolver is registered in ResourceName class."); + } + }; + + /** + * Sets the resource name resolver which is used by the {@link #resolve(Class, String)} method. + * By default, no resolver is registered. + */ + public static void registerResourceNameResolver(Resolver resolver) { + resourceNameResolver = resolver; + } + + // ResourceName + // ============ + + /** + * Creates a new resource name based on given template and path. The path must match + * the template, otherwise null is returned. + * + * @throws ValidationException if the path does not match the template. + */ + public static ResourceName create(PathTemplate template, String path) { + ImmutableMap values = template.match(path); + if (values == null) { + throw new ValidationException("path '%s' does not match template '%s'", path, template); + } + return new ResourceName(template, values, null); + } + + /** + * Creates a new resource name from a template and a value assignment for variables. + * + * @throws ValidationException if not all variables in the template are bound. + */ + public static ResourceName create(PathTemplate template, Map values) { + if (!values.keySet().containsAll(template.vars())) { + Set unbound = Sets.newLinkedHashSet(template.vars()); + unbound.removeAll(values.keySet()); + throw new ValidationException("unbound variables: %s", unbound); + } + return new ResourceName(template, values, null); + } + + /** + * Creates a new resource name based on given template and path, where the path contains an + * endpoint. If the path does not match, null is returned. + */ + @Nullable + public static ResourceName createFromFullName(PathTemplate template, String path) { + ImmutableMap values = template.matchFromFullName(path); + if (values == null) { + return null; + } + return new ResourceName(template, values, null); + } + + private final PathTemplate template; + private final ImmutableMap values; + private final String endpoint; + + private volatile String stringRepr; + + private ResourceName(PathTemplate template, Map values, String endpoint) { + this.template = template; + this.values = ImmutableMap.copyOf(values); + this.endpoint = endpoint; + } + + @Override + public String toString() { + if (stringRepr == null) { + stringRepr = template.instantiate(values); + } + return stringRepr; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ResourceName)) { + return false; + } + ResourceName other = (ResourceName) obj; + return Objects.equals(template, other.template) + && Objects.equals(endpoint, other.endpoint) + && Objects.equals(values, other.values); + } + + @Override + public int hashCode() { + return Objects.hash(template, endpoint, values); + } + + /** + * Gets the template associated with this resource name. + */ + public PathTemplate template() { + return template; + } + + /** + * Checks whether the resource name has an endpoint. + */ + public boolean hasEndpoint() { + return endpoint != null; + } + + /** + * Returns the endpoint of this resource name, or null if none is defined. + */ + @Nullable + public String endpoint() { + return endpoint; + } + + /** + * Returns a resource name with specified endpoint. + */ + public ResourceName withEndpoint(String endpoint) { + return new ResourceName(template, values, Preconditions.checkNotNull(endpoint)); + } + + /** + * Returns the parent resource name. For example, if the name is {@code shelves/s1/books/b1}, the + * parent is {@code shelves/s1/books}. + */ + public ResourceName parentName() { + PathTemplate parentTemplate = template.parentTemplate(); + return new ResourceName(parentTemplate, values, endpoint); + } + + /** + * Returns true of the resource name starts with the parent resource name, i.e. is a child + * of the parent. + */ + public boolean startsWith(ResourceName parentName) { + // TODO(wgg): more efficient implementation. + return toString().startsWith(parentName.toString()); + } + + /** + * Attempts to resolve a resource name into a resource, by calling the associated API. + * The resource name must have an endpoint. An optional version can be specified to + * determine in which version of the API to call. + */ + public T resolve(Class resourceType, @Nullable String version) { + Preconditions.checkArgument(hasEndpoint(), "Resource name must have an endpoint."); + return resourceNameResolver.resolve(resourceType, this, version); + } + + // Map Interface + // ============= + + @Override + public int size() { + return values.size(); + } + + @Override + public boolean isEmpty() { + return values.isEmpty(); + } + + @Override + public boolean containsKey(Object key) { + return values.containsKey(key); + } + + @Override + public boolean containsValue(Object value) { + return values.containsValue(value); + } + + @Override + public String get(Object key) { + return values.get(key); + } + + @Override + @Deprecated + public String put(String key, String value) { + return values.put(key, value); + } + + @Override + @Deprecated + public String remove(Object key) { + return values.remove(key); + } + + @Override + @Deprecated + public void putAll(Map m) { + values.putAll(m); + } + + @Override + @Deprecated + public void clear() { + values.clear(); + } + + @Override + public Set keySet() { + return values.keySet(); + } + + @Override + public Collection values() { + return values.values(); + } + + @Override + public Set> entrySet() { + return values.entrySet(); + } +} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ValidationException.java b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ValidationException.java new file mode 100644 index 000000000000..3e2d90e6d118 --- /dev/null +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ValidationException.java @@ -0,0 +1,63 @@ +package io.gapi.gax.protobuf; + +import com.google.common.annotations.Beta; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; + +import java.util.Stack; + +/** + * Exception thrown if there is a validation problem with a path template, http config, or related + * framework methods. Comes as an illegal argument exception subclass. Allows to globally + * set a thread-local validation context description which each exception inherits. + */ +@Beta +public class ValidationException extends IllegalArgumentException { + + private static ThreadLocal>> contextLocal = + new ThreadLocal>>(); + + /** + * Sets the validation context description. Each thread has its own description, so + * this is thread safe. + */ + public static void pushCurrentThreadValidationContext(Supplier supplier) { + Stack> stack = contextLocal.get(); + if (stack == null) { + stack = new Stack<>(); + contextLocal.set(stack); + } + stack.push(supplier); + } + + public static void pushCurrentThreadValidationContext(String context) { + pushCurrentThreadValidationContext(Suppliers.ofInstance(context)); + } + /** + * Clears the validation context. + */ + public static void popCurrentThreadValidationContext() { + Stack stack = contextLocal.get(); + if (stack != null) { + stack.pop(); + } + } + + /** + * Construct validation exception with implicit context. + */ + public ValidationException(String format, Object... args) { + super(message(contextLocal.get(), format, args)); + } + + private static String message(Stack> context, String format, Object... args) { + if (context == null || context.isEmpty()) { + return String.format(format, args); + } + StringBuilder result = new StringBuilder(); + for (Supplier supplier : context) { + result.append(supplier.get() + ": "); + } + return result.toString() + String.format(format, args); + } +} diff --git a/gcloud-java-gax/src/test/java/io/gapi/gax/grpc/ApiCallableTest.java b/gcloud-java-gax/src/test/java/io/gapi/gax/grpc/ApiCallableTest.java new file mode 100644 index 000000000000..359f9da3693d --- /dev/null +++ b/gcloud-java-gax/src/test/java/io/gapi/gax/grpc/ApiCallableTest.java @@ -0,0 +1,250 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.gapi.gax.grpc; + +import com.google.common.base.Strings; +import com.google.common.collect.Lists; +import com.google.common.truth.Truth; + +import io.gapi.gax.grpc.ApiCallable; +import io.gapi.gax.grpc.PageDescriptor; +import io.gapi.gax.grpc.ApiCallable.Transformer; +import io.grpc.Channel; +import io.grpc.MethodDescriptor; +import io.grpc.Status; +import io.grpc.StatusException; +import io.grpc.stub.ClientCalls; +import io.grpc.stub.StreamObserver; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import org.mockito.InOrder; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.Executors; + +/** + * Tests for {@link ApiCallable}. + */ +@RunWith(JUnit4.class) +public class ApiCallableTest { + + private static final Transformer PLUS_ONE = + new Transformer() { + @Override public Integer apply(Integer request) throws StatusException { + return request + 1; + } + }; + + private static final Transformer TO_STRING = + new Transformer() { + @Override public String apply(Object request) throws StatusException { + return request.toString(); + } + }; + + private static final Transformer TO_INT = + new Transformer() { + @Override public Integer apply(String request) throws StatusException { + return Integer.parseInt(request); + } + }; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Mock Channel channel; + + // Creation and Chaining + // ===================== + + @Mock StreamObserver output; + @Mock Transformer transformIntToInt; + + @Test public void transformAndFollowedBy() { + ApiCallable callable = + ApiCallable.create(TO_STRING) + .followedBy(ApiCallable.create(TO_INT)) + .followedBy(ApiCallable.create(PLUS_ONE)); + + // Unary call + Truth.assertThat(callable.call(channel, 1)).isEqualTo(2); + + // Streaming call + StreamObserver input = + ClientCalls.asyncBidiStreamingCall(callable.newCall(channel), output); + input.onNext(1); + input.onNext(2); + input.onNext(3); + input.onCompleted(); + + InOrder inOrder = Mockito.inOrder(output); + inOrder.verify(output).onNext(2); + inOrder.verify(output).onNext(3); + inOrder.verify(output).onNext(4); + } + + // Retry + // ===== + + @Test public void retry() throws StatusException { + Mockito.when(transformIntToInt.apply(Mockito.anyInt())) + .thenThrow(new StatusException(Status.UNAVAILABLE)) + .thenThrow(new StatusException(Status.UNAVAILABLE)) + .thenThrow(new StatusException(Status.UNAVAILABLE)) + .thenReturn(2); + ApiCallable callable = ApiCallable.create(transformIntToInt).retrying(); + Truth.assertThat(callable.call(channel, 1)).isEqualTo(2); + } + + + // Page Streaming + // ============== + + /** + * Request message. + */ + private static class Request { + String pageToken; + } + + /** + * Response message. + */ + private static class Response { + String nextPageToken; + List books; + } + + /** + * A page producer fake which uses a seeded random generator to produce different page + * sizes. + */ + private static class PageProducer implements Transformer { + List collection; + Random random = new Random(0); + + PageProducer() { + collection = new ArrayList(); + for (int i = 1; i < 20; i++) { + collection.add("book #" + i); + } + } + + @Override + public Response apply(Request request) { + int start = 0; + if (!Strings.isNullOrEmpty(request.pageToken)) { + start = Integer.parseInt(request.pageToken); + } + int end = start + random.nextInt(3); + String nextToken; + if (end >= collection.size()) { + end = collection.size(); + nextToken = ""; + } else { + nextToken = end + ""; + } + Response response = new Response(); + response.nextPageToken = nextToken; + response.books = collection.subList(start, end); + return response; + } + } + + private static class BooksPageDescriptor implements PageDescriptor { + + @Override + public Object emptyToken() { + return ""; + } + + @Override + public Request injectToken(Request payload, Object token) { + payload.pageToken = (String) token; + return payload; + } + + @Override + public Object extractNextToken(Response payload) { + return payload.nextPageToken; + } + + @Override + public Iterable extractResources(Response payload) { + return payload.books; + } + } + + @Test public void pageStreaming() { + + // Create a callable. + PageProducer producer = new PageProducer(); + ApiCallable callable = + ApiCallable.create(producer, Executors.newCachedThreadPool()) + .pageStreaming(new BooksPageDescriptor()); + + // Emit the call and check the result. + Truth.assertThat(Lists.newArrayList( + callable.iterableResponseStreamCall(channel, new Request()))) + .isEqualTo(producer.collection); + } + + // Binding + // ======= + + @Mock + MethodDescriptor method; + + @Test public void testUnboundFailure() { + Mockito.stub(method.getFullMethodName()).toReturn("mocked method"); + thrown.expectMessage( + "unbound callable for method 'mocked method' requires " + + "a channel for execution"); + + ApiCallable callable = ApiCallable.create(method); + callable.call(new Request()); + } +} diff --git a/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/PathTemplateTest.java b/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/PathTemplateTest.java new file mode 100644 index 000000000000..ecb16fc382aa --- /dev/null +++ b/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/PathTemplateTest.java @@ -0,0 +1,168 @@ +package io.gapi.gax.protobuf; + +import com.google.common.collect.ImmutableMap; +import com.google.common.truth.Truth; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.util.Map; + +/** + * Tests for {@link PathTemplate}. + */ +@RunWith(JUnit4.class) +public class PathTemplateTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + // Match + // ===== + + @Test + public void matchAtomicResourceName() { + PathTemplate template = PathTemplate.create("buckets/*/*/objects/*"); + assertPositionalMatch(template.match("buckets/f/o/objects/bar"), "f", "o", "bar"); + } + + @Test + public void matchTemplateWithUnboundedWildcard() { + PathTemplate template = PathTemplate.create("buckets/*/objects/**"); + assertPositionalMatch(template.match("buckets/foo/objects/bar/baz"), "foo", "bar/baz"); + } + + @Test + public void matchWithForcedHostName() { + PathTemplate template = PathTemplate.create("buckets/*/objects/*"); + Map match = template.matchFromFullName("somewhere.io/buckets/b/objects/o"); + Truth.assertThat(match).isNotNull(); + Truth.assertThat(match.get(PathTemplate.HOSTNAME_VAR)).isEqualTo("somewhere.io"); + Truth.assertThat(match.get("$0")).isEqualTo("b"); + Truth.assertThat(match.get("$1")).isEqualTo("o"); + } + + @Test + public void matchWithHostName() { + PathTemplate template = PathTemplate.create("buckets/*/objects/*"); + Map match = template.match("//somewhere.io/buckets/b/objects/o"); + Truth.assertThat(match).isNotNull(); + Truth.assertThat(match.get(PathTemplate.HOSTNAME_VAR)).isEqualTo("//somewhere.io"); + Truth.assertThat(match.get("$0")).isEqualTo("b"); + Truth.assertThat(match.get("$1")).isEqualTo("o"); + } + + @Test + public void matchFailWhenPathMismatch() { + PathTemplate template = PathTemplate.create("buckets/*/*/objects/*"); + Truth.assertThat(template.match("buckets/f/o/o/objects/bar")).isNull(); + } + + @Test + public void matchFailWhenPathTooShort() { + PathTemplate template = PathTemplate.create("buckets/*/*/objects/*"); + Truth.assertThat(template.match("buckets/f/o/objects")).isNull(); + } + + @Test + public void matchFailWhenPathTooLong() { + PathTemplate template = PathTemplate.create("buckets/*/*/objects/*"); + Truth.assertThat(template.match("buckets/f/o/objects/too/long")).isNull(); + } + + @Test + public void matchWithUnboundInMiddle() { + PathTemplate template = PathTemplate.create("bar/**/foo/*"); + assertPositionalMatch(template.match("bar/foo/foo/foo/bar"), "foo/foo", "bar"); + } + + // Instantiate + // =========== + + @Test + public void instantiateAtomicResource() { + PathTemplate template = PathTemplate.create("buckets/*/*/*/objects/*"); + String url = template.instantiate("$0", "f", "$1", "o", "$2", "o", "$3", "bar"); + Truth.assertThat(url).isEqualTo("buckets/f/o/o/objects/bar"); + } + + @Test + public void instantiateEscapeUnsafeChar() { + PathTemplate template = PathTemplate.create("buckets/*/objects/*"); + Truth.assertThat(template.instantiate("$0", "f/o/o", "$1", "b/a/r")) + .isEqualTo("buckets/f%2Fo%2Fo/objects/b%2Fa%2Fr"); + } + + @Test + public void instantiateNotEscapeForUnboundedWildcard() { + PathTemplate template = PathTemplate.create("buckets/*/objects/**"); + Truth.assertThat(template.instantiate("$0", "f/o/o", "$1", "b/a/r")) + .isEqualTo("buckets/f%2Fo%2Fo/objects/b/a/r"); + } + + @Test + public void instantiateFailWhenTooFewVariables() { + thrown.expect(ValidationException.class); + PathTemplate template = PathTemplate.create("buckets/*/*/*/objects/*"); + template.instantiate("$0", "f", "1", "o"); + } + + @Test + public void instantiateWithUnboundInMiddle() { + PathTemplate template = PathTemplate.create("bar/**/foo/*"); + Truth.assertThat(template.instantiate("$0", "1/2", "$1", "3")) + .isEqualTo("bar/1/2/foo/3"); + } + + @Test + public void instantiatePartial() { + PathTemplate template = PathTemplate.create("bar/*/foo/*"); + String instance = template.instantiatePartial(ImmutableMap.of("$0", "_1")); + Truth.assertThat(instance).isEqualTo("bar/_1/foo/*"); + } + + @Test + public void instantiateWithHostName() { + PathTemplate template = PathTemplate.create("bar/*"); + String instance = template.instantiate(ImmutableMap.of( + PathTemplate.HOSTNAME_VAR, "//somewhere.io", + "$0", "foo")); + Truth.assertThat(instance).isEqualTo("//somewhere.io/bar/foo"); + } + + // Other + // ===== + + @Test + public void testMultiplePathWildcardFailure() { + thrown.expect(IllegalArgumentException.class); + PathTemplate.create("bar/**/{name=foo/**}:verb"); + } + + @Test + public void testTemplateWithSimpleBinding() { + PathTemplate template = PathTemplate.create("/v1/messages/{message_id}"); + String url = template.instantiate("message_id", "mymessage"); + Truth.assertThat(url).isEqualTo("v1/messages/mymessage"); + } + + @Test + public void testTemplateWithMultipleSimpleBindings() { + PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}"); + String url = template.instantiate("shelf", "s1", "book", "b1"); + Truth.assertThat(url).isEqualTo("v1/shelves/s1/books/b1"); + } + + + private static void assertPositionalMatch(Map match, String... expected) { + Truth.assertThat(match).isNotNull(); + int i = 0; + for (; i < expected.length; ++i) { + Truth.assertThat(expected[i]).isEqualTo(match.get("$" + i)); + } + Truth.assertThat(i).isEqualTo(match.size()); + } +} diff --git a/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/ResourceNameTest.java b/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/ResourceNameTest.java new file mode 100644 index 000000000000..dbef60bb64c5 --- /dev/null +++ b/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/ResourceNameTest.java @@ -0,0 +1,25 @@ +package io.gapi.gax.protobuf; + +import com.google.common.truth.Truth; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Tests for {@link ResourceName}. As resource names are mostly a wrapper around path + * templates, not much needs to be done here. + */ +@RunWith(JUnit4.class) +public class ResourceNameTest { + + @Test + public void resourceNameMethods() { + PathTemplate template = PathTemplate.create("buckets/*/objects/**"); + ResourceName name = ResourceName.create(template, "buckets/b/objects/1/2"); + Truth.assertThat(name.toString()).isEqualTo("buckets/b/objects/1/2"); + Truth.assertThat(name.get("$1")).isEqualTo("1/2"); + Truth.assertThat(name.get("$0")).isEqualTo("b"); + Truth.assertThat(name.parentName().toString()).isEqualTo("buckets/b/objects"); + } +} From 3e5c22fdfde906941476a65760b04b6bfdaa8a73 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Tue, 3 Nov 2015 17:16:59 -0800 Subject: [PATCH 174/203] Adding implicit dependency, using constant instead of hardcoded string --- gcloud-java-gax/pom.xml | 5 +++++ .../src/main/java/io/gapi/gax/protobuf/PathTemplate.java | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcloud-java-gax/pom.xml b/gcloud-java-gax/pom.xml index 83bd92f49f3e..bbfd8c6007e5 100644 --- a/gcloud-java-gax/pom.xml +++ b/gcloud-java-gax/pom.xml @@ -27,6 +27,11 @@ auto-value 1.1 + + com.google.code.findbugs + jsr305 + 3.0.1 + junit junit diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java index c1a000d438a2..a20c2b6a1f10 100644 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java @@ -11,6 +11,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.ListIterator; import java.util.Map; @@ -766,7 +767,7 @@ private static ImmutableList parseTemplate(String template) { private static String encodeUrl(String text) { try { - return URLEncoder.encode(text, "UTF-8"); + return URLEncoder.encode(text, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new ValidationException("UTF-8 encoding is not supported on this platform"); } @@ -774,7 +775,7 @@ private static String encodeUrl(String text) { private static String decodeUrl(String url) { try { - return URLDecoder.decode(url, "UTF-8"); + return URLDecoder.decode(url, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new ValidationException("UTF-8 encoding is not supported on this platform"); } From e9e610a78f571f1eb60a8bda8b7ff0c379b31499 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Wed, 4 Nov 2015 11:41:39 -0800 Subject: [PATCH 175/203] Initial submission of generated pubsub protobuf classes --- gcloud-java-pubsub/README.md | 25 + .../google/pubsub/v1/AcknowledgeRequest.java | 710 +++++++++++ .../v1/AcknowledgeRequestOrBuilder.java | 66 ++ .../pubsub/v1/DeleteSubscriptionRequest.java | 476 ++++++++ .../DeleteSubscriptionRequestOrBuilder.java | 27 + .../google/pubsub/v1/DeleteTopicRequest.java | 476 ++++++++ .../v1/DeleteTopicRequestOrBuilder.java | 27 + .../pubsub/v1/GetSubscriptionRequest.java | 476 ++++++++ .../v1/GetSubscriptionRequestOrBuilder.java | 27 + .../com/google/pubsub/v1/GetTopicRequest.java | 476 ++++++++ .../pubsub/v1/GetTopicRequestOrBuilder.java | 27 + .../pubsub/v1/ListSubscriptionsRequest.java | 711 +++++++++++ .../v1/ListSubscriptionsRequestOrBuilder.java | 58 + .../pubsub/v1/ListSubscriptionsResponse.java | 923 +++++++++++++++ .../ListSubscriptionsResponseOrBuilder.java | 75 ++ .../v1/ListTopicSubscriptionsRequest.java | 711 +++++++++++ ...istTopicSubscriptionsRequestOrBuilder.java | 58 + .../v1/ListTopicSubscriptionsResponse.java | 711 +++++++++++ ...stTopicSubscriptionsResponseOrBuilder.java | 66 ++ .../google/pubsub/v1/ListTopicsRequest.java | 711 +++++++++++ .../pubsub/v1/ListTopicsRequestOrBuilder.java | 58 + .../google/pubsub/v1/ListTopicsResponse.java | 916 +++++++++++++++ .../v1/ListTopicsResponseOrBuilder.java | 73 ++ .../pubsub/v1/ModifyAckDeadlineRequest.java | 783 +++++++++++++ .../v1/ModifyAckDeadlineRequestOrBuilder.java | 75 ++ .../pubsub/v1/ModifyPushConfigRequest.java | 744 ++++++++++++ .../v1/ModifyPushConfigRequestOrBuilder.java | 64 + .../com/google/pubsub/v1/PublishRequest.java | 909 +++++++++++++++ .../pubsub/v1/PublishRequestOrBuilder.java | 71 ++ .../com/google/pubsub/v1/PublishResponse.java | 569 +++++++++ .../pubsub/v1/PublishResponseOrBuilder.java | 52 + .../com/google/pubsub/v1/PublisherGrpc.java | 406 +++++++ .../com/google/pubsub/v1/PubsubMessage.java | 740 ++++++++++++ .../pubsub/v1/PubsubMessageOrBuilder.java | 53 + .../com/google/pubsub/v1/PubsubProto.java | 409 +++++++ .../com/google/pubsub/v1/PullRequest.java | 636 ++++++++++ .../pubsub/v1/PullRequestOrBuilder.java | 50 + .../com/google/pubsub/v1/PullResponse.java | 824 +++++++++++++ .../pubsub/v1/PullResponseOrBuilder.java | 68 ++ .../java/com/google/pubsub/v1/PushConfig.java | 711 +++++++++++ .../google/pubsub/v1/PushConfigOrBuilder.java | 55 + .../com/google/pubsub/v1/ReceivedMessage.java | 696 +++++++++++ .../pubsub/v1/ReceivedMessageOrBuilder.java | 52 + .../com/google/pubsub/v1/SubscriberGrpc.java | 506 ++++++++ .../com/google/pubsub/v1/Subscription.java | 1038 +++++++++++++++++ .../pubsub/v1/SubscriptionOrBuilder.java | 111 ++ .../main/java/com/google/pubsub/v1/Topic.java | 511 ++++++++ .../com/google/pubsub/v1/TopicOrBuilder.java | 37 + gcloud-java-pubsub/pom.xml | 56 + 49 files changed, 18110 insertions(+) create mode 100644 gcloud-java-pubsub/README.md create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponse.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponseOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponse.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponseOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponse.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponseOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponse.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponseOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublisherGrpc.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessage.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessageOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubProto.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequest.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequestOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponse.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponseOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfig.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfigOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessage.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessageOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriberGrpc.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Subscription.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriptionOrBuilder.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Topic.java create mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/TopicOrBuilder.java create mode 100644 gcloud-java-pubsub/pom.xml diff --git a/gcloud-java-pubsub/README.md b/gcloud-java-pubsub/README.md new file mode 100644 index 000000000000..29d6990d18a2 --- /dev/null +++ b/gcloud-java-pubsub/README.md @@ -0,0 +1,25 @@ +Google Cloud Java Client for Pub/Sub +==================================== + +Java idiomatic client for [Google Cloud Pub/Sub] (https://cloud.google.com/pubsub/). + +[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) +[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) +[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-pubsub.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-pubsub.svg) + +- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) +- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs) + +> Note: This client is a work-in-progress, and may occasionally +> make backwards-incompatible changes. + +Quickstart +---------- +Add this to your pom.xml file +```xml + + com.google.gcloud + gcloud-java-pubsub + 0.0.10 + +``` diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequest.java new file mode 100644 index 000000000000..1c5af6fed5d6 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequest.java @@ -0,0 +1,710 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.AcknowledgeRequest} + * + *
      + * Request for the Acknowledge method.
      + * 
      + */ +public final class AcknowledgeRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.AcknowledgeRequest) + AcknowledgeRequestOrBuilder { + // Use AcknowledgeRequest.newBuilder() to construct. + private AcknowledgeRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private AcknowledgeRequest() { + subscription_ = ""; + ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private AcknowledgeRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + subscription_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + ackIds_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + ackIds_.add(s); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + ackIds_ = ackIds_.getUnmodifiableView(); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_AcknowledgeRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.AcknowledgeRequest.class, com.google.pubsub.v1.AcknowledgeRequest.Builder.class); + } + + private int bitField0_; + public static final int SUBSCRIPTION_FIELD_NUMBER = 1; + private volatile java.lang.Object subscription_; + /** + * optional string subscription = 1; + * + *
      +   * The subscription whose message is being acknowledged.
      +   * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } + } + /** + * optional string subscription = 1; + * + *
      +   * The subscription whose message is being acknowledged.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ACK_IDS_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList ackIds_; + /** + * repeated string ack_ids = 2; + * + *
      +   * The acknowledgment ID for the messages being acknowledged that was returned
      +   * by the Pub/Sub system in the Pull response. Must not be empty.
      +   * 
      + */ + public com.google.protobuf.ProtocolStringList + getAckIdsList() { + return ackIds_; + } + /** + * repeated string ack_ids = 2; + * + *
      +   * The acknowledgment ID for the messages being acknowledged that was returned
      +   * by the Pub/Sub system in the Pull response. Must not be empty.
      +   * 
      + */ + public int getAckIdsCount() { + return ackIds_.size(); + } + /** + * repeated string ack_ids = 2; + * + *
      +   * The acknowledgment ID for the messages being acknowledged that was returned
      +   * by the Pub/Sub system in the Pull response. Must not be empty.
      +   * 
      + */ + public java.lang.String getAckIds(int index) { + return ackIds_.get(index); + } + /** + * repeated string ack_ids = 2; + * + *
      +   * The acknowledgment ID for the messages being acknowledged that was returned
      +   * by the Pub/Sub system in the Pull response. Must not be empty.
      +   * 
      + */ + public com.google.protobuf.ByteString + getAckIdsBytes(int index) { + return ackIds_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSubscriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); + } + for (int i = 0; i < ackIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, ackIds_.getRaw(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSubscriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); + } + { + int dataSize = 0; + for (int i = 0; i < ackIds_.size(); i++) { + dataSize += computeStringSizeNoTag(ackIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getAckIdsList().size(); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.AcknowledgeRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.AcknowledgeRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.AcknowledgeRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.AcknowledgeRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.AcknowledgeRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.AcknowledgeRequest} + * + *
      +   * Request for the Acknowledge method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.AcknowledgeRequest) + com.google.pubsub.v1.AcknowledgeRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_AcknowledgeRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.AcknowledgeRequest.class, com.google.pubsub.v1.AcknowledgeRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.AcknowledgeRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + subscription_ = ""; + + ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor; + } + + public com.google.pubsub.v1.AcknowledgeRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.AcknowledgeRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.AcknowledgeRequest build() { + com.google.pubsub.v1.AcknowledgeRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.AcknowledgeRequest buildPartial() { + com.google.pubsub.v1.AcknowledgeRequest result = new com.google.pubsub.v1.AcknowledgeRequest(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.subscription_ = subscription_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + ackIds_ = ackIds_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.ackIds_ = ackIds_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.AcknowledgeRequest) { + return mergeFrom((com.google.pubsub.v1.AcknowledgeRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.AcknowledgeRequest other) { + if (other == com.google.pubsub.v1.AcknowledgeRequest.getDefaultInstance()) return this; + if (!other.getSubscription().isEmpty()) { + subscription_ = other.subscription_; + onChanged(); + } + if (!other.ackIds_.isEmpty()) { + if (ackIds_.isEmpty()) { + ackIds_ = other.ackIds_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureAckIdsIsMutable(); + ackIds_.addAll(other.ackIds_); + } + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.AcknowledgeRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.AcknowledgeRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object subscription_ = ""; + /** + * optional string subscription = 1; + * + *
      +     * The subscription whose message is being acknowledged.
      +     * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription whose message is being acknowledged.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription whose message is being acknowledged.
      +     * 
      + */ + public Builder setSubscription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + subscription_ = value; + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription whose message is being acknowledged.
      +     * 
      + */ + public Builder clearSubscription() { + + subscription_ = getDefaultInstance().getSubscription(); + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription whose message is being acknowledged.
      +     * 
      + */ + public Builder setSubscriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + subscription_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureAckIdsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + ackIds_ = new com.google.protobuf.LazyStringArrayList(ackIds_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated string ack_ids = 2; + * + *
      +     * The acknowledgment ID for the messages being acknowledged that was returned
      +     * by the Pub/Sub system in the Pull response. Must not be empty.
      +     * 
      + */ + public com.google.protobuf.ProtocolStringList + getAckIdsList() { + return ackIds_.getUnmodifiableView(); + } + /** + * repeated string ack_ids = 2; + * + *
      +     * The acknowledgment ID for the messages being acknowledged that was returned
      +     * by the Pub/Sub system in the Pull response. Must not be empty.
      +     * 
      + */ + public int getAckIdsCount() { + return ackIds_.size(); + } + /** + * repeated string ack_ids = 2; + * + *
      +     * The acknowledgment ID for the messages being acknowledged that was returned
      +     * by the Pub/Sub system in the Pull response. Must not be empty.
      +     * 
      + */ + public java.lang.String getAckIds(int index) { + return ackIds_.get(index); + } + /** + * repeated string ack_ids = 2; + * + *
      +     * The acknowledgment ID for the messages being acknowledged that was returned
      +     * by the Pub/Sub system in the Pull response. Must not be empty.
      +     * 
      + */ + public com.google.protobuf.ByteString + getAckIdsBytes(int index) { + return ackIds_.getByteString(index); + } + /** + * repeated string ack_ids = 2; + * + *
      +     * The acknowledgment ID for the messages being acknowledged that was returned
      +     * by the Pub/Sub system in the Pull response. Must not be empty.
      +     * 
      + */ + public Builder setAckIds( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAckIdsIsMutable(); + ackIds_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string ack_ids = 2; + * + *
      +     * The acknowledgment ID for the messages being acknowledged that was returned
      +     * by the Pub/Sub system in the Pull response. Must not be empty.
      +     * 
      + */ + public Builder addAckIds( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAckIdsIsMutable(); + ackIds_.add(value); + onChanged(); + return this; + } + /** + * repeated string ack_ids = 2; + * + *
      +     * The acknowledgment ID for the messages being acknowledged that was returned
      +     * by the Pub/Sub system in the Pull response. Must not be empty.
      +     * 
      + */ + public Builder addAllAckIds( + java.lang.Iterable values) { + ensureAckIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, ackIds_); + onChanged(); + return this; + } + /** + * repeated string ack_ids = 2; + * + *
      +     * The acknowledgment ID for the messages being acknowledged that was returned
      +     * by the Pub/Sub system in the Pull response. Must not be empty.
      +     * 
      + */ + public Builder clearAckIds() { + ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * repeated string ack_ids = 2; + * + *
      +     * The acknowledgment ID for the messages being acknowledged that was returned
      +     * by the Pub/Sub system in the Pull response. Must not be empty.
      +     * 
      + */ + public Builder addAckIdsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureAckIdsIsMutable(); + ackIds_.add(value); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.AcknowledgeRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.AcknowledgeRequest) + private static final com.google.pubsub.v1.AcknowledgeRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.AcknowledgeRequest(); + } + + public static com.google.pubsub.v1.AcknowledgeRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public AcknowledgeRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new AcknowledgeRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.AcknowledgeRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequestOrBuilder.java new file mode 100644 index 000000000000..7a89660bbcfb --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequestOrBuilder.java @@ -0,0 +1,66 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface AcknowledgeRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.AcknowledgeRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string subscription = 1; + * + *
      +   * The subscription whose message is being acknowledged.
      +   * 
      + */ + java.lang.String getSubscription(); + /** + * optional string subscription = 1; + * + *
      +   * The subscription whose message is being acknowledged.
      +   * 
      + */ + com.google.protobuf.ByteString + getSubscriptionBytes(); + + /** + * repeated string ack_ids = 2; + * + *
      +   * The acknowledgment ID for the messages being acknowledged that was returned
      +   * by the Pub/Sub system in the Pull response. Must not be empty.
      +   * 
      + */ + com.google.protobuf.ProtocolStringList + getAckIdsList(); + /** + * repeated string ack_ids = 2; + * + *
      +   * The acknowledgment ID for the messages being acknowledged that was returned
      +   * by the Pub/Sub system in the Pull response. Must not be empty.
      +   * 
      + */ + int getAckIdsCount(); + /** + * repeated string ack_ids = 2; + * + *
      +   * The acknowledgment ID for the messages being acknowledged that was returned
      +   * by the Pub/Sub system in the Pull response. Must not be empty.
      +   * 
      + */ + java.lang.String getAckIds(int index); + /** + * repeated string ack_ids = 2; + * + *
      +   * The acknowledgment ID for the messages being acknowledged that was returned
      +   * by the Pub/Sub system in the Pull response. Must not be empty.
      +   * 
      + */ + com.google.protobuf.ByteString + getAckIdsBytes(int index); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequest.java new file mode 100644 index 000000000000..acdfd0d71c83 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequest.java @@ -0,0 +1,476 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.DeleteSubscriptionRequest} + * + *
      + * Request for the DeleteSubscription method.
      + * 
      + */ +public final class DeleteSubscriptionRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.DeleteSubscriptionRequest) + DeleteSubscriptionRequestOrBuilder { + // Use DeleteSubscriptionRequest.newBuilder() to construct. + private DeleteSubscriptionRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private DeleteSubscriptionRequest() { + subscription_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private DeleteSubscriptionRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + subscription_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteSubscriptionRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.DeleteSubscriptionRequest.class, com.google.pubsub.v1.DeleteSubscriptionRequest.Builder.class); + } + + public static final int SUBSCRIPTION_FIELD_NUMBER = 1; + private volatile java.lang.Object subscription_; + /** + * optional string subscription = 1; + * + *
      +   * The subscription to delete.
      +   * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } + } + /** + * optional string subscription = 1; + * + *
      +   * The subscription to delete.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSubscriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSubscriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.DeleteSubscriptionRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.DeleteSubscriptionRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.DeleteSubscriptionRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.DeleteSubscriptionRequest} + * + *
      +   * Request for the DeleteSubscription method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.DeleteSubscriptionRequest) + com.google.pubsub.v1.DeleteSubscriptionRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteSubscriptionRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.DeleteSubscriptionRequest.class, com.google.pubsub.v1.DeleteSubscriptionRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.DeleteSubscriptionRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + subscription_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor; + } + + public com.google.pubsub.v1.DeleteSubscriptionRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.DeleteSubscriptionRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.DeleteSubscriptionRequest build() { + com.google.pubsub.v1.DeleteSubscriptionRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.DeleteSubscriptionRequest buildPartial() { + com.google.pubsub.v1.DeleteSubscriptionRequest result = new com.google.pubsub.v1.DeleteSubscriptionRequest(this); + result.subscription_ = subscription_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.DeleteSubscriptionRequest) { + return mergeFrom((com.google.pubsub.v1.DeleteSubscriptionRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.DeleteSubscriptionRequest other) { + if (other == com.google.pubsub.v1.DeleteSubscriptionRequest.getDefaultInstance()) return this; + if (!other.getSubscription().isEmpty()) { + subscription_ = other.subscription_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.DeleteSubscriptionRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.DeleteSubscriptionRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object subscription_ = ""; + /** + * optional string subscription = 1; + * + *
      +     * The subscription to delete.
      +     * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription to delete.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription to delete.
      +     * 
      + */ + public Builder setSubscription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + subscription_ = value; + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription to delete.
      +     * 
      + */ + public Builder clearSubscription() { + + subscription_ = getDefaultInstance().getSubscription(); + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription to delete.
      +     * 
      + */ + public Builder setSubscriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + subscription_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.DeleteSubscriptionRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.DeleteSubscriptionRequest) + private static final com.google.pubsub.v1.DeleteSubscriptionRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.DeleteSubscriptionRequest(); + } + + public static com.google.pubsub.v1.DeleteSubscriptionRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DeleteSubscriptionRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new DeleteSubscriptionRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.DeleteSubscriptionRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequestOrBuilder.java new file mode 100644 index 000000000000..d43222fb965c --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequestOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface DeleteSubscriptionRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.DeleteSubscriptionRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string subscription = 1; + * + *
      +   * The subscription to delete.
      +   * 
      + */ + java.lang.String getSubscription(); + /** + * optional string subscription = 1; + * + *
      +   * The subscription to delete.
      +   * 
      + */ + com.google.protobuf.ByteString + getSubscriptionBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequest.java new file mode 100644 index 000000000000..cb7dd1257eea --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequest.java @@ -0,0 +1,476 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.DeleteTopicRequest} + * + *
      + * Request for the DeleteTopic method.
      + * 
      + */ +public final class DeleteTopicRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.DeleteTopicRequest) + DeleteTopicRequestOrBuilder { + // Use DeleteTopicRequest.newBuilder() to construct. + private DeleteTopicRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private DeleteTopicRequest() { + topic_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private DeleteTopicRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteTopicRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.DeleteTopicRequest.class, com.google.pubsub.v1.DeleteTopicRequest.Builder.class); + } + + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile java.lang.Object topic_; + /** + * optional string topic = 1; + * + *
      +   * Name of the topic to delete.
      +   * 
      + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * optional string topic = 1; + * + *
      +   * Name of the topic to delete.
      +   * 
      + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, topic_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, topic_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.DeleteTopicRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.DeleteTopicRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.DeleteTopicRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.DeleteTopicRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.DeleteTopicRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.DeleteTopicRequest} + * + *
      +   * Request for the DeleteTopic method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.DeleteTopicRequest) + com.google.pubsub.v1.DeleteTopicRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteTopicRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.DeleteTopicRequest.class, com.google.pubsub.v1.DeleteTopicRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.DeleteTopicRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + topic_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor; + } + + public com.google.pubsub.v1.DeleteTopicRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.DeleteTopicRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.DeleteTopicRequest build() { + com.google.pubsub.v1.DeleteTopicRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.DeleteTopicRequest buildPartial() { + com.google.pubsub.v1.DeleteTopicRequest result = new com.google.pubsub.v1.DeleteTopicRequest(this); + result.topic_ = topic_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.DeleteTopicRequest) { + return mergeFrom((com.google.pubsub.v1.DeleteTopicRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.DeleteTopicRequest other) { + if (other == com.google.pubsub.v1.DeleteTopicRequest.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.DeleteTopicRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.DeleteTopicRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object topic_ = ""; + /** + * optional string topic = 1; + * + *
      +     * Name of the topic to delete.
      +     * 
      + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string topic = 1; + * + *
      +     * Name of the topic to delete.
      +     * 
      + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string topic = 1; + * + *
      +     * Name of the topic to delete.
      +     * 
      + */ + public Builder setTopic( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * optional string topic = 1; + * + *
      +     * Name of the topic to delete.
      +     * 
      + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * optional string topic = 1; + * + *
      +     * Name of the topic to delete.
      +     * 
      + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.DeleteTopicRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.DeleteTopicRequest) + private static final com.google.pubsub.v1.DeleteTopicRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.DeleteTopicRequest(); + } + + public static com.google.pubsub.v1.DeleteTopicRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public DeleteTopicRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new DeleteTopicRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.DeleteTopicRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequestOrBuilder.java new file mode 100644 index 000000000000..c08d12083d31 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequestOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface DeleteTopicRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.DeleteTopicRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string topic = 1; + * + *
      +   * Name of the topic to delete.
      +   * 
      + */ + java.lang.String getTopic(); + /** + * optional string topic = 1; + * + *
      +   * Name of the topic to delete.
      +   * 
      + */ + com.google.protobuf.ByteString + getTopicBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequest.java new file mode 100644 index 000000000000..b8bd3e5f0249 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequest.java @@ -0,0 +1,476 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.GetSubscriptionRequest} + * + *
      + * Request for the GetSubscription method.
      + * 
      + */ +public final class GetSubscriptionRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.GetSubscriptionRequest) + GetSubscriptionRequestOrBuilder { + // Use GetSubscriptionRequest.newBuilder() to construct. + private GetSubscriptionRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private GetSubscriptionRequest() { + subscription_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private GetSubscriptionRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + subscription_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetSubscriptionRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.GetSubscriptionRequest.class, com.google.pubsub.v1.GetSubscriptionRequest.Builder.class); + } + + public static final int SUBSCRIPTION_FIELD_NUMBER = 1; + private volatile java.lang.Object subscription_; + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription to get.
      +   * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } + } + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription to get.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSubscriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSubscriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.GetSubscriptionRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.GetSubscriptionRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.GetSubscriptionRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.GetSubscriptionRequest} + * + *
      +   * Request for the GetSubscription method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.GetSubscriptionRequest) + com.google.pubsub.v1.GetSubscriptionRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetSubscriptionRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.GetSubscriptionRequest.class, com.google.pubsub.v1.GetSubscriptionRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.GetSubscriptionRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + subscription_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor; + } + + public com.google.pubsub.v1.GetSubscriptionRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.GetSubscriptionRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.GetSubscriptionRequest build() { + com.google.pubsub.v1.GetSubscriptionRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.GetSubscriptionRequest buildPartial() { + com.google.pubsub.v1.GetSubscriptionRequest result = new com.google.pubsub.v1.GetSubscriptionRequest(this); + result.subscription_ = subscription_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.GetSubscriptionRequest) { + return mergeFrom((com.google.pubsub.v1.GetSubscriptionRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.GetSubscriptionRequest other) { + if (other == com.google.pubsub.v1.GetSubscriptionRequest.getDefaultInstance()) return this; + if (!other.getSubscription().isEmpty()) { + subscription_ = other.subscription_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.GetSubscriptionRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.GetSubscriptionRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object subscription_ = ""; + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription to get.
      +     * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription to get.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription to get.
      +     * 
      + */ + public Builder setSubscription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + subscription_ = value; + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription to get.
      +     * 
      + */ + public Builder clearSubscription() { + + subscription_ = getDefaultInstance().getSubscription(); + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription to get.
      +     * 
      + */ + public Builder setSubscriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + subscription_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.GetSubscriptionRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.GetSubscriptionRequest) + private static final com.google.pubsub.v1.GetSubscriptionRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.GetSubscriptionRequest(); + } + + public static com.google.pubsub.v1.GetSubscriptionRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public GetSubscriptionRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new GetSubscriptionRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.GetSubscriptionRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequestOrBuilder.java new file mode 100644 index 000000000000..248eb0561e6f --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequestOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface GetSubscriptionRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.GetSubscriptionRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription to get.
      +   * 
      + */ + java.lang.String getSubscription(); + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription to get.
      +   * 
      + */ + com.google.protobuf.ByteString + getSubscriptionBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequest.java new file mode 100644 index 000000000000..17961ce28ab0 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequest.java @@ -0,0 +1,476 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.GetTopicRequest} + * + *
      + * Request for the GetTopic method.
      + * 
      + */ +public final class GetTopicRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.GetTopicRequest) + GetTopicRequestOrBuilder { + // Use GetTopicRequest.newBuilder() to construct. + private GetTopicRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private GetTopicRequest() { + topic_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private GetTopicRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetTopicRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetTopicRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.GetTopicRequest.class, com.google.pubsub.v1.GetTopicRequest.Builder.class); + } + + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile java.lang.Object topic_; + /** + * optional string topic = 1; + * + *
      +   * The name of the topic to get.
      +   * 
      + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * optional string topic = 1; + * + *
      +   * The name of the topic to get.
      +   * 
      + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, topic_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, topic_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.GetTopicRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.GetTopicRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.GetTopicRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.GetTopicRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.GetTopicRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.GetTopicRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.GetTopicRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.GetTopicRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.GetTopicRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.GetTopicRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.GetTopicRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.GetTopicRequest} + * + *
      +   * Request for the GetTopic method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.GetTopicRequest) + com.google.pubsub.v1.GetTopicRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetTopicRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetTopicRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.GetTopicRequest.class, com.google.pubsub.v1.GetTopicRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.GetTopicRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + topic_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetTopicRequest_descriptor; + } + + public com.google.pubsub.v1.GetTopicRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.GetTopicRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.GetTopicRequest build() { + com.google.pubsub.v1.GetTopicRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.GetTopicRequest buildPartial() { + com.google.pubsub.v1.GetTopicRequest result = new com.google.pubsub.v1.GetTopicRequest(this); + result.topic_ = topic_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.GetTopicRequest) { + return mergeFrom((com.google.pubsub.v1.GetTopicRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.GetTopicRequest other) { + if (other == com.google.pubsub.v1.GetTopicRequest.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.GetTopicRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.GetTopicRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object topic_ = ""; + /** + * optional string topic = 1; + * + *
      +     * The name of the topic to get.
      +     * 
      + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string topic = 1; + * + *
      +     * The name of the topic to get.
      +     * 
      + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string topic = 1; + * + *
      +     * The name of the topic to get.
      +     * 
      + */ + public Builder setTopic( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * optional string topic = 1; + * + *
      +     * The name of the topic to get.
      +     * 
      + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * optional string topic = 1; + * + *
      +     * The name of the topic to get.
      +     * 
      + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.GetTopicRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.GetTopicRequest) + private static final com.google.pubsub.v1.GetTopicRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.GetTopicRequest(); + } + + public static com.google.pubsub.v1.GetTopicRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public GetTopicRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new GetTopicRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.GetTopicRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequestOrBuilder.java new file mode 100644 index 000000000000..c26b5276c5da --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequestOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface GetTopicRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.GetTopicRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string topic = 1; + * + *
      +   * The name of the topic to get.
      +   * 
      + */ + java.lang.String getTopic(); + /** + * optional string topic = 1; + * + *
      +   * The name of the topic to get.
      +   * 
      + */ + com.google.protobuf.ByteString + getTopicBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequest.java new file mode 100644 index 000000000000..8b0cc2e8a04f --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequest.java @@ -0,0 +1,711 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.ListSubscriptionsRequest} + * + *
      + * Request for the ListSubscriptions method.
      + * 
      + */ +public final class ListSubscriptionsRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListSubscriptionsRequest) + ListSubscriptionsRequestOrBuilder { + // Use ListSubscriptionsRequest.newBuilder() to construct. + private ListSubscriptionsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ListSubscriptionsRequest() { + project_ = ""; + pageSize_ = 0; + pageToken_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ListSubscriptionsRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + project_ = s; + break; + } + case 16: { + + pageSize_ = input.readInt32(); + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + pageToken_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListSubscriptionsRequest.class, com.google.pubsub.v1.ListSubscriptionsRequest.Builder.class); + } + + public static final int PROJECT_FIELD_NUMBER = 1; + private volatile java.lang.Object project_; + /** + * optional string project = 1; + * + *
      +   * The name of the cloud project that subscriptions belong to.
      +   * 
      + */ + public java.lang.String getProject() { + java.lang.Object ref = project_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + project_ = s; + return s; + } + } + /** + * optional string project = 1; + * + *
      +   * The name of the cloud project that subscriptions belong to.
      +   * 
      + */ + public com.google.protobuf.ByteString + getProjectBytes() { + java.lang.Object ref = project_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + project_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 2; + private int pageSize_; + /** + * optional int32 page_size = 2; + * + *
      +   * Maximum number of subscriptions to return.
      +   * 
      + */ + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 3; + private volatile java.lang.Object pageToken_; + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListSubscriptionsResponse; indicates that
      +   * this is a continuation of a prior ListSubscriptions call, and that the
      +   * system should return the next page of data.
      +   * 
      + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } + } + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListSubscriptionsResponse; indicates that
      +   * this is a continuation of a prior ListSubscriptions call, and that the
      +   * system should return the next page of data.
      +   * 
      + */ + public com.google.protobuf.ByteString + getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getProjectBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, project_); + } + if (pageSize_ != 0) { + output.writeInt32(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, pageToken_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getProjectBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, project_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pageToken_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListSubscriptionsRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.ListSubscriptionsRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.ListSubscriptionsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.ListSubscriptionsRequest} + * + *
      +   * Request for the ListSubscriptions method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListSubscriptionsRequest) + com.google.pubsub.v1.ListSubscriptionsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListSubscriptionsRequest.class, com.google.pubsub.v1.ListSubscriptionsRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.ListSubscriptionsRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + project_ = ""; + + pageSize_ = 0; + + pageToken_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor; + } + + public com.google.pubsub.v1.ListSubscriptionsRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.ListSubscriptionsRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.ListSubscriptionsRequest build() { + com.google.pubsub.v1.ListSubscriptionsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.ListSubscriptionsRequest buildPartial() { + com.google.pubsub.v1.ListSubscriptionsRequest result = new com.google.pubsub.v1.ListSubscriptionsRequest(this); + result.project_ = project_; + result.pageSize_ = pageSize_; + result.pageToken_ = pageToken_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.ListSubscriptionsRequest) { + return mergeFrom((com.google.pubsub.v1.ListSubscriptionsRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.ListSubscriptionsRequest other) { + if (other == com.google.pubsub.v1.ListSubscriptionsRequest.getDefaultInstance()) return this; + if (!other.getProject().isEmpty()) { + project_ = other.project_; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.ListSubscriptionsRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.ListSubscriptionsRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object project_ = ""; + /** + * optional string project = 1; + * + *
      +     * The name of the cloud project that subscriptions belong to.
      +     * 
      + */ + public java.lang.String getProject() { + java.lang.Object ref = project_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + project_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string project = 1; + * + *
      +     * The name of the cloud project that subscriptions belong to.
      +     * 
      + */ + public com.google.protobuf.ByteString + getProjectBytes() { + java.lang.Object ref = project_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + project_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string project = 1; + * + *
      +     * The name of the cloud project that subscriptions belong to.
      +     * 
      + */ + public Builder setProject( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + project_ = value; + onChanged(); + return this; + } + /** + * optional string project = 1; + * + *
      +     * The name of the cloud project that subscriptions belong to.
      +     * 
      + */ + public Builder clearProject() { + + project_ = getDefaultInstance().getProject(); + onChanged(); + return this; + } + /** + * optional string project = 1; + * + *
      +     * The name of the cloud project that subscriptions belong to.
      +     * 
      + */ + public Builder setProjectBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + project_ = value; + onChanged(); + return this; + } + + private int pageSize_ ; + /** + * optional int32 page_size = 2; + * + *
      +     * Maximum number of subscriptions to return.
      +     * 
      + */ + public int getPageSize() { + return pageSize_; + } + /** + * optional int32 page_size = 2; + * + *
      +     * Maximum number of subscriptions to return.
      +     * 
      + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + onChanged(); + return this; + } + /** + * optional int32 page_size = 2; + * + *
      +     * Maximum number of subscriptions to return.
      +     * 
      + */ + public Builder clearPageSize() { + + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListSubscriptionsResponse; indicates that
      +     * this is a continuation of a prior ListSubscriptions call, and that the
      +     * system should return the next page of data.
      +     * 
      + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListSubscriptionsResponse; indicates that
      +     * this is a continuation of a prior ListSubscriptions call, and that the
      +     * system should return the next page of data.
      +     * 
      + */ + public com.google.protobuf.ByteString + getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListSubscriptionsResponse; indicates that
      +     * this is a continuation of a prior ListSubscriptions call, and that the
      +     * system should return the next page of data.
      +     * 
      + */ + public Builder setPageToken( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + pageToken_ = value; + onChanged(); + return this; + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListSubscriptionsResponse; indicates that
      +     * this is a continuation of a prior ListSubscriptions call, and that the
      +     * system should return the next page of data.
      +     * 
      + */ + public Builder clearPageToken() { + + pageToken_ = getDefaultInstance().getPageToken(); + onChanged(); + return this; + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListSubscriptionsResponse; indicates that
      +     * this is a continuation of a prior ListSubscriptions call, and that the
      +     * system should return the next page of data.
      +     * 
      + */ + public Builder setPageTokenBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + pageToken_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListSubscriptionsRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListSubscriptionsRequest) + private static final com.google.pubsub.v1.ListSubscriptionsRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.ListSubscriptionsRequest(); + } + + public static com.google.pubsub.v1.ListSubscriptionsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ListSubscriptionsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ListSubscriptionsRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.ListSubscriptionsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequestOrBuilder.java new file mode 100644 index 000000000000..b8b08410f4a1 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequestOrBuilder.java @@ -0,0 +1,58 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface ListSubscriptionsRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListSubscriptionsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string project = 1; + * + *
      +   * The name of the cloud project that subscriptions belong to.
      +   * 
      + */ + java.lang.String getProject(); + /** + * optional string project = 1; + * + *
      +   * The name of the cloud project that subscriptions belong to.
      +   * 
      + */ + com.google.protobuf.ByteString + getProjectBytes(); + + /** + * optional int32 page_size = 2; + * + *
      +   * Maximum number of subscriptions to return.
      +   * 
      + */ + int getPageSize(); + + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListSubscriptionsResponse; indicates that
      +   * this is a continuation of a prior ListSubscriptions call, and that the
      +   * system should return the next page of data.
      +   * 
      + */ + java.lang.String getPageToken(); + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListSubscriptionsResponse; indicates that
      +   * this is a continuation of a prior ListSubscriptions call, and that the
      +   * system should return the next page of data.
      +   * 
      + */ + com.google.protobuf.ByteString + getPageTokenBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponse.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponse.java new file mode 100644 index 000000000000..3ef3d6cea957 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponse.java @@ -0,0 +1,923 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.ListSubscriptionsResponse} + * + *
      + * Response for the ListSubscriptions method.
      + * 
      + */ +public final class ListSubscriptionsResponse extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListSubscriptionsResponse) + ListSubscriptionsResponseOrBuilder { + // Use ListSubscriptionsResponse.newBuilder() to construct. + private ListSubscriptionsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ListSubscriptionsResponse() { + subscriptions_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ListSubscriptionsResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + subscriptions_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + subscriptions_.add(input.readMessage(com.google.pubsub.v1.Subscription.parser(), extensionRegistry)); + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + nextPageToken_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + subscriptions_ = java.util.Collections.unmodifiableList(subscriptions_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListSubscriptionsResponse.class, com.google.pubsub.v1.ListSubscriptionsResponse.Builder.class); + } + + private int bitField0_; + public static final int SUBSCRIPTIONS_FIELD_NUMBER = 1; + private java.util.List subscriptions_; + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +   * The subscriptions that match the request.
      +   * 
      + */ + public java.util.List getSubscriptionsList() { + return subscriptions_; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +   * The subscriptions that match the request.
      +   * 
      + */ + public java.util.List + getSubscriptionsOrBuilderList() { + return subscriptions_; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +   * The subscriptions that match the request.
      +   * 
      + */ + public int getSubscriptionsCount() { + return subscriptions_.size(); + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +   * The subscriptions that match the request.
      +   * 
      + */ + public com.google.pubsub.v1.Subscription getSubscriptions(int index) { + return subscriptions_.get(index); + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +   * The subscriptions that match the request.
      +   * 
      + */ + public com.google.pubsub.v1.SubscriptionOrBuilder getSubscriptionsOrBuilder( + int index) { + return subscriptions_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + private volatile java.lang.Object nextPageToken_; + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more subscriptions that match
      +   * the request; this value should be passed in a new ListSubscriptionsRequest
      +   * to get more subscriptions.
      +   * 
      + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } + } + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more subscriptions that match
      +   * the request; this value should be passed in a new ListSubscriptionsRequest
      +   * to get more subscriptions.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < subscriptions_.size(); i++) { + output.writeMessage(1, subscriptions_.get(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < subscriptions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, subscriptions_.get(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListSubscriptionsResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.ListSubscriptionsResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.ListSubscriptionsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.ListSubscriptionsResponse} + * + *
      +   * Response for the ListSubscriptions method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListSubscriptionsResponse) + com.google.pubsub.v1.ListSubscriptionsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListSubscriptionsResponse.class, com.google.pubsub.v1.ListSubscriptionsResponse.Builder.class); + } + + // Construct using com.google.pubsub.v1.ListSubscriptionsResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getSubscriptionsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (subscriptionsBuilder_ == null) { + subscriptions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + subscriptionsBuilder_.clear(); + } + nextPageToken_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor; + } + + public com.google.pubsub.v1.ListSubscriptionsResponse getDefaultInstanceForType() { + return com.google.pubsub.v1.ListSubscriptionsResponse.getDefaultInstance(); + } + + public com.google.pubsub.v1.ListSubscriptionsResponse build() { + com.google.pubsub.v1.ListSubscriptionsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.ListSubscriptionsResponse buildPartial() { + com.google.pubsub.v1.ListSubscriptionsResponse result = new com.google.pubsub.v1.ListSubscriptionsResponse(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (subscriptionsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subscriptions_ = java.util.Collections.unmodifiableList(subscriptions_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.subscriptions_ = subscriptions_; + } else { + result.subscriptions_ = subscriptionsBuilder_.build(); + } + result.nextPageToken_ = nextPageToken_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.ListSubscriptionsResponse) { + return mergeFrom((com.google.pubsub.v1.ListSubscriptionsResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.ListSubscriptionsResponse other) { + if (other == com.google.pubsub.v1.ListSubscriptionsResponse.getDefaultInstance()) return this; + if (subscriptionsBuilder_ == null) { + if (!other.subscriptions_.isEmpty()) { + if (subscriptions_.isEmpty()) { + subscriptions_ = other.subscriptions_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureSubscriptionsIsMutable(); + subscriptions_.addAll(other.subscriptions_); + } + onChanged(); + } + } else { + if (!other.subscriptions_.isEmpty()) { + if (subscriptionsBuilder_.isEmpty()) { + subscriptionsBuilder_.dispose(); + subscriptionsBuilder_ = null; + subscriptions_ = other.subscriptions_; + bitField0_ = (bitField0_ & ~0x00000001); + subscriptionsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getSubscriptionsFieldBuilder() : null; + } else { + subscriptionsBuilder_.addAllMessages(other.subscriptions_); + } + } + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.ListSubscriptionsResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.ListSubscriptionsResponse) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List subscriptions_ = + java.util.Collections.emptyList(); + private void ensureSubscriptionsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + subscriptions_ = new java.util.ArrayList(subscriptions_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.Subscription, com.google.pubsub.v1.Subscription.Builder, com.google.pubsub.v1.SubscriptionOrBuilder> subscriptionsBuilder_; + + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public java.util.List getSubscriptionsList() { + if (subscriptionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(subscriptions_); + } else { + return subscriptionsBuilder_.getMessageList(); + } + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public int getSubscriptionsCount() { + if (subscriptionsBuilder_ == null) { + return subscriptions_.size(); + } else { + return subscriptionsBuilder_.getCount(); + } + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public com.google.pubsub.v1.Subscription getSubscriptions(int index) { + if (subscriptionsBuilder_ == null) { + return subscriptions_.get(index); + } else { + return subscriptionsBuilder_.getMessage(index); + } + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public Builder setSubscriptions( + int index, com.google.pubsub.v1.Subscription value) { + if (subscriptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionsIsMutable(); + subscriptions_.set(index, value); + onChanged(); + } else { + subscriptionsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public Builder setSubscriptions( + int index, com.google.pubsub.v1.Subscription.Builder builderForValue) { + if (subscriptionsBuilder_ == null) { + ensureSubscriptionsIsMutable(); + subscriptions_.set(index, builderForValue.build()); + onChanged(); + } else { + subscriptionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public Builder addSubscriptions(com.google.pubsub.v1.Subscription value) { + if (subscriptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionsIsMutable(); + subscriptions_.add(value); + onChanged(); + } else { + subscriptionsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public Builder addSubscriptions( + int index, com.google.pubsub.v1.Subscription value) { + if (subscriptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionsIsMutable(); + subscriptions_.add(index, value); + onChanged(); + } else { + subscriptionsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public Builder addSubscriptions( + com.google.pubsub.v1.Subscription.Builder builderForValue) { + if (subscriptionsBuilder_ == null) { + ensureSubscriptionsIsMutable(); + subscriptions_.add(builderForValue.build()); + onChanged(); + } else { + subscriptionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public Builder addSubscriptions( + int index, com.google.pubsub.v1.Subscription.Builder builderForValue) { + if (subscriptionsBuilder_ == null) { + ensureSubscriptionsIsMutable(); + subscriptions_.add(index, builderForValue.build()); + onChanged(); + } else { + subscriptionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public Builder addAllSubscriptions( + java.lang.Iterable values) { + if (subscriptionsBuilder_ == null) { + ensureSubscriptionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, subscriptions_); + onChanged(); + } else { + subscriptionsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public Builder clearSubscriptions() { + if (subscriptionsBuilder_ == null) { + subscriptions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + subscriptionsBuilder_.clear(); + } + return this; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public Builder removeSubscriptions(int index) { + if (subscriptionsBuilder_ == null) { + ensureSubscriptionsIsMutable(); + subscriptions_.remove(index); + onChanged(); + } else { + subscriptionsBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public com.google.pubsub.v1.Subscription.Builder getSubscriptionsBuilder( + int index) { + return getSubscriptionsFieldBuilder().getBuilder(index); + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public com.google.pubsub.v1.SubscriptionOrBuilder getSubscriptionsOrBuilder( + int index) { + if (subscriptionsBuilder_ == null) { + return subscriptions_.get(index); } else { + return subscriptionsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public java.util.List + getSubscriptionsOrBuilderList() { + if (subscriptionsBuilder_ != null) { + return subscriptionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(subscriptions_); + } + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public com.google.pubsub.v1.Subscription.Builder addSubscriptionsBuilder() { + return getSubscriptionsFieldBuilder().addBuilder( + com.google.pubsub.v1.Subscription.getDefaultInstance()); + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public com.google.pubsub.v1.Subscription.Builder addSubscriptionsBuilder( + int index) { + return getSubscriptionsFieldBuilder().addBuilder( + index, com.google.pubsub.v1.Subscription.getDefaultInstance()); + } + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +     * The subscriptions that match the request.
      +     * 
      + */ + public java.util.List + getSubscriptionsBuilderList() { + return getSubscriptionsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.Subscription, com.google.pubsub.v1.Subscription.Builder, com.google.pubsub.v1.SubscriptionOrBuilder> + getSubscriptionsFieldBuilder() { + if (subscriptionsBuilder_ == null) { + subscriptionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.Subscription, com.google.pubsub.v1.Subscription.Builder, com.google.pubsub.v1.SubscriptionOrBuilder>( + subscriptions_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + subscriptions_ = null; + } + return subscriptionsBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more subscriptions that match
      +     * the request; this value should be passed in a new ListSubscriptionsRequest
      +     * to get more subscriptions.
      +     * 
      + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more subscriptions that match
      +     * the request; this value should be passed in a new ListSubscriptionsRequest
      +     * to get more subscriptions.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more subscriptions that match
      +     * the request; this value should be passed in a new ListSubscriptionsRequest
      +     * to get more subscriptions.
      +     * 
      + */ + public Builder setNextPageToken( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + nextPageToken_ = value; + onChanged(); + return this; + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more subscriptions that match
      +     * the request; this value should be passed in a new ListSubscriptionsRequest
      +     * to get more subscriptions.
      +     * 
      + */ + public Builder clearNextPageToken() { + + nextPageToken_ = getDefaultInstance().getNextPageToken(); + onChanged(); + return this; + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more subscriptions that match
      +     * the request; this value should be passed in a new ListSubscriptionsRequest
      +     * to get more subscriptions.
      +     * 
      + */ + public Builder setNextPageTokenBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + nextPageToken_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListSubscriptionsResponse) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListSubscriptionsResponse) + private static final com.google.pubsub.v1.ListSubscriptionsResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.ListSubscriptionsResponse(); + } + + public static com.google.pubsub.v1.ListSubscriptionsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ListSubscriptionsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ListSubscriptionsResponse(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.ListSubscriptionsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponseOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponseOrBuilder.java new file mode 100644 index 000000000000..c931a95d7dc1 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponseOrBuilder.java @@ -0,0 +1,75 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface ListSubscriptionsResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListSubscriptionsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +   * The subscriptions that match the request.
      +   * 
      + */ + java.util.List + getSubscriptionsList(); + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +   * The subscriptions that match the request.
      +   * 
      + */ + com.google.pubsub.v1.Subscription getSubscriptions(int index); + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +   * The subscriptions that match the request.
      +   * 
      + */ + int getSubscriptionsCount(); + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +   * The subscriptions that match the request.
      +   * 
      + */ + java.util.List + getSubscriptionsOrBuilderList(); + /** + * repeated .google.pubsub.v1.Subscription subscriptions = 1; + * + *
      +   * The subscriptions that match the request.
      +   * 
      + */ + com.google.pubsub.v1.SubscriptionOrBuilder getSubscriptionsOrBuilder( + int index); + + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more subscriptions that match
      +   * the request; this value should be passed in a new ListSubscriptionsRequest
      +   * to get more subscriptions.
      +   * 
      + */ + java.lang.String getNextPageToken(); + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more subscriptions that match
      +   * the request; this value should be passed in a new ListSubscriptionsRequest
      +   * to get more subscriptions.
      +   * 
      + */ + com.google.protobuf.ByteString + getNextPageTokenBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequest.java new file mode 100644 index 000000000000..c0e56b784e13 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequest.java @@ -0,0 +1,711 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.ListTopicSubscriptionsRequest} + * + *
      + * Request for the ListTopicSubscriptions method.
      + * 
      + */ +public final class ListTopicSubscriptionsRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListTopicSubscriptionsRequest) + ListTopicSubscriptionsRequestOrBuilder { + // Use ListTopicSubscriptionsRequest.newBuilder() to construct. + private ListTopicSubscriptionsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ListTopicSubscriptionsRequest() { + topic_ = ""; + pageSize_ = 0; + pageToken_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ListTopicSubscriptionsRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 16: { + + pageSize_ = input.readInt32(); + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + pageToken_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListTopicSubscriptionsRequest.class, com.google.pubsub.v1.ListTopicSubscriptionsRequest.Builder.class); + } + + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile java.lang.Object topic_; + /** + * optional string topic = 1; + * + *
      +   * The name of the topic that subscriptions are attached to.
      +   * 
      + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * optional string topic = 1; + * + *
      +   * The name of the topic that subscriptions are attached to.
      +   * 
      + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 2; + private int pageSize_; + /** + * optional int32 page_size = 2; + * + *
      +   * Maximum number of subscription names to return.
      +   * 
      + */ + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 3; + private volatile java.lang.Object pageToken_; + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListTopicSubscriptionsResponse; indicates
      +   * that this is a continuation of a prior ListTopicSubscriptions call, and
      +   * that the system should return the next page of data.
      +   * 
      + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } + } + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListTopicSubscriptionsResponse; indicates
      +   * that this is a continuation of a prior ListTopicSubscriptions call, and
      +   * that the system should return the next page of data.
      +   * 
      + */ + public com.google.protobuf.ByteString + getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, topic_); + } + if (pageSize_ != 0) { + output.writeInt32(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, pageToken_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, topic_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pageToken_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.ListTopicSubscriptionsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.ListTopicSubscriptionsRequest} + * + *
      +   * Request for the ListTopicSubscriptions method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListTopicSubscriptionsRequest) + com.google.pubsub.v1.ListTopicSubscriptionsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListTopicSubscriptionsRequest.class, com.google.pubsub.v1.ListTopicSubscriptionsRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.ListTopicSubscriptionsRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + topic_ = ""; + + pageSize_ = 0; + + pageToken_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor; + } + + public com.google.pubsub.v1.ListTopicSubscriptionsRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.ListTopicSubscriptionsRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.ListTopicSubscriptionsRequest build() { + com.google.pubsub.v1.ListTopicSubscriptionsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.ListTopicSubscriptionsRequest buildPartial() { + com.google.pubsub.v1.ListTopicSubscriptionsRequest result = new com.google.pubsub.v1.ListTopicSubscriptionsRequest(this); + result.topic_ = topic_; + result.pageSize_ = pageSize_; + result.pageToken_ = pageToken_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.ListTopicSubscriptionsRequest) { + return mergeFrom((com.google.pubsub.v1.ListTopicSubscriptionsRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.ListTopicSubscriptionsRequest other) { + if (other == com.google.pubsub.v1.ListTopicSubscriptionsRequest.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.ListTopicSubscriptionsRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.ListTopicSubscriptionsRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object topic_ = ""; + /** + * optional string topic = 1; + * + *
      +     * The name of the topic that subscriptions are attached to.
      +     * 
      + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string topic = 1; + * + *
      +     * The name of the topic that subscriptions are attached to.
      +     * 
      + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string topic = 1; + * + *
      +     * The name of the topic that subscriptions are attached to.
      +     * 
      + */ + public Builder setTopic( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * optional string topic = 1; + * + *
      +     * The name of the topic that subscriptions are attached to.
      +     * 
      + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * optional string topic = 1; + * + *
      +     * The name of the topic that subscriptions are attached to.
      +     * 
      + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private int pageSize_ ; + /** + * optional int32 page_size = 2; + * + *
      +     * Maximum number of subscription names to return.
      +     * 
      + */ + public int getPageSize() { + return pageSize_; + } + /** + * optional int32 page_size = 2; + * + *
      +     * Maximum number of subscription names to return.
      +     * 
      + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + onChanged(); + return this; + } + /** + * optional int32 page_size = 2; + * + *
      +     * Maximum number of subscription names to return.
      +     * 
      + */ + public Builder clearPageSize() { + + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListTopicSubscriptionsResponse; indicates
      +     * that this is a continuation of a prior ListTopicSubscriptions call, and
      +     * that the system should return the next page of data.
      +     * 
      + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListTopicSubscriptionsResponse; indicates
      +     * that this is a continuation of a prior ListTopicSubscriptions call, and
      +     * that the system should return the next page of data.
      +     * 
      + */ + public com.google.protobuf.ByteString + getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListTopicSubscriptionsResponse; indicates
      +     * that this is a continuation of a prior ListTopicSubscriptions call, and
      +     * that the system should return the next page of data.
      +     * 
      + */ + public Builder setPageToken( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + pageToken_ = value; + onChanged(); + return this; + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListTopicSubscriptionsResponse; indicates
      +     * that this is a continuation of a prior ListTopicSubscriptions call, and
      +     * that the system should return the next page of data.
      +     * 
      + */ + public Builder clearPageToken() { + + pageToken_ = getDefaultInstance().getPageToken(); + onChanged(); + return this; + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListTopicSubscriptionsResponse; indicates
      +     * that this is a continuation of a prior ListTopicSubscriptions call, and
      +     * that the system should return the next page of data.
      +     * 
      + */ + public Builder setPageTokenBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + pageToken_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListTopicSubscriptionsRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListTopicSubscriptionsRequest) + private static final com.google.pubsub.v1.ListTopicSubscriptionsRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.ListTopicSubscriptionsRequest(); + } + + public static com.google.pubsub.v1.ListTopicSubscriptionsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ListTopicSubscriptionsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ListTopicSubscriptionsRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.ListTopicSubscriptionsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequestOrBuilder.java new file mode 100644 index 000000000000..dafee9be2078 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequestOrBuilder.java @@ -0,0 +1,58 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface ListTopicSubscriptionsRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListTopicSubscriptionsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string topic = 1; + * + *
      +   * The name of the topic that subscriptions are attached to.
      +   * 
      + */ + java.lang.String getTopic(); + /** + * optional string topic = 1; + * + *
      +   * The name of the topic that subscriptions are attached to.
      +   * 
      + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * optional int32 page_size = 2; + * + *
      +   * Maximum number of subscription names to return.
      +   * 
      + */ + int getPageSize(); + + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListTopicSubscriptionsResponse; indicates
      +   * that this is a continuation of a prior ListTopicSubscriptions call, and
      +   * that the system should return the next page of data.
      +   * 
      + */ + java.lang.String getPageToken(); + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListTopicSubscriptionsResponse; indicates
      +   * that this is a continuation of a prior ListTopicSubscriptions call, and
      +   * that the system should return the next page of data.
      +   * 
      + */ + com.google.protobuf.ByteString + getPageTokenBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponse.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponse.java new file mode 100644 index 000000000000..3fe8e4ccf74b --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponse.java @@ -0,0 +1,711 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.ListTopicSubscriptionsResponse} + * + *
      + * Response for the ListTopicSubscriptions method.
      + * 
      + */ +public final class ListTopicSubscriptionsResponse extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListTopicSubscriptionsResponse) + ListTopicSubscriptionsResponseOrBuilder { + // Use ListTopicSubscriptionsResponse.newBuilder() to construct. + private ListTopicSubscriptionsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ListTopicSubscriptionsResponse() { + subscriptions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + nextPageToken_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ListTopicSubscriptionsResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + subscriptions_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + subscriptions_.add(s); + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + nextPageToken_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + subscriptions_ = subscriptions_.getUnmodifiableView(); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListTopicSubscriptionsResponse.class, com.google.pubsub.v1.ListTopicSubscriptionsResponse.Builder.class); + } + + private int bitField0_; + public static final int SUBSCRIPTIONS_FIELD_NUMBER = 1; + private com.google.protobuf.LazyStringList subscriptions_; + /** + * repeated string subscriptions = 1; + * + *
      +   * The names of the subscriptions that match the request.
      +   * 
      + */ + public com.google.protobuf.ProtocolStringList + getSubscriptionsList() { + return subscriptions_; + } + /** + * repeated string subscriptions = 1; + * + *
      +   * The names of the subscriptions that match the request.
      +   * 
      + */ + public int getSubscriptionsCount() { + return subscriptions_.size(); + } + /** + * repeated string subscriptions = 1; + * + *
      +   * The names of the subscriptions that match the request.
      +   * 
      + */ + public java.lang.String getSubscriptions(int index) { + return subscriptions_.get(index); + } + /** + * repeated string subscriptions = 1; + * + *
      +   * The names of the subscriptions that match the request.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionsBytes(int index) { + return subscriptions_.getByteString(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + private volatile java.lang.Object nextPageToken_; + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more subscriptions that match
      +   * the request; this value should be passed in a new
      +   * ListTopicSubscriptionsRequest to get more subscriptions.
      +   * 
      + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } + } + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more subscriptions that match
      +   * the request; this value should be passed in a new
      +   * ListTopicSubscriptionsRequest to get more subscriptions.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < subscriptions_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, subscriptions_.getRaw(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < subscriptions_.size(); i++) { + dataSize += computeStringSizeNoTag(subscriptions_.getRaw(i)); + } + size += dataSize; + size += 1 * getSubscriptionsList().size(); + } + if (!getNextPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.ListTopicSubscriptionsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.ListTopicSubscriptionsResponse} + * + *
      +   * Response for the ListTopicSubscriptions method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListTopicSubscriptionsResponse) + com.google.pubsub.v1.ListTopicSubscriptionsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListTopicSubscriptionsResponse.class, com.google.pubsub.v1.ListTopicSubscriptionsResponse.Builder.class); + } + + // Construct using com.google.pubsub.v1.ListTopicSubscriptionsResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + subscriptions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + nextPageToken_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor; + } + + public com.google.pubsub.v1.ListTopicSubscriptionsResponse getDefaultInstanceForType() { + return com.google.pubsub.v1.ListTopicSubscriptionsResponse.getDefaultInstance(); + } + + public com.google.pubsub.v1.ListTopicSubscriptionsResponse build() { + com.google.pubsub.v1.ListTopicSubscriptionsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.ListTopicSubscriptionsResponse buildPartial() { + com.google.pubsub.v1.ListTopicSubscriptionsResponse result = new com.google.pubsub.v1.ListTopicSubscriptionsResponse(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subscriptions_ = subscriptions_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.subscriptions_ = subscriptions_; + result.nextPageToken_ = nextPageToken_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.ListTopicSubscriptionsResponse) { + return mergeFrom((com.google.pubsub.v1.ListTopicSubscriptionsResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.ListTopicSubscriptionsResponse other) { + if (other == com.google.pubsub.v1.ListTopicSubscriptionsResponse.getDefaultInstance()) return this; + if (!other.subscriptions_.isEmpty()) { + if (subscriptions_.isEmpty()) { + subscriptions_ = other.subscriptions_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureSubscriptionsIsMutable(); + subscriptions_.addAll(other.subscriptions_); + } + onChanged(); + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.ListTopicSubscriptionsResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.ListTopicSubscriptionsResponse) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.LazyStringList subscriptions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureSubscriptionsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + subscriptions_ = new com.google.protobuf.LazyStringArrayList(subscriptions_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated string subscriptions = 1; + * + *
      +     * The names of the subscriptions that match the request.
      +     * 
      + */ + public com.google.protobuf.ProtocolStringList + getSubscriptionsList() { + return subscriptions_.getUnmodifiableView(); + } + /** + * repeated string subscriptions = 1; + * + *
      +     * The names of the subscriptions that match the request.
      +     * 
      + */ + public int getSubscriptionsCount() { + return subscriptions_.size(); + } + /** + * repeated string subscriptions = 1; + * + *
      +     * The names of the subscriptions that match the request.
      +     * 
      + */ + public java.lang.String getSubscriptions(int index) { + return subscriptions_.get(index); + } + /** + * repeated string subscriptions = 1; + * + *
      +     * The names of the subscriptions that match the request.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionsBytes(int index) { + return subscriptions_.getByteString(index); + } + /** + * repeated string subscriptions = 1; + * + *
      +     * The names of the subscriptions that match the request.
      +     * 
      + */ + public Builder setSubscriptions( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionsIsMutable(); + subscriptions_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string subscriptions = 1; + * + *
      +     * The names of the subscriptions that match the request.
      +     * 
      + */ + public Builder addSubscriptions( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureSubscriptionsIsMutable(); + subscriptions_.add(value); + onChanged(); + return this; + } + /** + * repeated string subscriptions = 1; + * + *
      +     * The names of the subscriptions that match the request.
      +     * 
      + */ + public Builder addAllSubscriptions( + java.lang.Iterable values) { + ensureSubscriptionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, subscriptions_); + onChanged(); + return this; + } + /** + * repeated string subscriptions = 1; + * + *
      +     * The names of the subscriptions that match the request.
      +     * 
      + */ + public Builder clearSubscriptions() { + subscriptions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * repeated string subscriptions = 1; + * + *
      +     * The names of the subscriptions that match the request.
      +     * 
      + */ + public Builder addSubscriptionsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureSubscriptionsIsMutable(); + subscriptions_.add(value); + onChanged(); + return this; + } + + private java.lang.Object nextPageToken_ = ""; + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more subscriptions that match
      +     * the request; this value should be passed in a new
      +     * ListTopicSubscriptionsRequest to get more subscriptions.
      +     * 
      + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more subscriptions that match
      +     * the request; this value should be passed in a new
      +     * ListTopicSubscriptionsRequest to get more subscriptions.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more subscriptions that match
      +     * the request; this value should be passed in a new
      +     * ListTopicSubscriptionsRequest to get more subscriptions.
      +     * 
      + */ + public Builder setNextPageToken( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + nextPageToken_ = value; + onChanged(); + return this; + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more subscriptions that match
      +     * the request; this value should be passed in a new
      +     * ListTopicSubscriptionsRequest to get more subscriptions.
      +     * 
      + */ + public Builder clearNextPageToken() { + + nextPageToken_ = getDefaultInstance().getNextPageToken(); + onChanged(); + return this; + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more subscriptions that match
      +     * the request; this value should be passed in a new
      +     * ListTopicSubscriptionsRequest to get more subscriptions.
      +     * 
      + */ + public Builder setNextPageTokenBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + nextPageToken_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListTopicSubscriptionsResponse) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListTopicSubscriptionsResponse) + private static final com.google.pubsub.v1.ListTopicSubscriptionsResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.ListTopicSubscriptionsResponse(); + } + + public static com.google.pubsub.v1.ListTopicSubscriptionsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ListTopicSubscriptionsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ListTopicSubscriptionsResponse(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.ListTopicSubscriptionsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponseOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponseOrBuilder.java new file mode 100644 index 000000000000..7cfc77118c55 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponseOrBuilder.java @@ -0,0 +1,66 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface ListTopicSubscriptionsResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListTopicSubscriptionsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated string subscriptions = 1; + * + *
      +   * The names of the subscriptions that match the request.
      +   * 
      + */ + com.google.protobuf.ProtocolStringList + getSubscriptionsList(); + /** + * repeated string subscriptions = 1; + * + *
      +   * The names of the subscriptions that match the request.
      +   * 
      + */ + int getSubscriptionsCount(); + /** + * repeated string subscriptions = 1; + * + *
      +   * The names of the subscriptions that match the request.
      +   * 
      + */ + java.lang.String getSubscriptions(int index); + /** + * repeated string subscriptions = 1; + * + *
      +   * The names of the subscriptions that match the request.
      +   * 
      + */ + com.google.protobuf.ByteString + getSubscriptionsBytes(int index); + + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more subscriptions that match
      +   * the request; this value should be passed in a new
      +   * ListTopicSubscriptionsRequest to get more subscriptions.
      +   * 
      + */ + java.lang.String getNextPageToken(); + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more subscriptions that match
      +   * the request; this value should be passed in a new
      +   * ListTopicSubscriptionsRequest to get more subscriptions.
      +   * 
      + */ + com.google.protobuf.ByteString + getNextPageTokenBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequest.java new file mode 100644 index 000000000000..3657dfe92162 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequest.java @@ -0,0 +1,711 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.ListTopicsRequest} + * + *
      + * Request for the ListTopics method.
      + * 
      + */ +public final class ListTopicsRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListTopicsRequest) + ListTopicsRequestOrBuilder { + // Use ListTopicsRequest.newBuilder() to construct. + private ListTopicsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ListTopicsRequest() { + project_ = ""; + pageSize_ = 0; + pageToken_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ListTopicsRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + project_ = s; + break; + } + case 16: { + + pageSize_ = input.readInt32(); + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + pageToken_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListTopicsRequest.class, com.google.pubsub.v1.ListTopicsRequest.Builder.class); + } + + public static final int PROJECT_FIELD_NUMBER = 1; + private volatile java.lang.Object project_; + /** + * optional string project = 1; + * + *
      +   * The name of the cloud project that topics belong to.
      +   * 
      + */ + public java.lang.String getProject() { + java.lang.Object ref = project_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + project_ = s; + return s; + } + } + /** + * optional string project = 1; + * + *
      +   * The name of the cloud project that topics belong to.
      +   * 
      + */ + public com.google.protobuf.ByteString + getProjectBytes() { + java.lang.Object ref = project_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + project_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 2; + private int pageSize_; + /** + * optional int32 page_size = 2; + * + *
      +   * Maximum number of topics to return.
      +   * 
      + */ + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 3; + private volatile java.lang.Object pageToken_; + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListTopicsResponse; indicates that this is
      +   * a continuation of a prior ListTopics call, and that the system should
      +   * return the next page of data.
      +   * 
      + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } + } + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListTopicsResponse; indicates that this is
      +   * a continuation of a prior ListTopics call, and that the system should
      +   * return the next page of data.
      +   * 
      + */ + public com.google.protobuf.ByteString + getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getProjectBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, project_); + } + if (pageSize_ != 0) { + output.writeInt32(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, pageToken_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getProjectBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, project_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pageToken_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.ListTopicsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListTopicsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListTopicsRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicsRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListTopicsRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicsRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.ListTopicsRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicsRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListTopicsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.ListTopicsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.ListTopicsRequest} + * + *
      +   * Request for the ListTopics method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListTopicsRequest) + com.google.pubsub.v1.ListTopicsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListTopicsRequest.class, com.google.pubsub.v1.ListTopicsRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.ListTopicsRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + project_ = ""; + + pageSize_ = 0; + + pageToken_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsRequest_descriptor; + } + + public com.google.pubsub.v1.ListTopicsRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.ListTopicsRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.ListTopicsRequest build() { + com.google.pubsub.v1.ListTopicsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.ListTopicsRequest buildPartial() { + com.google.pubsub.v1.ListTopicsRequest result = new com.google.pubsub.v1.ListTopicsRequest(this); + result.project_ = project_; + result.pageSize_ = pageSize_; + result.pageToken_ = pageToken_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.ListTopicsRequest) { + return mergeFrom((com.google.pubsub.v1.ListTopicsRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.ListTopicsRequest other) { + if (other == com.google.pubsub.v1.ListTopicsRequest.getDefaultInstance()) return this; + if (!other.getProject().isEmpty()) { + project_ = other.project_; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.ListTopicsRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.ListTopicsRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object project_ = ""; + /** + * optional string project = 1; + * + *
      +     * The name of the cloud project that topics belong to.
      +     * 
      + */ + public java.lang.String getProject() { + java.lang.Object ref = project_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + project_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string project = 1; + * + *
      +     * The name of the cloud project that topics belong to.
      +     * 
      + */ + public com.google.protobuf.ByteString + getProjectBytes() { + java.lang.Object ref = project_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + project_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string project = 1; + * + *
      +     * The name of the cloud project that topics belong to.
      +     * 
      + */ + public Builder setProject( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + project_ = value; + onChanged(); + return this; + } + /** + * optional string project = 1; + * + *
      +     * The name of the cloud project that topics belong to.
      +     * 
      + */ + public Builder clearProject() { + + project_ = getDefaultInstance().getProject(); + onChanged(); + return this; + } + /** + * optional string project = 1; + * + *
      +     * The name of the cloud project that topics belong to.
      +     * 
      + */ + public Builder setProjectBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + project_ = value; + onChanged(); + return this; + } + + private int pageSize_ ; + /** + * optional int32 page_size = 2; + * + *
      +     * Maximum number of topics to return.
      +     * 
      + */ + public int getPageSize() { + return pageSize_; + } + /** + * optional int32 page_size = 2; + * + *
      +     * Maximum number of topics to return.
      +     * 
      + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + onChanged(); + return this; + } + /** + * optional int32 page_size = 2; + * + *
      +     * Maximum number of topics to return.
      +     * 
      + */ + public Builder clearPageSize() { + + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListTopicsResponse; indicates that this is
      +     * a continuation of a prior ListTopics call, and that the system should
      +     * return the next page of data.
      +     * 
      + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListTopicsResponse; indicates that this is
      +     * a continuation of a prior ListTopics call, and that the system should
      +     * return the next page of data.
      +     * 
      + */ + public com.google.protobuf.ByteString + getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListTopicsResponse; indicates that this is
      +     * a continuation of a prior ListTopics call, and that the system should
      +     * return the next page of data.
      +     * 
      + */ + public Builder setPageToken( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + pageToken_ = value; + onChanged(); + return this; + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListTopicsResponse; indicates that this is
      +     * a continuation of a prior ListTopics call, and that the system should
      +     * return the next page of data.
      +     * 
      + */ + public Builder clearPageToken() { + + pageToken_ = getDefaultInstance().getPageToken(); + onChanged(); + return this; + } + /** + * optional string page_token = 3; + * + *
      +     * The value returned by the last ListTopicsResponse; indicates that this is
      +     * a continuation of a prior ListTopics call, and that the system should
      +     * return the next page of data.
      +     * 
      + */ + public Builder setPageTokenBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + pageToken_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListTopicsRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListTopicsRequest) + private static final com.google.pubsub.v1.ListTopicsRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.ListTopicsRequest(); + } + + public static com.google.pubsub.v1.ListTopicsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ListTopicsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ListTopicsRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.ListTopicsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequestOrBuilder.java new file mode 100644 index 000000000000..2b8d27032226 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequestOrBuilder.java @@ -0,0 +1,58 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface ListTopicsRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListTopicsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string project = 1; + * + *
      +   * The name of the cloud project that topics belong to.
      +   * 
      + */ + java.lang.String getProject(); + /** + * optional string project = 1; + * + *
      +   * The name of the cloud project that topics belong to.
      +   * 
      + */ + com.google.protobuf.ByteString + getProjectBytes(); + + /** + * optional int32 page_size = 2; + * + *
      +   * Maximum number of topics to return.
      +   * 
      + */ + int getPageSize(); + + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListTopicsResponse; indicates that this is
      +   * a continuation of a prior ListTopics call, and that the system should
      +   * return the next page of data.
      +   * 
      + */ + java.lang.String getPageToken(); + /** + * optional string page_token = 3; + * + *
      +   * The value returned by the last ListTopicsResponse; indicates that this is
      +   * a continuation of a prior ListTopics call, and that the system should
      +   * return the next page of data.
      +   * 
      + */ + com.google.protobuf.ByteString + getPageTokenBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponse.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponse.java new file mode 100644 index 000000000000..80928fca5160 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponse.java @@ -0,0 +1,916 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.ListTopicsResponse} + * + *
      + * Response for the ListTopics method.
      + * 
      + */ +public final class ListTopicsResponse extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListTopicsResponse) + ListTopicsResponseOrBuilder { + // Use ListTopicsResponse.newBuilder() to construct. + private ListTopicsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ListTopicsResponse() { + topics_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ListTopicsResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + topics_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + topics_.add(input.readMessage(com.google.pubsub.v1.Topic.parser(), extensionRegistry)); + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + nextPageToken_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + topics_ = java.util.Collections.unmodifiableList(topics_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListTopicsResponse.class, com.google.pubsub.v1.ListTopicsResponse.Builder.class); + } + + private int bitField0_; + public static final int TOPICS_FIELD_NUMBER = 1; + private java.util.List topics_; + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +   * The resulting topics.
      +   * 
      + */ + public java.util.List getTopicsList() { + return topics_; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +   * The resulting topics.
      +   * 
      + */ + public java.util.List + getTopicsOrBuilderList() { + return topics_; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +   * The resulting topics.
      +   * 
      + */ + public int getTopicsCount() { + return topics_.size(); + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +   * The resulting topics.
      +   * 
      + */ + public com.google.pubsub.v1.Topic getTopics(int index) { + return topics_.get(index); + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +   * The resulting topics.
      +   * 
      + */ + public com.google.pubsub.v1.TopicOrBuilder getTopicsOrBuilder( + int index) { + return topics_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + private volatile java.lang.Object nextPageToken_; + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more topics that match the
      +   * request; this value should be passed in a new ListTopicsRequest.
      +   * 
      + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } + } + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more topics that match the
      +   * request; this value should be passed in a new ListTopicsRequest.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < topics_.size(); i++) { + output.writeMessage(1, topics_.get(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < topics_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, topics_.get(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.ListTopicsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListTopicsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ListTopicsResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicsResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListTopicsResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicsResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.ListTopicsResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ListTopicsResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ListTopicsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.ListTopicsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.ListTopicsResponse} + * + *
      +   * Response for the ListTopics method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListTopicsResponse) + com.google.pubsub.v1.ListTopicsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ListTopicsResponse.class, com.google.pubsub.v1.ListTopicsResponse.Builder.class); + } + + // Construct using com.google.pubsub.v1.ListTopicsResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getTopicsFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (topicsBuilder_ == null) { + topics_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + topicsBuilder_.clear(); + } + nextPageToken_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsResponse_descriptor; + } + + public com.google.pubsub.v1.ListTopicsResponse getDefaultInstanceForType() { + return com.google.pubsub.v1.ListTopicsResponse.getDefaultInstance(); + } + + public com.google.pubsub.v1.ListTopicsResponse build() { + com.google.pubsub.v1.ListTopicsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.ListTopicsResponse buildPartial() { + com.google.pubsub.v1.ListTopicsResponse result = new com.google.pubsub.v1.ListTopicsResponse(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (topicsBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + topics_ = java.util.Collections.unmodifiableList(topics_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.topics_ = topics_; + } else { + result.topics_ = topicsBuilder_.build(); + } + result.nextPageToken_ = nextPageToken_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.ListTopicsResponse) { + return mergeFrom((com.google.pubsub.v1.ListTopicsResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.ListTopicsResponse other) { + if (other == com.google.pubsub.v1.ListTopicsResponse.getDefaultInstance()) return this; + if (topicsBuilder_ == null) { + if (!other.topics_.isEmpty()) { + if (topics_.isEmpty()) { + topics_ = other.topics_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTopicsIsMutable(); + topics_.addAll(other.topics_); + } + onChanged(); + } + } else { + if (!other.topics_.isEmpty()) { + if (topicsBuilder_.isEmpty()) { + topicsBuilder_.dispose(); + topicsBuilder_ = null; + topics_ = other.topics_; + bitField0_ = (bitField0_ & ~0x00000001); + topicsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getTopicsFieldBuilder() : null; + } else { + topicsBuilder_.addAllMessages(other.topics_); + } + } + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.ListTopicsResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.ListTopicsResponse) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List topics_ = + java.util.Collections.emptyList(); + private void ensureTopicsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + topics_ = new java.util.ArrayList(topics_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.Topic, com.google.pubsub.v1.Topic.Builder, com.google.pubsub.v1.TopicOrBuilder> topicsBuilder_; + + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public java.util.List getTopicsList() { + if (topicsBuilder_ == null) { + return java.util.Collections.unmodifiableList(topics_); + } else { + return topicsBuilder_.getMessageList(); + } + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public int getTopicsCount() { + if (topicsBuilder_ == null) { + return topics_.size(); + } else { + return topicsBuilder_.getCount(); + } + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public com.google.pubsub.v1.Topic getTopics(int index) { + if (topicsBuilder_ == null) { + return topics_.get(index); + } else { + return topicsBuilder_.getMessage(index); + } + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public Builder setTopics( + int index, com.google.pubsub.v1.Topic value) { + if (topicsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTopicsIsMutable(); + topics_.set(index, value); + onChanged(); + } else { + topicsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public Builder setTopics( + int index, com.google.pubsub.v1.Topic.Builder builderForValue) { + if (topicsBuilder_ == null) { + ensureTopicsIsMutable(); + topics_.set(index, builderForValue.build()); + onChanged(); + } else { + topicsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public Builder addTopics(com.google.pubsub.v1.Topic value) { + if (topicsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTopicsIsMutable(); + topics_.add(value); + onChanged(); + } else { + topicsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public Builder addTopics( + int index, com.google.pubsub.v1.Topic value) { + if (topicsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTopicsIsMutable(); + topics_.add(index, value); + onChanged(); + } else { + topicsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public Builder addTopics( + com.google.pubsub.v1.Topic.Builder builderForValue) { + if (topicsBuilder_ == null) { + ensureTopicsIsMutable(); + topics_.add(builderForValue.build()); + onChanged(); + } else { + topicsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public Builder addTopics( + int index, com.google.pubsub.v1.Topic.Builder builderForValue) { + if (topicsBuilder_ == null) { + ensureTopicsIsMutable(); + topics_.add(index, builderForValue.build()); + onChanged(); + } else { + topicsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public Builder addAllTopics( + java.lang.Iterable values) { + if (topicsBuilder_ == null) { + ensureTopicsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, topics_); + onChanged(); + } else { + topicsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public Builder clearTopics() { + if (topicsBuilder_ == null) { + topics_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + topicsBuilder_.clear(); + } + return this; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public Builder removeTopics(int index) { + if (topicsBuilder_ == null) { + ensureTopicsIsMutable(); + topics_.remove(index); + onChanged(); + } else { + topicsBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public com.google.pubsub.v1.Topic.Builder getTopicsBuilder( + int index) { + return getTopicsFieldBuilder().getBuilder(index); + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public com.google.pubsub.v1.TopicOrBuilder getTopicsOrBuilder( + int index) { + if (topicsBuilder_ == null) { + return topics_.get(index); } else { + return topicsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public java.util.List + getTopicsOrBuilderList() { + if (topicsBuilder_ != null) { + return topicsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(topics_); + } + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public com.google.pubsub.v1.Topic.Builder addTopicsBuilder() { + return getTopicsFieldBuilder().addBuilder( + com.google.pubsub.v1.Topic.getDefaultInstance()); + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public com.google.pubsub.v1.Topic.Builder addTopicsBuilder( + int index) { + return getTopicsFieldBuilder().addBuilder( + index, com.google.pubsub.v1.Topic.getDefaultInstance()); + } + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +     * The resulting topics.
      +     * 
      + */ + public java.util.List + getTopicsBuilderList() { + return getTopicsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.Topic, com.google.pubsub.v1.Topic.Builder, com.google.pubsub.v1.TopicOrBuilder> + getTopicsFieldBuilder() { + if (topicsBuilder_ == null) { + topicsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.Topic, com.google.pubsub.v1.Topic.Builder, com.google.pubsub.v1.TopicOrBuilder>( + topics_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + topics_ = null; + } + return topicsBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more topics that match the
      +     * request; this value should be passed in a new ListTopicsRequest.
      +     * 
      + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more topics that match the
      +     * request; this value should be passed in a new ListTopicsRequest.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more topics that match the
      +     * request; this value should be passed in a new ListTopicsRequest.
      +     * 
      + */ + public Builder setNextPageToken( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + nextPageToken_ = value; + onChanged(); + return this; + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more topics that match the
      +     * request; this value should be passed in a new ListTopicsRequest.
      +     * 
      + */ + public Builder clearNextPageToken() { + + nextPageToken_ = getDefaultInstance().getNextPageToken(); + onChanged(); + return this; + } + /** + * optional string next_page_token = 2; + * + *
      +     * If not empty, indicates that there may be more topics that match the
      +     * request; this value should be passed in a new ListTopicsRequest.
      +     * 
      + */ + public Builder setNextPageTokenBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + nextPageToken_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListTopicsResponse) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListTopicsResponse) + private static final com.google.pubsub.v1.ListTopicsResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.ListTopicsResponse(); + } + + public static com.google.pubsub.v1.ListTopicsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ListTopicsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ListTopicsResponse(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.ListTopicsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponseOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponseOrBuilder.java new file mode 100644 index 000000000000..60d5d7ac17da --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponseOrBuilder.java @@ -0,0 +1,73 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface ListTopicsResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListTopicsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +   * The resulting topics.
      +   * 
      + */ + java.util.List + getTopicsList(); + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +   * The resulting topics.
      +   * 
      + */ + com.google.pubsub.v1.Topic getTopics(int index); + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +   * The resulting topics.
      +   * 
      + */ + int getTopicsCount(); + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +   * The resulting topics.
      +   * 
      + */ + java.util.List + getTopicsOrBuilderList(); + /** + * repeated .google.pubsub.v1.Topic topics = 1; + * + *
      +   * The resulting topics.
      +   * 
      + */ + com.google.pubsub.v1.TopicOrBuilder getTopicsOrBuilder( + int index); + + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more topics that match the
      +   * request; this value should be passed in a new ListTopicsRequest.
      +   * 
      + */ + java.lang.String getNextPageToken(); + /** + * optional string next_page_token = 2; + * + *
      +   * If not empty, indicates that there may be more topics that match the
      +   * request; this value should be passed in a new ListTopicsRequest.
      +   * 
      + */ + com.google.protobuf.ByteString + getNextPageTokenBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequest.java new file mode 100644 index 000000000000..aa51afc2f99e --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequest.java @@ -0,0 +1,783 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.ModifyAckDeadlineRequest} + * + *
      + * Request for the ModifyAckDeadline method.
      + * 
      + */ +public final class ModifyAckDeadlineRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.ModifyAckDeadlineRequest) + ModifyAckDeadlineRequestOrBuilder { + // Use ModifyAckDeadlineRequest.newBuilder() to construct. + private ModifyAckDeadlineRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ModifyAckDeadlineRequest() { + subscription_ = ""; + ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + ackDeadlineSeconds_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ModifyAckDeadlineRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + subscription_ = s; + break; + } + case 24: { + + ackDeadlineSeconds_ = input.readInt32(); + break; + } + case 34: { + String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + ackIds_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + ackIds_.add(s); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + ackIds_ = ackIds_.getUnmodifiableView(); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ModifyAckDeadlineRequest.class, com.google.pubsub.v1.ModifyAckDeadlineRequest.Builder.class); + } + + private int bitField0_; + public static final int SUBSCRIPTION_FIELD_NUMBER = 1; + private volatile java.lang.Object subscription_; + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription.
      +   * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } + } + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ACK_IDS_FIELD_NUMBER = 4; + private com.google.protobuf.LazyStringList ackIds_; + /** + * repeated string ack_ids = 4; + * + *
      +   * List of acknowledgment IDs.
      +   * 
      + */ + public com.google.protobuf.ProtocolStringList + getAckIdsList() { + return ackIds_; + } + /** + * repeated string ack_ids = 4; + * + *
      +   * List of acknowledgment IDs.
      +   * 
      + */ + public int getAckIdsCount() { + return ackIds_.size(); + } + /** + * repeated string ack_ids = 4; + * + *
      +   * List of acknowledgment IDs.
      +   * 
      + */ + public java.lang.String getAckIds(int index) { + return ackIds_.get(index); + } + /** + * repeated string ack_ids = 4; + * + *
      +   * List of acknowledgment IDs.
      +   * 
      + */ + public com.google.protobuf.ByteString + getAckIdsBytes(int index) { + return ackIds_.getByteString(index); + } + + public static final int ACK_DEADLINE_SECONDS_FIELD_NUMBER = 3; + private int ackDeadlineSeconds_; + /** + * optional int32 ack_deadline_seconds = 3; + * + *
      +   * The new ack deadline with respect to the time this request was sent to the
      +   * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
      +   * deadline will expire 10 seconds after the ModifyAckDeadline call was made.
      +   * Specifying zero may immediately make the message available for another pull
      +   * request.
      +   * 
      + */ + public int getAckDeadlineSeconds() { + return ackDeadlineSeconds_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSubscriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); + } + if (ackDeadlineSeconds_ != 0) { + output.writeInt32(3, ackDeadlineSeconds_); + } + for (int i = 0; i < ackIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, ackIds_.getRaw(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSubscriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); + } + if (ackDeadlineSeconds_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, ackDeadlineSeconds_); + } + { + int dataSize = 0; + for (int i = 0; i < ackIds_.size(); i++) { + dataSize += computeStringSizeNoTag(ackIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getAckIdsList().size(); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.ModifyAckDeadlineRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.ModifyAckDeadlineRequest} + * + *
      +   * Request for the ModifyAckDeadline method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ModifyAckDeadlineRequest) + com.google.pubsub.v1.ModifyAckDeadlineRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ModifyAckDeadlineRequest.class, com.google.pubsub.v1.ModifyAckDeadlineRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.ModifyAckDeadlineRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + subscription_ = ""; + + ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + ackDeadlineSeconds_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor; + } + + public com.google.pubsub.v1.ModifyAckDeadlineRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.ModifyAckDeadlineRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.ModifyAckDeadlineRequest build() { + com.google.pubsub.v1.ModifyAckDeadlineRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.ModifyAckDeadlineRequest buildPartial() { + com.google.pubsub.v1.ModifyAckDeadlineRequest result = new com.google.pubsub.v1.ModifyAckDeadlineRequest(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.subscription_ = subscription_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + ackIds_ = ackIds_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.ackIds_ = ackIds_; + result.ackDeadlineSeconds_ = ackDeadlineSeconds_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.ModifyAckDeadlineRequest) { + return mergeFrom((com.google.pubsub.v1.ModifyAckDeadlineRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.ModifyAckDeadlineRequest other) { + if (other == com.google.pubsub.v1.ModifyAckDeadlineRequest.getDefaultInstance()) return this; + if (!other.getSubscription().isEmpty()) { + subscription_ = other.subscription_; + onChanged(); + } + if (!other.ackIds_.isEmpty()) { + if (ackIds_.isEmpty()) { + ackIds_ = other.ackIds_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureAckIdsIsMutable(); + ackIds_.addAll(other.ackIds_); + } + onChanged(); + } + if (other.getAckDeadlineSeconds() != 0) { + setAckDeadlineSeconds(other.getAckDeadlineSeconds()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.ModifyAckDeadlineRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.ModifyAckDeadlineRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object subscription_ = ""; + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription.
      +     * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription.
      +     * 
      + */ + public Builder setSubscription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + subscription_ = value; + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription.
      +     * 
      + */ + public Builder clearSubscription() { + + subscription_ = getDefaultInstance().getSubscription(); + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription.
      +     * 
      + */ + public Builder setSubscriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + subscription_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureAckIdsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + ackIds_ = new com.google.protobuf.LazyStringArrayList(ackIds_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated string ack_ids = 4; + * + *
      +     * List of acknowledgment IDs.
      +     * 
      + */ + public com.google.protobuf.ProtocolStringList + getAckIdsList() { + return ackIds_.getUnmodifiableView(); + } + /** + * repeated string ack_ids = 4; + * + *
      +     * List of acknowledgment IDs.
      +     * 
      + */ + public int getAckIdsCount() { + return ackIds_.size(); + } + /** + * repeated string ack_ids = 4; + * + *
      +     * List of acknowledgment IDs.
      +     * 
      + */ + public java.lang.String getAckIds(int index) { + return ackIds_.get(index); + } + /** + * repeated string ack_ids = 4; + * + *
      +     * List of acknowledgment IDs.
      +     * 
      + */ + public com.google.protobuf.ByteString + getAckIdsBytes(int index) { + return ackIds_.getByteString(index); + } + /** + * repeated string ack_ids = 4; + * + *
      +     * List of acknowledgment IDs.
      +     * 
      + */ + public Builder setAckIds( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAckIdsIsMutable(); + ackIds_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string ack_ids = 4; + * + *
      +     * List of acknowledgment IDs.
      +     * 
      + */ + public Builder addAckIds( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAckIdsIsMutable(); + ackIds_.add(value); + onChanged(); + return this; + } + /** + * repeated string ack_ids = 4; + * + *
      +     * List of acknowledgment IDs.
      +     * 
      + */ + public Builder addAllAckIds( + java.lang.Iterable values) { + ensureAckIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, ackIds_); + onChanged(); + return this; + } + /** + * repeated string ack_ids = 4; + * + *
      +     * List of acknowledgment IDs.
      +     * 
      + */ + public Builder clearAckIds() { + ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * repeated string ack_ids = 4; + * + *
      +     * List of acknowledgment IDs.
      +     * 
      + */ + public Builder addAckIdsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureAckIdsIsMutable(); + ackIds_.add(value); + onChanged(); + return this; + } + + private int ackDeadlineSeconds_ ; + /** + * optional int32 ack_deadline_seconds = 3; + * + *
      +     * The new ack deadline with respect to the time this request was sent to the
      +     * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
      +     * deadline will expire 10 seconds after the ModifyAckDeadline call was made.
      +     * Specifying zero may immediately make the message available for another pull
      +     * request.
      +     * 
      + */ + public int getAckDeadlineSeconds() { + return ackDeadlineSeconds_; + } + /** + * optional int32 ack_deadline_seconds = 3; + * + *
      +     * The new ack deadline with respect to the time this request was sent to the
      +     * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
      +     * deadline will expire 10 seconds after the ModifyAckDeadline call was made.
      +     * Specifying zero may immediately make the message available for another pull
      +     * request.
      +     * 
      + */ + public Builder setAckDeadlineSeconds(int value) { + + ackDeadlineSeconds_ = value; + onChanged(); + return this; + } + /** + * optional int32 ack_deadline_seconds = 3; + * + *
      +     * The new ack deadline with respect to the time this request was sent to the
      +     * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
      +     * deadline will expire 10 seconds after the ModifyAckDeadline call was made.
      +     * Specifying zero may immediately make the message available for another pull
      +     * request.
      +     * 
      + */ + public Builder clearAckDeadlineSeconds() { + + ackDeadlineSeconds_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ModifyAckDeadlineRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.ModifyAckDeadlineRequest) + private static final com.google.pubsub.v1.ModifyAckDeadlineRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.ModifyAckDeadlineRequest(); + } + + public static com.google.pubsub.v1.ModifyAckDeadlineRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ModifyAckDeadlineRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ModifyAckDeadlineRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.ModifyAckDeadlineRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequestOrBuilder.java new file mode 100644 index 000000000000..1e375b70cc30 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequestOrBuilder.java @@ -0,0 +1,75 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface ModifyAckDeadlineRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ModifyAckDeadlineRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription.
      +   * 
      + */ + java.lang.String getSubscription(); + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription.
      +   * 
      + */ + com.google.protobuf.ByteString + getSubscriptionBytes(); + + /** + * repeated string ack_ids = 4; + * + *
      +   * List of acknowledgment IDs.
      +   * 
      + */ + com.google.protobuf.ProtocolStringList + getAckIdsList(); + /** + * repeated string ack_ids = 4; + * + *
      +   * List of acknowledgment IDs.
      +   * 
      + */ + int getAckIdsCount(); + /** + * repeated string ack_ids = 4; + * + *
      +   * List of acknowledgment IDs.
      +   * 
      + */ + java.lang.String getAckIds(int index); + /** + * repeated string ack_ids = 4; + * + *
      +   * List of acknowledgment IDs.
      +   * 
      + */ + com.google.protobuf.ByteString + getAckIdsBytes(int index); + + /** + * optional int32 ack_deadline_seconds = 3; + * + *
      +   * The new ack deadline with respect to the time this request was sent to the
      +   * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
      +   * deadline will expire 10 seconds after the ModifyAckDeadline call was made.
      +   * Specifying zero may immediately make the message available for another pull
      +   * request.
      +   * 
      + */ + int getAckDeadlineSeconds(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequest.java new file mode 100644 index 000000000000..d3706a1c87c4 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequest.java @@ -0,0 +1,744 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.ModifyPushConfigRequest} + * + *
      + * Request for the ModifyPushConfig method.
      + * 
      + */ +public final class ModifyPushConfigRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.ModifyPushConfigRequest) + ModifyPushConfigRequestOrBuilder { + // Use ModifyPushConfigRequest.newBuilder() to construct. + private ModifyPushConfigRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ModifyPushConfigRequest() { + subscription_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ModifyPushConfigRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + subscription_ = s; + break; + } + case 18: { + com.google.pubsub.v1.PushConfig.Builder subBuilder = null; + if (pushConfig_ != null) { + subBuilder = pushConfig_.toBuilder(); + } + pushConfig_ = input.readMessage(com.google.pubsub.v1.PushConfig.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(pushConfig_); + pushConfig_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyPushConfigRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ModifyPushConfigRequest.class, com.google.pubsub.v1.ModifyPushConfigRequest.Builder.class); + } + + public static final int SUBSCRIPTION_FIELD_NUMBER = 1; + private volatile java.lang.Object subscription_; + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription.
      +   * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } + } + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PUSH_CONFIG_FIELD_NUMBER = 2; + private com.google.pubsub.v1.PushConfig pushConfig_; + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +   * The push configuration for future deliveries.
      +   * An empty pushConfig indicates that the Pub/Sub system should
      +   * stop pushing messages from the given subscription and allow
      +   * messages to be pulled and acknowledged - effectively pausing
      +   * the subscription if Pull is not called.
      +   * 
      + */ + public boolean hasPushConfig() { + return pushConfig_ != null; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +   * The push configuration for future deliveries.
      +   * An empty pushConfig indicates that the Pub/Sub system should
      +   * stop pushing messages from the given subscription and allow
      +   * messages to be pulled and acknowledged - effectively pausing
      +   * the subscription if Pull is not called.
      +   * 
      + */ + public com.google.pubsub.v1.PushConfig getPushConfig() { + return pushConfig_ == null ? com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +   * The push configuration for future deliveries.
      +   * An empty pushConfig indicates that the Pub/Sub system should
      +   * stop pushing messages from the given subscription and allow
      +   * messages to be pulled and acknowledged - effectively pausing
      +   * the subscription if Pull is not called.
      +   * 
      + */ + public com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder() { + return getPushConfig(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSubscriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); + } + if (pushConfig_ != null) { + output.writeMessage(2, getPushConfig()); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSubscriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); + } + if (pushConfig_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getPushConfig()); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ModifyPushConfigRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.ModifyPushConfigRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.ModifyPushConfigRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.ModifyPushConfigRequest} + * + *
      +   * Request for the ModifyPushConfig method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ModifyPushConfigRequest) + com.google.pubsub.v1.ModifyPushConfigRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyPushConfigRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ModifyPushConfigRequest.class, com.google.pubsub.v1.ModifyPushConfigRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.ModifyPushConfigRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + subscription_ = ""; + + if (pushConfigBuilder_ == null) { + pushConfig_ = null; + } else { + pushConfig_ = null; + pushConfigBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor; + } + + public com.google.pubsub.v1.ModifyPushConfigRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.ModifyPushConfigRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.ModifyPushConfigRequest build() { + com.google.pubsub.v1.ModifyPushConfigRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.ModifyPushConfigRequest buildPartial() { + com.google.pubsub.v1.ModifyPushConfigRequest result = new com.google.pubsub.v1.ModifyPushConfigRequest(this); + result.subscription_ = subscription_; + if (pushConfigBuilder_ == null) { + result.pushConfig_ = pushConfig_; + } else { + result.pushConfig_ = pushConfigBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.ModifyPushConfigRequest) { + return mergeFrom((com.google.pubsub.v1.ModifyPushConfigRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.ModifyPushConfigRequest other) { + if (other == com.google.pubsub.v1.ModifyPushConfigRequest.getDefaultInstance()) return this; + if (!other.getSubscription().isEmpty()) { + subscription_ = other.subscription_; + onChanged(); + } + if (other.hasPushConfig()) { + mergePushConfig(other.getPushConfig()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.ModifyPushConfigRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.ModifyPushConfigRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object subscription_ = ""; + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription.
      +     * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription.
      +     * 
      + */ + public Builder setSubscription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + subscription_ = value; + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription.
      +     * 
      + */ + public Builder clearSubscription() { + + subscription_ = getDefaultInstance().getSubscription(); + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The name of the subscription.
      +     * 
      + */ + public Builder setSubscriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + subscription_ = value; + onChanged(); + return this; + } + + private com.google.pubsub.v1.PushConfig pushConfig_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder> pushConfigBuilder_; + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +     * The push configuration for future deliveries.
      +     * An empty pushConfig indicates that the Pub/Sub system should
      +     * stop pushing messages from the given subscription and allow
      +     * messages to be pulled and acknowledged - effectively pausing
      +     * the subscription if Pull is not called.
      +     * 
      + */ + public boolean hasPushConfig() { + return pushConfigBuilder_ != null || pushConfig_ != null; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +     * The push configuration for future deliveries.
      +     * An empty pushConfig indicates that the Pub/Sub system should
      +     * stop pushing messages from the given subscription and allow
      +     * messages to be pulled and acknowledged - effectively pausing
      +     * the subscription if Pull is not called.
      +     * 
      + */ + public com.google.pubsub.v1.PushConfig getPushConfig() { + if (pushConfigBuilder_ == null) { + return pushConfig_ == null ? com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; + } else { + return pushConfigBuilder_.getMessage(); + } + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +     * The push configuration for future deliveries.
      +     * An empty pushConfig indicates that the Pub/Sub system should
      +     * stop pushing messages from the given subscription and allow
      +     * messages to be pulled and acknowledged - effectively pausing
      +     * the subscription if Pull is not called.
      +     * 
      + */ + public Builder setPushConfig(com.google.pubsub.v1.PushConfig value) { + if (pushConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pushConfig_ = value; + onChanged(); + } else { + pushConfigBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +     * The push configuration for future deliveries.
      +     * An empty pushConfig indicates that the Pub/Sub system should
      +     * stop pushing messages from the given subscription and allow
      +     * messages to be pulled and acknowledged - effectively pausing
      +     * the subscription if Pull is not called.
      +     * 
      + */ + public Builder setPushConfig( + com.google.pubsub.v1.PushConfig.Builder builderForValue) { + if (pushConfigBuilder_ == null) { + pushConfig_ = builderForValue.build(); + onChanged(); + } else { + pushConfigBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +     * The push configuration for future deliveries.
      +     * An empty pushConfig indicates that the Pub/Sub system should
      +     * stop pushing messages from the given subscription and allow
      +     * messages to be pulled and acknowledged - effectively pausing
      +     * the subscription if Pull is not called.
      +     * 
      + */ + public Builder mergePushConfig(com.google.pubsub.v1.PushConfig value) { + if (pushConfigBuilder_ == null) { + if (pushConfig_ != null) { + pushConfig_ = + com.google.pubsub.v1.PushConfig.newBuilder(pushConfig_).mergeFrom(value).buildPartial(); + } else { + pushConfig_ = value; + } + onChanged(); + } else { + pushConfigBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +     * The push configuration for future deliveries.
      +     * An empty pushConfig indicates that the Pub/Sub system should
      +     * stop pushing messages from the given subscription and allow
      +     * messages to be pulled and acknowledged - effectively pausing
      +     * the subscription if Pull is not called.
      +     * 
      + */ + public Builder clearPushConfig() { + if (pushConfigBuilder_ == null) { + pushConfig_ = null; + onChanged(); + } else { + pushConfig_ = null; + pushConfigBuilder_ = null; + } + + return this; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +     * The push configuration for future deliveries.
      +     * An empty pushConfig indicates that the Pub/Sub system should
      +     * stop pushing messages from the given subscription and allow
      +     * messages to be pulled and acknowledged - effectively pausing
      +     * the subscription if Pull is not called.
      +     * 
      + */ + public com.google.pubsub.v1.PushConfig.Builder getPushConfigBuilder() { + + onChanged(); + return getPushConfigFieldBuilder().getBuilder(); + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +     * The push configuration for future deliveries.
      +     * An empty pushConfig indicates that the Pub/Sub system should
      +     * stop pushing messages from the given subscription and allow
      +     * messages to be pulled and acknowledged - effectively pausing
      +     * the subscription if Pull is not called.
      +     * 
      + */ + public com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder() { + if (pushConfigBuilder_ != null) { + return pushConfigBuilder_.getMessageOrBuilder(); + } else { + return pushConfig_ == null ? + com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; + } + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +     * The push configuration for future deliveries.
      +     * An empty pushConfig indicates that the Pub/Sub system should
      +     * stop pushing messages from the given subscription and allow
      +     * messages to be pulled and acknowledged - effectively pausing
      +     * the subscription if Pull is not called.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder> + getPushConfigFieldBuilder() { + if (pushConfigBuilder_ == null) { + pushConfigBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder>( + getPushConfig(), + getParentForChildren(), + isClean()); + pushConfig_ = null; + } + return pushConfigBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ModifyPushConfigRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.ModifyPushConfigRequest) + private static final com.google.pubsub.v1.ModifyPushConfigRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.ModifyPushConfigRequest(); + } + + public static com.google.pubsub.v1.ModifyPushConfigRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ModifyPushConfigRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ModifyPushConfigRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.ModifyPushConfigRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequestOrBuilder.java new file mode 100644 index 000000000000..50d85cc4ad08 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequestOrBuilder.java @@ -0,0 +1,64 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface ModifyPushConfigRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ModifyPushConfigRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription.
      +   * 
      + */ + java.lang.String getSubscription(); + /** + * optional string subscription = 1; + * + *
      +   * The name of the subscription.
      +   * 
      + */ + com.google.protobuf.ByteString + getSubscriptionBytes(); + + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +   * The push configuration for future deliveries.
      +   * An empty pushConfig indicates that the Pub/Sub system should
      +   * stop pushing messages from the given subscription and allow
      +   * messages to be pulled and acknowledged - effectively pausing
      +   * the subscription if Pull is not called.
      +   * 
      + */ + boolean hasPushConfig(); + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +   * The push configuration for future deliveries.
      +   * An empty pushConfig indicates that the Pub/Sub system should
      +   * stop pushing messages from the given subscription and allow
      +   * messages to be pulled and acknowledged - effectively pausing
      +   * the subscription if Pull is not called.
      +   * 
      + */ + com.google.pubsub.v1.PushConfig getPushConfig(); + /** + * optional .google.pubsub.v1.PushConfig push_config = 2; + * + *
      +   * The push configuration for future deliveries.
      +   * An empty pushConfig indicates that the Pub/Sub system should
      +   * stop pushing messages from the given subscription and allow
      +   * messages to be pulled and acknowledged - effectively pausing
      +   * the subscription if Pull is not called.
      +   * 
      + */ + com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequest.java new file mode 100644 index 000000000000..b68d33924dd0 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequest.java @@ -0,0 +1,909 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.PublishRequest} + * + *
      + * Request for the Publish method.
      + * 
      + */ +public final class PublishRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.PublishRequest) + PublishRequestOrBuilder { + // Use PublishRequest.newBuilder() to construct. + private PublishRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private PublishRequest() { + topic_ = ""; + messages_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private PublishRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + messages_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + messages_.add(input.readMessage(com.google.pubsub.v1.PubsubMessage.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + messages_ = java.util.Collections.unmodifiableList(messages_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PublishRequest.class, com.google.pubsub.v1.PublishRequest.Builder.class); + } + + private int bitField0_; + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile java.lang.Object topic_; + /** + * optional string topic = 1; + * + *
      +   * The messages in the request will be published on this topic.
      +   * 
      + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * optional string topic = 1; + * + *
      +   * The messages in the request will be published on this topic.
      +   * 
      + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MESSAGES_FIELD_NUMBER = 2; + private java.util.List messages_; + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +   * The messages to publish.
      +   * 
      + */ + public java.util.List getMessagesList() { + return messages_; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +   * The messages to publish.
      +   * 
      + */ + public java.util.List + getMessagesOrBuilderList() { + return messages_; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +   * The messages to publish.
      +   * 
      + */ + public int getMessagesCount() { + return messages_.size(); + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +   * The messages to publish.
      +   * 
      + */ + public com.google.pubsub.v1.PubsubMessage getMessages(int index) { + return messages_.get(index); + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +   * The messages to publish.
      +   * 
      + */ + public com.google.pubsub.v1.PubsubMessageOrBuilder getMessagesOrBuilder( + int index) { + return messages_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, topic_); + } + for (int i = 0; i < messages_.size(); i++) { + output.writeMessage(2, messages_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, topic_); + } + for (int i = 0; i < messages_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, messages_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.PublishRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PublishRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PublishRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PublishRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PublishRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PublishRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PublishRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.PublishRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PublishRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PublishRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.PublishRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.PublishRequest} + * + *
      +   * Request for the Publish method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PublishRequest) + com.google.pubsub.v1.PublishRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PublishRequest.class, com.google.pubsub.v1.PublishRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.PublishRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getMessagesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + topic_ = ""; + + if (messagesBuilder_ == null) { + messages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + messagesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishRequest_descriptor; + } + + public com.google.pubsub.v1.PublishRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.PublishRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.PublishRequest build() { + com.google.pubsub.v1.PublishRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.PublishRequest buildPartial() { + com.google.pubsub.v1.PublishRequest result = new com.google.pubsub.v1.PublishRequest(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.topic_ = topic_; + if (messagesBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + messages_ = java.util.Collections.unmodifiableList(messages_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.messages_ = messages_; + } else { + result.messages_ = messagesBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.PublishRequest) { + return mergeFrom((com.google.pubsub.v1.PublishRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.PublishRequest other) { + if (other == com.google.pubsub.v1.PublishRequest.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (messagesBuilder_ == null) { + if (!other.messages_.isEmpty()) { + if (messages_.isEmpty()) { + messages_ = other.messages_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureMessagesIsMutable(); + messages_.addAll(other.messages_); + } + onChanged(); + } + } else { + if (!other.messages_.isEmpty()) { + if (messagesBuilder_.isEmpty()) { + messagesBuilder_.dispose(); + messagesBuilder_ = null; + messages_ = other.messages_; + bitField0_ = (bitField0_ & ~0x00000002); + messagesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getMessagesFieldBuilder() : null; + } else { + messagesBuilder_.addAllMessages(other.messages_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.PublishRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.PublishRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object topic_ = ""; + /** + * optional string topic = 1; + * + *
      +     * The messages in the request will be published on this topic.
      +     * 
      + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string topic = 1; + * + *
      +     * The messages in the request will be published on this topic.
      +     * 
      + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string topic = 1; + * + *
      +     * The messages in the request will be published on this topic.
      +     * 
      + */ + public Builder setTopic( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * optional string topic = 1; + * + *
      +     * The messages in the request will be published on this topic.
      +     * 
      + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * optional string topic = 1; + * + *
      +     * The messages in the request will be published on this topic.
      +     * 
      + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private java.util.List messages_ = + java.util.Collections.emptyList(); + private void ensureMessagesIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + messages_ = new java.util.ArrayList(messages_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder> messagesBuilder_; + + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public java.util.List getMessagesList() { + if (messagesBuilder_ == null) { + return java.util.Collections.unmodifiableList(messages_); + } else { + return messagesBuilder_.getMessageList(); + } + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public int getMessagesCount() { + if (messagesBuilder_ == null) { + return messages_.size(); + } else { + return messagesBuilder_.getCount(); + } + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public com.google.pubsub.v1.PubsubMessage getMessages(int index) { + if (messagesBuilder_ == null) { + return messages_.get(index); + } else { + return messagesBuilder_.getMessage(index); + } + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public Builder setMessages( + int index, com.google.pubsub.v1.PubsubMessage value) { + if (messagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMessagesIsMutable(); + messages_.set(index, value); + onChanged(); + } else { + messagesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public Builder setMessages( + int index, com.google.pubsub.v1.PubsubMessage.Builder builderForValue) { + if (messagesBuilder_ == null) { + ensureMessagesIsMutable(); + messages_.set(index, builderForValue.build()); + onChanged(); + } else { + messagesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public Builder addMessages(com.google.pubsub.v1.PubsubMessage value) { + if (messagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMessagesIsMutable(); + messages_.add(value); + onChanged(); + } else { + messagesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public Builder addMessages( + int index, com.google.pubsub.v1.PubsubMessage value) { + if (messagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMessagesIsMutable(); + messages_.add(index, value); + onChanged(); + } else { + messagesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public Builder addMessages( + com.google.pubsub.v1.PubsubMessage.Builder builderForValue) { + if (messagesBuilder_ == null) { + ensureMessagesIsMutable(); + messages_.add(builderForValue.build()); + onChanged(); + } else { + messagesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public Builder addMessages( + int index, com.google.pubsub.v1.PubsubMessage.Builder builderForValue) { + if (messagesBuilder_ == null) { + ensureMessagesIsMutable(); + messages_.add(index, builderForValue.build()); + onChanged(); + } else { + messagesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public Builder addAllMessages( + java.lang.Iterable values) { + if (messagesBuilder_ == null) { + ensureMessagesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, messages_); + onChanged(); + } else { + messagesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public Builder clearMessages() { + if (messagesBuilder_ == null) { + messages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + messagesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public Builder removeMessages(int index) { + if (messagesBuilder_ == null) { + ensureMessagesIsMutable(); + messages_.remove(index); + onChanged(); + } else { + messagesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public com.google.pubsub.v1.PubsubMessage.Builder getMessagesBuilder( + int index) { + return getMessagesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public com.google.pubsub.v1.PubsubMessageOrBuilder getMessagesOrBuilder( + int index) { + if (messagesBuilder_ == null) { + return messages_.get(index); } else { + return messagesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public java.util.List + getMessagesOrBuilderList() { + if (messagesBuilder_ != null) { + return messagesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(messages_); + } + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public com.google.pubsub.v1.PubsubMessage.Builder addMessagesBuilder() { + return getMessagesFieldBuilder().addBuilder( + com.google.pubsub.v1.PubsubMessage.getDefaultInstance()); + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public com.google.pubsub.v1.PubsubMessage.Builder addMessagesBuilder( + int index) { + return getMessagesFieldBuilder().addBuilder( + index, com.google.pubsub.v1.PubsubMessage.getDefaultInstance()); + } + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +     * The messages to publish.
      +     * 
      + */ + public java.util.List + getMessagesBuilderList() { + return getMessagesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder> + getMessagesFieldBuilder() { + if (messagesBuilder_ == null) { + messagesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder>( + messages_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + messages_ = null; + } + return messagesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PublishRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.PublishRequest) + private static final com.google.pubsub.v1.PublishRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.PublishRequest(); + } + + public static com.google.pubsub.v1.PublishRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PublishRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new PublishRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.PublishRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequestOrBuilder.java new file mode 100644 index 000000000000..d862735fe6df --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequestOrBuilder.java @@ -0,0 +1,71 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface PublishRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PublishRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string topic = 1; + * + *
      +   * The messages in the request will be published on this topic.
      +   * 
      + */ + java.lang.String getTopic(); + /** + * optional string topic = 1; + * + *
      +   * The messages in the request will be published on this topic.
      +   * 
      + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +   * The messages to publish.
      +   * 
      + */ + java.util.List + getMessagesList(); + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +   * The messages to publish.
      +   * 
      + */ + com.google.pubsub.v1.PubsubMessage getMessages(int index); + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +   * The messages to publish.
      +   * 
      + */ + int getMessagesCount(); + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +   * The messages to publish.
      +   * 
      + */ + java.util.List + getMessagesOrBuilderList(); + /** + * repeated .google.pubsub.v1.PubsubMessage messages = 2; + * + *
      +   * The messages to publish.
      +   * 
      + */ + com.google.pubsub.v1.PubsubMessageOrBuilder getMessagesOrBuilder( + int index); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponse.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponse.java new file mode 100644 index 000000000000..9a7a30834bce --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponse.java @@ -0,0 +1,569 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.PublishResponse} + * + *
      + * Response for the Publish method.
      + * 
      + */ +public final class PublishResponse extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.PublishResponse) + PublishResponseOrBuilder { + // Use PublishResponse.newBuilder() to construct. + private PublishResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private PublishResponse() { + messageIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private PublishResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + messageIds_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + messageIds_.add(s); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + messageIds_ = messageIds_.getUnmodifiableView(); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PublishResponse.class, com.google.pubsub.v1.PublishResponse.Builder.class); + } + + public static final int MESSAGE_IDS_FIELD_NUMBER = 1; + private com.google.protobuf.LazyStringList messageIds_; + /** + * repeated string message_ids = 1; + * + *
      +   * The server-assigned ID of each published message, in the same order as
      +   * the messages in the request. IDs are guaranteed to be unique within
      +   * the topic.
      +   * 
      + */ + public com.google.protobuf.ProtocolStringList + getMessageIdsList() { + return messageIds_; + } + /** + * repeated string message_ids = 1; + * + *
      +   * The server-assigned ID of each published message, in the same order as
      +   * the messages in the request. IDs are guaranteed to be unique within
      +   * the topic.
      +   * 
      + */ + public int getMessageIdsCount() { + return messageIds_.size(); + } + /** + * repeated string message_ids = 1; + * + *
      +   * The server-assigned ID of each published message, in the same order as
      +   * the messages in the request. IDs are guaranteed to be unique within
      +   * the topic.
      +   * 
      + */ + public java.lang.String getMessageIds(int index) { + return messageIds_.get(index); + } + /** + * repeated string message_ids = 1; + * + *
      +   * The server-assigned ID of each published message, in the same order as
      +   * the messages in the request. IDs are guaranteed to be unique within
      +   * the topic.
      +   * 
      + */ + public com.google.protobuf.ByteString + getMessageIdsBytes(int index) { + return messageIds_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < messageIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, messageIds_.getRaw(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < messageIds_.size(); i++) { + dataSize += computeStringSizeNoTag(messageIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getMessageIdsList().size(); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.PublishResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PublishResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PublishResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PublishResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PublishResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PublishResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PublishResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.PublishResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PublishResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PublishResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.PublishResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.PublishResponse} + * + *
      +   * Response for the Publish method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PublishResponse) + com.google.pubsub.v1.PublishResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PublishResponse.class, com.google.pubsub.v1.PublishResponse.Builder.class); + } + + // Construct using com.google.pubsub.v1.PublishResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + messageIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishResponse_descriptor; + } + + public com.google.pubsub.v1.PublishResponse getDefaultInstanceForType() { + return com.google.pubsub.v1.PublishResponse.getDefaultInstance(); + } + + public com.google.pubsub.v1.PublishResponse build() { + com.google.pubsub.v1.PublishResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.PublishResponse buildPartial() { + com.google.pubsub.v1.PublishResponse result = new com.google.pubsub.v1.PublishResponse(this); + int from_bitField0_ = bitField0_; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + messageIds_ = messageIds_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.messageIds_ = messageIds_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.PublishResponse) { + return mergeFrom((com.google.pubsub.v1.PublishResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.PublishResponse other) { + if (other == com.google.pubsub.v1.PublishResponse.getDefaultInstance()) return this; + if (!other.messageIds_.isEmpty()) { + if (messageIds_.isEmpty()) { + messageIds_ = other.messageIds_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureMessageIdsIsMutable(); + messageIds_.addAll(other.messageIds_); + } + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.PublishResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.PublishResponse) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.LazyStringList messageIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureMessageIdsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + messageIds_ = new com.google.protobuf.LazyStringArrayList(messageIds_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated string message_ids = 1; + * + *
      +     * The server-assigned ID of each published message, in the same order as
      +     * the messages in the request. IDs are guaranteed to be unique within
      +     * the topic.
      +     * 
      + */ + public com.google.protobuf.ProtocolStringList + getMessageIdsList() { + return messageIds_.getUnmodifiableView(); + } + /** + * repeated string message_ids = 1; + * + *
      +     * The server-assigned ID of each published message, in the same order as
      +     * the messages in the request. IDs are guaranteed to be unique within
      +     * the topic.
      +     * 
      + */ + public int getMessageIdsCount() { + return messageIds_.size(); + } + /** + * repeated string message_ids = 1; + * + *
      +     * The server-assigned ID of each published message, in the same order as
      +     * the messages in the request. IDs are guaranteed to be unique within
      +     * the topic.
      +     * 
      + */ + public java.lang.String getMessageIds(int index) { + return messageIds_.get(index); + } + /** + * repeated string message_ids = 1; + * + *
      +     * The server-assigned ID of each published message, in the same order as
      +     * the messages in the request. IDs are guaranteed to be unique within
      +     * the topic.
      +     * 
      + */ + public com.google.protobuf.ByteString + getMessageIdsBytes(int index) { + return messageIds_.getByteString(index); + } + /** + * repeated string message_ids = 1; + * + *
      +     * The server-assigned ID of each published message, in the same order as
      +     * the messages in the request. IDs are guaranteed to be unique within
      +     * the topic.
      +     * 
      + */ + public Builder setMessageIds( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureMessageIdsIsMutable(); + messageIds_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string message_ids = 1; + * + *
      +     * The server-assigned ID of each published message, in the same order as
      +     * the messages in the request. IDs are guaranteed to be unique within
      +     * the topic.
      +     * 
      + */ + public Builder addMessageIds( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureMessageIdsIsMutable(); + messageIds_.add(value); + onChanged(); + return this; + } + /** + * repeated string message_ids = 1; + * + *
      +     * The server-assigned ID of each published message, in the same order as
      +     * the messages in the request. IDs are guaranteed to be unique within
      +     * the topic.
      +     * 
      + */ + public Builder addAllMessageIds( + java.lang.Iterable values) { + ensureMessageIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, messageIds_); + onChanged(); + return this; + } + /** + * repeated string message_ids = 1; + * + *
      +     * The server-assigned ID of each published message, in the same order as
      +     * the messages in the request. IDs are guaranteed to be unique within
      +     * the topic.
      +     * 
      + */ + public Builder clearMessageIds() { + messageIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * repeated string message_ids = 1; + * + *
      +     * The server-assigned ID of each published message, in the same order as
      +     * the messages in the request. IDs are guaranteed to be unique within
      +     * the topic.
      +     * 
      + */ + public Builder addMessageIdsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureMessageIdsIsMutable(); + messageIds_.add(value); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PublishResponse) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.PublishResponse) + private static final com.google.pubsub.v1.PublishResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.PublishResponse(); + } + + public static com.google.pubsub.v1.PublishResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PublishResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new PublishResponse(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.PublishResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponseOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponseOrBuilder.java new file mode 100644 index 000000000000..6908fac0c93b --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponseOrBuilder.java @@ -0,0 +1,52 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface PublishResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PublishResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated string message_ids = 1; + * + *
      +   * The server-assigned ID of each published message, in the same order as
      +   * the messages in the request. IDs are guaranteed to be unique within
      +   * the topic.
      +   * 
      + */ + com.google.protobuf.ProtocolStringList + getMessageIdsList(); + /** + * repeated string message_ids = 1; + * + *
      +   * The server-assigned ID of each published message, in the same order as
      +   * the messages in the request. IDs are guaranteed to be unique within
      +   * the topic.
      +   * 
      + */ + int getMessageIdsCount(); + /** + * repeated string message_ids = 1; + * + *
      +   * The server-assigned ID of each published message, in the same order as
      +   * the messages in the request. IDs are guaranteed to be unique within
      +   * the topic.
      +   * 
      + */ + java.lang.String getMessageIds(int index); + /** + * repeated string message_ids = 1; + * + *
      +   * The server-assigned ID of each published message, in the same order as
      +   * the messages in the request. IDs are guaranteed to be unique within
      +   * the topic.
      +   * 
      + */ + com.google.protobuf.ByteString + getMessageIdsBytes(int index); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublisherGrpc.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublisherGrpc.java new file mode 100644 index 000000000000..a2c47fcdeb01 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublisherGrpc.java @@ -0,0 +1,406 @@ +package com.google.pubsub.v1; + +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; + +@javax.annotation.Generated("by gRPC proto compiler") +public class PublisherGrpc { + + private PublisherGrpc() {} + + public static final String SERVICE_NAME = "google.pubsub.v1.Publisher"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_CREATE_TOPIC = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Publisher", "CreateTopic"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Topic.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Topic.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_PUBLISH = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Publisher", "Publish"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.PublishRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.PublishResponse.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_GET_TOPIC = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Publisher", "GetTopic"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.GetTopicRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Topic.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_LIST_TOPICS = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Publisher", "ListTopics"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListTopicsRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListTopicsResponse.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_LIST_TOPIC_SUBSCRIPTIONS = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Publisher", "ListTopicSubscriptions"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListTopicSubscriptionsRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListTopicSubscriptionsResponse.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_DELETE_TOPIC = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Publisher", "DeleteTopic"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.DeleteTopicRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); + + public static PublisherStub newStub(io.grpc.Channel channel) { + return new PublisherStub(channel); + } + + public static PublisherBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new PublisherBlockingStub(channel); + } + + public static PublisherFutureStub newFutureStub( + io.grpc.Channel channel) { + return new PublisherFutureStub(channel); + } + + public static interface Publisher { + + public void createTopic(com.google.pubsub.v1.Topic request, + io.grpc.stub.StreamObserver responseObserver); + + public void publish(com.google.pubsub.v1.PublishRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void getTopic(com.google.pubsub.v1.GetTopicRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void listTopics(com.google.pubsub.v1.ListTopicsRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void listTopicSubscriptions(com.google.pubsub.v1.ListTopicSubscriptionsRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void deleteTopic(com.google.pubsub.v1.DeleteTopicRequest request, + io.grpc.stub.StreamObserver responseObserver); + } + + public static interface PublisherBlockingClient { + + public com.google.pubsub.v1.Topic createTopic(com.google.pubsub.v1.Topic request); + + public com.google.pubsub.v1.PublishResponse publish(com.google.pubsub.v1.PublishRequest request); + + public com.google.pubsub.v1.Topic getTopic(com.google.pubsub.v1.GetTopicRequest request); + + public com.google.pubsub.v1.ListTopicsResponse listTopics(com.google.pubsub.v1.ListTopicsRequest request); + + public com.google.pubsub.v1.ListTopicSubscriptionsResponse listTopicSubscriptions(com.google.pubsub.v1.ListTopicSubscriptionsRequest request); + + public com.google.protobuf.Empty deleteTopic(com.google.pubsub.v1.DeleteTopicRequest request); + } + + public static interface PublisherFutureClient { + + public com.google.common.util.concurrent.ListenableFuture createTopic( + com.google.pubsub.v1.Topic request); + + public com.google.common.util.concurrent.ListenableFuture publish( + com.google.pubsub.v1.PublishRequest request); + + public com.google.common.util.concurrent.ListenableFuture getTopic( + com.google.pubsub.v1.GetTopicRequest request); + + public com.google.common.util.concurrent.ListenableFuture listTopics( + com.google.pubsub.v1.ListTopicsRequest request); + + public com.google.common.util.concurrent.ListenableFuture listTopicSubscriptions( + com.google.pubsub.v1.ListTopicSubscriptionsRequest request); + + public com.google.common.util.concurrent.ListenableFuture deleteTopic( + com.google.pubsub.v1.DeleteTopicRequest request); + } + + public static class PublisherStub extends io.grpc.stub.AbstractStub + implements Publisher { + private PublisherStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected PublisherStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherStub(channel, callOptions); + } + + @java.lang.Override + public void createTopic(com.google.pubsub.v1.Topic request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_CREATE_TOPIC, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void publish(com.google.pubsub.v1.PublishRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_PUBLISH, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void getTopic(com.google.pubsub.v1.GetTopicRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_GET_TOPIC, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void listTopics(com.google.pubsub.v1.ListTopicsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_LIST_TOPICS, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void listTopicSubscriptions(com.google.pubsub.v1.ListTopicSubscriptionsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_LIST_TOPIC_SUBSCRIPTIONS, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void deleteTopic(com.google.pubsub.v1.DeleteTopicRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_DELETE_TOPIC, getCallOptions()), request, responseObserver); + } + } + + public static class PublisherBlockingStub extends io.grpc.stub.AbstractStub + implements PublisherBlockingClient { + private PublisherBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected PublisherBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherBlockingStub(channel, callOptions); + } + + @java.lang.Override + public com.google.pubsub.v1.Topic createTopic(com.google.pubsub.v1.Topic request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_CREATE_TOPIC, getCallOptions()), request); + } + + @java.lang.Override + public com.google.pubsub.v1.PublishResponse publish(com.google.pubsub.v1.PublishRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_PUBLISH, getCallOptions()), request); + } + + @java.lang.Override + public com.google.pubsub.v1.Topic getTopic(com.google.pubsub.v1.GetTopicRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_GET_TOPIC, getCallOptions()), request); + } + + @java.lang.Override + public com.google.pubsub.v1.ListTopicsResponse listTopics(com.google.pubsub.v1.ListTopicsRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_LIST_TOPICS, getCallOptions()), request); + } + + @java.lang.Override + public com.google.pubsub.v1.ListTopicSubscriptionsResponse listTopicSubscriptions(com.google.pubsub.v1.ListTopicSubscriptionsRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_LIST_TOPIC_SUBSCRIPTIONS, getCallOptions()), request); + } + + @java.lang.Override + public com.google.protobuf.Empty deleteTopic(com.google.pubsub.v1.DeleteTopicRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_DELETE_TOPIC, getCallOptions()), request); + } + } + + public static class PublisherFutureStub extends io.grpc.stub.AbstractStub + implements PublisherFutureClient { + private PublisherFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private PublisherFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected PublisherFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new PublisherFutureStub(channel, callOptions); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture createTopic( + com.google.pubsub.v1.Topic request) { + return futureUnaryCall( + getChannel().newCall(METHOD_CREATE_TOPIC, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture publish( + com.google.pubsub.v1.PublishRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_PUBLISH, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture getTopic( + com.google.pubsub.v1.GetTopicRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_GET_TOPIC, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture listTopics( + com.google.pubsub.v1.ListTopicsRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_LIST_TOPICS, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture listTopicSubscriptions( + com.google.pubsub.v1.ListTopicSubscriptionsRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_LIST_TOPIC_SUBSCRIPTIONS, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture deleteTopic( + com.google.pubsub.v1.DeleteTopicRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_DELETE_TOPIC, getCallOptions()), request); + } + } + + public static io.grpc.ServerServiceDefinition bindService( + final Publisher serviceImpl) { + return io.grpc.ServerServiceDefinition.builder(SERVICE_NAME) + .addMethod( + METHOD_CREATE_TOPIC, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.Topic, + com.google.pubsub.v1.Topic>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.Topic request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.createTopic(request, responseObserver); + } + })) + .addMethod( + METHOD_PUBLISH, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.PublishRequest, + com.google.pubsub.v1.PublishResponse>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.PublishRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.publish(request, responseObserver); + } + })) + .addMethod( + METHOD_GET_TOPIC, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.GetTopicRequest, + com.google.pubsub.v1.Topic>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.GetTopicRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.getTopic(request, responseObserver); + } + })) + .addMethod( + METHOD_LIST_TOPICS, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.ListTopicsRequest, + com.google.pubsub.v1.ListTopicsResponse>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.ListTopicsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.listTopics(request, responseObserver); + } + })) + .addMethod( + METHOD_LIST_TOPIC_SUBSCRIPTIONS, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.ListTopicSubscriptionsRequest, + com.google.pubsub.v1.ListTopicSubscriptionsResponse>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.ListTopicSubscriptionsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.listTopicSubscriptions(request, responseObserver); + } + })) + .addMethod( + METHOD_DELETE_TOPIC, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.DeleteTopicRequest, + com.google.protobuf.Empty>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.DeleteTopicRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.deleteTopic(request, responseObserver); + } + })).build(); + } +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessage.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessage.java new file mode 100644 index 000000000000..5228be2f8998 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessage.java @@ -0,0 +1,740 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.PubsubMessage} + * + *
      + * A message data and its attributes. The message payload must not be empty;
      + * it must contain either a non-empty data field, or at least one attribute.
      + * 
      + */ +public final class PubsubMessage extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.PubsubMessage) + PubsubMessageOrBuilder { + // Use PubsubMessage.newBuilder() to construct. + private PubsubMessage(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private PubsubMessage() { + data_ = com.google.protobuf.ByteString.EMPTY; + messageId_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private PubsubMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + + data_ = input.readBytes(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + attributes_ = com.google.protobuf.MapField.newMapField( + AttributesDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000002; + } + com.google.protobuf.MapEntry + attributes = input.readMessage( + AttributesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + attributes_.getMutableMap().put(attributes.getKey(), attributes.getValue()); + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + messageId_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 2: + return internalGetAttributes(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PubsubMessage.class, com.google.pubsub.v1.PubsubMessage.Builder.class); + } + + private int bitField0_; + public static final int DATA_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString data_; + /** + * optional bytes data = 1; + * + *
      +   * The message payload. For JSON requests, the value of this field must be
      +   * base64-encoded.
      +   * 
      + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + + public static final int ATTRIBUTES_FIELD_NUMBER = 2; + private static final class AttributesDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> attributes_; + private com.google.protobuf.MapField + internalGetAttributes() { + if (attributes_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AttributesDefaultEntryHolder.defaultEntry); + } + return attributes_; + } + /** + * map<string, string> attributes = 2; + * + *
      +   * Optional attributes for this message.
      +   * 
      + */ + + public java.util.Map getAttributes() { + return internalGetAttributes().getMap(); + } + + public static final int MESSAGE_ID_FIELD_NUMBER = 3; + private volatile java.lang.Object messageId_; + /** + * optional string message_id = 3; + * + *
      +   * ID of this message assigned by the server at publication time. Guaranteed
      +   * to be unique within the topic. This value may be read by a subscriber
      +   * that receives a PubsubMessage via a Pull call or a push delivery. It must
      +   * not be populated by a publisher in a Publish call.
      +   * 
      + */ + public java.lang.String getMessageId() { + java.lang.Object ref = messageId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + messageId_ = s; + return s; + } + } + /** + * optional string message_id = 3; + * + *
      +   * ID of this message assigned by the server at publication time. Guaranteed
      +   * to be unique within the topic. This value may be read by a subscriber
      +   * that receives a PubsubMessage via a Pull call or a push delivery. It must
      +   * not be populated by a publisher in a Publish call.
      +   * 
      + */ + public com.google.protobuf.ByteString + getMessageIdBytes() { + java.lang.Object ref = messageId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + messageId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!data_.isEmpty()) { + output.writeBytes(1, data_); + } + for (java.util.Map.Entry entry + : internalGetAttributes().getMap().entrySet()) { + com.google.protobuf.MapEntry + attributes = AttributesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + output.writeMessage(2, attributes); + } + if (!getMessageIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, messageId_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!data_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, data_); + } + for (java.util.Map.Entry entry + : internalGetAttributes().getMap().entrySet()) { + com.google.protobuf.MapEntry + attributes = AttributesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, attributes); + } + if (!getMessageIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, messageId_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.PubsubMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PubsubMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PubsubMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PubsubMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PubsubMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PubsubMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PubsubMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.PubsubMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PubsubMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PubsubMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.PubsubMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.PubsubMessage} + * + *
      +   * A message data and its attributes. The message payload must not be empty;
      +   * it must contain either a non-empty data field, or at least one attribute.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PubsubMessage) + com.google.pubsub.v1.PubsubMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 2: + return internalGetAttributes(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 2: + return internalGetMutableAttributes(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PubsubMessage.class, com.google.pubsub.v1.PubsubMessage.Builder.class); + } + + // Construct using com.google.pubsub.v1.PubsubMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + data_ = com.google.protobuf.ByteString.EMPTY; + + internalGetMutableAttributes().clear(); + messageId_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_descriptor; + } + + public com.google.pubsub.v1.PubsubMessage getDefaultInstanceForType() { + return com.google.pubsub.v1.PubsubMessage.getDefaultInstance(); + } + + public com.google.pubsub.v1.PubsubMessage build() { + com.google.pubsub.v1.PubsubMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.PubsubMessage buildPartial() { + com.google.pubsub.v1.PubsubMessage result = new com.google.pubsub.v1.PubsubMessage(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.data_ = data_; + result.attributes_ = internalGetAttributes(); + result.attributes_.makeImmutable(); + result.messageId_ = messageId_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.PubsubMessage) { + return mergeFrom((com.google.pubsub.v1.PubsubMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.PubsubMessage other) { + if (other == com.google.pubsub.v1.PubsubMessage.getDefaultInstance()) return this; + if (other.getData() != com.google.protobuf.ByteString.EMPTY) { + setData(other.getData()); + } + internalGetMutableAttributes().mergeFrom( + other.internalGetAttributes()); + if (!other.getMessageId().isEmpty()) { + messageId_ = other.messageId_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.PubsubMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.PubsubMessage) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; + /** + * optional bytes data = 1; + * + *
      +     * The message payload. For JSON requests, the value of this field must be
      +     * base64-encoded.
      +     * 
      + */ + public com.google.protobuf.ByteString getData() { + return data_; + } + /** + * optional bytes data = 1; + * + *
      +     * The message payload. For JSON requests, the value of this field must be
      +     * base64-encoded.
      +     * 
      + */ + public Builder setData(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + data_ = value; + onChanged(); + return this; + } + /** + * optional bytes data = 1; + * + *
      +     * The message payload. For JSON requests, the value of this field must be
      +     * base64-encoded.
      +     * 
      + */ + public Builder clearData() { + + data_ = getDefaultInstance().getData(); + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> attributes_; + private com.google.protobuf.MapField + internalGetAttributes() { + if (attributes_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AttributesDefaultEntryHolder.defaultEntry); + } + return attributes_; + } + private com.google.protobuf.MapField + internalGetMutableAttributes() { + onChanged();; + if (attributes_ == null) { + attributes_ = com.google.protobuf.MapField.newMapField( + AttributesDefaultEntryHolder.defaultEntry); + } + if (!attributes_.isMutable()) { + attributes_ = attributes_.copy(); + } + return attributes_; + } + /** + * map<string, string> attributes = 2; + * + *
      +     * Optional attributes for this message.
      +     * 
      + */ + public java.util.Map getAttributes() { + return internalGetAttributes().getMap(); + } + /** + * map<string, string> attributes = 2; + * + *
      +     * Optional attributes for this message.
      +     * 
      + */ + public java.util.Map + getMutableAttributes() { + return internalGetMutableAttributes().getMutableMap(); + } + /** + * map<string, string> attributes = 2; + * + *
      +     * Optional attributes for this message.
      +     * 
      + */ + public Builder putAllAttributes( + java.util.Map values) { + getMutableAttributes().putAll(values); + return this; + } + + private java.lang.Object messageId_ = ""; + /** + * optional string message_id = 3; + * + *
      +     * ID of this message assigned by the server at publication time. Guaranteed
      +     * to be unique within the topic. This value may be read by a subscriber
      +     * that receives a PubsubMessage via a Pull call or a push delivery. It must
      +     * not be populated by a publisher in a Publish call.
      +     * 
      + */ + public java.lang.String getMessageId() { + java.lang.Object ref = messageId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + messageId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string message_id = 3; + * + *
      +     * ID of this message assigned by the server at publication time. Guaranteed
      +     * to be unique within the topic. This value may be read by a subscriber
      +     * that receives a PubsubMessage via a Pull call or a push delivery. It must
      +     * not be populated by a publisher in a Publish call.
      +     * 
      + */ + public com.google.protobuf.ByteString + getMessageIdBytes() { + java.lang.Object ref = messageId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + messageId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string message_id = 3; + * + *
      +     * ID of this message assigned by the server at publication time. Guaranteed
      +     * to be unique within the topic. This value may be read by a subscriber
      +     * that receives a PubsubMessage via a Pull call or a push delivery. It must
      +     * not be populated by a publisher in a Publish call.
      +     * 
      + */ + public Builder setMessageId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + messageId_ = value; + onChanged(); + return this; + } + /** + * optional string message_id = 3; + * + *
      +     * ID of this message assigned by the server at publication time. Guaranteed
      +     * to be unique within the topic. This value may be read by a subscriber
      +     * that receives a PubsubMessage via a Pull call or a push delivery. It must
      +     * not be populated by a publisher in a Publish call.
      +     * 
      + */ + public Builder clearMessageId() { + + messageId_ = getDefaultInstance().getMessageId(); + onChanged(); + return this; + } + /** + * optional string message_id = 3; + * + *
      +     * ID of this message assigned by the server at publication time. Guaranteed
      +     * to be unique within the topic. This value may be read by a subscriber
      +     * that receives a PubsubMessage via a Pull call or a push delivery. It must
      +     * not be populated by a publisher in a Publish call.
      +     * 
      + */ + public Builder setMessageIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + messageId_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PubsubMessage) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.PubsubMessage) + private static final com.google.pubsub.v1.PubsubMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.PubsubMessage(); + } + + public static com.google.pubsub.v1.PubsubMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PubsubMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new PubsubMessage(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.PubsubMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessageOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessageOrBuilder.java new file mode 100644 index 000000000000..706d17d65291 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessageOrBuilder.java @@ -0,0 +1,53 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface PubsubMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PubsubMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * optional bytes data = 1; + * + *
      +   * The message payload. For JSON requests, the value of this field must be
      +   * base64-encoded.
      +   * 
      + */ + com.google.protobuf.ByteString getData(); + + /** + * map<string, string> attributes = 2; + * + *
      +   * Optional attributes for this message.
      +   * 
      + */ + java.util.Map + getAttributes(); + + /** + * optional string message_id = 3; + * + *
      +   * ID of this message assigned by the server at publication time. Guaranteed
      +   * to be unique within the topic. This value may be read by a subscriber
      +   * that receives a PubsubMessage via a Pull call or a push delivery. It must
      +   * not be populated by a publisher in a Publish call.
      +   * 
      + */ + java.lang.String getMessageId(); + /** + * optional string message_id = 3; + * + *
      +   * ID of this message assigned by the server at publication time. Guaranteed
      +   * to be unique within the topic. This value may be read by a subscriber
      +   * that receives a PubsubMessage via a Pull call or a push delivery. It must
      +   * not be populated by a publisher in a Publish call.
      +   * 
      + */ + com.google.protobuf.ByteString + getMessageIdBytes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubProto.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubProto.java new file mode 100644 index 000000000000..197384a867d9 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubProto.java @@ -0,0 +1,409 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public final class PubsubProto { + private PubsubProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_Topic_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_Topic_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_PubsubMessage_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_PubsubMessage_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_GetTopicRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_GetTopicRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_PublishRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_PublishRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_PublishResponse_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_PublishResponse_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_ListTopicsRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_ListTopicsRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_ListTopicsResponse_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_ListTopicsResponse_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_DeleteTopicRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_Subscription_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_Subscription_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_PushConfig_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_PushConfig_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_PushConfig_AttributesEntry_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_PushConfig_AttributesEntry_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_ReceivedMessage_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_ReceivedMessage_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_GetSubscriptionRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_ListSubscriptionsRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_ListSubscriptionsResponse_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_DeleteSubscriptionRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_ModifyPushConfigRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_PullRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_PullRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_PullResponse_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_PullResponse_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_pubsub_v1_AcknowledgeRequest_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\035google/pubsub/v1/pubsub.proto\022\020google." + + "pubsub.v1\032\034google/api/annotations.proto\032" + + "\033google/protobuf/empty.proto\"\025\n\005Topic\022\014\n" + + "\004name\030\001 \001(\t\"\251\001\n\rPubsubMessage\022\014\n\004data\030\001 " + + "\001(\014\022C\n\nattributes\030\002 \003(\0132/.google.pubsub." + + "v1.PubsubMessage.AttributesEntry\022\022\n\nmess" + + "age_id\030\003 \001(\t\0321\n\017AttributesEntry\022\013\n\003key\030\001" + + " \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\" \n\017GetTopicReque" + + "st\022\r\n\005topic\030\001 \001(\t\"R\n\016PublishRequest\022\r\n\005t" + + "opic\030\001 \001(\t\0221\n\010messages\030\002 \003(\0132\037.google.pu", + "bsub.v1.PubsubMessage\"&\n\017PublishResponse" + + "\022\023\n\013message_ids\030\001 \003(\t\"K\n\021ListTopicsReque" + + "st\022\017\n\007project\030\001 \001(\t\022\021\n\tpage_size\030\002 \001(\005\022\022" + + "\n\npage_token\030\003 \001(\t\"V\n\022ListTopicsResponse" + + "\022\'\n\006topics\030\001 \003(\0132\027.google.pubsub.v1.Topi" + + "c\022\027\n\017next_page_token\030\002 \001(\t\"U\n\035ListTopicS" + + "ubscriptionsRequest\022\r\n\005topic\030\001 \001(\t\022\021\n\tpa" + + "ge_size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\"P\n\036Lis" + + "tTopicSubscriptionsResponse\022\025\n\rsubscript" + + "ions\030\001 \003(\t\022\027\n\017next_page_token\030\002 \001(\t\"#\n\022D", + "eleteTopicRequest\022\r\n\005topic\030\001 \001(\t\"|\n\014Subs" + + "cription\022\014\n\004name\030\001 \001(\t\022\r\n\005topic\030\002 \001(\t\0221\n" + + "\013push_config\030\004 \001(\0132\034.google.pubsub.v1.Pu" + + "shConfig\022\034\n\024ack_deadline_seconds\030\005 \001(\005\"\230" + + "\001\n\nPushConfig\022\025\n\rpush_endpoint\030\001 \001(\t\022@\n\n" + + "attributes\030\002 \003(\0132,.google.pubsub.v1.Push" + + "Config.AttributesEntry\0321\n\017AttributesEntr" + + "y\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"S\n\017Rec" + + "eivedMessage\022\016\n\006ack_id\030\001 \001(\t\0220\n\007message\030" + + "\002 \001(\0132\037.google.pubsub.v1.PubsubMessage\".", + "\n\026GetSubscriptionRequest\022\024\n\014subscription" + + "\030\001 \001(\t\"R\n\030ListSubscriptionsRequest\022\017\n\007pr" + + "oject\030\001 \001(\t\022\021\n\tpage_size\030\002 \001(\005\022\022\n\npage_t" + + "oken\030\003 \001(\t\"k\n\031ListSubscriptionsResponse\022" + + "5\n\rsubscriptions\030\001 \003(\0132\036.google.pubsub.v" + + "1.Subscription\022\027\n\017next_page_token\030\002 \001(\t\"" + + "1\n\031DeleteSubscriptionRequest\022\024\n\014subscrip" + + "tion\030\001 \001(\t\"b\n\027ModifyPushConfigRequest\022\024\n" + + "\014subscription\030\001 \001(\t\0221\n\013push_config\030\002 \001(\013" + + "2\034.google.pubsub.v1.PushConfig\"U\n\013PullRe", + "quest\022\024\n\014subscription\030\001 \001(\t\022\032\n\022return_im" + + "mediately\030\002 \001(\010\022\024\n\014max_messages\030\003 \001(\005\"L\n" + + "\014PullResponse\022<\n\021received_messages\030\001 \003(\013" + + "2!.google.pubsub.v1.ReceivedMessage\"_\n\030M" + + "odifyAckDeadlineRequest\022\024\n\014subscription\030" + + "\001 \001(\t\022\017\n\007ack_ids\030\004 \003(\t\022\034\n\024ack_deadline_s" + + "econds\030\003 \001(\005\";\n\022AcknowledgeRequest\022\024\n\014su" + + "bscription\030\001 \001(\t\022\017\n\007ack_ids\030\002 \003(\t2\300\t\n\nSu" + + "bscriber\022\206\001\n\022CreateSubscription\022\036.google" + + ".pubsub.v1.Subscription\032\036.google.pubsub.", + "v1.Subscription\"0\202\323\344\223\002*\032%/v1/{name=proje" + + "cts/*/subscriptions/*}:\001*\022\222\001\n\017GetSubscri" + + "ption\022(.google.pubsub.v1.GetSubscription" + + "Request\032\036.google.pubsub.v1.Subscription\"" + + "5\202\323\344\223\002/\022-/v1/{subscription=projects/*/su" + + "bscriptions/*}\022\234\001\n\021ListSubscriptions\022*.g" + + "oogle.pubsub.v1.ListSubscriptionsRequest" + + "\032+.google.pubsub.v1.ListSubscriptionsRes" + + "ponse\".\202\323\344\223\002(\022&/v1/{project=projects/*}/" + + "subscriptions\022\220\001\n\022DeleteSubscription\022+.g", + "oogle.pubsub.v1.DeleteSubscriptionReques" + + "t\032\026.google.protobuf.Empty\"5\202\323\344\223\002/*-/v1/{" + + "subscription=projects/*/subscriptions/*}" + + "\022\243\001\n\021ModifyAckDeadline\022*.google.pubsub.v" + + "1.ModifyAckDeadlineRequest\032\026.google.prot" + + "obuf.Empty\"J\202\323\344\223\002D\"?/v1/{subscription=pr" + + "ojects/*/subscriptions/*}:modifyAckDeadl" + + "ine:\001*\022\221\001\n\013Acknowledge\022$.google.pubsub.v" + + "1.AcknowledgeRequest\032\026.google.protobuf.E" + + "mpty\"D\202\323\344\223\002>\"9/v1/{subscription=projects", + "/*/subscriptions/*}:acknowledge:\001*\022\204\001\n\004P" + + "ull\022\035.google.pubsub.v1.PullRequest\032\036.goo" + + "gle.pubsub.v1.PullResponse\"=\202\323\344\223\0027\"2/v1/" + + "{subscription=projects/*/subscriptions/*" + + "}:pull:\001*\022\240\001\n\020ModifyPushConfig\022).google." + + "pubsub.v1.ModifyPushConfigRequest\032\026.goog" + + "le.protobuf.Empty\"I\202\323\344\223\002C\">/v1/{subscrip" + + "tion=projects/*/subscriptions/*}:modifyP" + + "ushConfig:\001*2\233\006\n\tPublisher\022j\n\013CreateTopi" + + "c\022\027.google.pubsub.v1.Topic\032\027.google.pubs", + "ub.v1.Topic\")\202\323\344\223\002#\032\036/v1/{name=projects/" + + "*/topics/*}:\001*\022\202\001\n\007Publish\022 .google.pubs" + + "ub.v1.PublishRequest\032!.google.pubsub.v1." + + "PublishResponse\"2\202\323\344\223\002,\"\'/v1/{topic=proj" + + "ects/*/topics/*}:publish:\001*\022o\n\010GetTopic\022" + + "!.google.pubsub.v1.GetTopicRequest\032\027.goo" + + "gle.pubsub.v1.Topic\"\'\202\323\344\223\002!\022\037/v1/{topic=" + + "projects/*/topics/*}\022\200\001\n\nListTopics\022#.go" + + "ogle.pubsub.v1.ListTopicsRequest\032$.googl" + + "e.pubsub.v1.ListTopicsResponse\"\'\202\323\344\223\002!\022\037", + "/v1/{project=projects/*}/topics\022\262\001\n\026List" + + "TopicSubscriptions\022/.google.pubsub.v1.Li" + + "stTopicSubscriptionsRequest\0320.google.pub" + + "sub.v1.ListTopicSubscriptionsResponse\"5\202" + + "\323\344\223\002/\022-/v1/{topic=projects/*/topics/*}/s" + + "ubscriptions\022t\n\013DeleteTopic\022$.google.pub" + + "sub.v1.DeleteTopicRequest\032\026.google.proto" + + "buf.Empty\"\'\202\323\344\223\002!*\037/v1/{topic=projects/*" + + "/topics/*}B%\n\024com.google.pubsub.v1B\013Pubs" + + "ubProtoP\001b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + com.google.protobuf.EmptyProto.getDescriptor(), + }, assigner); + internal_static_google_pubsub_v1_Topic_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_pubsub_v1_Topic_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_Topic_descriptor, + new java.lang.String[] { "Name", }); + internal_static_google_pubsub_v1_PubsubMessage_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_pubsub_v1_PubsubMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_PubsubMessage_descriptor, + new java.lang.String[] { "Data", "Attributes", "MessageId", }); + internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_descriptor = + internal_static_google_pubsub_v1_PubsubMessage_descriptor.getNestedTypes().get(0); + internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_google_pubsub_v1_GetTopicRequest_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_pubsub_v1_GetTopicRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_GetTopicRequest_descriptor, + new java.lang.String[] { "Topic", }); + internal_static_google_pubsub_v1_PublishRequest_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_pubsub_v1_PublishRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_PublishRequest_descriptor, + new java.lang.String[] { "Topic", "Messages", }); + internal_static_google_pubsub_v1_PublishResponse_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_pubsub_v1_PublishResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_PublishResponse_descriptor, + new java.lang.String[] { "MessageIds", }); + internal_static_google_pubsub_v1_ListTopicsRequest_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_pubsub_v1_ListTopicsRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_ListTopicsRequest_descriptor, + new java.lang.String[] { "Project", "PageSize", "PageToken", }); + internal_static_google_pubsub_v1_ListTopicsResponse_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_google_pubsub_v1_ListTopicsResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_ListTopicsResponse_descriptor, + new java.lang.String[] { "Topics", "NextPageToken", }); + internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor, + new java.lang.String[] { "Topic", "PageSize", "PageToken", }); + internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor, + new java.lang.String[] { "Subscriptions", "NextPageToken", }); + internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_google_pubsub_v1_DeleteTopicRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor, + new java.lang.String[] { "Topic", }); + internal_static_google_pubsub_v1_Subscription_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_google_pubsub_v1_Subscription_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_Subscription_descriptor, + new java.lang.String[] { "Name", "Topic", "PushConfig", "AckDeadlineSeconds", }); + internal_static_google_pubsub_v1_PushConfig_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_google_pubsub_v1_PushConfig_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_PushConfig_descriptor, + new java.lang.String[] { "PushEndpoint", "Attributes", }); + internal_static_google_pubsub_v1_PushConfig_AttributesEntry_descriptor = + internal_static_google_pubsub_v1_PushConfig_descriptor.getNestedTypes().get(0); + internal_static_google_pubsub_v1_PushConfig_AttributesEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_PushConfig_AttributesEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_google_pubsub_v1_ReceivedMessage_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_google_pubsub_v1_ReceivedMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_ReceivedMessage_descriptor, + new java.lang.String[] { "AckId", "Message", }); + internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor = + getDescriptor().getMessageTypes().get(13); + internal_static_google_pubsub_v1_GetSubscriptionRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor, + new java.lang.String[] { "Subscription", }); + internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor = + getDescriptor().getMessageTypes().get(14); + internal_static_google_pubsub_v1_ListSubscriptionsRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor, + new java.lang.String[] { "Project", "PageSize", "PageToken", }); + internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor = + getDescriptor().getMessageTypes().get(15); + internal_static_google_pubsub_v1_ListSubscriptionsResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor, + new java.lang.String[] { "Subscriptions", "NextPageToken", }); + internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor = + getDescriptor().getMessageTypes().get(16); + internal_static_google_pubsub_v1_DeleteSubscriptionRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor, + new java.lang.String[] { "Subscription", }); + internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor = + getDescriptor().getMessageTypes().get(17); + internal_static_google_pubsub_v1_ModifyPushConfigRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor, + new java.lang.String[] { "Subscription", "PushConfig", }); + internal_static_google_pubsub_v1_PullRequest_descriptor = + getDescriptor().getMessageTypes().get(18); + internal_static_google_pubsub_v1_PullRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_PullRequest_descriptor, + new java.lang.String[] { "Subscription", "ReturnImmediately", "MaxMessages", }); + internal_static_google_pubsub_v1_PullResponse_descriptor = + getDescriptor().getMessageTypes().get(19); + internal_static_google_pubsub_v1_PullResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_PullResponse_descriptor, + new java.lang.String[] { "ReceivedMessages", }); + internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor = + getDescriptor().getMessageTypes().get(20); + internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor, + new java.lang.String[] { "Subscription", "AckIds", "AckDeadlineSeconds", }); + internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor = + getDescriptor().getMessageTypes().get(21); + internal_static_google_pubsub_v1_AcknowledgeRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor, + new java.lang.String[] { "Subscription", "AckIds", }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.AnnotationsProto.http); + com.google.protobuf.Descriptors.FileDescriptor + .internalUpdateFileDescriptor(descriptor, registry); + com.google.api.AnnotationsProto.getDescriptor(); + com.google.protobuf.EmptyProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequest.java new file mode 100644 index 000000000000..faab0adbe20d --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequest.java @@ -0,0 +1,636 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.PullRequest} + * + *
      + * Request for the Pull method.
      + * 
      + */ +public final class PullRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.PullRequest) + PullRequestOrBuilder { + // Use PullRequest.newBuilder() to construct. + private PullRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private PullRequest() { + subscription_ = ""; + returnImmediately_ = false; + maxMessages_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private PullRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + subscription_ = s; + break; + } + case 16: { + + returnImmediately_ = input.readBool(); + break; + } + case 24: { + + maxMessages_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PullRequest.class, com.google.pubsub.v1.PullRequest.Builder.class); + } + + public static final int SUBSCRIPTION_FIELD_NUMBER = 1; + private volatile java.lang.Object subscription_; + /** + * optional string subscription = 1; + * + *
      +   * The subscription from which messages should be pulled.
      +   * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } + } + /** + * optional string subscription = 1; + * + *
      +   * The subscription from which messages should be pulled.
      +   * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RETURN_IMMEDIATELY_FIELD_NUMBER = 2; + private boolean returnImmediately_; + /** + * optional bool return_immediately = 2; + * + *
      +   * If this is specified as true the system will respond immediately even if
      +   * it is not able to return a message in the Pull response. Otherwise the
      +   * system is allowed to wait until at least one message is available rather
      +   * than returning no messages. The client may cancel the request if it does
      +   * not wish to wait any longer for the response.
      +   * 
      + */ + public boolean getReturnImmediately() { + return returnImmediately_; + } + + public static final int MAX_MESSAGES_FIELD_NUMBER = 3; + private int maxMessages_; + /** + * optional int32 max_messages = 3; + * + *
      +   * The maximum number of messages returned for this request. The Pub/Sub
      +   * system may return fewer than the number specified.
      +   * 
      + */ + public int getMaxMessages() { + return maxMessages_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getSubscriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); + } + if (returnImmediately_ != false) { + output.writeBool(2, returnImmediately_); + } + if (maxMessages_ != 0) { + output.writeInt32(3, maxMessages_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getSubscriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); + } + if (returnImmediately_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(2, returnImmediately_); + } + if (maxMessages_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, maxMessages_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.PullRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PullRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PullRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PullRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PullRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PullRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PullRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.PullRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PullRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PullRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.PullRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.PullRequest} + * + *
      +   * Request for the Pull method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PullRequest) + com.google.pubsub.v1.PullRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PullRequest.class, com.google.pubsub.v1.PullRequest.Builder.class); + } + + // Construct using com.google.pubsub.v1.PullRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + subscription_ = ""; + + returnImmediately_ = false; + + maxMessages_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullRequest_descriptor; + } + + public com.google.pubsub.v1.PullRequest getDefaultInstanceForType() { + return com.google.pubsub.v1.PullRequest.getDefaultInstance(); + } + + public com.google.pubsub.v1.PullRequest build() { + com.google.pubsub.v1.PullRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.PullRequest buildPartial() { + com.google.pubsub.v1.PullRequest result = new com.google.pubsub.v1.PullRequest(this); + result.subscription_ = subscription_; + result.returnImmediately_ = returnImmediately_; + result.maxMessages_ = maxMessages_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.PullRequest) { + return mergeFrom((com.google.pubsub.v1.PullRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.PullRequest other) { + if (other == com.google.pubsub.v1.PullRequest.getDefaultInstance()) return this; + if (!other.getSubscription().isEmpty()) { + subscription_ = other.subscription_; + onChanged(); + } + if (other.getReturnImmediately() != false) { + setReturnImmediately(other.getReturnImmediately()); + } + if (other.getMaxMessages() != 0) { + setMaxMessages(other.getMaxMessages()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.PullRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.PullRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object subscription_ = ""; + /** + * optional string subscription = 1; + * + *
      +     * The subscription from which messages should be pulled.
      +     * 
      + */ + public java.lang.String getSubscription() { + java.lang.Object ref = subscription_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscription_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription from which messages should be pulled.
      +     * 
      + */ + public com.google.protobuf.ByteString + getSubscriptionBytes() { + java.lang.Object ref = subscription_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscription_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription from which messages should be pulled.
      +     * 
      + */ + public Builder setSubscription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + subscription_ = value; + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription from which messages should be pulled.
      +     * 
      + */ + public Builder clearSubscription() { + + subscription_ = getDefaultInstance().getSubscription(); + onChanged(); + return this; + } + /** + * optional string subscription = 1; + * + *
      +     * The subscription from which messages should be pulled.
      +     * 
      + */ + public Builder setSubscriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + subscription_ = value; + onChanged(); + return this; + } + + private boolean returnImmediately_ ; + /** + * optional bool return_immediately = 2; + * + *
      +     * If this is specified as true the system will respond immediately even if
      +     * it is not able to return a message in the Pull response. Otherwise the
      +     * system is allowed to wait until at least one message is available rather
      +     * than returning no messages. The client may cancel the request if it does
      +     * not wish to wait any longer for the response.
      +     * 
      + */ + public boolean getReturnImmediately() { + return returnImmediately_; + } + /** + * optional bool return_immediately = 2; + * + *
      +     * If this is specified as true the system will respond immediately even if
      +     * it is not able to return a message in the Pull response. Otherwise the
      +     * system is allowed to wait until at least one message is available rather
      +     * than returning no messages. The client may cancel the request if it does
      +     * not wish to wait any longer for the response.
      +     * 
      + */ + public Builder setReturnImmediately(boolean value) { + + returnImmediately_ = value; + onChanged(); + return this; + } + /** + * optional bool return_immediately = 2; + * + *
      +     * If this is specified as true the system will respond immediately even if
      +     * it is not able to return a message in the Pull response. Otherwise the
      +     * system is allowed to wait until at least one message is available rather
      +     * than returning no messages. The client may cancel the request if it does
      +     * not wish to wait any longer for the response.
      +     * 
      + */ + public Builder clearReturnImmediately() { + + returnImmediately_ = false; + onChanged(); + return this; + } + + private int maxMessages_ ; + /** + * optional int32 max_messages = 3; + * + *
      +     * The maximum number of messages returned for this request. The Pub/Sub
      +     * system may return fewer than the number specified.
      +     * 
      + */ + public int getMaxMessages() { + return maxMessages_; + } + /** + * optional int32 max_messages = 3; + * + *
      +     * The maximum number of messages returned for this request. The Pub/Sub
      +     * system may return fewer than the number specified.
      +     * 
      + */ + public Builder setMaxMessages(int value) { + + maxMessages_ = value; + onChanged(); + return this; + } + /** + * optional int32 max_messages = 3; + * + *
      +     * The maximum number of messages returned for this request. The Pub/Sub
      +     * system may return fewer than the number specified.
      +     * 
      + */ + public Builder clearMaxMessages() { + + maxMessages_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PullRequest) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.PullRequest) + private static final com.google.pubsub.v1.PullRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.PullRequest(); + } + + public static com.google.pubsub.v1.PullRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PullRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new PullRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.PullRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequestOrBuilder.java new file mode 100644 index 000000000000..698925a51401 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequestOrBuilder.java @@ -0,0 +1,50 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface PullRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PullRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string subscription = 1; + * + *
      +   * The subscription from which messages should be pulled.
      +   * 
      + */ + java.lang.String getSubscription(); + /** + * optional string subscription = 1; + * + *
      +   * The subscription from which messages should be pulled.
      +   * 
      + */ + com.google.protobuf.ByteString + getSubscriptionBytes(); + + /** + * optional bool return_immediately = 2; + * + *
      +   * If this is specified as true the system will respond immediately even if
      +   * it is not able to return a message in the Pull response. Otherwise the
      +   * system is allowed to wait until at least one message is available rather
      +   * than returning no messages. The client may cancel the request if it does
      +   * not wish to wait any longer for the response.
      +   * 
      + */ + boolean getReturnImmediately(); + + /** + * optional int32 max_messages = 3; + * + *
      +   * The maximum number of messages returned for this request. The Pub/Sub
      +   * system may return fewer than the number specified.
      +   * 
      + */ + int getMaxMessages(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponse.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponse.java new file mode 100644 index 000000000000..738e34b0137d --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponse.java @@ -0,0 +1,824 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.PullResponse} + * + *
      + * Response for the Pull method.
      + * 
      + */ +public final class PullResponse extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.PullResponse) + PullResponseOrBuilder { + // Use PullResponse.newBuilder() to construct. + private PullResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private PullResponse() { + receivedMessages_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private PullResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + receivedMessages_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + receivedMessages_.add(input.readMessage(com.google.pubsub.v1.ReceivedMessage.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + receivedMessages_ = java.util.Collections.unmodifiableList(receivedMessages_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PullResponse.class, com.google.pubsub.v1.PullResponse.Builder.class); + } + + public static final int RECEIVED_MESSAGES_FIELD_NUMBER = 1; + private java.util.List receivedMessages_; + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +   * there are no more available in the backlog. The Pub/Sub system may return
      +   * fewer than the maxMessages requested even if there are more messages
      +   * available in the backlog.
      +   * 
      + */ + public java.util.List getReceivedMessagesList() { + return receivedMessages_; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +   * there are no more available in the backlog. The Pub/Sub system may return
      +   * fewer than the maxMessages requested even if there are more messages
      +   * available in the backlog.
      +   * 
      + */ + public java.util.List + getReceivedMessagesOrBuilderList() { + return receivedMessages_; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +   * there are no more available in the backlog. The Pub/Sub system may return
      +   * fewer than the maxMessages requested even if there are more messages
      +   * available in the backlog.
      +   * 
      + */ + public int getReceivedMessagesCount() { + return receivedMessages_.size(); + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +   * there are no more available in the backlog. The Pub/Sub system may return
      +   * fewer than the maxMessages requested even if there are more messages
      +   * available in the backlog.
      +   * 
      + */ + public com.google.pubsub.v1.ReceivedMessage getReceivedMessages(int index) { + return receivedMessages_.get(index); + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +   * there are no more available in the backlog. The Pub/Sub system may return
      +   * fewer than the maxMessages requested even if there are more messages
      +   * available in the backlog.
      +   * 
      + */ + public com.google.pubsub.v1.ReceivedMessageOrBuilder getReceivedMessagesOrBuilder( + int index) { + return receivedMessages_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < receivedMessages_.size(); i++) { + output.writeMessage(1, receivedMessages_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < receivedMessages_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, receivedMessages_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.PullResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PullResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PullResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PullResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PullResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PullResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PullResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.PullResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PullResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PullResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.PullResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.PullResponse} + * + *
      +   * Response for the Pull method.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PullResponse) + com.google.pubsub.v1.PullResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullResponse_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PullResponse.class, com.google.pubsub.v1.PullResponse.Builder.class); + } + + // Construct using com.google.pubsub.v1.PullResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getReceivedMessagesFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (receivedMessagesBuilder_ == null) { + receivedMessages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + receivedMessagesBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullResponse_descriptor; + } + + public com.google.pubsub.v1.PullResponse getDefaultInstanceForType() { + return com.google.pubsub.v1.PullResponse.getDefaultInstance(); + } + + public com.google.pubsub.v1.PullResponse build() { + com.google.pubsub.v1.PullResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.PullResponse buildPartial() { + com.google.pubsub.v1.PullResponse result = new com.google.pubsub.v1.PullResponse(this); + int from_bitField0_ = bitField0_; + if (receivedMessagesBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + receivedMessages_ = java.util.Collections.unmodifiableList(receivedMessages_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.receivedMessages_ = receivedMessages_; + } else { + result.receivedMessages_ = receivedMessagesBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.PullResponse) { + return mergeFrom((com.google.pubsub.v1.PullResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.PullResponse other) { + if (other == com.google.pubsub.v1.PullResponse.getDefaultInstance()) return this; + if (receivedMessagesBuilder_ == null) { + if (!other.receivedMessages_.isEmpty()) { + if (receivedMessages_.isEmpty()) { + receivedMessages_ = other.receivedMessages_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureReceivedMessagesIsMutable(); + receivedMessages_.addAll(other.receivedMessages_); + } + onChanged(); + } + } else { + if (!other.receivedMessages_.isEmpty()) { + if (receivedMessagesBuilder_.isEmpty()) { + receivedMessagesBuilder_.dispose(); + receivedMessagesBuilder_ = null; + receivedMessages_ = other.receivedMessages_; + bitField0_ = (bitField0_ & ~0x00000001); + receivedMessagesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getReceivedMessagesFieldBuilder() : null; + } else { + receivedMessagesBuilder_.addAllMessages(other.receivedMessages_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.PullResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.PullResponse) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List receivedMessages_ = + java.util.Collections.emptyList(); + private void ensureReceivedMessagesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + receivedMessages_ = new java.util.ArrayList(receivedMessages_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.ReceivedMessage, com.google.pubsub.v1.ReceivedMessage.Builder, com.google.pubsub.v1.ReceivedMessageOrBuilder> receivedMessagesBuilder_; + + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public java.util.List getReceivedMessagesList() { + if (receivedMessagesBuilder_ == null) { + return java.util.Collections.unmodifiableList(receivedMessages_); + } else { + return receivedMessagesBuilder_.getMessageList(); + } + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public int getReceivedMessagesCount() { + if (receivedMessagesBuilder_ == null) { + return receivedMessages_.size(); + } else { + return receivedMessagesBuilder_.getCount(); + } + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public com.google.pubsub.v1.ReceivedMessage getReceivedMessages(int index) { + if (receivedMessagesBuilder_ == null) { + return receivedMessages_.get(index); + } else { + return receivedMessagesBuilder_.getMessage(index); + } + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public Builder setReceivedMessages( + int index, com.google.pubsub.v1.ReceivedMessage value) { + if (receivedMessagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureReceivedMessagesIsMutable(); + receivedMessages_.set(index, value); + onChanged(); + } else { + receivedMessagesBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public Builder setReceivedMessages( + int index, com.google.pubsub.v1.ReceivedMessage.Builder builderForValue) { + if (receivedMessagesBuilder_ == null) { + ensureReceivedMessagesIsMutable(); + receivedMessages_.set(index, builderForValue.build()); + onChanged(); + } else { + receivedMessagesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public Builder addReceivedMessages(com.google.pubsub.v1.ReceivedMessage value) { + if (receivedMessagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureReceivedMessagesIsMutable(); + receivedMessages_.add(value); + onChanged(); + } else { + receivedMessagesBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public Builder addReceivedMessages( + int index, com.google.pubsub.v1.ReceivedMessage value) { + if (receivedMessagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureReceivedMessagesIsMutable(); + receivedMessages_.add(index, value); + onChanged(); + } else { + receivedMessagesBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public Builder addReceivedMessages( + com.google.pubsub.v1.ReceivedMessage.Builder builderForValue) { + if (receivedMessagesBuilder_ == null) { + ensureReceivedMessagesIsMutable(); + receivedMessages_.add(builderForValue.build()); + onChanged(); + } else { + receivedMessagesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public Builder addReceivedMessages( + int index, com.google.pubsub.v1.ReceivedMessage.Builder builderForValue) { + if (receivedMessagesBuilder_ == null) { + ensureReceivedMessagesIsMutable(); + receivedMessages_.add(index, builderForValue.build()); + onChanged(); + } else { + receivedMessagesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public Builder addAllReceivedMessages( + java.lang.Iterable values) { + if (receivedMessagesBuilder_ == null) { + ensureReceivedMessagesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, receivedMessages_); + onChanged(); + } else { + receivedMessagesBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public Builder clearReceivedMessages() { + if (receivedMessagesBuilder_ == null) { + receivedMessages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + receivedMessagesBuilder_.clear(); + } + return this; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public Builder removeReceivedMessages(int index) { + if (receivedMessagesBuilder_ == null) { + ensureReceivedMessagesIsMutable(); + receivedMessages_.remove(index); + onChanged(); + } else { + receivedMessagesBuilder_.remove(index); + } + return this; + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public com.google.pubsub.v1.ReceivedMessage.Builder getReceivedMessagesBuilder( + int index) { + return getReceivedMessagesFieldBuilder().getBuilder(index); + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public com.google.pubsub.v1.ReceivedMessageOrBuilder getReceivedMessagesOrBuilder( + int index) { + if (receivedMessagesBuilder_ == null) { + return receivedMessages_.get(index); } else { + return receivedMessagesBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public java.util.List + getReceivedMessagesOrBuilderList() { + if (receivedMessagesBuilder_ != null) { + return receivedMessagesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(receivedMessages_); + } + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public com.google.pubsub.v1.ReceivedMessage.Builder addReceivedMessagesBuilder() { + return getReceivedMessagesFieldBuilder().addBuilder( + com.google.pubsub.v1.ReceivedMessage.getDefaultInstance()); + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public com.google.pubsub.v1.ReceivedMessage.Builder addReceivedMessagesBuilder( + int index) { + return getReceivedMessagesFieldBuilder().addBuilder( + index, com.google.pubsub.v1.ReceivedMessage.getDefaultInstance()); + } + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +     * there are no more available in the backlog. The Pub/Sub system may return
      +     * fewer than the maxMessages requested even if there are more messages
      +     * available in the backlog.
      +     * 
      + */ + public java.util.List + getReceivedMessagesBuilderList() { + return getReceivedMessagesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.ReceivedMessage, com.google.pubsub.v1.ReceivedMessage.Builder, com.google.pubsub.v1.ReceivedMessageOrBuilder> + getReceivedMessagesFieldBuilder() { + if (receivedMessagesBuilder_ == null) { + receivedMessagesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + com.google.pubsub.v1.ReceivedMessage, com.google.pubsub.v1.ReceivedMessage.Builder, com.google.pubsub.v1.ReceivedMessageOrBuilder>( + receivedMessages_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + receivedMessages_ = null; + } + return receivedMessagesBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PullResponse) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.PullResponse) + private static final com.google.pubsub.v1.PullResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.PullResponse(); + } + + public static com.google.pubsub.v1.PullResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PullResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new PullResponse(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.PullResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponseOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponseOrBuilder.java new file mode 100644 index 000000000000..a93ac1757e3b --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponseOrBuilder.java @@ -0,0 +1,68 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface PullResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PullResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +   * there are no more available in the backlog. The Pub/Sub system may return
      +   * fewer than the maxMessages requested even if there are more messages
      +   * available in the backlog.
      +   * 
      + */ + java.util.List + getReceivedMessagesList(); + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +   * there are no more available in the backlog. The Pub/Sub system may return
      +   * fewer than the maxMessages requested even if there are more messages
      +   * available in the backlog.
      +   * 
      + */ + com.google.pubsub.v1.ReceivedMessage getReceivedMessages(int index); + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +   * there are no more available in the backlog. The Pub/Sub system may return
      +   * fewer than the maxMessages requested even if there are more messages
      +   * available in the backlog.
      +   * 
      + */ + int getReceivedMessagesCount(); + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +   * there are no more available in the backlog. The Pub/Sub system may return
      +   * fewer than the maxMessages requested even if there are more messages
      +   * available in the backlog.
      +   * 
      + */ + java.util.List + getReceivedMessagesOrBuilderList(); + /** + * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; + * + *
      +   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      +   * there are no more available in the backlog. The Pub/Sub system may return
      +   * fewer than the maxMessages requested even if there are more messages
      +   * available in the backlog.
      +   * 
      + */ + com.google.pubsub.v1.ReceivedMessageOrBuilder getReceivedMessagesOrBuilder( + int index); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfig.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfig.java new file mode 100644 index 000000000000..fc8c34dc5be5 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfig.java @@ -0,0 +1,711 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.PushConfig} + * + *
      + * Configuration for a push delivery endpoint.
      + * 
      + */ +public final class PushConfig extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.PushConfig) + PushConfigOrBuilder { + // Use PushConfig.newBuilder() to construct. + private PushConfig(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private PushConfig() { + pushEndpoint_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private PushConfig( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + pushEndpoint_ = s; + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + attributes_ = com.google.protobuf.MapField.newMapField( + AttributesDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000002; + } + com.google.protobuf.MapEntry + attributes = input.readMessage( + AttributesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + attributes_.getMutableMap().put(attributes.getKey(), attributes.getValue()); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 2: + return internalGetAttributes(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PushConfig.class, com.google.pubsub.v1.PushConfig.Builder.class); + } + + private int bitField0_; + public static final int PUSH_ENDPOINT_FIELD_NUMBER = 1; + private volatile java.lang.Object pushEndpoint_; + /** + * optional string push_endpoint = 1; + * + *
      +   * A URL locating the endpoint to which messages should be pushed.
      +   * For example, a Webhook endpoint might use "https://example.com/push".
      +   * 
      + */ + public java.lang.String getPushEndpoint() { + java.lang.Object ref = pushEndpoint_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pushEndpoint_ = s; + return s; + } + } + /** + * optional string push_endpoint = 1; + * + *
      +   * A URL locating the endpoint to which messages should be pushed.
      +   * For example, a Webhook endpoint might use "https://example.com/push".
      +   * 
      + */ + public com.google.protobuf.ByteString + getPushEndpointBytes() { + java.lang.Object ref = pushEndpoint_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + pushEndpoint_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ATTRIBUTES_FIELD_NUMBER = 2; + private static final class AttributesDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_AttributesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> attributes_; + private com.google.protobuf.MapField + internalGetAttributes() { + if (attributes_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AttributesDefaultEntryHolder.defaultEntry); + } + return attributes_; + } + /** + * map<string, string> attributes = 2; + * + *
      +   * Endpoint configuration attributes.
      +   * Every endpoint has a set of API supported attributes that can be used to
      +   * control different aspects of the message delivery.
      +   * The currently supported attribute is `x-goog-version`, which you can
      +   * use to change the format of the push message. This attribute
      +   * indicates the version of the data expected by the endpoint. This
      +   * controls the shape of the envelope (i.e. its fields and metadata).
      +   * The endpoint version is based on the version of the Pub/Sub
      +   * API.
      +   * If not present during the CreateSubscription call, it will default to
      +   * the version of the API used to make such call. If not present during a
      +   * ModifyPushConfig call, its value will not be changed. GetSubscription
      +   * calls will always return a valid version, even if the subscription was
      +   * created without this attribute.
      +   * The possible values for this attribute are:
      +   * * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
      +   * * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
      +   * 
      + */ + + public java.util.Map getAttributes() { + return internalGetAttributes().getMap(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getPushEndpointBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, pushEndpoint_); + } + for (java.util.Map.Entry entry + : internalGetAttributes().getMap().entrySet()) { + com.google.protobuf.MapEntry + attributes = AttributesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + output.writeMessage(2, attributes); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getPushEndpointBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, pushEndpoint_); + } + for (java.util.Map.Entry entry + : internalGetAttributes().getMap().entrySet()) { + com.google.protobuf.MapEntry + attributes = AttributesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, attributes); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.PushConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PushConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PushConfig parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.PushConfig parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.PushConfig parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PushConfig parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PushConfig parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.PushConfig parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.PushConfig parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.PushConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.PushConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.PushConfig} + * + *
      +   * Configuration for a push delivery endpoint.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PushConfig) + com.google.pubsub.v1.PushConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 2: + return internalGetAttributes(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 2: + return internalGetMutableAttributes(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.PushConfig.class, com.google.pubsub.v1.PushConfig.Builder.class); + } + + // Construct using com.google.pubsub.v1.PushConfig.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + pushEndpoint_ = ""; + + internalGetMutableAttributes().clear(); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_descriptor; + } + + public com.google.pubsub.v1.PushConfig getDefaultInstanceForType() { + return com.google.pubsub.v1.PushConfig.getDefaultInstance(); + } + + public com.google.pubsub.v1.PushConfig build() { + com.google.pubsub.v1.PushConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.PushConfig buildPartial() { + com.google.pubsub.v1.PushConfig result = new com.google.pubsub.v1.PushConfig(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.pushEndpoint_ = pushEndpoint_; + result.attributes_ = internalGetAttributes(); + result.attributes_.makeImmutable(); + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.PushConfig) { + return mergeFrom((com.google.pubsub.v1.PushConfig)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.PushConfig other) { + if (other == com.google.pubsub.v1.PushConfig.getDefaultInstance()) return this; + if (!other.getPushEndpoint().isEmpty()) { + pushEndpoint_ = other.pushEndpoint_; + onChanged(); + } + internalGetMutableAttributes().mergeFrom( + other.internalGetAttributes()); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.PushConfig parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.PushConfig) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object pushEndpoint_ = ""; + /** + * optional string push_endpoint = 1; + * + *
      +     * A URL locating the endpoint to which messages should be pushed.
      +     * For example, a Webhook endpoint might use "https://example.com/push".
      +     * 
      + */ + public java.lang.String getPushEndpoint() { + java.lang.Object ref = pushEndpoint_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pushEndpoint_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string push_endpoint = 1; + * + *
      +     * A URL locating the endpoint to which messages should be pushed.
      +     * For example, a Webhook endpoint might use "https://example.com/push".
      +     * 
      + */ + public com.google.protobuf.ByteString + getPushEndpointBytes() { + java.lang.Object ref = pushEndpoint_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + pushEndpoint_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string push_endpoint = 1; + * + *
      +     * A URL locating the endpoint to which messages should be pushed.
      +     * For example, a Webhook endpoint might use "https://example.com/push".
      +     * 
      + */ + public Builder setPushEndpoint( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + pushEndpoint_ = value; + onChanged(); + return this; + } + /** + * optional string push_endpoint = 1; + * + *
      +     * A URL locating the endpoint to which messages should be pushed.
      +     * For example, a Webhook endpoint might use "https://example.com/push".
      +     * 
      + */ + public Builder clearPushEndpoint() { + + pushEndpoint_ = getDefaultInstance().getPushEndpoint(); + onChanged(); + return this; + } + /** + * optional string push_endpoint = 1; + * + *
      +     * A URL locating the endpoint to which messages should be pushed.
      +     * For example, a Webhook endpoint might use "https://example.com/push".
      +     * 
      + */ + public Builder setPushEndpointBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + pushEndpoint_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> attributes_; + private com.google.protobuf.MapField + internalGetAttributes() { + if (attributes_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AttributesDefaultEntryHolder.defaultEntry); + } + return attributes_; + } + private com.google.protobuf.MapField + internalGetMutableAttributes() { + onChanged();; + if (attributes_ == null) { + attributes_ = com.google.protobuf.MapField.newMapField( + AttributesDefaultEntryHolder.defaultEntry); + } + if (!attributes_.isMutable()) { + attributes_ = attributes_.copy(); + } + return attributes_; + } + /** + * map<string, string> attributes = 2; + * + *
      +     * Endpoint configuration attributes.
      +     * Every endpoint has a set of API supported attributes that can be used to
      +     * control different aspects of the message delivery.
      +     * The currently supported attribute is `x-goog-version`, which you can
      +     * use to change the format of the push message. This attribute
      +     * indicates the version of the data expected by the endpoint. This
      +     * controls the shape of the envelope (i.e. its fields and metadata).
      +     * The endpoint version is based on the version of the Pub/Sub
      +     * API.
      +     * If not present during the CreateSubscription call, it will default to
      +     * the version of the API used to make such call. If not present during a
      +     * ModifyPushConfig call, its value will not be changed. GetSubscription
      +     * calls will always return a valid version, even if the subscription was
      +     * created without this attribute.
      +     * The possible values for this attribute are:
      +     * * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
      +     * * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
      +     * 
      + */ + public java.util.Map getAttributes() { + return internalGetAttributes().getMap(); + } + /** + * map<string, string> attributes = 2; + * + *
      +     * Endpoint configuration attributes.
      +     * Every endpoint has a set of API supported attributes that can be used to
      +     * control different aspects of the message delivery.
      +     * The currently supported attribute is `x-goog-version`, which you can
      +     * use to change the format of the push message. This attribute
      +     * indicates the version of the data expected by the endpoint. This
      +     * controls the shape of the envelope (i.e. its fields and metadata).
      +     * The endpoint version is based on the version of the Pub/Sub
      +     * API.
      +     * If not present during the CreateSubscription call, it will default to
      +     * the version of the API used to make such call. If not present during a
      +     * ModifyPushConfig call, its value will not be changed. GetSubscription
      +     * calls will always return a valid version, even if the subscription was
      +     * created without this attribute.
      +     * The possible values for this attribute are:
      +     * * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
      +     * * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
      +     * 
      + */ + public java.util.Map + getMutableAttributes() { + return internalGetMutableAttributes().getMutableMap(); + } + /** + * map<string, string> attributes = 2; + * + *
      +     * Endpoint configuration attributes.
      +     * Every endpoint has a set of API supported attributes that can be used to
      +     * control different aspects of the message delivery.
      +     * The currently supported attribute is `x-goog-version`, which you can
      +     * use to change the format of the push message. This attribute
      +     * indicates the version of the data expected by the endpoint. This
      +     * controls the shape of the envelope (i.e. its fields and metadata).
      +     * The endpoint version is based on the version of the Pub/Sub
      +     * API.
      +     * If not present during the CreateSubscription call, it will default to
      +     * the version of the API used to make such call. If not present during a
      +     * ModifyPushConfig call, its value will not be changed. GetSubscription
      +     * calls will always return a valid version, even if the subscription was
      +     * created without this attribute.
      +     * The possible values for this attribute are:
      +     * * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
      +     * * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
      +     * 
      + */ + public Builder putAllAttributes( + java.util.Map values) { + getMutableAttributes().putAll(values); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PushConfig) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.PushConfig) + private static final com.google.pubsub.v1.PushConfig DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.PushConfig(); + } + + public static com.google.pubsub.v1.PushConfig getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public PushConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new PushConfig(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.PushConfig getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfigOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfigOrBuilder.java new file mode 100644 index 000000000000..6a4e995b8232 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfigOrBuilder.java @@ -0,0 +1,55 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface PushConfigOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PushConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string push_endpoint = 1; + * + *
      +   * A URL locating the endpoint to which messages should be pushed.
      +   * For example, a Webhook endpoint might use "https://example.com/push".
      +   * 
      + */ + java.lang.String getPushEndpoint(); + /** + * optional string push_endpoint = 1; + * + *
      +   * A URL locating the endpoint to which messages should be pushed.
      +   * For example, a Webhook endpoint might use "https://example.com/push".
      +   * 
      + */ + com.google.protobuf.ByteString + getPushEndpointBytes(); + + /** + * map<string, string> attributes = 2; + * + *
      +   * Endpoint configuration attributes.
      +   * Every endpoint has a set of API supported attributes that can be used to
      +   * control different aspects of the message delivery.
      +   * The currently supported attribute is `x-goog-version`, which you can
      +   * use to change the format of the push message. This attribute
      +   * indicates the version of the data expected by the endpoint. This
      +   * controls the shape of the envelope (i.e. its fields and metadata).
      +   * The endpoint version is based on the version of the Pub/Sub
      +   * API.
      +   * If not present during the CreateSubscription call, it will default to
      +   * the version of the API used to make such call. If not present during a
      +   * ModifyPushConfig call, its value will not be changed. GetSubscription
      +   * calls will always return a valid version, even if the subscription was
      +   * created without this attribute.
      +   * The possible values for this attribute are:
      +   * * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
      +   * * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
      +   * 
      + */ + java.util.Map + getAttributes(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessage.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessage.java new file mode 100644 index 000000000000..091d0ca610b2 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessage.java @@ -0,0 +1,696 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.ReceivedMessage} + * + *
      + * A message and its corresponding acknowledgment ID.
      + * 
      + */ +public final class ReceivedMessage extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.ReceivedMessage) + ReceivedMessageOrBuilder { + // Use ReceivedMessage.newBuilder() to construct. + private ReceivedMessage(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ReceivedMessage() { + ackId_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ReceivedMessage( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + ackId_ = s; + break; + } + case 18: { + com.google.pubsub.v1.PubsubMessage.Builder subBuilder = null; + if (message_ != null) { + subBuilder = message_.toBuilder(); + } + message_ = input.readMessage(com.google.pubsub.v1.PubsubMessage.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(message_); + message_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ReceivedMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ReceivedMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ReceivedMessage.class, com.google.pubsub.v1.ReceivedMessage.Builder.class); + } + + public static final int ACK_ID_FIELD_NUMBER = 1; + private volatile java.lang.Object ackId_; + /** + * optional string ack_id = 1; + * + *
      +   * This ID can be used to acknowledge the received message.
      +   * 
      + */ + public java.lang.String getAckId() { + java.lang.Object ref = ackId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + ackId_ = s; + return s; + } + } + /** + * optional string ack_id = 1; + * + *
      +   * This ID can be used to acknowledge the received message.
      +   * 
      + */ + public com.google.protobuf.ByteString + getAckIdBytes() { + java.lang.Object ref = ackId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + ackId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MESSAGE_FIELD_NUMBER = 2; + private com.google.pubsub.v1.PubsubMessage message_; + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +   * The message.
      +   * 
      + */ + public boolean hasMessage() { + return message_ != null; + } + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +   * The message.
      +   * 
      + */ + public com.google.pubsub.v1.PubsubMessage getMessage() { + return message_ == null ? com.google.pubsub.v1.PubsubMessage.getDefaultInstance() : message_; + } + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +   * The message.
      +   * 
      + */ + public com.google.pubsub.v1.PubsubMessageOrBuilder getMessageOrBuilder() { + return getMessage(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getAckIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, ackId_); + } + if (message_ != null) { + output.writeMessage(2, getMessage()); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getAckIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, ackId_); + } + if (message_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getMessage()); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.ReceivedMessage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ReceivedMessage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ReceivedMessage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.ReceivedMessage parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.ReceivedMessage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ReceivedMessage parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ReceivedMessage parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.ReceivedMessage parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.ReceivedMessage parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.ReceivedMessage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.ReceivedMessage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.ReceivedMessage} + * + *
      +   * A message and its corresponding acknowledgment ID.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ReceivedMessage) + com.google.pubsub.v1.ReceivedMessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ReceivedMessage_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ReceivedMessage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.ReceivedMessage.class, com.google.pubsub.v1.ReceivedMessage.Builder.class); + } + + // Construct using com.google.pubsub.v1.ReceivedMessage.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + ackId_ = ""; + + if (messageBuilder_ == null) { + message_ = null; + } else { + message_ = null; + messageBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ReceivedMessage_descriptor; + } + + public com.google.pubsub.v1.ReceivedMessage getDefaultInstanceForType() { + return com.google.pubsub.v1.ReceivedMessage.getDefaultInstance(); + } + + public com.google.pubsub.v1.ReceivedMessage build() { + com.google.pubsub.v1.ReceivedMessage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.ReceivedMessage buildPartial() { + com.google.pubsub.v1.ReceivedMessage result = new com.google.pubsub.v1.ReceivedMessage(this); + result.ackId_ = ackId_; + if (messageBuilder_ == null) { + result.message_ = message_; + } else { + result.message_ = messageBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.ReceivedMessage) { + return mergeFrom((com.google.pubsub.v1.ReceivedMessage)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.ReceivedMessage other) { + if (other == com.google.pubsub.v1.ReceivedMessage.getDefaultInstance()) return this; + if (!other.getAckId().isEmpty()) { + ackId_ = other.ackId_; + onChanged(); + } + if (other.hasMessage()) { + mergeMessage(other.getMessage()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.ReceivedMessage parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.ReceivedMessage) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object ackId_ = ""; + /** + * optional string ack_id = 1; + * + *
      +     * This ID can be used to acknowledge the received message.
      +     * 
      + */ + public java.lang.String getAckId() { + java.lang.Object ref = ackId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + ackId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string ack_id = 1; + * + *
      +     * This ID can be used to acknowledge the received message.
      +     * 
      + */ + public com.google.protobuf.ByteString + getAckIdBytes() { + java.lang.Object ref = ackId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + ackId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string ack_id = 1; + * + *
      +     * This ID can be used to acknowledge the received message.
      +     * 
      + */ + public Builder setAckId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + ackId_ = value; + onChanged(); + return this; + } + /** + * optional string ack_id = 1; + * + *
      +     * This ID can be used to acknowledge the received message.
      +     * 
      + */ + public Builder clearAckId() { + + ackId_ = getDefaultInstance().getAckId(); + onChanged(); + return this; + } + /** + * optional string ack_id = 1; + * + *
      +     * This ID can be used to acknowledge the received message.
      +     * 
      + */ + public Builder setAckIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + ackId_ = value; + onChanged(); + return this; + } + + private com.google.pubsub.v1.PubsubMessage message_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder> messageBuilder_; + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +     * The message.
      +     * 
      + */ + public boolean hasMessage() { + return messageBuilder_ != null || message_ != null; + } + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +     * The message.
      +     * 
      + */ + public com.google.pubsub.v1.PubsubMessage getMessage() { + if (messageBuilder_ == null) { + return message_ == null ? com.google.pubsub.v1.PubsubMessage.getDefaultInstance() : message_; + } else { + return messageBuilder_.getMessage(); + } + } + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +     * The message.
      +     * 
      + */ + public Builder setMessage(com.google.pubsub.v1.PubsubMessage value) { + if (messageBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + message_ = value; + onChanged(); + } else { + messageBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +     * The message.
      +     * 
      + */ + public Builder setMessage( + com.google.pubsub.v1.PubsubMessage.Builder builderForValue) { + if (messageBuilder_ == null) { + message_ = builderForValue.build(); + onChanged(); + } else { + messageBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +     * The message.
      +     * 
      + */ + public Builder mergeMessage(com.google.pubsub.v1.PubsubMessage value) { + if (messageBuilder_ == null) { + if (message_ != null) { + message_ = + com.google.pubsub.v1.PubsubMessage.newBuilder(message_).mergeFrom(value).buildPartial(); + } else { + message_ = value; + } + onChanged(); + } else { + messageBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +     * The message.
      +     * 
      + */ + public Builder clearMessage() { + if (messageBuilder_ == null) { + message_ = null; + onChanged(); + } else { + message_ = null; + messageBuilder_ = null; + } + + return this; + } + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +     * The message.
      +     * 
      + */ + public com.google.pubsub.v1.PubsubMessage.Builder getMessageBuilder() { + + onChanged(); + return getMessageFieldBuilder().getBuilder(); + } + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +     * The message.
      +     * 
      + */ + public com.google.pubsub.v1.PubsubMessageOrBuilder getMessageOrBuilder() { + if (messageBuilder_ != null) { + return messageBuilder_.getMessageOrBuilder(); + } else { + return message_ == null ? + com.google.pubsub.v1.PubsubMessage.getDefaultInstance() : message_; + } + } + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +     * The message.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder> + getMessageFieldBuilder() { + if (messageBuilder_ == null) { + messageBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder>( + getMessage(), + getParentForChildren(), + isClean()); + message_ = null; + } + return messageBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ReceivedMessage) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.ReceivedMessage) + private static final com.google.pubsub.v1.ReceivedMessage DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.ReceivedMessage(); + } + + public static com.google.pubsub.v1.ReceivedMessage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ReceivedMessage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ReceivedMessage(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.ReceivedMessage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessageOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessageOrBuilder.java new file mode 100644 index 000000000000..c832555d57a4 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessageOrBuilder.java @@ -0,0 +1,52 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface ReceivedMessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ReceivedMessage) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string ack_id = 1; + * + *
      +   * This ID can be used to acknowledge the received message.
      +   * 
      + */ + java.lang.String getAckId(); + /** + * optional string ack_id = 1; + * + *
      +   * This ID can be used to acknowledge the received message.
      +   * 
      + */ + com.google.protobuf.ByteString + getAckIdBytes(); + + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +   * The message.
      +   * 
      + */ + boolean hasMessage(); + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +   * The message.
      +   * 
      + */ + com.google.pubsub.v1.PubsubMessage getMessage(); + /** + * optional .google.pubsub.v1.PubsubMessage message = 2; + * + *
      +   * The message.
      +   * 
      + */ + com.google.pubsub.v1.PubsubMessageOrBuilder getMessageOrBuilder(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriberGrpc.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriberGrpc.java new file mode 100644 index 000000000000..32c81fe096a5 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriberGrpc.java @@ -0,0 +1,506 @@ +package com.google.pubsub.v1; + +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; + +@javax.annotation.Generated("by gRPC proto compiler") +public class SubscriberGrpc { + + private SubscriberGrpc() {} + + public static final String SERVICE_NAME = "google.pubsub.v1.Subscriber"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_CREATE_SUBSCRIPTION = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Subscriber", "CreateSubscription"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Subscription.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Subscription.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_GET_SUBSCRIPTION = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Subscriber", "GetSubscription"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.GetSubscriptionRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Subscription.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_LIST_SUBSCRIPTIONS = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Subscriber", "ListSubscriptions"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListSubscriptionsRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListSubscriptionsResponse.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_DELETE_SUBSCRIPTION = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Subscriber", "DeleteSubscription"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.DeleteSubscriptionRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_MODIFY_ACK_DEADLINE = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Subscriber", "ModifyAckDeadline"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ModifyAckDeadlineRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_ACKNOWLEDGE = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Subscriber", "Acknowledge"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.AcknowledgeRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_PULL = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Subscriber", "Pull"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.PullRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.PullResponse.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_MODIFY_PUSH_CONFIG = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "google.pubsub.v1.Subscriber", "ModifyPushConfig"), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ModifyPushConfigRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); + + public static SubscriberStub newStub(io.grpc.Channel channel) { + return new SubscriberStub(channel); + } + + public static SubscriberBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new SubscriberBlockingStub(channel); + } + + public static SubscriberFutureStub newFutureStub( + io.grpc.Channel channel) { + return new SubscriberFutureStub(channel); + } + + public static interface Subscriber { + + public void createSubscription(com.google.pubsub.v1.Subscription request, + io.grpc.stub.StreamObserver responseObserver); + + public void getSubscription(com.google.pubsub.v1.GetSubscriptionRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void listSubscriptions(com.google.pubsub.v1.ListSubscriptionsRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void deleteSubscription(com.google.pubsub.v1.DeleteSubscriptionRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void modifyAckDeadline(com.google.pubsub.v1.ModifyAckDeadlineRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void acknowledge(com.google.pubsub.v1.AcknowledgeRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void pull(com.google.pubsub.v1.PullRequest request, + io.grpc.stub.StreamObserver responseObserver); + + public void modifyPushConfig(com.google.pubsub.v1.ModifyPushConfigRequest request, + io.grpc.stub.StreamObserver responseObserver); + } + + public static interface SubscriberBlockingClient { + + public com.google.pubsub.v1.Subscription createSubscription(com.google.pubsub.v1.Subscription request); + + public com.google.pubsub.v1.Subscription getSubscription(com.google.pubsub.v1.GetSubscriptionRequest request); + + public com.google.pubsub.v1.ListSubscriptionsResponse listSubscriptions(com.google.pubsub.v1.ListSubscriptionsRequest request); + + public com.google.protobuf.Empty deleteSubscription(com.google.pubsub.v1.DeleteSubscriptionRequest request); + + public com.google.protobuf.Empty modifyAckDeadline(com.google.pubsub.v1.ModifyAckDeadlineRequest request); + + public com.google.protobuf.Empty acknowledge(com.google.pubsub.v1.AcknowledgeRequest request); + + public com.google.pubsub.v1.PullResponse pull(com.google.pubsub.v1.PullRequest request); + + public com.google.protobuf.Empty modifyPushConfig(com.google.pubsub.v1.ModifyPushConfigRequest request); + } + + public static interface SubscriberFutureClient { + + public com.google.common.util.concurrent.ListenableFuture createSubscription( + com.google.pubsub.v1.Subscription request); + + public com.google.common.util.concurrent.ListenableFuture getSubscription( + com.google.pubsub.v1.GetSubscriptionRequest request); + + public com.google.common.util.concurrent.ListenableFuture listSubscriptions( + com.google.pubsub.v1.ListSubscriptionsRequest request); + + public com.google.common.util.concurrent.ListenableFuture deleteSubscription( + com.google.pubsub.v1.DeleteSubscriptionRequest request); + + public com.google.common.util.concurrent.ListenableFuture modifyAckDeadline( + com.google.pubsub.v1.ModifyAckDeadlineRequest request); + + public com.google.common.util.concurrent.ListenableFuture acknowledge( + com.google.pubsub.v1.AcknowledgeRequest request); + + public com.google.common.util.concurrent.ListenableFuture pull( + com.google.pubsub.v1.PullRequest request); + + public com.google.common.util.concurrent.ListenableFuture modifyPushConfig( + com.google.pubsub.v1.ModifyPushConfigRequest request); + } + + public static class SubscriberStub extends io.grpc.stub.AbstractStub + implements Subscriber { + private SubscriberStub(io.grpc.Channel channel) { + super(channel); + } + + private SubscriberStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected SubscriberStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new SubscriberStub(channel, callOptions); + } + + @java.lang.Override + public void createSubscription(com.google.pubsub.v1.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_CREATE_SUBSCRIPTION, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void getSubscription(com.google.pubsub.v1.GetSubscriptionRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_GET_SUBSCRIPTION, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void listSubscriptions(com.google.pubsub.v1.ListSubscriptionsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_LIST_SUBSCRIPTIONS, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void deleteSubscription(com.google.pubsub.v1.DeleteSubscriptionRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_DELETE_SUBSCRIPTION, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void modifyAckDeadline(com.google.pubsub.v1.ModifyAckDeadlineRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_MODIFY_ACK_DEADLINE, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void acknowledge(com.google.pubsub.v1.AcknowledgeRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_ACKNOWLEDGE, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void pull(com.google.pubsub.v1.PullRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_PULL, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void modifyPushConfig(com.google.pubsub.v1.ModifyPushConfigRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_MODIFY_PUSH_CONFIG, getCallOptions()), request, responseObserver); + } + } + + public static class SubscriberBlockingStub extends io.grpc.stub.AbstractStub + implements SubscriberBlockingClient { + private SubscriberBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private SubscriberBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected SubscriberBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new SubscriberBlockingStub(channel, callOptions); + } + + @java.lang.Override + public com.google.pubsub.v1.Subscription createSubscription(com.google.pubsub.v1.Subscription request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_CREATE_SUBSCRIPTION, getCallOptions()), request); + } + + @java.lang.Override + public com.google.pubsub.v1.Subscription getSubscription(com.google.pubsub.v1.GetSubscriptionRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_GET_SUBSCRIPTION, getCallOptions()), request); + } + + @java.lang.Override + public com.google.pubsub.v1.ListSubscriptionsResponse listSubscriptions(com.google.pubsub.v1.ListSubscriptionsRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_LIST_SUBSCRIPTIONS, getCallOptions()), request); + } + + @java.lang.Override + public com.google.protobuf.Empty deleteSubscription(com.google.pubsub.v1.DeleteSubscriptionRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_DELETE_SUBSCRIPTION, getCallOptions()), request); + } + + @java.lang.Override + public com.google.protobuf.Empty modifyAckDeadline(com.google.pubsub.v1.ModifyAckDeadlineRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_MODIFY_ACK_DEADLINE, getCallOptions()), request); + } + + @java.lang.Override + public com.google.protobuf.Empty acknowledge(com.google.pubsub.v1.AcknowledgeRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_ACKNOWLEDGE, getCallOptions()), request); + } + + @java.lang.Override + public com.google.pubsub.v1.PullResponse pull(com.google.pubsub.v1.PullRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_PULL, getCallOptions()), request); + } + + @java.lang.Override + public com.google.protobuf.Empty modifyPushConfig(com.google.pubsub.v1.ModifyPushConfigRequest request) { + return blockingUnaryCall( + getChannel().newCall(METHOD_MODIFY_PUSH_CONFIG, getCallOptions()), request); + } + } + + public static class SubscriberFutureStub extends io.grpc.stub.AbstractStub + implements SubscriberFutureClient { + private SubscriberFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private SubscriberFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected SubscriberFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new SubscriberFutureStub(channel, callOptions); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture createSubscription( + com.google.pubsub.v1.Subscription request) { + return futureUnaryCall( + getChannel().newCall(METHOD_CREATE_SUBSCRIPTION, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture getSubscription( + com.google.pubsub.v1.GetSubscriptionRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_GET_SUBSCRIPTION, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture listSubscriptions( + com.google.pubsub.v1.ListSubscriptionsRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_LIST_SUBSCRIPTIONS, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture deleteSubscription( + com.google.pubsub.v1.DeleteSubscriptionRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_DELETE_SUBSCRIPTION, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture modifyAckDeadline( + com.google.pubsub.v1.ModifyAckDeadlineRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_MODIFY_ACK_DEADLINE, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture acknowledge( + com.google.pubsub.v1.AcknowledgeRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_ACKNOWLEDGE, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture pull( + com.google.pubsub.v1.PullRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_PULL, getCallOptions()), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture modifyPushConfig( + com.google.pubsub.v1.ModifyPushConfigRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_MODIFY_PUSH_CONFIG, getCallOptions()), request); + } + } + + public static io.grpc.ServerServiceDefinition bindService( + final Subscriber serviceImpl) { + return io.grpc.ServerServiceDefinition.builder(SERVICE_NAME) + .addMethod( + METHOD_CREATE_SUBSCRIPTION, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.Subscription, + com.google.pubsub.v1.Subscription>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.Subscription request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.createSubscription(request, responseObserver); + } + })) + .addMethod( + METHOD_GET_SUBSCRIPTION, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.GetSubscriptionRequest, + com.google.pubsub.v1.Subscription>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.GetSubscriptionRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.getSubscription(request, responseObserver); + } + })) + .addMethod( + METHOD_LIST_SUBSCRIPTIONS, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.ListSubscriptionsRequest, + com.google.pubsub.v1.ListSubscriptionsResponse>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.ListSubscriptionsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.listSubscriptions(request, responseObserver); + } + })) + .addMethod( + METHOD_DELETE_SUBSCRIPTION, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.DeleteSubscriptionRequest, + com.google.protobuf.Empty>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.DeleteSubscriptionRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.deleteSubscription(request, responseObserver); + } + })) + .addMethod( + METHOD_MODIFY_ACK_DEADLINE, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.ModifyAckDeadlineRequest, + com.google.protobuf.Empty>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.ModifyAckDeadlineRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.modifyAckDeadline(request, responseObserver); + } + })) + .addMethod( + METHOD_ACKNOWLEDGE, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.AcknowledgeRequest, + com.google.protobuf.Empty>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.AcknowledgeRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.acknowledge(request, responseObserver); + } + })) + .addMethod( + METHOD_PULL, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.PullRequest, + com.google.pubsub.v1.PullResponse>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.PullRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.pull(request, responseObserver); + } + })) + .addMethod( + METHOD_MODIFY_PUSH_CONFIG, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.pubsub.v1.ModifyPushConfigRequest, + com.google.protobuf.Empty>() { + @java.lang.Override + public void invoke( + com.google.pubsub.v1.ModifyPushConfigRequest request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.modifyPushConfig(request, responseObserver); + } + })).build(); + } +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Subscription.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Subscription.java new file mode 100644 index 000000000000..45175301338d --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Subscription.java @@ -0,0 +1,1038 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.Subscription} + * + *
      + * A subscription resource.
      + * 
      + */ +public final class Subscription extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.Subscription) + SubscriptionOrBuilder { + // Use Subscription.newBuilder() to construct. + private Subscription(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Subscription() { + name_ = ""; + topic_ = ""; + ackDeadlineSeconds_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Subscription( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 34: { + com.google.pubsub.v1.PushConfig.Builder subBuilder = null; + if (pushConfig_ != null) { + subBuilder = pushConfig_.toBuilder(); + } + pushConfig_ = input.readMessage(com.google.pubsub.v1.PushConfig.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(pushConfig_); + pushConfig_ = subBuilder.buildPartial(); + } + + break; + } + case 40: { + + ackDeadlineSeconds_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Subscription_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Subscription_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.Subscription.class, com.google.pubsub.v1.Subscription.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * optional string name = 1; + * + *
      +   * The name of the subscription. It must have the format
      +   * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      +   * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      +   * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      +   * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      +   * in length, and it must not start with `"goog"`.
      +   * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + * + *
      +   * The name of the subscription. It must have the format
      +   * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      +   * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      +   * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      +   * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      +   * in length, and it must not start with `"goog"`.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TOPIC_FIELD_NUMBER = 2; + private volatile java.lang.Object topic_; + /** + * optional string topic = 2; + * + *
      +   * The name of the topic from which this subscription is receiving messages.
      +   * The value of this field will be `_deleted-topic_` if the topic has been
      +   * deleted.
      +   * 
      + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } + } + /** + * optional string topic = 2; + * + *
      +   * The name of the topic from which this subscription is receiving messages.
      +   * The value of this field will be `_deleted-topic_` if the topic has been
      +   * deleted.
      +   * 
      + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PUSH_CONFIG_FIELD_NUMBER = 4; + private com.google.pubsub.v1.PushConfig pushConfig_; + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +   * If push delivery is used with this subscription, this field is
      +   * used to configure it. An empty pushConfig signifies that the subscriber
      +   * will pull and ack messages using API methods.
      +   * 
      + */ + public boolean hasPushConfig() { + return pushConfig_ != null; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +   * If push delivery is used with this subscription, this field is
      +   * used to configure it. An empty pushConfig signifies that the subscriber
      +   * will pull and ack messages using API methods.
      +   * 
      + */ + public com.google.pubsub.v1.PushConfig getPushConfig() { + return pushConfig_ == null ? com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +   * If push delivery is used with this subscription, this field is
      +   * used to configure it. An empty pushConfig signifies that the subscriber
      +   * will pull and ack messages using API methods.
      +   * 
      + */ + public com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder() { + return getPushConfig(); + } + + public static final int ACK_DEADLINE_SECONDS_FIELD_NUMBER = 5; + private int ackDeadlineSeconds_; + /** + * optional int32 ack_deadline_seconds = 5; + * + *
      +   * This value is the maximum time after a subscriber receives a message
      +   * before the subscriber should acknowledge the message. After message
      +   * delivery but before the ack deadline expires and before the message is
      +   * acknowledged, it is an outstanding message and will not be delivered
      +   * again during that time (on a best-effort basis).
      +   * For pull delivery this value is used as the initial value for the ack
      +   * deadline. To override this value for a given message, call
      +   * ModifyAckDeadline with the corresponding ack_id.
      +   * For push delivery, this value is also used to set the request timeout for
      +   * the call to the push endpoint.
      +   * If the subscriber never acknowledges the message, the Pub/Sub
      +   * system will eventually redeliver the message.
      +   * If this parameter is not set, the default value of 10 seconds is used.
      +   * 
      + */ + public int getAckDeadlineSeconds() { + return ackDeadlineSeconds_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, topic_); + } + if (pushConfig_ != null) { + output.writeMessage(4, getPushConfig()); + } + if (ackDeadlineSeconds_ != 0) { + output.writeInt32(5, ackDeadlineSeconds_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, topic_); + } + if (pushConfig_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getPushConfig()); + } + if (ackDeadlineSeconds_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(5, ackDeadlineSeconds_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.Subscription parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.Subscription parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.Subscription parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.Subscription parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.Subscription parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.Subscription parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.Subscription parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.Subscription parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.Subscription parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.Subscription parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.Subscription prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.Subscription} + * + *
      +   * A subscription resource.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.Subscription) + com.google.pubsub.v1.SubscriptionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Subscription_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Subscription_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.Subscription.class, com.google.pubsub.v1.Subscription.Builder.class); + } + + // Construct using com.google.pubsub.v1.Subscription.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + topic_ = ""; + + if (pushConfigBuilder_ == null) { + pushConfig_ = null; + } else { + pushConfig_ = null; + pushConfigBuilder_ = null; + } + ackDeadlineSeconds_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Subscription_descriptor; + } + + public com.google.pubsub.v1.Subscription getDefaultInstanceForType() { + return com.google.pubsub.v1.Subscription.getDefaultInstance(); + } + + public com.google.pubsub.v1.Subscription build() { + com.google.pubsub.v1.Subscription result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.Subscription buildPartial() { + com.google.pubsub.v1.Subscription result = new com.google.pubsub.v1.Subscription(this); + result.name_ = name_; + result.topic_ = topic_; + if (pushConfigBuilder_ == null) { + result.pushConfig_ = pushConfig_; + } else { + result.pushConfig_ = pushConfigBuilder_.build(); + } + result.ackDeadlineSeconds_ = ackDeadlineSeconds_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.Subscription) { + return mergeFrom((com.google.pubsub.v1.Subscription)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.Subscription other) { + if (other == com.google.pubsub.v1.Subscription.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (other.hasPushConfig()) { + mergePushConfig(other.getPushConfig()); + } + if (other.getAckDeadlineSeconds() != 0) { + setAckDeadlineSeconds(other.getAckDeadlineSeconds()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.Subscription parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.Subscription) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * optional string name = 1; + * + *
      +     * The name of the subscription. It must have the format
      +     * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      +     * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      +     * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      +     * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      +     * in length, and it must not start with `"goog"`.
      +     * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the subscription. It must have the format
      +     * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      +     * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      +     * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      +     * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      +     * in length, and it must not start with `"goog"`.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the subscription. It must have the format
      +     * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      +     * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      +     * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      +     * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      +     * in length, and it must not start with `"goog"`.
      +     * 
      + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the subscription. It must have the format
      +     * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      +     * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      +     * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      +     * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      +     * in length, and it must not start with `"goog"`.
      +     * 
      + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the subscription. It must have the format
      +     * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      +     * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      +     * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      +     * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      +     * in length, and it must not start with `"goog"`.
      +     * 
      + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object topic_ = ""; + /** + * optional string topic = 2; + * + *
      +     * The name of the topic from which this subscription is receiving messages.
      +     * The value of this field will be `_deleted-topic_` if the topic has been
      +     * deleted.
      +     * 
      + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string topic = 2; + * + *
      +     * The name of the topic from which this subscription is receiving messages.
      +     * The value of this field will be `_deleted-topic_` if the topic has been
      +     * deleted.
      +     * 
      + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string topic = 2; + * + *
      +     * The name of the topic from which this subscription is receiving messages.
      +     * The value of this field will be `_deleted-topic_` if the topic has been
      +     * deleted.
      +     * 
      + */ + public Builder setTopic( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * optional string topic = 2; + * + *
      +     * The name of the topic from which this subscription is receiving messages.
      +     * The value of this field will be `_deleted-topic_` if the topic has been
      +     * deleted.
      +     * 
      + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * optional string topic = 2; + * + *
      +     * The name of the topic from which this subscription is receiving messages.
      +     * The value of this field will be `_deleted-topic_` if the topic has been
      +     * deleted.
      +     * 
      + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private com.google.pubsub.v1.PushConfig pushConfig_ = null; + private com.google.protobuf.SingleFieldBuilder< + com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder> pushConfigBuilder_; + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +     * If push delivery is used with this subscription, this field is
      +     * used to configure it. An empty pushConfig signifies that the subscriber
      +     * will pull and ack messages using API methods.
      +     * 
      + */ + public boolean hasPushConfig() { + return pushConfigBuilder_ != null || pushConfig_ != null; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +     * If push delivery is used with this subscription, this field is
      +     * used to configure it. An empty pushConfig signifies that the subscriber
      +     * will pull and ack messages using API methods.
      +     * 
      + */ + public com.google.pubsub.v1.PushConfig getPushConfig() { + if (pushConfigBuilder_ == null) { + return pushConfig_ == null ? com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; + } else { + return pushConfigBuilder_.getMessage(); + } + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +     * If push delivery is used with this subscription, this field is
      +     * used to configure it. An empty pushConfig signifies that the subscriber
      +     * will pull and ack messages using API methods.
      +     * 
      + */ + public Builder setPushConfig(com.google.pubsub.v1.PushConfig value) { + if (pushConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pushConfig_ = value; + onChanged(); + } else { + pushConfigBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +     * If push delivery is used with this subscription, this field is
      +     * used to configure it. An empty pushConfig signifies that the subscriber
      +     * will pull and ack messages using API methods.
      +     * 
      + */ + public Builder setPushConfig( + com.google.pubsub.v1.PushConfig.Builder builderForValue) { + if (pushConfigBuilder_ == null) { + pushConfig_ = builderForValue.build(); + onChanged(); + } else { + pushConfigBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +     * If push delivery is used with this subscription, this field is
      +     * used to configure it. An empty pushConfig signifies that the subscriber
      +     * will pull and ack messages using API methods.
      +     * 
      + */ + public Builder mergePushConfig(com.google.pubsub.v1.PushConfig value) { + if (pushConfigBuilder_ == null) { + if (pushConfig_ != null) { + pushConfig_ = + com.google.pubsub.v1.PushConfig.newBuilder(pushConfig_).mergeFrom(value).buildPartial(); + } else { + pushConfig_ = value; + } + onChanged(); + } else { + pushConfigBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +     * If push delivery is used with this subscription, this field is
      +     * used to configure it. An empty pushConfig signifies that the subscriber
      +     * will pull and ack messages using API methods.
      +     * 
      + */ + public Builder clearPushConfig() { + if (pushConfigBuilder_ == null) { + pushConfig_ = null; + onChanged(); + } else { + pushConfig_ = null; + pushConfigBuilder_ = null; + } + + return this; + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +     * If push delivery is used with this subscription, this field is
      +     * used to configure it. An empty pushConfig signifies that the subscriber
      +     * will pull and ack messages using API methods.
      +     * 
      + */ + public com.google.pubsub.v1.PushConfig.Builder getPushConfigBuilder() { + + onChanged(); + return getPushConfigFieldBuilder().getBuilder(); + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +     * If push delivery is used with this subscription, this field is
      +     * used to configure it. An empty pushConfig signifies that the subscriber
      +     * will pull and ack messages using API methods.
      +     * 
      + */ + public com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder() { + if (pushConfigBuilder_ != null) { + return pushConfigBuilder_.getMessageOrBuilder(); + } else { + return pushConfig_ == null ? + com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; + } + } + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +     * If push delivery is used with this subscription, this field is
      +     * used to configure it. An empty pushConfig signifies that the subscriber
      +     * will pull and ack messages using API methods.
      +     * 
      + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder> + getPushConfigFieldBuilder() { + if (pushConfigBuilder_ == null) { + pushConfigBuilder_ = new com.google.protobuf.SingleFieldBuilder< + com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder>( + getPushConfig(), + getParentForChildren(), + isClean()); + pushConfig_ = null; + } + return pushConfigBuilder_; + } + + private int ackDeadlineSeconds_ ; + /** + * optional int32 ack_deadline_seconds = 5; + * + *
      +     * This value is the maximum time after a subscriber receives a message
      +     * before the subscriber should acknowledge the message. After message
      +     * delivery but before the ack deadline expires and before the message is
      +     * acknowledged, it is an outstanding message and will not be delivered
      +     * again during that time (on a best-effort basis).
      +     * For pull delivery this value is used as the initial value for the ack
      +     * deadline. To override this value for a given message, call
      +     * ModifyAckDeadline with the corresponding ack_id.
      +     * For push delivery, this value is also used to set the request timeout for
      +     * the call to the push endpoint.
      +     * If the subscriber never acknowledges the message, the Pub/Sub
      +     * system will eventually redeliver the message.
      +     * If this parameter is not set, the default value of 10 seconds is used.
      +     * 
      + */ + public int getAckDeadlineSeconds() { + return ackDeadlineSeconds_; + } + /** + * optional int32 ack_deadline_seconds = 5; + * + *
      +     * This value is the maximum time after a subscriber receives a message
      +     * before the subscriber should acknowledge the message. After message
      +     * delivery but before the ack deadline expires and before the message is
      +     * acknowledged, it is an outstanding message and will not be delivered
      +     * again during that time (on a best-effort basis).
      +     * For pull delivery this value is used as the initial value for the ack
      +     * deadline. To override this value for a given message, call
      +     * ModifyAckDeadline with the corresponding ack_id.
      +     * For push delivery, this value is also used to set the request timeout for
      +     * the call to the push endpoint.
      +     * If the subscriber never acknowledges the message, the Pub/Sub
      +     * system will eventually redeliver the message.
      +     * If this parameter is not set, the default value of 10 seconds is used.
      +     * 
      + */ + public Builder setAckDeadlineSeconds(int value) { + + ackDeadlineSeconds_ = value; + onChanged(); + return this; + } + /** + * optional int32 ack_deadline_seconds = 5; + * + *
      +     * This value is the maximum time after a subscriber receives a message
      +     * before the subscriber should acknowledge the message. After message
      +     * delivery but before the ack deadline expires and before the message is
      +     * acknowledged, it is an outstanding message and will not be delivered
      +     * again during that time (on a best-effort basis).
      +     * For pull delivery this value is used as the initial value for the ack
      +     * deadline. To override this value for a given message, call
      +     * ModifyAckDeadline with the corresponding ack_id.
      +     * For push delivery, this value is also used to set the request timeout for
      +     * the call to the push endpoint.
      +     * If the subscriber never acknowledges the message, the Pub/Sub
      +     * system will eventually redeliver the message.
      +     * If this parameter is not set, the default value of 10 seconds is used.
      +     * 
      + */ + public Builder clearAckDeadlineSeconds() { + + ackDeadlineSeconds_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.Subscription) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.Subscription) + private static final com.google.pubsub.v1.Subscription DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.Subscription(); + } + + public static com.google.pubsub.v1.Subscription getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Subscription parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Subscription(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.Subscription getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriptionOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriptionOrBuilder.java new file mode 100644 index 000000000000..b74cbb696209 --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriptionOrBuilder.java @@ -0,0 +1,111 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface SubscriptionOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.Subscription) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 1; + * + *
      +   * The name of the subscription. It must have the format
      +   * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      +   * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      +   * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      +   * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      +   * in length, and it must not start with `"goog"`.
      +   * 
      + */ + java.lang.String getName(); + /** + * optional string name = 1; + * + *
      +   * The name of the subscription. It must have the format
      +   * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      +   * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      +   * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      +   * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      +   * in length, and it must not start with `"goog"`.
      +   * 
      + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * optional string topic = 2; + * + *
      +   * The name of the topic from which this subscription is receiving messages.
      +   * The value of this field will be `_deleted-topic_` if the topic has been
      +   * deleted.
      +   * 
      + */ + java.lang.String getTopic(); + /** + * optional string topic = 2; + * + *
      +   * The name of the topic from which this subscription is receiving messages.
      +   * The value of this field will be `_deleted-topic_` if the topic has been
      +   * deleted.
      +   * 
      + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +   * If push delivery is used with this subscription, this field is
      +   * used to configure it. An empty pushConfig signifies that the subscriber
      +   * will pull and ack messages using API methods.
      +   * 
      + */ + boolean hasPushConfig(); + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +   * If push delivery is used with this subscription, this field is
      +   * used to configure it. An empty pushConfig signifies that the subscriber
      +   * will pull and ack messages using API methods.
      +   * 
      + */ + com.google.pubsub.v1.PushConfig getPushConfig(); + /** + * optional .google.pubsub.v1.PushConfig push_config = 4; + * + *
      +   * If push delivery is used with this subscription, this field is
      +   * used to configure it. An empty pushConfig signifies that the subscriber
      +   * will pull and ack messages using API methods.
      +   * 
      + */ + com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder(); + + /** + * optional int32 ack_deadline_seconds = 5; + * + *
      +   * This value is the maximum time after a subscriber receives a message
      +   * before the subscriber should acknowledge the message. After message
      +   * delivery but before the ack deadline expires and before the message is
      +   * acknowledged, it is an outstanding message and will not be delivered
      +   * again during that time (on a best-effort basis).
      +   * For pull delivery this value is used as the initial value for the ack
      +   * deadline. To override this value for a given message, call
      +   * ModifyAckDeadline with the corresponding ack_id.
      +   * For push delivery, this value is also used to set the request timeout for
      +   * the call to the push endpoint.
      +   * If the subscriber never acknowledges the message, the Pub/Sub
      +   * system will eventually redeliver the message.
      +   * If this parameter is not set, the default value of 10 seconds is used.
      +   * 
      + */ + int getAckDeadlineSeconds(); +} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Topic.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Topic.java new file mode 100644 index 000000000000..d1317aed31ef --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Topic.java @@ -0,0 +1,511 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +/** + * Protobuf type {@code google.pubsub.v1.Topic} + * + *
      + * A topic resource.
      + * 
      + */ +public final class Topic extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:google.pubsub.v1.Topic) + TopicOrBuilder { + // Use Topic.newBuilder() to construct. + private Topic(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Topic() { + name_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Topic( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Topic_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Topic_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.Topic.class, com.google.pubsub.v1.Topic.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * optional string name = 1; + * + *
      +   * The name of the topic. It must have the format
      +   * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      +   * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      +   * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      +   * signs (`%`). It must be between 3 and 255 characters in length, and it
      +   * must not start with `"goog"`.
      +   * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + * + *
      +   * The name of the topic. It must have the format
      +   * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      +   * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      +   * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      +   * signs (`%`). It must be between 3 and 255 characters in length, and it
      +   * must not start with `"goog"`.
      +   * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static com.google.pubsub.v1.Topic parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.Topic parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.Topic parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.google.pubsub.v1.Topic parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.google.pubsub.v1.Topic parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.Topic parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.Topic parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static com.google.pubsub.v1.Topic parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static com.google.pubsub.v1.Topic parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static com.google.pubsub.v1.Topic parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.google.pubsub.v1.Topic prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code google.pubsub.v1.Topic} + * + *
      +   * A topic resource.
      +   * 
      + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:google.pubsub.v1.Topic) + com.google.pubsub.v1.TopicOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Topic_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Topic_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.pubsub.v1.Topic.class, com.google.pubsub.v1.Topic.Builder.class); + } + + // Construct using com.google.pubsub.v1.Topic.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Topic_descriptor; + } + + public com.google.pubsub.v1.Topic getDefaultInstanceForType() { + return com.google.pubsub.v1.Topic.getDefaultInstance(); + } + + public com.google.pubsub.v1.Topic build() { + com.google.pubsub.v1.Topic result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.google.pubsub.v1.Topic buildPartial() { + com.google.pubsub.v1.Topic result = new com.google.pubsub.v1.Topic(this); + result.name_ = name_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.pubsub.v1.Topic) { + return mergeFrom((com.google.pubsub.v1.Topic)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.pubsub.v1.Topic other) { + if (other == com.google.pubsub.v1.Topic.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.pubsub.v1.Topic parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.pubsub.v1.Topic) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * optional string name = 1; + * + *
      +     * The name of the topic. It must have the format
      +     * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      +     * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      +     * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      +     * signs (`%`). It must be between 3 and 255 characters in length, and it
      +     * must not start with `"goog"`.
      +     * 
      + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the topic. It must have the format
      +     * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      +     * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      +     * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      +     * signs (`%`). It must be between 3 and 255 characters in length, and it
      +     * must not start with `"goog"`.
      +     * 
      + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + * + *
      +     * The name of the topic. It must have the format
      +     * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      +     * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      +     * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      +     * signs (`%`). It must be between 3 and 255 characters in length, and it
      +     * must not start with `"goog"`.
      +     * 
      + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the topic. It must have the format
      +     * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      +     * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      +     * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      +     * signs (`%`). It must be between 3 and 255 characters in length, and it
      +     * must not start with `"goog"`.
      +     * 
      + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
      +     * The name of the topic. It must have the format
      +     * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      +     * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      +     * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      +     * signs (`%`). It must be between 3 and 255 characters in length, and it
      +     * must not start with `"goog"`.
      +     * 
      + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:google.pubsub.v1.Topic) + } + + // @@protoc_insertion_point(class_scope:google.pubsub.v1.Topic) + private static final com.google.pubsub.v1.Topic DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.google.pubsub.v1.Topic(); + } + + public static com.google.pubsub.v1.Topic getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Topic parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Topic(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.google.pubsub.v1.Topic getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/TopicOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/TopicOrBuilder.java new file mode 100644 index 000000000000..9a80b8a4512b --- /dev/null +++ b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/TopicOrBuilder.java @@ -0,0 +1,37 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/pubsub/v1/pubsub.proto + +package com.google.pubsub.v1; + +public interface TopicOrBuilder extends + // @@protoc_insertion_point(interface_extends:google.pubsub.v1.Topic) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 1; + * + *
      +   * The name of the topic. It must have the format
      +   * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      +   * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      +   * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      +   * signs (`%`). It must be between 3 and 255 characters in length, and it
      +   * must not start with `"goog"`.
      +   * 
      + */ + java.lang.String getName(); + /** + * optional string name = 1; + * + *
      +   * The name of the topic. It must have the format
      +   * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      +   * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      +   * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      +   * signs (`%`). It must be between 3 and 255 characters in length, and it
      +   * must not start with `"goog"`.
      +   * 
      + */ + com.google.protobuf.ByteString + getNameBytes(); +} diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml new file mode 100644 index 000000000000..3bcdd9d68f12 --- /dev/null +++ b/gcloud-java-pubsub/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + com.google.gcloud + gcloud-java-pubsub + jar + GCloud Java Pub/Sub + + Java idiomatic client for Google Cloud Pub/Sub. + + + com.google.gcloud + gcloud-java-pom + 0.0.11-SNAPSHOT + + + gcloud-java-pubsub + + + + ${project.groupId} + gcloud-java-gax + ${project.version} + + + io.grpc + grpc-all + 0.9.0 + + + com.google.auto.value + auto-value + 1.1 + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + generate-sources + add-source + + + generated/src/main + + + + + + + + From 344229390ce6297f0f39fbd79c7effa1b6d93045 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Wed, 4 Nov 2015 16:16:37 -0800 Subject: [PATCH 176/203] Adding all sections to readme, with TODOs for missing content --- gcloud-java-pubsub/README.md | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/gcloud-java-pubsub/README.md b/gcloud-java-pubsub/README.md index 29d6990d18a2..70393a4b7998 100644 --- a/gcloud-java-pubsub/README.md +++ b/gcloud-java-pubsub/README.md @@ -23,3 +23,62 @@ Add this to your pom.xml file 0.0.10
      ``` + +Example Application +------------------- +TODO + +Authentication +-------------- + +See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the base directory's README. + +About Google Cloud Pub/Sub +-------------------------- + +[Google Cloud Pub/Sub][cloud-pubsub] is designed to provide reliable, +many-to-many, asynchronous messaging between applications. Publisher +applications can send messages to a ``topic`` and other applications can +subscribe to that topic to receive the messages. By decoupling senders and +receivers, Google Cloud Pub/Sub allows developers to communicate between +independently written applications. + +TODO: link to docs on activating Pub/Sub, high-level documentation on +the API, and code snippet + +Java Versions +------------- + +Java 7 or above is required for using this client. + +Testing +------- + +TODO + +Versioning +---------- + +This library follows [Semantic Versioning] (http://semver.org/). + +It is currently in major version zero (``0.y.z``), which means that anything +may change at any time and the public API should not be considered +stable. + +Contributing +------------ + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING] for more information on how to get started. + +License +------- + +Apache 2.0 - See [LICENSE] for more information. + + +[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md +[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE + +[cloud-pubsub]: https://cloud.google.com/storage/ From 926c9ae645d4afe857f8b00fcae25151f8ccfc01 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Tue, 10 Nov 2015 11:07:00 -0800 Subject: [PATCH 177/203] Generated Pub/Sub client classes and unit tests --- gcloud-java-pubsub/pom.xml | 6 + .../gcloud/pubsub/spi/PublisherApi.java | 498 +++++++++++++ .../gcloud/pubsub/spi/SubscriberApi.java | 663 ++++++++++++++++++ .../gcloud/pubsub/spi/LocalPublisherImpl.java | 138 ++++ .../gcloud/pubsub/spi/PublisherApiTest.java | 175 +++++ 5 files changed, 1480 insertions(+) create mode 100644 gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java create mode 100644 gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java create mode 100644 gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/LocalPublisherImpl.java create mode 100644 gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index 3bcdd9d68f12..df9debe4a030 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -32,6 +32,12 @@ auto-value 1.1 + + junit + junit + 4.12 + test + diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java new file mode 100644 index 000000000000..3c239c3923e4 --- /dev/null +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -0,0 +1,498 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * EDITING INSTRUCTIONS + * This file was generated from the file google/pubsub/v1/pubsub.proto, + * and updates to that file get reflected here through a regular refresh process. + * However, manual additions are allowed because the refresh process performs + * a 3-way merge in order to preserve those manual additions. In order to not + * break the refresh process, only certain types of modifications are + * allowed. + * + * Allowed modifications - currently there is only one type allowed: + * 1. New methods (these should be added to the end of the class) + * + * Happy editing! + */ +package com.google.gcloud.pubsub.spi; + +import com.google.protobuf.Empty; +import com.google.pubsub.v1.DeleteTopicRequest; +import com.google.pubsub.v1.GetTopicRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsResponse; +import com.google.pubsub.v1.ListTopicsRequest; +import com.google.pubsub.v1.ListTopicsResponse; +import com.google.pubsub.v1.PublishRequest; +import com.google.pubsub.v1.PublishResponse; +import com.google.pubsub.v1.PublisherGrpc; +import com.google.pubsub.v1.PubsubMessage; +import com.google.pubsub.v1.Topic; + +import io.gapi.gax.grpc.ApiCallable; +import io.gapi.gax.grpc.PageDescriptor; +import io.gapi.gax.grpc.ServiceApiSettings; +import io.gapi.gax.internal.ApiUtils; +import io.gapi.gax.protobuf.PathTemplate; +import io.grpc.Channel; +import io.grpc.ManagedChannel; + +import java.io.IOException; +import java.util.List; + +// Manually-added imports: add custom (non-generated) imports after this point. + + + +// AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. +/** + * The service that an application uses to manipulate topics, and to send + * messages to a topic. + */ +@javax.annotation.Generated("by the veneer generator") +public class PublisherApi implements AutoCloseable { + + // ========= + // Constants + // ========= + + /** + * The default address of the service. + */ + public static final String SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; + + /** + * The default port of the service. + */ + public static final int DEFAULT_SERVICE_PORT = 443; + + + public static final ApiCallable + CREATE_TOPIC = ApiCallable.create(PublisherGrpc.METHOD_CREATE_TOPIC); + public static final ApiCallable + PUBLISH = ApiCallable.create(PublisherGrpc.METHOD_PUBLISH); + public static final ApiCallable + GET_TOPIC = ApiCallable.create(PublisherGrpc.METHOD_GET_TOPIC); + public static final ApiCallable + LIST_TOPICS = ApiCallable.create(PublisherGrpc.METHOD_LIST_TOPICS); + public static final ApiCallable + LIST_TOPIC_SUBSCRIPTIONS = ApiCallable.create(PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS); + public static final ApiCallable + DELETE_TOPIC = ApiCallable.create(PublisherGrpc.METHOD_DELETE_TOPIC); + + + + + private static PageDescriptor LIST_TOPICS_PAGE_DESC = + new PageDescriptor() { + @Override public Object emptyToken() { + return ""; + } + @Override public ListTopicsRequest injectToken( + ListTopicsRequest payload, Object token) { + return ListTopicsRequest + .newBuilder(payload) + .setPageToken((String) token) + .build(); + } + @Override + public Object extractNextToken(ListTopicsResponse payload) { + return payload.getNextPageToken(); + } + @Override + public Iterable extractResources(ListTopicsResponse payload) { + return payload.getTopicsList(); + } + }; + private static PageDescriptor LIST_TOPIC_SUBSCRIPTIONS_PAGE_DESC = + new PageDescriptor() { + @Override public Object emptyToken() { + return ""; + } + @Override public ListTopicSubscriptionsRequest injectToken( + ListTopicSubscriptionsRequest payload, Object token) { + return ListTopicSubscriptionsRequest + .newBuilder(payload) + .setPageToken((String) token) + .build(); + } + @Override + public Object extractNextToken(ListTopicSubscriptionsResponse payload) { + return payload.getNextPageToken(); + } + @Override + public Iterable extractResources(ListTopicSubscriptionsResponse payload) { + return payload.getSubscriptionsList(); + } + }; + + private static String ALL_SCOPES[] = { + "https://www.googleapis.com/auth/pubsub" + }; + + public static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.create("/projects/{project}"); + public static final PathTemplate TOPIC_PATH_TEMPLATE = + PathTemplate.create("/projects/{project}/topics/{topic}"); + + // ======== + // Members + // ======== + + private final ManagedChannel channel; + private final ServiceApiSettings settings; + + // =============== + // Factory Methods + // =============== + + /** + * Constructs an instance of PublisherApi with default settings. + */ + public static PublisherApi create() throws IOException { + return create(new ServiceApiSettings()); + } + + /** + * Constructs an instance of PublisherApi, using the given settings. The channels are created based + * on the settings passed in, or defaults for any settings that are not set. + */ + public static PublisherApi create(ServiceApiSettings settings) throws IOException { + return new PublisherApi(settings); + } + + private PublisherApi(ServiceApiSettings settings) throws IOException { + ServiceApiSettings internalSettings = ApiUtils.settingsWithChannels(settings, + SERVICE_ADDRESS, DEFAULT_SERVICE_PORT, ALL_SCOPES); + this.settings = internalSettings; + this.channel = internalSettings.getChannel(); + } + + // ============================== + // Resource Name Helper Functions + // ============================== + + public static final String createProject(String project) { + return PROJECT_PATH_TEMPLATE.instantiate( + "project", project); + } + + public static final String createTopic(String project, String topic) { + return TOPIC_PATH_TEMPLATE.instantiate( + "project", project,"topic", topic); + } + + + // ======== + // Getters + // ======== + + public Channel getChannel() { + return channel; + } + + + // ============= + // Service Calls + // ============= + + // ----- createTopic ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates the given topic with the given name. + * + * @param name The name of the topic. It must have the format + * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, + * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), + * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent + * signs (`%`). It must be between 3 and 255 characters in length, and it + * must not start with `"goog"`. + */ + public Topic createTopic(String name) { + Topic request = + Topic.newBuilder() + .setName(name) + .build(); + + return createTopic(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates the given topic with the given name. + * + * @param request The request object containing all of the parameters for the API call. + */ + public Topic createTopic(Topic request) { + return createTopicCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates the given topic with the given name. + */ + public ApiCallable createTopicCallable() { + return ApiUtils.prepareIdempotentCallable(CREATE_TOPIC, settings).bind(channel); + } + + // ----- publish ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Adds one or more messages to the topic. Returns NOT_FOUND if the topic does + * not exist. The message payload must not be empty; it must contain either a + * non-empty data field, or at least one attribute. + * + * @param topic The messages in the request will be published on this topic. + * @param messages The messages to publish. + */ + public PublishResponse publish(String topic, List messages) { + PublishRequest request = + PublishRequest.newBuilder() + .setTopic(topic) + .addAllMessages(messages) + .build(); + + return publish(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Adds one or more messages to the topic. Returns NOT_FOUND if the topic does + * not exist. The message payload must not be empty; it must contain either a + * non-empty data field, or at least one attribute. + * + * @param request The request object containing all of the parameters for the API call. + */ + public PublishResponse publish(PublishRequest request) { + return publishCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Adds one or more messages to the topic. Returns NOT_FOUND if the topic does + * not exist. The message payload must not be empty; it must contain either a + * non-empty data field, or at least one attribute. + */ + public ApiCallable publishCallable() { + return PUBLISH.bind(channel); + } + + // ----- getTopic ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration of a topic. + * + * @param topic The name of the topic to get. + */ + public Topic getTopic(String topic) { + GetTopicRequest request = + GetTopicRequest.newBuilder() + .setTopic(topic) + .build(); + + return getTopic(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration of a topic. + * + * @param request The request object containing all of the parameters for the API call. + */ + public Topic getTopic(GetTopicRequest request) { + return getTopicCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration of a topic. + */ + public ApiCallable getTopicCallable() { + return ApiUtils.prepareIdempotentCallable(GET_TOPIC, settings).bind(channel); + } + + // ----- listTopics ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching topics. + */ + public Iterable listTopics(String project) { + ListTopicsRequest request = + ListTopicsRequest.newBuilder() + .setProject(project) + .build(); + return listTopics(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching topics. + * + * @param request The request object containing all of the parameters for the API call. + */ + public Iterable listTopics(ListTopicsRequest request) { + return listTopicsStreamingCallable() + .iterableResponseStreamCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching topics. + */ + public ApiCallable listTopicsStreamingCallable() { + return listTopicsCallable().pageStreaming(LIST_TOPICS_PAGE_DESC); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching topics. + */ + public ApiCallable listTopicsCallable() { + return ApiUtils.prepareIdempotentCallable(LIST_TOPICS, settings).bind(channel); + } + + // ----- listTopicSubscriptions ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists the name of the subscriptions for this topic. + */ + public Iterable listTopicSubscriptions(String topic) { + ListTopicSubscriptionsRequest request = + ListTopicSubscriptionsRequest.newBuilder() + .setTopic(topic) + .build(); + return listTopicSubscriptions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists the name of the subscriptions for this topic. + * + * @param request The request object containing all of the parameters for the API call. + */ + public Iterable listTopicSubscriptions(ListTopicSubscriptionsRequest request) { + return listTopicSubscriptionsStreamingCallable() + .iterableResponseStreamCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists the name of the subscriptions for this topic. + */ + public ApiCallable listTopicSubscriptionsStreamingCallable() { + return listTopicSubscriptionsCallable().pageStreaming(LIST_TOPIC_SUBSCRIPTIONS_PAGE_DESC); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists the name of the subscriptions for this topic. + */ + public ApiCallable listTopicSubscriptionsCallable() { + return ApiUtils.prepareIdempotentCallable(LIST_TOPIC_SUBSCRIPTIONS, settings).bind(channel); + } + + // ----- deleteTopic ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes the topic with the given name. Returns NOT_FOUND if the topic does + * not exist. After a topic is deleted, a new topic may be created with the + * same name; this is an entirely new topic with none of the old + * configuration or subscriptions. Existing subscriptions to this topic are + * not deleted, but their `topic` field is set to `_deleted-topic_`. + * + * @param topic Name of the topic to delete. + */ + public void deleteTopic(String topic) { + DeleteTopicRequest request = + DeleteTopicRequest.newBuilder() + .setTopic(topic) + .build(); + + deleteTopic(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes the topic with the given name. Returns NOT_FOUND if the topic does + * not exist. After a topic is deleted, a new topic may be created with the + * same name; this is an entirely new topic with none of the old + * configuration or subscriptions. Existing subscriptions to this topic are + * not deleted, but their `topic` field is set to `_deleted-topic_`. + * + * @param request The request object containing all of the parameters for the API call. + */ + public void deleteTopic(DeleteTopicRequest request) { + deleteTopicCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes the topic with the given name. Returns NOT_FOUND if the topic does + * not exist. After a topic is deleted, a new topic may be created with the + * same name; this is an entirely new topic with none of the old + * configuration or subscriptions. Existing subscriptions to this topic are + * not deleted, but their `topic` field is set to `_deleted-topic_`. + */ + public ApiCallable deleteTopicCallable() { + return ApiUtils.prepareIdempotentCallable(DELETE_TOPIC, settings).bind(channel); + } + + + // ======== + // Cleanup + // ======== + + /** + * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately + * cancelled. + */ + @Override public void close() { + // Manually-added shutdown code + + // Auto-generated shutdown code + channel.shutdown(); + + // Manually-added shutdown code + } + + + // ======== + // Manually-added methods: add custom (non-generated) methods after this point. + // ======== + +} diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java new file mode 100644 index 000000000000..6afe0da72d51 --- /dev/null +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -0,0 +1,663 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * EDITING INSTRUCTIONS + * This file was generated from the file google/pubsub/v1/pubsub.proto, + * and updates to that file get reflected here through a regular refresh process. + * However, manual additions are allowed because the refresh process performs + * a 3-way merge in order to preserve those manual additions. In order to not + * break the refresh process, only certain types of modifications are + * allowed. + * + * Allowed modifications - currently there is only one type allowed: + * 1. New methods (these should be added to the end of the class) + * + * Happy editing! + */ +package com.google.gcloud.pubsub.spi; + +import com.google.protobuf.Empty; +import com.google.pubsub.v1.AcknowledgeRequest; +import com.google.pubsub.v1.DeleteSubscriptionRequest; +import com.google.pubsub.v1.GetSubscriptionRequest; +import com.google.pubsub.v1.ListSubscriptionsRequest; +import com.google.pubsub.v1.ListSubscriptionsResponse; +import com.google.pubsub.v1.ModifyAckDeadlineRequest; +import com.google.pubsub.v1.ModifyPushConfigRequest; +import com.google.pubsub.v1.PullRequest; +import com.google.pubsub.v1.PullResponse; +import com.google.pubsub.v1.PushConfig; +import com.google.pubsub.v1.SubscriberGrpc; +import com.google.pubsub.v1.Subscription; + +import io.gapi.gax.grpc.ApiCallable; +import io.gapi.gax.grpc.PageDescriptor; +import io.gapi.gax.grpc.ServiceApiSettings; +import io.gapi.gax.internal.ApiUtils; +import io.gapi.gax.protobuf.PathTemplate; +import io.grpc.Channel; +import io.grpc.ManagedChannel; + +import java.io.IOException; +import java.util.List; + +// Manually-added imports: add custom (non-generated) imports after this point. + + + +// AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. +/** + * The service that an application uses to manipulate subscriptions and to + * consume messages from a subscription via the Pull method. + */ +@javax.annotation.Generated("by the veneer generator") +public class SubscriberApi implements AutoCloseable { + + // ========= + // Constants + // ========= + + /** + * The default address of the service. + */ + public static final String SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; + + /** + * The default port of the service. + */ + public static final int DEFAULT_SERVICE_PORT = 443; + + + public static final ApiCallable + CREATE_SUBSCRIPTION = ApiCallable.create(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); + public static final ApiCallable + GET_SUBSCRIPTION = ApiCallable.create(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); + public static final ApiCallable + LIST_SUBSCRIPTIONS = ApiCallable.create(SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS); + public static final ApiCallable + DELETE_SUBSCRIPTION = ApiCallable.create(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); + public static final ApiCallable + MODIFY_ACK_DEADLINE = ApiCallable.create(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); + public static final ApiCallable + ACKNOWLEDGE = ApiCallable.create(SubscriberGrpc.METHOD_ACKNOWLEDGE); + public static final ApiCallable + PULL = ApiCallable.create(SubscriberGrpc.METHOD_PULL); + public static final ApiCallable + MODIFY_PUSH_CONFIG = ApiCallable.create(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); + + + + private static PageDescriptor LIST_SUBSCRIPTIONS_PAGE_DESC = + new PageDescriptor() { + @Override public Object emptyToken() { + return ""; + } + @Override public ListSubscriptionsRequest injectToken( + ListSubscriptionsRequest payload, Object token) { + return ListSubscriptionsRequest + .newBuilder(payload) + .setPageToken((String) token) + .build(); + } + @Override + public Object extractNextToken(ListSubscriptionsResponse payload) { + return payload.getNextPageToken(); + } + @Override + public Iterable extractResources(ListSubscriptionsResponse payload) { + return payload.getSubscriptionsList(); + } + }; + + + + + + private static String ALL_SCOPES[] = { + "https://www.googleapis.com/auth/pubsub" + }; + + public static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.create("/projects/{project}"); + public static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = + PathTemplate.create("/projects/{project}/subscriptions/{subscription}"); + + // ======== + // Members + // ======== + + private final ManagedChannel channel; + private final ServiceApiSettings settings; + + // =============== + // Factory Methods + // =============== + + /** + * Constructs an instance of SubscriberApi with default settings. + */ + public static SubscriberApi create() throws IOException { + return create(new ServiceApiSettings()); + } + + /** + * Constructs an instance of SubscriberApi, using the given settings. The channels are created based + * on the settings passed in, or defaults for any settings that are not set. + */ + public static SubscriberApi create(ServiceApiSettings settings) throws IOException { + return new SubscriberApi(settings); + } + + private SubscriberApi(ServiceApiSettings settings) throws IOException { + ServiceApiSettings internalSettings = ApiUtils.settingsWithChannels(settings, + SERVICE_ADDRESS, DEFAULT_SERVICE_PORT, ALL_SCOPES); + this.settings = internalSettings; + this.channel = internalSettings.getChannel(); + } + + // ============================== + // Resource Name Helper Functions + // ============================== + + public static final String createProject(String project) { + return PROJECT_PATH_TEMPLATE.instantiate( + "project", project); + } + + public static final String createSubscription(String project, String subscription) { + return SUBSCRIPTION_PATH_TEMPLATE.instantiate( + "project", project,"subscription", subscription); + } + + + // ======== + // Getters + // ======== + + public Channel getChannel() { + return channel; + } + + + // ============= + // Service Calls + // ============= + + // ----- createSubscription ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates a subscription to a given topic for a given subscriber. + * If the subscription already exists, returns ALREADY_EXISTS. + * If the corresponding topic doesn't exist, returns NOT_FOUND. + * + * If the name is not provided in the request, the server will assign a random + * name for this subscription on the same project as the topic. + * + * @param name The name of the subscription. It must have the format + * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must + * start with a letter, and contain only letters (`[A-Za-z]`), numbers + * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), + * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters + * in length, and it must not start with `"goog"`. + * @param topic The name of the topic from which this subscription is receiving messages. + * The value of this field will be `_deleted-topic_` if the topic has been + * deleted. + * @param pushConfig If push delivery is used with this subscription, this field is + * used to configure it. An empty pushConfig signifies that the subscriber + * will pull and ack messages using API methods. + * @param ackDeadlineSeconds This value is the maximum time after a subscriber receives a message + * before the subscriber should acknowledge the message. After message + * delivery but before the ack deadline expires and before the message is + * acknowledged, it is an outstanding message and will not be delivered + * again during that time (on a best-effort basis). + * + * For pull delivery this value is used as the initial value for the ack + * deadline. To override this value for a given message, call + * ModifyAckDeadline with the corresponding ack_id. + * + * For push delivery, this value is also used to set the request timeout for + * the call to the push endpoint. + * + * If the subscriber never acknowledges the message, the Pub/Sub + * system will eventually redeliver the message. + * + * If this parameter is not set, the default value of 10 seconds is used. + */ + public Subscription createSubscription(String name, String topic, PushConfig pushConfig, int ackDeadlineSeconds) { + Subscription request = + Subscription.newBuilder() + .setName(name) + .setTopic(topic) + .setPushConfig(pushConfig) + .setAckDeadlineSeconds(ackDeadlineSeconds) + .build(); + + return createSubscription(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates a subscription to a given topic for a given subscriber. + * If the subscription already exists, returns ALREADY_EXISTS. + * If the corresponding topic doesn't exist, returns NOT_FOUND. + * + * If the name is not provided in the request, the server will assign a random + * name for this subscription on the same project as the topic. + * + * @param request The request object containing all of the parameters for the API call. + */ + public Subscription createSubscription(Subscription request) { + return createSubscriptionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates a subscription to a given topic for a given subscriber. + * If the subscription already exists, returns ALREADY_EXISTS. + * If the corresponding topic doesn't exist, returns NOT_FOUND. + * + * If the name is not provided in the request, the server will assign a random + * name for this subscription on the same project as the topic. + */ + public ApiCallable createSubscriptionCallable() { + return ApiUtils.prepareIdempotentCallable(CREATE_SUBSCRIPTION, settings).bind(channel); + } + + // ----- getSubscription ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration details of a subscription. + * + * @param subscription The name of the subscription to get. + */ + public Subscription getSubscription(String subscription) { + GetSubscriptionRequest request = + GetSubscriptionRequest.newBuilder() + .setSubscription(subscription) + .build(); + + return getSubscription(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration details of a subscription. + * + * @param request The request object containing all of the parameters for the API call. + */ + public Subscription getSubscription(GetSubscriptionRequest request) { + return getSubscriptionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration details of a subscription. + */ + public ApiCallable getSubscriptionCallable() { + return ApiUtils.prepareIdempotentCallable(GET_SUBSCRIPTION, settings).bind(channel); + } + + // ----- listSubscriptions ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching subscriptions. + */ + public Iterable listSubscriptions(String project) { + ListSubscriptionsRequest request = + ListSubscriptionsRequest.newBuilder() + .setProject(project) + .build(); + return listSubscriptions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching subscriptions. + * + * @param request The request object containing all of the parameters for the API call. + */ + public Iterable listSubscriptions(ListSubscriptionsRequest request) { + return listSubscriptionsStreamingCallable() + .iterableResponseStreamCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching subscriptions. + */ + public ApiCallable listSubscriptionsStreamingCallable() { + return listSubscriptionsCallable().pageStreaming(LIST_SUBSCRIPTIONS_PAGE_DESC); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching subscriptions. + */ + public ApiCallable listSubscriptionsCallable() { + return ApiUtils.prepareIdempotentCallable(LIST_SUBSCRIPTIONS, settings).bind(channel); + } + + // ----- deleteSubscription ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes an existing subscription. All pending messages in the subscription + * are immediately dropped. Calls to Pull after deletion will return + * NOT_FOUND. After a subscription is deleted, a new one may be created with + * the same name, but the new one has no association with the old + * subscription, or its topic unless the same topic is specified. + * + * @param subscription The subscription to delete. + */ + public void deleteSubscription(String subscription) { + DeleteSubscriptionRequest request = + DeleteSubscriptionRequest.newBuilder() + .setSubscription(subscription) + .build(); + + deleteSubscription(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes an existing subscription. All pending messages in the subscription + * are immediately dropped. Calls to Pull after deletion will return + * NOT_FOUND. After a subscription is deleted, a new one may be created with + * the same name, but the new one has no association with the old + * subscription, or its topic unless the same topic is specified. + * + * @param request The request object containing all of the parameters for the API call. + */ + public void deleteSubscription(DeleteSubscriptionRequest request) { + deleteSubscriptionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes an existing subscription. All pending messages in the subscription + * are immediately dropped. Calls to Pull after deletion will return + * NOT_FOUND. After a subscription is deleted, a new one may be created with + * the same name, but the new one has no association with the old + * subscription, or its topic unless the same topic is specified. + */ + public ApiCallable deleteSubscriptionCallable() { + return ApiUtils.prepareIdempotentCallable(DELETE_SUBSCRIPTION, settings).bind(channel); + } + + // ----- modifyAckDeadline ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the ack deadline for a specific message. This method is useful to + * indicate that more time is needed to process a message by the subscriber, + * or to make the message available for redelivery if the processing was + * interrupted. + * + * @param subscription The name of the subscription. + * @param ackIds List of acknowledgment IDs. + * @param ackDeadlineSeconds The new ack deadline with respect to the time this request was sent to the + * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack + * deadline will expire 10 seconds after the ModifyAckDeadline call was made. + * Specifying zero may immediately make the message available for another pull + * request. + */ + public void modifyAckDeadline(String subscription, List ackIds, int ackDeadlineSeconds) { + ModifyAckDeadlineRequest request = + ModifyAckDeadlineRequest.newBuilder() + .setSubscription(subscription) + .addAllAckIds(ackIds) + .setAckDeadlineSeconds(ackDeadlineSeconds) + .build(); + + modifyAckDeadline(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the ack deadline for a specific message. This method is useful to + * indicate that more time is needed to process a message by the subscriber, + * or to make the message available for redelivery if the processing was + * interrupted. + * + * @param request The request object containing all of the parameters for the API call. + */ + public void modifyAckDeadline(ModifyAckDeadlineRequest request) { + modifyAckDeadlineCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the ack deadline for a specific message. This method is useful to + * indicate that more time is needed to process a message by the subscriber, + * or to make the message available for redelivery if the processing was + * interrupted. + */ + public ApiCallable modifyAckDeadlineCallable() { + return MODIFY_ACK_DEADLINE.bind(channel); + } + + // ----- acknowledge ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Acknowledges the messages associated with the ack tokens in the + * AcknowledgeRequest. The Pub/Sub system can remove the relevant messages + * from the subscription. + * + * Acknowledging a message whose ack deadline has expired may succeed, + * but such a message may be redelivered later. Acknowledging a message more + * than once will not result in an error. + * + * @param subscription The subscription whose message is being acknowledged. + * @param ackIds The acknowledgment ID for the messages being acknowledged that was returned + * by the Pub/Sub system in the Pull response. Must not be empty. + */ + public void acknowledge(String subscription, List ackIds) { + AcknowledgeRequest request = + AcknowledgeRequest.newBuilder() + .setSubscription(subscription) + .addAllAckIds(ackIds) + .build(); + + acknowledge(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Acknowledges the messages associated with the ack tokens in the + * AcknowledgeRequest. The Pub/Sub system can remove the relevant messages + * from the subscription. + * + * Acknowledging a message whose ack deadline has expired may succeed, + * but such a message may be redelivered later. Acknowledging a message more + * than once will not result in an error. + * + * @param request The request object containing all of the parameters for the API call. + */ + public void acknowledge(AcknowledgeRequest request) { + acknowledgeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Acknowledges the messages associated with the ack tokens in the + * AcknowledgeRequest. The Pub/Sub system can remove the relevant messages + * from the subscription. + * + * Acknowledging a message whose ack deadline has expired may succeed, + * but such a message may be redelivered later. Acknowledging a message more + * than once will not result in an error. + */ + public ApiCallable acknowledgeCallable() { + return ACKNOWLEDGE.bind(channel); + } + + // ----- pull ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Pulls messages from the server. Returns an empty list if there are no + * messages available in the backlog. The server may return UNAVAILABLE if + * there are too many concurrent pull requests pending for the given + * subscription. + * + * @param subscription The subscription from which messages should be pulled. + * @param returnImmediately If this is specified as true the system will respond immediately even if + * it is not able to return a message in the Pull response. Otherwise the + * system is allowed to wait until at least one message is available rather + * than returning no messages. The client may cancel the request if it does + * not wish to wait any longer for the response. + * @param maxMessages The maximum number of messages returned for this request. The Pub/Sub + * system may return fewer than the number specified. + */ + public PullResponse pull(String subscription, boolean returnImmediately, int maxMessages) { + PullRequest request = + PullRequest.newBuilder() + .setSubscription(subscription) + .setReturnImmediately(returnImmediately) + .setMaxMessages(maxMessages) + .build(); + + return pull(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Pulls messages from the server. Returns an empty list if there are no + * messages available in the backlog. The server may return UNAVAILABLE if + * there are too many concurrent pull requests pending for the given + * subscription. + * + * @param request The request object containing all of the parameters for the API call. + */ + public PullResponse pull(PullRequest request) { + return pullCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Pulls messages from the server. Returns an empty list if there are no + * messages available in the backlog. The server may return UNAVAILABLE if + * there are too many concurrent pull requests pending for the given + * subscription. + */ + public ApiCallable pullCallable() { + return PULL.bind(channel); + } + + // ----- modifyPushConfig ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the PushConfig for a specified subscription. + * + * This may be used to change a push subscription to a pull one (signified + * by an empty PushConfig) or vice versa, or change the endpoint URL and other + * attributes of a push subscription. Messages will accumulate for + * delivery continuously through the call regardless of changes to the + * PushConfig. + * + * @param subscription The name of the subscription. + * @param pushConfig The push configuration for future deliveries. + * + * An empty pushConfig indicates that the Pub/Sub system should + * stop pushing messages from the given subscription and allow + * messages to be pulled and acknowledged - effectively pausing + * the subscription if Pull is not called. + */ + public void modifyPushConfig(String subscription, PushConfig pushConfig) { + ModifyPushConfigRequest request = + ModifyPushConfigRequest.newBuilder() + .setSubscription(subscription) + .setPushConfig(pushConfig) + .build(); + + modifyPushConfig(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the PushConfig for a specified subscription. + * + * This may be used to change a push subscription to a pull one (signified + * by an empty PushConfig) or vice versa, or change the endpoint URL and other + * attributes of a push subscription. Messages will accumulate for + * delivery continuously through the call regardless of changes to the + * PushConfig. + * + * @param request The request object containing all of the parameters for the API call. + */ + public void modifyPushConfig(ModifyPushConfigRequest request) { + modifyPushConfigCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the PushConfig for a specified subscription. + * + * This may be used to change a push subscription to a pull one (signified + * by an empty PushConfig) or vice versa, or change the endpoint URL and other + * attributes of a push subscription. Messages will accumulate for + * delivery continuously through the call regardless of changes to the + * PushConfig. + */ + public ApiCallable modifyPushConfigCallable() { + return MODIFY_PUSH_CONFIG.bind(channel); + } + + + // ======== + // Cleanup + // ======== + + /** + * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately + * cancelled. + */ + @Override public void close() { + // Manually-added shutdown code + + // Auto-generated shutdown code + channel.shutdown(); + + // Manually-added shutdown code + } + + + // ======== + // Manually-added methods: add custom (non-generated) methods after this point. + // ======== + +} diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/LocalPublisherImpl.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/LocalPublisherImpl.java new file mode 100644 index 000000000000..c6cd637dd980 --- /dev/null +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/LocalPublisherImpl.java @@ -0,0 +1,138 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.google.gcloud.pubsub.spi; + +import com.google.protobuf.Empty; +import com.google.pubsub.v1.DeleteTopicRequest; +import com.google.pubsub.v1.GetTopicRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsResponse; +import com.google.pubsub.v1.ListTopicsRequest; +import com.google.pubsub.v1.ListTopicsResponse; +import com.google.pubsub.v1.PublishRequest; +import com.google.pubsub.v1.PublishResponse; +import com.google.pubsub.v1.PublisherGrpc.Publisher; +import com.google.pubsub.v1.PubsubMessage; +import com.google.pubsub.v1.Topic; + +import io.grpc.stub.StreamObserver; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class LocalPublisherImpl implements Publisher { + + private Map> topics = new HashMap<>(); + + @Override + public void createTopic(Topic request, StreamObserver responseObserver) { + topics.put(request.getName(), new ArrayList()); + + Topic response = Topic.newBuilder().setName(request.getName()).build(); + responseObserver.onNext(response); + responseObserver.onCompleted(); + } + + @Override + public void publish(PublishRequest request, StreamObserver responseObserver) { + List topicMessages = topics.get(request.getTopic()); + List ids = new ArrayList<>(); + int index = 0; + for (PubsubMessage msg : request.getMessagesList()) { + topicMessages.add(msg); + ids.add(new Integer(index).toString()); + } + + responseObserver.onNext(PublishResponse.newBuilder().addAllMessageIds(ids).build()); + responseObserver.onCompleted(); + } + + @Override + public void getTopic(GetTopicRequest request, StreamObserver responseObserver) { + if (topics.get(request.getTopic()) == null) { + throw new IllegalArgumentException("topic doesn't exist: " + request.getTopic()); + } + + Topic response = Topic.newBuilder().setName(request.getTopic()).build(); + responseObserver.onNext(response); + responseObserver.onCompleted(); + } + + @Override + public void listTopics(ListTopicsRequest request, StreamObserver responseObserver) { + List responseTopics = new ArrayList<>(); + for (String topicName : topics.keySet()) { + String projectOfTopic = PublisherApi.TOPIC_PATH_TEMPLATE.parse(topicName).get("project"); + String projectOfRequest = PublisherApi.PROJECT_PATH_TEMPLATE.parse(request.getProject()).get("project"); + if (projectOfTopic.equals(projectOfRequest)) { + Topic topicObj = Topic.newBuilder().setName(topicName).build(); + responseTopics.add(topicObj); + } + } + Collections.sort(responseTopics, new Comparator() { + @Override public int compare(Topic o1, Topic o2) { + return o1.getName().compareTo(o2.getName()); + } + }); + ListTopicsResponse.Builder response = ListTopicsResponse.newBuilder(); + response.setNextPageToken(""); + response.addAllTopics(responseTopics); + responseObserver.onNext(response.build()); + responseObserver.onCompleted(); + } + + @Override + public void listTopicSubscriptions(ListTopicSubscriptionsRequest request, + StreamObserver responseObserver) { + responseObserver.onNext(ListTopicSubscriptionsResponse.getDefaultInstance()); + responseObserver.onCompleted(); + } + + @Override + public void deleteTopic(DeleteTopicRequest request, StreamObserver responseObserver) { + topics.remove(request.getTopic()); + responseObserver.onNext(Empty.getDefaultInstance()); + responseObserver.onCompleted(); + } + + public Map> getTopics() { + return topics; + } + + public void reset() { + topics = new HashMap<>(); + } +} diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java new file mode 100644 index 000000000000..41dc3bb7c160 --- /dev/null +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java @@ -0,0 +1,175 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.google.gcloud.pubsub.spi; + +import com.google.protobuf.ByteString; +import com.google.pubsub.v1.PublisherGrpc; +import com.google.pubsub.v1.PubsubMessage; +import com.google.pubsub.v1.Topic; + +import io.gapi.gax.grpc.ServiceApiSettings; +import io.grpc.ManagedChannel; +import io.grpc.Server; +import io.grpc.netty.NegotiationType; +import io.grpc.netty.NettyChannelBuilder; +import io.grpc.netty.NettyServerBuilder; +import io.netty.channel.local.LocalAddress; +import io.netty.channel.local.LocalChannel; +import io.netty.channel.local.LocalServerChannel; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class PublisherApiTest { + private static Server server; + private static LocalPublisherImpl publisherImpl; + private ManagedChannel channel; + private PublisherApi publisherApi; + + @BeforeClass + public static void startStaticServer() { + publisherImpl = new LocalPublisherImpl(); + NettyServerBuilder builder = NettyServerBuilder + .forAddress(new LocalAddress("in-process-1")) + .flowControlWindow(65 * 1024) + .channelType(LocalServerChannel.class); + builder.addService(PublisherGrpc.bindService(publisherImpl)); + try { + server = builder.build().start(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + + @AfterClass + public static void stopServer() { + server.shutdownNow(); + } + + @Before + public void setUp() throws Exception { + publisherImpl.reset(); + channel = NettyChannelBuilder + .forAddress(new LocalAddress("in-process-1")) + .negotiationType(NegotiationType.PLAINTEXT) + .channelType(LocalChannel.class) + .build(); + + ServiceApiSettings settings = new ServiceApiSettings(); + settings.setChannel(channel); + publisherApi = PublisherApi.create(settings); + } + + @After + public void tearDown() throws Exception { + if (channel != null) { + channel.shutdown(); + } + if (publisherApi != null) { + publisherApi.close(); + } + publisherImpl.reset(); + } + + @Test + public void testCreateTopic() throws Exception { + String topicName = PublisherApi.createTopic("my-project", "my-topic"); + + Topic result = publisherApi.createTopic(topicName); + Assert.assertEquals(topicName, result.getName()); + + Assert.assertEquals(1, publisherImpl.getTopics().size()); + Assert.assertNotNull(publisherImpl.getTopics().get(topicName)); + } + + @Test + public void testPublish() throws Exception { + String topicName = PublisherApi.createTopic("my-project", "publish-topic"); + + publisherApi.createTopic(topicName); + PubsubMessage msg = PubsubMessage.newBuilder() + .setData(ByteString.copyFromUtf8("pubsub-message")) + .build(); + publisherApi.publish(topicName, Collections.singletonList(msg)); + List publishedMessages = publisherImpl.getTopics().get(topicName); + Assert.assertEquals(1, publishedMessages.size()); + Assert.assertEquals("pubsub-message", publishedMessages.get(0).getData().toStringUtf8()); + } + + @Test + public void testGetTopic() throws Exception { + String topicName = PublisherApi.createTopic("my-project", "fun-topic"); + + publisherApi.createTopic(topicName); + Topic result = publisherApi.getTopic(topicName); + Assert.assertNotNull(result); + Assert.assertEquals(topicName, result.getName()); + } + + @Test + public void testListTopics() throws Exception { + String project1 = PublisherApi.createProject("project.1"); + String topicName1 = PublisherApi.createTopic("project.1", "topic.1"); + String topicName2 = PublisherApi.createTopic("project.1", "topic.2"); + String topicName3 = PublisherApi.createTopic("project.2", "topic.3"); + + publisherApi.createTopic(topicName1); + publisherApi.createTopic(topicName2); + publisherApi.createTopic(topicName3); + + List topics = new ArrayList<>(); + for (Topic topic : publisherApi.listTopics(project1)) { + topics.add(topic); + } + Assert.assertEquals(2, topics.size()); + Assert.assertEquals(topicName1, topics.get(0).getName()); + Assert.assertEquals(topicName2, topics.get(1).getName()); + } + + @Test + public void testDeleteTopic() throws Exception { + String topicName = PublisherApi.createTopic("my-project", "fun-topic"); + + publisherApi.createTopic(topicName); + publisherApi.deleteTopic(topicName); + Assert.assertEquals(0, publisherImpl.getTopics().size()); + } +} From d470e5681120857f6db0f001d63eed1c23b1c996 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Wed, 11 Nov 2015 11:33:07 -0800 Subject: [PATCH 178/203] Fixing source paths and module configuration --- gcloud-java-gax/pom.xml | 2 +- gcloud-java-pubsub/.classpath | 32 ++++++++++++++++++++++++++++++++ gcloud-java-pubsub/pom.xml | 2 +- pom.xml | 5 +++-- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 gcloud-java-pubsub/.classpath diff --git a/gcloud-java-gax/pom.xml b/gcloud-java-gax/pom.xml index bbfd8c6007e5..5710df3d5bfe 100644 --- a/gcloud-java-gax/pom.xml +++ b/gcloud-java-gax/pom.xml @@ -63,7 +63,7 @@ add-source - generated/src/main + generated/src/main/java diff --git a/gcloud-java-pubsub/.classpath b/gcloud-java-pubsub/.classpath new file mode 100644 index 000000000000..19d2611e3109 --- /dev/null +++ b/gcloud-java-pubsub/.classpath @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index df9debe4a030..998adeee4827 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -51,7 +51,7 @@ add-source - generated/src/main + generated/src/main/java diff --git a/pom.xml b/pom.xml index d73956f506ee..e42a0939ff04 100644 --- a/pom.xml +++ b/pom.xml @@ -97,8 +97,9 @@ gcloud-java-bigquery gcloud-java-contrib gcloud-java-core + gcloud-java-gax gcloud-java-datastore - gcloud-java-dns + gcloud-java-pubsub gcloud-java-examples gcloud-java-resourcemanager gcloud-java-storage @@ -160,7 +161,7 @@ [1.7,) - + From 0a3e09b5726496343d5599dfc310e4ad5b433718 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Tue, 17 Nov 2015 15:40:58 -0800 Subject: [PATCH 179/203] Updates to address PR comments. * license change * update to notes on code updating * renaming helper functions for creating fully-qualified paths * making certain static final members private * adding some documentation * minor reformating * Creating LocalPubsubHelper, using it in PublisherApiTest * Making the constructor of PublisherApi protected so that subclasses can be created --- .../io/gapi/gax/grpc/ServiceApiSettings.java | 6 +- .../gcloud/pubsub/spi/PublisherApi.java | 102 ++++++++------- .../gcloud/pubsub/spi/SubscriberApi.java | 96 +++++++------- .../spi/testing/LocalPublisherImpl.java | 120 ++++++++++++++++++ .../pubsub/testing/LocalPubsubHelper.java | 83 ++++++++++++ .../gcloud/pubsub/spi/PublisherApiTest.java | 109 ++++------------ 6 files changed, 339 insertions(+), 177 deletions(-) create mode 100644 gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java create mode 100644 gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java index 485d4794d917..13da3abe911b 100644 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java @@ -105,8 +105,10 @@ public int getPort() { } /** - * An instance of ManagedChannel; shutdown will be called on this channel when - * the instance of LoggingServiceApi is shut down. + * The channel used to send requests to the service. Whichever service api class that + * this instance of ServiceApiSettings is passed to will call shutdown() on this + * channel. This injection mechanism is intended for use by unit tests to override + * the channel that would be created by default for real calls to the service. */ public ServiceApiSettings setChannel(ManagedChannel channel) { this.channel = channel; diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index 3c239c3923e4..08d4181c8fd3 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -1,45 +1,31 @@ /* - * Copyright 2015, Google Inc. All rights reserved. + * Copyright 2015 Google Inc. All Rights Reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * 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 * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. + * http://www.apache.org/licenses/LICENSE-2.0 * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * 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. */ /* * EDITING INSTRUCTIONS - * This file was generated from the file google/pubsub/v1/pubsub.proto, - * and updates to that file get reflected here through a regular refresh process. - * However, manual additions are allowed because the refresh process performs + * This file was generated from the file + * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google engineers. + * Manual additions are allowed because the refresh process performs * a 3-way merge in order to preserve those manual additions. In order to not * break the refresh process, only certain types of modifications are * allowed. * - * Allowed modifications - currently there is only one type allowed: + * Allowed modifications - currently these are the only types allowed: * 1. New methods (these should be added to the end of the class) + * 2. New imports * * Happy editing! */ @@ -96,28 +82,27 @@ public class PublisherApi implements AutoCloseable { public static final int DEFAULT_SERVICE_PORT = 443; - public static final ApiCallable + private static final ApiCallable CREATE_TOPIC = ApiCallable.create(PublisherGrpc.METHOD_CREATE_TOPIC); - public static final ApiCallable + private static final ApiCallable PUBLISH = ApiCallable.create(PublisherGrpc.METHOD_PUBLISH); - public static final ApiCallable + private static final ApiCallable GET_TOPIC = ApiCallable.create(PublisherGrpc.METHOD_GET_TOPIC); - public static final ApiCallable + private static final ApiCallable LIST_TOPICS = ApiCallable.create(PublisherGrpc.METHOD_LIST_TOPICS); - public static final ApiCallable + private static final ApiCallable LIST_TOPIC_SUBSCRIPTIONS = ApiCallable.create(PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS); - public static final ApiCallable + private static final ApiCallable DELETE_TOPIC = ApiCallable.create(PublisherGrpc.METHOD_DELETE_TOPIC); - - - private static PageDescriptor LIST_TOPICS_PAGE_DESC = new PageDescriptor() { - @Override public Object emptyToken() { + @Override + public Object emptyToken() { return ""; } - @Override public ListTopicsRequest injectToken( + @Override + public ListTopicsRequest injectToken( ListTopicsRequest payload, Object token) { return ListTopicsRequest .newBuilder(payload) @@ -133,12 +118,15 @@ public Iterable extractResources(ListTopicsResponse payload) { return payload.getTopicsList(); } }; + private static PageDescriptor LIST_TOPIC_SUBSCRIPTIONS_PAGE_DESC = new PageDescriptor() { - @Override public Object emptyToken() { + @Override + public Object emptyToken() { return ""; } - @Override public ListTopicSubscriptionsRequest injectToken( + @Override + public ListTopicSubscriptionsRequest injectToken( ListTopicSubscriptionsRequest payload, Object token) { return ListTopicSubscriptionsRequest .newBuilder(payload) @@ -159,8 +147,17 @@ public Iterable extractResources(ListTopicSubscriptionsResponse payload) "https://www.googleapis.com/auth/pubsub" }; + /** + * A PathTemplate representing the fully-qualified path to represent + * a project resource. + */ public static final PathTemplate PROJECT_PATH_TEMPLATE = PathTemplate.create("/projects/{project}"); + + /** + * A PathTemplate representing the fully-qualified path to represent + * a topic resource. + */ public static final PathTemplate TOPIC_PATH_TEMPLATE = PathTemplate.create("/projects/{project}/topics/{topic}"); @@ -190,7 +187,11 @@ public static PublisherApi create(ServiceApiSettings settings) throws IOExceptio return new PublisherApi(settings); } - private PublisherApi(ServiceApiSettings settings) throws IOException { + /** + * Constructs an instance of PublisherApi, using the given settings. This is protected so that it + * easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected PublisherApi(ServiceApiSettings settings) throws IOException { ServiceApiSettings internalSettings = ApiUtils.settingsWithChannels(settings, SERVICE_ADDRESS, DEFAULT_SERVICE_PORT, ALL_SCOPES); this.settings = internalSettings; @@ -201,12 +202,20 @@ private PublisherApi(ServiceApiSettings settings) throws IOException { // Resource Name Helper Functions // ============================== - public static final String createProject(String project) { + /** + * Creates a string containing the fully-qualified path to represent + * a project resource. + */ + public static final String createProjectPath(String project) { return PROJECT_PATH_TEMPLATE.instantiate( "project", project); } - public static final String createTopic(String project, String topic) { + /** + * Creates a string containing the fully-qualified path to represent + * a topic resource. + */ + public static final String createTopicPath(String project, String topic) { return TOPIC_PATH_TEMPLATE.instantiate( "project", project,"topic", topic); } @@ -481,7 +490,8 @@ public ApiCallable deleteTopicCallable() { * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately * cancelled. */ - @Override public void close() { + @Override + public void close() { // Manually-added shutdown code // Auto-generated shutdown code diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index 6afe0da72d51..6ec9195d25a2 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -1,45 +1,31 @@ /* - * Copyright 2015, Google Inc. All rights reserved. + * Copyright 2015 Google Inc. All Rights Reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * 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 * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. + * http://www.apache.org/licenses/LICENSE-2.0 * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * 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. */ /* * EDITING INSTRUCTIONS - * This file was generated from the file google/pubsub/v1/pubsub.proto, - * and updates to that file get reflected here through a regular refresh process. - * However, manual additions are allowed because the refresh process performs + * This file was generated from the file + * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google engineers. + * Manual additions are allowed because the refresh process performs * a 3-way merge in order to preserve those manual additions. In order to not * break the refresh process, only certain types of modifications are * allowed. * - * Allowed modifications - currently there is only one type allowed: + * Allowed modifications - currently these are the only types allowed: * 1. New methods (these should be added to the end of the class) + * 2. New imports * * Happy editing! */ @@ -97,31 +83,31 @@ public class SubscriberApi implements AutoCloseable { public static final int DEFAULT_SERVICE_PORT = 443; - public static final ApiCallable + private static final ApiCallable CREATE_SUBSCRIPTION = ApiCallable.create(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); - public static final ApiCallable + private static final ApiCallable GET_SUBSCRIPTION = ApiCallable.create(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); - public static final ApiCallable + private static final ApiCallable LIST_SUBSCRIPTIONS = ApiCallable.create(SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS); - public static final ApiCallable + private static final ApiCallable DELETE_SUBSCRIPTION = ApiCallable.create(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); - public static final ApiCallable + private static final ApiCallable MODIFY_ACK_DEADLINE = ApiCallable.create(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); - public static final ApiCallable + private static final ApiCallable ACKNOWLEDGE = ApiCallable.create(SubscriberGrpc.METHOD_ACKNOWLEDGE); - public static final ApiCallable + private static final ApiCallable PULL = ApiCallable.create(SubscriberGrpc.METHOD_PULL); - public static final ApiCallable + private static final ApiCallable MODIFY_PUSH_CONFIG = ApiCallable.create(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); - - private static PageDescriptor LIST_SUBSCRIPTIONS_PAGE_DESC = new PageDescriptor() { - @Override public Object emptyToken() { + @Override + public Object emptyToken() { return ""; } - @Override public ListSubscriptionsRequest injectToken( + @Override + public ListSubscriptionsRequest injectToken( ListSubscriptionsRequest payload, Object token) { return ListSubscriptionsRequest .newBuilder(payload) @@ -138,16 +124,21 @@ public Iterable extractResources(ListSubscriptionsResponse payload } }; - - - - private static String ALL_SCOPES[] = { "https://www.googleapis.com/auth/pubsub" }; + /** + * A PathTemplate representing the fully-qualified path to represent + * a project resource. + */ public static final PathTemplate PROJECT_PATH_TEMPLATE = PathTemplate.create("/projects/{project}"); + + /** + * A PathTemplate representing the fully-qualified path to represent + * a subscription resource. + */ public static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = PathTemplate.create("/projects/{project}/subscriptions/{subscription}"); @@ -188,12 +179,20 @@ private SubscriberApi(ServiceApiSettings settings) throws IOException { // Resource Name Helper Functions // ============================== - public static final String createProject(String project) { + /** + * Creates a string containing the fully-qualified path to represent + * a project resource. + */ + public static final String createProjectPath(String project) { return PROJECT_PATH_TEMPLATE.instantiate( "project", project); } - public static final String createSubscription(String project, String subscription) { + /** + * Creates a string containing the fully-qualified path to represent + * a subscription resource. + */ + public static final String createSubscriptionPath(String project, String subscription) { return SUBSCRIPTION_PATH_TEMPLATE.instantiate( "project", project,"subscription", subscription); } @@ -646,7 +645,8 @@ public ApiCallable modifyPushConfigCallable() { * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately * cancelled. */ - @Override public void close() { + @Override + public void close() { // Manually-added shutdown code // Auto-generated shutdown code diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java new file mode 100644 index 000000000000..b9c5f9d513bd --- /dev/null +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java @@ -0,0 +1,120 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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.gcloud.pubsub.spi.testing; + +import com.google.gcloud.pubsub.spi.PublisherApi; +import com.google.protobuf.Empty; +import com.google.pubsub.v1.DeleteTopicRequest; +import com.google.pubsub.v1.GetTopicRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsResponse; +import com.google.pubsub.v1.ListTopicsRequest; +import com.google.pubsub.v1.ListTopicsResponse; +import com.google.pubsub.v1.PublishRequest; +import com.google.pubsub.v1.PublishResponse; +import com.google.pubsub.v1.PublisherGrpc.Publisher; +import com.google.pubsub.v1.PubsubMessage; +import com.google.pubsub.v1.Topic; + +import io.grpc.stub.StreamObserver; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class LocalPublisherImpl implements Publisher { + + private Map> topics = new HashMap<>(); + + @Override + public void createTopic(Topic request, StreamObserver responseObserver) { + topics.put(request.getName(), new ArrayList()); + + Topic response = Topic.newBuilder().setName(request.getName()).build(); + responseObserver.onNext(response); + responseObserver.onCompleted(); + } + + @Override + public void publish(PublishRequest request, StreamObserver responseObserver) { + List topicMessages = topics.get(request.getTopic()); + List ids = new ArrayList<>(); + int index = 0; + for (PubsubMessage msg : request.getMessagesList()) { + topicMessages.add(msg); + ids.add(new Integer(index).toString()); + } + responseObserver.onNext(PublishResponse.newBuilder().addAllMessageIds(ids).build()); + responseObserver.onCompleted(); + } + + @Override + public void getTopic(GetTopicRequest request, StreamObserver responseObserver) { + if (topics.get(request.getTopic()) == null) { + throw new IllegalArgumentException("topic doesn't exist: " + request.getTopic()); + } + Topic response = Topic.newBuilder().setName(request.getTopic()).build(); + responseObserver.onNext(response); + responseObserver.onCompleted(); + } + + @Override + public void listTopics(ListTopicsRequest request, StreamObserver responseObserver) { + List responseTopics = new ArrayList<>(); + for (String topicName : topics.keySet()) { + String projectOfTopic = PublisherApi.TOPIC_PATH_TEMPLATE.parse(topicName).get("project"); + String projectOfRequest = PublisherApi.PROJECT_PATH_TEMPLATE.parse(request.getProject()).get("project"); + if (projectOfTopic.equals(projectOfRequest)) { + Topic topicObj = Topic.newBuilder().setName(topicName).build(); + responseTopics.add(topicObj); + } + } + Collections.sort(responseTopics, new Comparator() { + @Override public int compare(Topic o1, Topic o2) { + return o1.getName().compareTo(o2.getName()); + } + }); + ListTopicsResponse.Builder response = ListTopicsResponse.newBuilder(); + response.setNextPageToken(""); + response.addAllTopics(responseTopics); + responseObserver.onNext(response.build()); + responseObserver.onCompleted(); + } + + @Override + public void listTopicSubscriptions(ListTopicSubscriptionsRequest request, + StreamObserver responseObserver) { + responseObserver.onNext(ListTopicSubscriptionsResponse.getDefaultInstance()); + responseObserver.onCompleted(); + } + + @Override + public void deleteTopic(DeleteTopicRequest request, StreamObserver responseObserver) { + topics.remove(request.getTopic()); + responseObserver.onNext(Empty.getDefaultInstance()); + responseObserver.onCompleted(); + } + + public Map> getTopics() { + return topics; + } + + public void reset() { + topics = new HashMap<>(); + } +} diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java new file mode 100644 index 000000000000..13fbf5208047 --- /dev/null +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java @@ -0,0 +1,83 @@ +package com.google.gcloud.pubsub.testing; + +import com.google.gcloud.pubsub.spi.testing.LocalPublisherImpl; +import com.google.pubsub.v1.PublisherGrpc; + +import io.grpc.ManagedChannel; +import io.grpc.Server; +import io.grpc.netty.NegotiationType; +import io.grpc.netty.NettyChannelBuilder; +import io.grpc.netty.NettyServerBuilder; +import io.netty.channel.local.LocalAddress; +import io.netty.channel.local.LocalChannel; +import io.netty.channel.local.LocalServerChannel; + +import java.io.IOException; +import java.net.SocketAddress; + +/** + * A class that runs an in-memory Publisher instance for use in tests. + */ +public class LocalPubsubHelper { + private static final SocketAddress address = new LocalAddress("in-process-1"); + private static Server server; + private static LocalPublisherImpl publisherImpl; + + /** + * Constructs a new LocalPubsubHelper. The method start() must + * be called before it is used. + */ + public LocalPubsubHelper() { + publisherImpl = new LocalPublisherImpl(); + NettyServerBuilder builder = NettyServerBuilder + .forAddress(address) + .flowControlWindow(65 * 1024) + .channelType(LocalServerChannel.class); + builder.addService(PublisherGrpc.bindService(publisherImpl)); + server = builder.build(); + } + + /** + * Starts the in-memory service. + */ + public LocalPubsubHelper start() { + try { + server.start(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + return this; + } + + /** + * Resets the state of the in-memory service. + */ + public void reset() { + publisherImpl.reset(); + } + + /** + * Returns the internal in-memory service. + */ + public LocalPublisherImpl getPublisherImpl() { + return publisherImpl; + } + + /** + * Creates a channel for making requests to the in-memory service. + */ + public ManagedChannel createChannel() { + return NettyChannelBuilder + .forAddress(address) + .negotiationType(NegotiationType.PLAINTEXT) + .channelType(LocalChannel.class) + .build(); + } + + /** + * Shuts down the in-memory service. + */ + public void shutdownNow() { + server.shutdownNow(); + } +} diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java index 41dc3bb7c160..96bdd9106497 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java @@ -1,52 +1,26 @@ /* - * Copyright 2015, Google Inc. All rights reserved. + * Copyright 2015 Google Inc. All Rights Reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * 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 * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. + * http://www.apache.org/licenses/LICENSE-2.0 * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * 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.gcloud.pubsub.spi; +import com.google.gcloud.pubsub.testing.LocalPubsubHelper; import com.google.protobuf.ByteString; -import com.google.pubsub.v1.PublisherGrpc; import com.google.pubsub.v1.PubsubMessage; import com.google.pubsub.v1.Topic; import io.gapi.gax.grpc.ServiceApiSettings; -import io.grpc.ManagedChannel; -import io.grpc.Server; -import io.grpc.netty.NegotiationType; -import io.grpc.netty.NettyChannelBuilder; -import io.grpc.netty.NettyServerBuilder; -import io.netty.channel.local.LocalAddress; -import io.netty.channel.local.LocalChannel; -import io.netty.channel.local.LocalServerChannel; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -59,85 +33,61 @@ import org.junit.Test; public class PublisherApiTest { - private static Server server; - private static LocalPublisherImpl publisherImpl; - private ManagedChannel channel; + private static LocalPubsubHelper pubsubHelper; private PublisherApi publisherApi; @BeforeClass public static void startStaticServer() { - publisherImpl = new LocalPublisherImpl(); - NettyServerBuilder builder = NettyServerBuilder - .forAddress(new LocalAddress("in-process-1")) - .flowControlWindow(65 * 1024) - .channelType(LocalServerChannel.class); - builder.addService(PublisherGrpc.bindService(publisherImpl)); - try { - server = builder.build().start(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } + pubsubHelper = new LocalPubsubHelper().start(); } @AfterClass public static void stopServer() { - server.shutdownNow(); + pubsubHelper.shutdownNow(); } @Before public void setUp() throws Exception { - publisherImpl.reset(); - channel = NettyChannelBuilder - .forAddress(new LocalAddress("in-process-1")) - .negotiationType(NegotiationType.PLAINTEXT) - .channelType(LocalChannel.class) - .build(); - + pubsubHelper.reset(); ServiceApiSettings settings = new ServiceApiSettings(); - settings.setChannel(channel); + settings.setChannel(pubsubHelper.createChannel()); publisherApi = PublisherApi.create(settings); } @After public void tearDown() throws Exception { - if (channel != null) { - channel.shutdown(); - } if (publisherApi != null) { publisherApi.close(); } - publisherImpl.reset(); + pubsubHelper.reset(); } @Test public void testCreateTopic() throws Exception { - String topicName = PublisherApi.createTopic("my-project", "my-topic"); - + String topicName = PublisherApi.createTopicPath("my-project", "my-topic"); Topic result = publisherApi.createTopic(topicName); Assert.assertEquals(topicName, result.getName()); - - Assert.assertEquals(1, publisherImpl.getTopics().size()); - Assert.assertNotNull(publisherImpl.getTopics().get(topicName)); + Assert.assertEquals(1, pubsubHelper.getPublisherImpl().getTopics().size()); + Assert.assertNotNull(pubsubHelper.getPublisherImpl().getTopics().get(topicName)); } @Test public void testPublish() throws Exception { - String topicName = PublisherApi.createTopic("my-project", "publish-topic"); - + String topicName = PublisherApi.createTopicPath("my-project", "publish-topic"); publisherApi.createTopic(topicName); PubsubMessage msg = PubsubMessage.newBuilder() .setData(ByteString.copyFromUtf8("pubsub-message")) .build(); publisherApi.publish(topicName, Collections.singletonList(msg)); - List publishedMessages = publisherImpl.getTopics().get(topicName); + List publishedMessages = + pubsubHelper.getPublisherImpl().getTopics().get(topicName); Assert.assertEquals(1, publishedMessages.size()); Assert.assertEquals("pubsub-message", publishedMessages.get(0).getData().toStringUtf8()); } @Test public void testGetTopic() throws Exception { - String topicName = PublisherApi.createTopic("my-project", "fun-topic"); - + String topicName = PublisherApi.createTopicPath("my-project", "fun-topic"); publisherApi.createTopic(topicName); Topic result = publisherApi.getTopic(topicName); Assert.assertNotNull(result); @@ -146,15 +96,13 @@ public void testGetTopic() throws Exception { @Test public void testListTopics() throws Exception { - String project1 = PublisherApi.createProject("project.1"); - String topicName1 = PublisherApi.createTopic("project.1", "topic.1"); - String topicName2 = PublisherApi.createTopic("project.1", "topic.2"); - String topicName3 = PublisherApi.createTopic("project.2", "topic.3"); - + String project1 = PublisherApi.createProjectPath("project.1"); + String topicName1 = PublisherApi.createTopicPath("project.1", "topic.1"); + String topicName2 = PublisherApi.createTopicPath("project.1", "topic.2"); + String topicName3 = PublisherApi.createTopicPath("project.2", "topic.3"); publisherApi.createTopic(topicName1); publisherApi.createTopic(topicName2); publisherApi.createTopic(topicName3); - List topics = new ArrayList<>(); for (Topic topic : publisherApi.listTopics(project1)) { topics.add(topic); @@ -166,10 +114,9 @@ public void testListTopics() throws Exception { @Test public void testDeleteTopic() throws Exception { - String topicName = PublisherApi.createTopic("my-project", "fun-topic"); - + String topicName = PublisherApi.createTopicPath("my-project", "fun-topic"); publisherApi.createTopic(topicName); publisherApi.deleteTopic(topicName); - Assert.assertEquals(0, publisherImpl.getTopics().size()); + Assert.assertEquals(0, pubsubHelper.getPublisherImpl().getTopics().size()); } } From 2f29b75790573a1bb105ddc25f6c48727f4d5d60 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Thu, 19 Nov 2015 10:35:52 -0800 Subject: [PATCH 180/203] More updates to address PR comments * Making template constants private * Adding helper methods to extract variables from template paths * Making it possible to have multiple instances of LocalPubsubHelper * Removing getChannel from *Api classes (not used anywhere) * Other cleanup --- .../gcloud/pubsub/spi/PublisherApi.java | 30 +++++++++++----- .../gcloud/pubsub/spi/SubscriberApi.java | 36 ++++++++++++++----- .../spi/testing/LocalPublisherImpl.java | 4 +-- .../pubsub/testing/LocalPubsubHelper.java | 13 ++++--- .../gcloud/pubsub/spi/PublisherApiTest.java | 2 +- 5 files changed, 60 insertions(+), 25 deletions(-) diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index 08d4181c8fd3..cb78e3f9c728 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -49,7 +49,6 @@ import io.gapi.gax.grpc.ServiceApiSettings; import io.gapi.gax.internal.ApiUtils; import io.gapi.gax.protobuf.PathTemplate; -import io.grpc.Channel; import io.grpc.ManagedChannel; import java.io.IOException; @@ -151,14 +150,14 @@ public Iterable extractResources(ListTopicSubscriptionsResponse payload) * A PathTemplate representing the fully-qualified path to represent * a project resource. */ - public static final PathTemplate PROJECT_PATH_TEMPLATE = + private static final PathTemplate PROJECT_PATH_TEMPLATE = PathTemplate.create("/projects/{project}"); /** * A PathTemplate representing the fully-qualified path to represent * a topic resource. */ - public static final PathTemplate TOPIC_PATH_TEMPLATE = + private static final PathTemplate TOPIC_PATH_TEMPLATE = PathTemplate.create("/projects/{project}/topics/{topic}"); // ======== @@ -220,13 +219,28 @@ public static final String createTopicPath(String project, String topic) { "project", project,"topic", topic); } + /** + * Extracts the project from the given fully-qualified path which + * represents a project resource. + */ + public static final String extractProjectFromProjectPath(String projectPath) { + return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); + } - // ======== - // Getters - // ======== + /** + * Extracts the project from the given fully-qualified path which + * represents a topic resource. + */ + public static final String extractProjectFromTopicPath(String topicPath) { + return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project"); + } - public Channel getChannel() { - return channel; + /** + * Extracts the topic from the given fully-qualified path which + * represents a topic resource. + */ + public static final String extractTopicFromTopicPath(String topicPath) { + return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic"); } diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index 6ec9195d25a2..1c9daaf82384 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -50,7 +50,6 @@ import io.gapi.gax.grpc.ServiceApiSettings; import io.gapi.gax.internal.ApiUtils; import io.gapi.gax.protobuf.PathTemplate; -import io.grpc.Channel; import io.grpc.ManagedChannel; import java.io.IOException; @@ -132,14 +131,14 @@ public Iterable extractResources(ListSubscriptionsResponse payload * A PathTemplate representing the fully-qualified path to represent * a project resource. */ - public static final PathTemplate PROJECT_PATH_TEMPLATE = + private static final PathTemplate PROJECT_PATH_TEMPLATE = PathTemplate.create("/projects/{project}"); /** * A PathTemplate representing the fully-qualified path to represent * a subscription resource. */ - public static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = + private static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = PathTemplate.create("/projects/{project}/subscriptions/{subscription}"); // ======== @@ -168,7 +167,11 @@ public static SubscriberApi create(ServiceApiSettings settings) throws IOExcepti return new SubscriberApi(settings); } - private SubscriberApi(ServiceApiSettings settings) throws IOException { + /** + * Constructs an instance of SubscriberApi, using the given settings. This is protected so that it + * easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected SubscriberApi(ServiceApiSettings settings) throws IOException { ServiceApiSettings internalSettings = ApiUtils.settingsWithChannels(settings, SERVICE_ADDRESS, DEFAULT_SERVICE_PORT, ALL_SCOPES); this.settings = internalSettings; @@ -197,13 +200,28 @@ public static final String createSubscriptionPath(String project, String subscri "project", project,"subscription", subscription); } + /** + * Extracts the project from the given fully-qualified path which + * represents a project resource. + */ + public static final String extractProjectFromProjectPath(String projectPath) { + return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); + } - // ======== - // Getters - // ======== + /** + * Extracts the project from the given fully-qualified path which + * represents a subscription resource. + */ + public static final String extractProjectFromSubscriptionPath(String subscriptionPath) { + return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("project"); + } - public Channel getChannel() { - return channel; + /** + * Extracts the subscription from the given fully-qualified path which + * represents a subscription resource. + */ + public static final String extractSubscriptionFromSubscriptionPath(String subscriptionPath) { + return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("subscription"); } diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java index b9c5f9d513bd..6ec1c008f6d0 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java @@ -77,8 +77,8 @@ public void getTopic(GetTopicRequest request, StreamObserver responseObse public void listTopics(ListTopicsRequest request, StreamObserver responseObserver) { List responseTopics = new ArrayList<>(); for (String topicName : topics.keySet()) { - String projectOfTopic = PublisherApi.TOPIC_PATH_TEMPLATE.parse(topicName).get("project"); - String projectOfRequest = PublisherApi.PROJECT_PATH_TEMPLATE.parse(request.getProject()).get("project"); + String projectOfTopic = PublisherApi.extractProjectFromTopicPath(topicName); + String projectOfRequest = PublisherApi.extractProjectFromProjectPath(request.getProject()); if (projectOfTopic.equals(projectOfRequest)) { Topic topicObj = Topic.newBuilder().setName(topicName).build(); responseTopics.add(topicObj); diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java index 13fbf5208047..033330ad6b83 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java @@ -19,19 +19,22 @@ * A class that runs an in-memory Publisher instance for use in tests. */ public class LocalPubsubHelper { - private static final SocketAddress address = new LocalAddress("in-process-1"); - private static Server server; - private static LocalPublisherImpl publisherImpl; + private static int FLOW_CONTROL_WINDOW = 65 * 1024; + + private final SocketAddress address; + private final Server server; + private final LocalPublisherImpl publisherImpl; /** * Constructs a new LocalPubsubHelper. The method start() must * be called before it is used. */ - public LocalPubsubHelper() { + public LocalPubsubHelper(String addressString) { + address = new LocalAddress(addressString); publisherImpl = new LocalPublisherImpl(); NettyServerBuilder builder = NettyServerBuilder .forAddress(address) - .flowControlWindow(65 * 1024) + .flowControlWindow(FLOW_CONTROL_WINDOW) .channelType(LocalServerChannel.class); builder.addService(PublisherGrpc.bindService(publisherImpl)); server = builder.build(); diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java index 96bdd9106497..19939e0876b6 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java @@ -38,7 +38,7 @@ public class PublisherApiTest { @BeforeClass public static void startStaticServer() { - pubsubHelper = new LocalPubsubHelper().start(); + pubsubHelper = new LocalPubsubHelper("in-process-1").start(); } @AfterClass From 2b75937518106bb2aab274e09046315882e97fc7 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Thu, 19 Nov 2015 16:18:07 -0800 Subject: [PATCH 181/203] Third round of updates to address PR comments * ApiUtils: Fixing usage of credentials when channel is null * ApiUtils: Function rename for clarity * ApiUtils, ServiceApiSettings: improving comments * ApiCallable: Removing obsolete stuff * not returning 'this' from LocalPubsubHelper.start() --- .../java/io/gapi/gax/grpc/ApiCallable.java | 18 ------ .../io/gapi/gax/grpc/ServiceApiSettings.java | 22 ++++--- .../java/io/gapi/gax/internal/ApiUtils.java | 61 ++++++++++++------- .../gcloud/pubsub/spi/PublisherApi.java | 2 +- .../gcloud/pubsub/spi/SubscriberApi.java | 2 +- .../pubsub/testing/LocalPubsubHelper.java | 3 +- .../gcloud/pubsub/spi/PublisherApiTest.java | 3 +- 7 files changed, 57 insertions(+), 54 deletions(-) diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java index edaa0885d46f..2e563a4413d0 100644 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java @@ -62,8 +62,6 @@ public abstract class ApiCallable { // TODO(wrwg): Support interceptors and method/call option configurations. - // TODO(wrwg): gather more feedback whether the overload with java.util.Concurrent hurts that - // much that we want to rename this into ClientCallable or such. // Subclass Contract // ================= @@ -390,20 +388,4 @@ public ApiCallable retrying() { return new PageStreamingCallable(this, pageDescriptor); } - /** - * Returns a callable which behaves the same as {@link #pageStreaming(PageDescriptor)}, with - * the page descriptor attempted to derive from the callable descriptor. - * - * @throws IllegalArgumentException if a page descriptor is not derivable. - */ - public ApiCallable - pageStreaming(Class resourceType) { - PageDescriptor pageDescriptor = - getDescriptor() != null ? getDescriptor().getPageDescriptor(resourceType) : null; - if (pageDescriptor == null) { - throw new IllegalArgumentException(String.format( - "cannot derive page descriptor for '%s'", this)); - } - return pageStreaming(pageDescriptor); - } } diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java index 13da3abe911b..eb3ca2b7a9d9 100644 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java @@ -35,12 +35,15 @@ import io.grpc.ManagedChannel; +/** + * A settings class to configure a service api class. + */ public class ServiceApiSettings { private boolean isIdempotentRetrying; private Credentials credentials; - private String servicePath; + private String serviceAddress; private int port; private ManagedChannel channel; @@ -48,7 +51,7 @@ public class ServiceApiSettings { public ServiceApiSettings() { isIdempotentRetrying = true; credentials = null; - servicePath = null; + serviceAddress = null; port = 0; } @@ -69,7 +72,8 @@ public boolean getIsIdempotentRetrying() { /** * Sets the credentials to use in order to call the service. The default is to acquire - * the credentials using GoogleCredentials.getApplicationDefault(). + * the credentials using GoogleCredentials.getApplicationDefault(). These credentials + * will not be used if the channel is set. */ public ServiceApiSettings setCredentials(Credentials credentials) { this.credentials = credentials; @@ -81,19 +85,19 @@ public Credentials getCredentials() { } /** - * The path used to reach the service. + * The path used to reach the service. This value will not be used if the channel is set. */ - public ServiceApiSettings setServicePath(String servicePath) { - this.servicePath = servicePath; + public ServiceApiSettings setServiceAddress(String serviceAddress) { + this.serviceAddress = serviceAddress; return this; } - public String getServicePath() { - return servicePath; + public String getServiceAddress() { + return serviceAddress; } /** - * The port used to reach the service. + * The port used to reach the service. This value will not be used if the channel is set. */ public ServiceApiSettings setPort(int port) { this.port = port; diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java b/gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java index 6673726f761e..3327db0c0211 100644 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java +++ b/gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java @@ -31,12 +31,7 @@ package io.gapi.gax.internal; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.Executors; - +import com.google.auth.Credentials; import com.google.auth.oauth2.GoogleCredentials; import com.google.common.collect.Lists; @@ -48,6 +43,11 @@ import io.grpc.netty.NegotiationType; import io.grpc.netty.NettyChannelBuilder; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.Executors; + public class ApiUtils { // TODO(wgg): make this configurable @@ -63,17 +63,26 @@ public static ApiCallable prepareIdem } /** - * Creates a channel for the given path, address and port. + * Acquires application-default credentials, applying the given scopes if the + * credentials require scopes. + */ + public static Credentials credentialsWithScopes(String scopes[]) throws IOException { + List scopeList = Arrays.asList(scopes); + GoogleCredentials credentials = GoogleCredentials.getApplicationDefault(); + if (credentials.createScopedRequired()) { + credentials = credentials.createScoped(scopeList); + } + return credentials; + } + + /** + * Creates a channel for the given address, port, and credentials. */ - public static ManagedChannel createChannel(String address, int port, Collection scopes) + public static ManagedChannel createChannel(String address, int port, Credentials credentials) throws IOException { List interceptors = Lists.newArrayList(); //TODO: MIGRATION interceptors.add(ChannelFactory.authorityInterceptor(address)); - GoogleCredentials credentials = GoogleCredentials.getApplicationDefault(); - if (credentials.createScopedRequired()) { - credentials = credentials.createScoped(scopes); - } interceptors.add(new ClientAuthInterceptor(credentials, Executors.newFixedThreadPool(AUTH_THREADS))); @@ -84,23 +93,31 @@ public static ManagedChannel createChannel(String address, int port, Collection< .build(); } - public static ServiceApiSettings settingsWithChannels(ServiceApiSettings settings, - String defaultServicePath, int defaultServicePort, String scopes[]) throws IOException { + /** + * Creates a new instance of ServiceApiSettings with all fields populated, using + * the given defaults if the corresponding values are not set on ServiceApiSettings. + */ + public static ServiceApiSettings populateSettings(ServiceApiSettings settings, + String defaultServiceAddress, int defaultServicePort, String scopes[]) throws IOException { ManagedChannel channel = settings.getChannel(); if (channel == null) { - String servicePath = defaultServicePath; - if (settings.getServicePath() != null) { - servicePath = settings.getServicePath(); + String servicePath = settings.getServiceAddress(); + if (servicePath == null) { + servicePath = defaultServiceAddress; + } + + int port = settings.getPort(); + if (port == 0) { + port = defaultServicePort; } - int port = defaultServicePort; - if (settings.getPort() != 0) { - port = settings.getPort(); + Credentials credentials = settings.getCredentials(); + if (credentials == null) { + credentials = credentialsWithScopes(scopes); } - List scopeList = Arrays.asList(scopes); - channel = ApiUtils.createChannel(servicePath, port, scopeList); + channel = ApiUtils.createChannel(servicePath, port, credentials); } return new ServiceApiSettings() diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index cb78e3f9c728..54572afa2e6d 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -191,7 +191,7 @@ public static PublisherApi create(ServiceApiSettings settings) throws IOExceptio * easy to make a subclass, but otherwise, the static factory methods should be preferred. */ protected PublisherApi(ServiceApiSettings settings) throws IOException { - ServiceApiSettings internalSettings = ApiUtils.settingsWithChannels(settings, + ServiceApiSettings internalSettings = ApiUtils.populateSettings(settings, SERVICE_ADDRESS, DEFAULT_SERVICE_PORT, ALL_SCOPES); this.settings = internalSettings; this.channel = internalSettings.getChannel(); diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index 1c9daaf82384..ff320597ddf7 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -172,7 +172,7 @@ public static SubscriberApi create(ServiceApiSettings settings) throws IOExcepti * easy to make a subclass, but otherwise, the static factory methods should be preferred. */ protected SubscriberApi(ServiceApiSettings settings) throws IOException { - ServiceApiSettings internalSettings = ApiUtils.settingsWithChannels(settings, + ServiceApiSettings internalSettings = ApiUtils.populateSettings(settings, SERVICE_ADDRESS, DEFAULT_SERVICE_PORT, ALL_SCOPES); this.settings = internalSettings; this.channel = internalSettings.getChannel(); diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java index 033330ad6b83..b9c17e0f0831 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java @@ -43,13 +43,12 @@ public LocalPubsubHelper(String addressString) { /** * Starts the in-memory service. */ - public LocalPubsubHelper start() { + public void start() { try { server.start(); } catch (IOException ex) { throw new RuntimeException(ex); } - return this; } /** diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java index 19939e0876b6..38e337890aa1 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java @@ -38,7 +38,8 @@ public class PublisherApiTest { @BeforeClass public static void startStaticServer() { - pubsubHelper = new LocalPubsubHelper("in-process-1").start(); + pubsubHelper = new LocalPubsubHelper("in-process-1"); + pubsubHelper.start(); } @AfterClass From 9d16e980c2232d141698e942a13ccc094babee2b Mon Sep 17 00:00:00 2001 From: Michael Darakananda Date: Mon, 30 Nov 2015 14:58:14 -0800 Subject: [PATCH 182/203] Delete duplicate LocalPublisherImpl.java --- .../gcloud/pubsub/spi/LocalPublisherImpl.java | 138 ------------------ 1 file changed, 138 deletions(-) delete mode 100644 gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/LocalPublisherImpl.java diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/LocalPublisherImpl.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/LocalPublisherImpl.java deleted file mode 100644 index c6cd637dd980..000000000000 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/LocalPublisherImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.google.gcloud.pubsub.spi; - -import com.google.protobuf.Empty; -import com.google.pubsub.v1.DeleteTopicRequest; -import com.google.pubsub.v1.GetTopicRequest; -import com.google.pubsub.v1.ListTopicSubscriptionsRequest; -import com.google.pubsub.v1.ListTopicSubscriptionsResponse; -import com.google.pubsub.v1.ListTopicsRequest; -import com.google.pubsub.v1.ListTopicsResponse; -import com.google.pubsub.v1.PublishRequest; -import com.google.pubsub.v1.PublishResponse; -import com.google.pubsub.v1.PublisherGrpc.Publisher; -import com.google.pubsub.v1.PubsubMessage; -import com.google.pubsub.v1.Topic; - -import io.grpc.stub.StreamObserver; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class LocalPublisherImpl implements Publisher { - - private Map> topics = new HashMap<>(); - - @Override - public void createTopic(Topic request, StreamObserver responseObserver) { - topics.put(request.getName(), new ArrayList()); - - Topic response = Topic.newBuilder().setName(request.getName()).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); - } - - @Override - public void publish(PublishRequest request, StreamObserver responseObserver) { - List topicMessages = topics.get(request.getTopic()); - List ids = new ArrayList<>(); - int index = 0; - for (PubsubMessage msg : request.getMessagesList()) { - topicMessages.add(msg); - ids.add(new Integer(index).toString()); - } - - responseObserver.onNext(PublishResponse.newBuilder().addAllMessageIds(ids).build()); - responseObserver.onCompleted(); - } - - @Override - public void getTopic(GetTopicRequest request, StreamObserver responseObserver) { - if (topics.get(request.getTopic()) == null) { - throw new IllegalArgumentException("topic doesn't exist: " + request.getTopic()); - } - - Topic response = Topic.newBuilder().setName(request.getTopic()).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); - } - - @Override - public void listTopics(ListTopicsRequest request, StreamObserver responseObserver) { - List responseTopics = new ArrayList<>(); - for (String topicName : topics.keySet()) { - String projectOfTopic = PublisherApi.TOPIC_PATH_TEMPLATE.parse(topicName).get("project"); - String projectOfRequest = PublisherApi.PROJECT_PATH_TEMPLATE.parse(request.getProject()).get("project"); - if (projectOfTopic.equals(projectOfRequest)) { - Topic topicObj = Topic.newBuilder().setName(topicName).build(); - responseTopics.add(topicObj); - } - } - Collections.sort(responseTopics, new Comparator() { - @Override public int compare(Topic o1, Topic o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - ListTopicsResponse.Builder response = ListTopicsResponse.newBuilder(); - response.setNextPageToken(""); - response.addAllTopics(responseTopics); - responseObserver.onNext(response.build()); - responseObserver.onCompleted(); - } - - @Override - public void listTopicSubscriptions(ListTopicSubscriptionsRequest request, - StreamObserver responseObserver) { - responseObserver.onNext(ListTopicSubscriptionsResponse.getDefaultInstance()); - responseObserver.onCompleted(); - } - - @Override - public void deleteTopic(DeleteTopicRequest request, StreamObserver responseObserver) { - topics.remove(request.getTopic()); - responseObserver.onNext(Empty.getDefaultInstance()); - responseObserver.onCompleted(); - } - - public Map> getTopics() { - return topics; - } - - public void reset() { - topics = new HashMap<>(); - } -} From e8f09ef3a86cca89887fe0e368264a9be00c1387 Mon Sep 17 00:00:00 2001 From: aozarov Date: Fri, 5 Feb 2016 10:15:21 -0800 Subject: [PATCH 183/203] merge from master --- gcloud-java-gax/pom.xml | 5 ++--- gcloud-java-pubsub/pom.xml | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/gcloud-java-gax/pom.xml b/gcloud-java-gax/pom.xml index 5710df3d5bfe..c74839c3ba40 100644 --- a/gcloud-java-gax/pom.xml +++ b/gcloud-java-gax/pom.xml @@ -1,7 +1,6 @@ 4.0.0 - com.google.gcloud gcloud-java-gax jar GCloud Api Extensions @@ -11,8 +10,8 @@ com.google.gcloud gcloud-java-pom - 0.0.11-SNAPSHOT - + 0.1.4-SNAPSHOT + gcloud-java-gax diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index 998adeee4827..871c041815ca 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -1,7 +1,6 @@ 4.0.0 - com.google.gcloud gcloud-java-pubsub jar GCloud Java Pub/Sub @@ -11,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.0.11-SNAPSHOT + 0.1.4-SNAPSHOT gcloud-java-pubsub From 2e3464e16694f204cf4c433d104f76ffc9dbe74c Mon Sep 17 00:00:00 2001 From: aozarov Date: Fri, 5 Feb 2016 15:01:02 -0800 Subject: [PATCH 184/203] fix pom to avoid compiler failure due to code generation by annotation processing --- pom.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e42a0939ff04..b9aeb421b87e 100644 --- a/pom.xml +++ b/pom.xml @@ -227,7 +227,10 @@ maven-compiler-plugin - 3.5.1 + + + + 3.1 1.7 1.7 From 309a6b9861f02fedc23476e40fd4cbc5b140081b Mon Sep 17 00:00:00 2001 From: aozarov Date: Fri, 5 Feb 2016 16:37:14 -0800 Subject: [PATCH 185/203] disable javadoc generation for java 8 on gcloud-java-pubsub --- gcloud-java-pubsub/pom.xml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index 871c041815ca..289580c9eeb2 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -38,6 +38,18 @@ test + + + doclint-java8-disable + + [1.8,) + + + + -Xdoclint:none + + + @@ -56,6 +68,22 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + + attach-javadocs + + jar + + + ${javadoc.opts} + + + + From de3ad8f105e924a019a4217c6b9a897c3682b367 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Thu, 18 Feb 2016 13:10:12 -0800 Subject: [PATCH 186/203] Removing GAX from gcloud-java --- gcloud-java-gax/README.md | 53 - .../java/com/google/api/AnnotationsProto.java | 222 - .../src/main/java/com/google/api/Context.java | 779 --- .../java/com/google/api/ContextOrBuilder.java | 53 - .../java/com/google/api/ContextProto.java | 64 - .../main/java/com/google/api/ContextRule.java | 922 ---- .../com/google/api/ContextRuleOrBuilder.java | 99 - .../main/java/com/google/api/CustomError.java | 1016 ---- .../com/google/api/CustomErrorOrBuilder.java | 93 - .../java/com/google/api/CustomErrorRule.java | 627 --- .../google/api/CustomErrorRuleOrBuilder.java | 48 - .../com/google/api/CustomHttpPattern.java | 627 --- .../api/CustomHttpPatternOrBuilder.java | 45 - .../java/com/google/api/Documentation.java | 1816 ------- .../google/api/DocumentationOrBuilder.java | 173 - .../com/google/api/DocumentationProto.java | 79 - .../com/google/api/DocumentationRule.java | 662 --- .../api/DocumentationRuleOrBuilder.java | 55 - .../java/com/google/api/ErrorFormatProto.java | 65 - .../src/main/java/com/google/api/Http.java | 759 --- .../java/com/google/api/HttpOrBuilder.java | 53 - .../main/java/com/google/api/HttpProto.java | 106 - .../main/java/com/google/api/HttpRule.java | 3069 ----------- .../com/google/api/HttpRuleOrBuilder.java | 276 - .../java/com/google/api/MediaDownload.java | 399 -- .../google/api/MediaDownloadOrBuilder.java | 18 - .../main/java/com/google/api/MediaUpload.java | 399 -- .../com/google/api/MediaUploadOrBuilder.java | 18 - .../src/main/java/com/google/api/Page.java | 1176 ----- .../java/com/google/api/PageOrBuilder.java | 120 - .../src/main/java/com/google/api/Service.java | 4591 ----------------- .../java/com/google/api/ServiceOrBuilder.java | 530 -- .../java/com/google/api/ServiceProto.java | 95 - .../main/java/com/google/api/Visibility.java | 1370 ----- .../com/google/api/VisibilityOrBuilder.java | 148 - .../java/com/google/api/VisibilityProto.java | 70 - .../java/com/google/api/VisibilityRule.java | 998 ---- .../google/api/VisibilityRuleOrBuilder.java | 110 - .../longrunning/CancelOperationRequest.java | 476 -- .../CancelOperationRequestOrBuilder.java | 27 - .../longrunning/DeleteOperationRequest.java | 476 -- .../DeleteOperationRequestOrBuilder.java | 27 - .../longrunning/GetOperationRequest.java | 476 -- .../GetOperationRequestOrBuilder.java | 27 - .../longrunning/ListOperationsRequest.java | 848 --- .../ListOperationsRequestOrBuilder.java | 72 - .../longrunning/ListOperationsResponse.java | 909 ---- .../ListOperationsResponseOrBuilder.java | 71 - .../com/google/longrunning/Operation.java | 1383 ----- .../longrunning/OperationOrBuilder.java | 123 - .../google/longrunning/OperationsGrpc.java | 306 -- .../google/longrunning/OperationsProto.java | 146 - .../main/java/com/google/rpc/BadRequest.java | 1437 ------ .../com/google/rpc/BadRequestOrBuilder.java | 53 - .../src/main/java/com/google/rpc/Code.java | 543 -- .../main/java/com/google/rpc/CodeProto.java | 46 - .../main/java/com/google/rpc/DebugInfo.java | 697 --- .../com/google/rpc/DebugInfoOrBuilder.java | 62 - .../com/google/rpc/ErrorDetailsProto.java | 167 - .../src/main/java/com/google/rpc/Help.java | 1423 ----- .../java/com/google/rpc/HelpOrBuilder.java | 53 - .../java/com/google/rpc/QuotaFailure.java | 1498 ------ .../com/google/rpc/QuotaFailureOrBuilder.java | 53 - .../main/java/com/google/rpc/RequestInfo.java | 643 --- .../com/google/rpc/RequestInfoOrBuilder.java | 49 - .../java/com/google/rpc/ResourceInfo.java | 985 ---- .../com/google/rpc/ResourceInfoOrBuilder.java | 97 - .../main/java/com/google/rpc/RetryInfo.java | 565 -- .../com/google/rpc/RetryInfoOrBuilder.java | 34 - .../src/main/java/com/google/rpc/Status.java | 1092 ---- .../java/com/google/rpc/StatusOrBuilder.java | 89 - .../main/java/com/google/rpc/StatusProto.java | 54 - .../src/main/java/com/google/type/Color.java | 1047 ---- .../java/com/google/type/ColorOrBuilder.java | 85 - .../main/java/com/google/type/ColorProto.java | 55 - .../src/main/java/com/google/type/Date.java | 593 --- .../java/com/google/type/DateOrBuilder.java | 38 - .../main/java/com/google/type/DateProto.java | 51 - .../main/java/com/google/type/DayOfWeek.java | 220 - .../java/com/google/type/DayOfWeekProto.java | 42 - .../src/main/java/com/google/type/LatLng.java | 513 -- .../java/com/google/type/LatLngOrBuilder.java | 27 - .../java/com/google/type/LatLngProto.java | 51 - .../src/main/java/com/google/type/Money.java | 640 --- .../java/com/google/type/MoneyOrBuilder.java | 51 - .../main/java/com/google/type/MoneyProto.java | 51 - .../main/java/com/google/type/TimeOfDay.java | 659 --- .../com/google/type/TimeOfDayOrBuilder.java | 47 - .../java/com/google/type/TimeOfDayProto.java | 52 - .../java/io/gapi/gax/grpc/ApiCallable.java | 391 -- .../io/gapi/gax/grpc/CallableDescriptor.java | 76 - .../io/gapi/gax/grpc/CompoundClientCall.java | 78 - .../io/gapi/gax/grpc/FollowedByCallable.java | 146 - .../java/io/gapi/gax/grpc/PageDescriptor.java | 62 - .../gapi/gax/grpc/PageStreamingCallable.java | 185 - .../io/gapi/gax/grpc/RetryingCallable.java | 197 - .../io/gapi/gax/grpc/ServiceApiSettings.java | 125 - .../gapi/gax/grpc/TransformingCallable.java | 171 - .../java/io/gapi/gax/internal/ApiUtils.java | 127 - .../io/gapi/gax/protobuf/PathTemplate.java | 881 ---- .../io/gapi/gax/protobuf/ResourceName.java | 275 - .../gax/protobuf/ValidationException.java | 63 - .../io/gapi/gax/grpc/ApiCallableTest.java | 250 - .../gapi/gax/protobuf/PathTemplateTest.java | 168 - .../gapi/gax/protobuf/ResourceNameTest.java | 25 - 105 files changed, 44252 deletions(-) delete mode 100644 gcloud-java-gax/README.md delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/AnnotationsProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Context.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ContextOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ContextProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ContextRule.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ContextRuleOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomError.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRule.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRuleOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPattern.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPatternOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Documentation.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRule.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRuleOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ErrorFormatProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Http.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/HttpOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/HttpProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/HttpRule.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/HttpRuleOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownload.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownloadOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/MediaUpload.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/MediaUploadOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Page.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/PageOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Service.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ServiceOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/ServiceProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/Visibility.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRule.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRuleOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequest.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequestOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequest.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequestOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequest.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequestOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequest.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequestOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponse.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponseOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/Operation.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsGrpc.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequest.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequestOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/Code.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/CodeProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfo.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfoOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/ErrorDetailsProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/Help.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/HelpOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailure.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailureOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfo.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfoOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfo.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfoOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfo.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfoOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/Status.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/Color.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/ColorOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/ColorProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/Date.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/DateOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/DateProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeek.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeekProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/LatLng.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/LatLngOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/LatLngProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/Money.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/MoneyOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/MoneyProto.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDay.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayOrBuilder.java delete mode 100644 gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayProto.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CallableDescriptor.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CompoundClientCall.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/FollowedByCallable.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageDescriptor.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageStreamingCallable.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/RetryingCallable.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/grpc/TransformingCallable.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ResourceName.java delete mode 100644 gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ValidationException.java delete mode 100644 gcloud-java-gax/src/test/java/io/gapi/gax/grpc/ApiCallableTest.java delete mode 100644 gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/PathTemplateTest.java delete mode 100644 gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/ResourceNameTest.java diff --git a/gcloud-java-gax/README.md b/gcloud-java-gax/README.md deleted file mode 100644 index d3dfbdde1ca8..000000000000 --- a/gcloud-java-gax/README.md +++ /dev/null @@ -1,53 +0,0 @@ -Google Cloud Java Client -- GAX -========================================= - -This module provides common functionality required by service-specific modules of this library. - -[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) -[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) -[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-gax.svg)](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-gax.svg) - -- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) -- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/package-summary.html) - -Quickstart ----------- -Add this to your pom.xml file -```xml - - com.google.gcloud - gcloud-java-gax - 0.0.10 - -``` - -Java Versions -------------- - -Java 7 or above is required for using this client. - -Contributing ------------- - -Contributions to this library are always welcome and highly encouraged. - -See [CONTRIBUTING] for more information on how to get started. - -Versioning ----------- - -This library follows [Semantic Versioning] (http://semver.org/). - -It is currently in major version zero (``0.y.z``), which means that anything -may change at any time and the public API should not be considered -stable. - -License -------- - -Apache 2.0 - See [LICENSE] for more information. - - -[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md -[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE -[cloud-platform]: https://cloud.google.com/ diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/AnnotationsProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/AnnotationsProto.java deleted file mode 100644 index 0281d9ddd73b..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/AnnotationsProto.java +++ /dev/null @@ -1,222 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/annotations.proto - -package com.google.api; - -public final class AnnotationsProto { - private AnnotationsProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registry.add(com.google.api.AnnotationsProto.fileVisibility); - registry.add(com.google.api.AnnotationsProto.apiVisibility); - registry.add(com.google.api.AnnotationsProto.methodVisibility); - registry.add(com.google.api.AnnotationsProto.http); - registry.add(com.google.api.AnnotationsProto.messageVisibility); - registry.add(com.google.api.AnnotationsProto.customError); - registry.add(com.google.api.AnnotationsProto.fieldVisibility); - registry.add(com.google.api.AnnotationsProto.enumVisibility); - registry.add(com.google.api.AnnotationsProto.valueVisibility); - } - public static final int FILE_VISIBILITY_FIELD_NUMBER = 72295727; - /** - * extend .google.protobuf.FileOptions { ... } - * - *
      -   * See `VisibilityRule`.
      -   * 
      - */ - public static final - com.google.protobuf.GeneratedMessage.GeneratedExtension< - com.google.protobuf.DescriptorProtos.FileOptions, - com.google.api.VisibilityRule> fileVisibility = com.google.protobuf.GeneratedMessage - .newFileScopedGeneratedExtension( - com.google.api.VisibilityRule.class, - com.google.api.VisibilityRule.getDefaultInstance()); - public static final int API_VISIBILITY_FIELD_NUMBER = 72295727; - /** - * extend .google.protobuf.ServiceOptions { ... } - * - *
      -   * See `VisibilityRule`.
      -   * 
      - */ - public static final - com.google.protobuf.GeneratedMessage.GeneratedExtension< - com.google.protobuf.DescriptorProtos.ServiceOptions, - com.google.api.VisibilityRule> apiVisibility = com.google.protobuf.GeneratedMessage - .newFileScopedGeneratedExtension( - com.google.api.VisibilityRule.class, - com.google.api.VisibilityRule.getDefaultInstance()); - public static final int METHOD_VISIBILITY_FIELD_NUMBER = 72295727; - /** - * extend .google.protobuf.MethodOptions { ... } - * - *
      -   * See `VisibilityRule`.
      -   * 
      - */ - public static final - com.google.protobuf.GeneratedMessage.GeneratedExtension< - com.google.protobuf.DescriptorProtos.MethodOptions, - com.google.api.VisibilityRule> methodVisibility = com.google.protobuf.GeneratedMessage - .newFileScopedGeneratedExtension( - com.google.api.VisibilityRule.class, - com.google.api.VisibilityRule.getDefaultInstance()); - public static final int HTTP_FIELD_NUMBER = 72295728; - /** - * extend .google.protobuf.MethodOptions { ... } - * - *
      -   * See `HttpRule`.
      -   * 
      - */ - public static final - com.google.protobuf.GeneratedMessage.GeneratedExtension< - com.google.protobuf.DescriptorProtos.MethodOptions, - com.google.api.HttpRule> http = com.google.protobuf.GeneratedMessage - .newFileScopedGeneratedExtension( - com.google.api.HttpRule.class, - com.google.api.HttpRule.getDefaultInstance()); - public static final int MESSAGE_VISIBILITY_FIELD_NUMBER = 72295727; - /** - * extend .google.protobuf.MessageOptions { ... } - * - *
      -   * See `VisibilityRule`.
      -   * 
      - */ - public static final - com.google.protobuf.GeneratedMessage.GeneratedExtension< - com.google.protobuf.DescriptorProtos.MessageOptions, - com.google.api.VisibilityRule> messageVisibility = com.google.protobuf.GeneratedMessage - .newFileScopedGeneratedExtension( - com.google.api.VisibilityRule.class, - com.google.api.VisibilityRule.getDefaultInstance()); - public static final int CUSTOM_ERROR_FIELD_NUMBER = 79365461; - /** - * extend .google.protobuf.MessageOptions { ... } - * - *
      -   * See `CustomErrorRule`.
      -   * 
      - */ - public static final - com.google.protobuf.GeneratedMessage.GeneratedExtension< - com.google.protobuf.DescriptorProtos.MessageOptions, - com.google.api.CustomErrorRule> customError = com.google.protobuf.GeneratedMessage - .newFileScopedGeneratedExtension( - com.google.api.CustomErrorRule.class, - com.google.api.CustomErrorRule.getDefaultInstance()); - public static final int FIELD_VISIBILITY_FIELD_NUMBER = 72295727; - /** - * extend .google.protobuf.FieldOptions { ... } - * - *
      -   * See `VisibilityRule`.
      -   * 
      - */ - public static final - com.google.protobuf.GeneratedMessage.GeneratedExtension< - com.google.protobuf.DescriptorProtos.FieldOptions, - com.google.api.VisibilityRule> fieldVisibility = com.google.protobuf.GeneratedMessage - .newFileScopedGeneratedExtension( - com.google.api.VisibilityRule.class, - com.google.api.VisibilityRule.getDefaultInstance()); - public static final int ENUM_VISIBILITY_FIELD_NUMBER = 72295727; - /** - * extend .google.protobuf.EnumOptions { ... } - * - *
      -   * See `VisibilityRule`.
      -   * 
      - */ - public static final - com.google.protobuf.GeneratedMessage.GeneratedExtension< - com.google.protobuf.DescriptorProtos.EnumOptions, - com.google.api.VisibilityRule> enumVisibility = com.google.protobuf.GeneratedMessage - .newFileScopedGeneratedExtension( - com.google.api.VisibilityRule.class, - com.google.api.VisibilityRule.getDefaultInstance()); - public static final int VALUE_VISIBILITY_FIELD_NUMBER = 72295727; - /** - * extend .google.protobuf.EnumValueOptions { ... } - * - *
      -   * See `VisibilityRule`.
      -   * 
      - */ - public static final - com.google.protobuf.GeneratedMessage.GeneratedExtension< - com.google.protobuf.DescriptorProtos.EnumValueOptions, - com.google.api.VisibilityRule> valueVisibility = com.google.protobuf.GeneratedMessage - .newFileScopedGeneratedExtension( - com.google.api.VisibilityRule.class, - com.google.api.VisibilityRule.getDefaultInstance()); - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\034google/api/annotations.proto\022\ngoogle.a" + - "pi\032 google/protobuf/descriptor.proto\032\026go" + - "ogle/api/error.proto\032\025google/api/http.pr" + - "oto\032\033google/api/visibility.proto:T\n\017file" + - "_visibility\022\034.google.protobuf.FileOption" + - "s\030\257\312\274\" \001(\0132\032.google.api.VisibilityRule:V" + - "\n\016api_visibility\022\037.google.protobuf.Servi" + - "ceOptions\030\257\312\274\" \001(\0132\032.google.api.Visibili" + - "tyRule:X\n\021method_visibility\022\036.google.pro" + - "tobuf.MethodOptions\030\257\312\274\" \001(\0132\032.google.ap", - "i.VisibilityRule:E\n\004http\022\036.google.protob" + - "uf.MethodOptions\030\260\312\274\" \001(\0132\024.google.api.H" + - "ttpRule:Z\n\022message_visibility\022\037.google.p" + - "rotobuf.MessageOptions\030\257\312\274\" \001(\0132\032.google" + - ".api.VisibilityRule:U\n\014custom_error\022\037.go" + - "ogle.protobuf.MessageOptions\030\325\212\354% \001(\0132\033." + - "google.api.CustomErrorRule:V\n\020field_visi" + - "bility\022\035.google.protobuf.FieldOptions\030\257\312" + - "\274\" \001(\0132\032.google.api.VisibilityRule:T\n\017en" + - "um_visibility\022\034.google.protobuf.EnumOpti", - "ons\030\257\312\274\" \001(\0132\032.google.api.VisibilityRule" + - ":Z\n\020value_visibility\022!.google.protobuf.E" + - "numValueOptions\030\257\312\274\" \001(\0132\032.google.api.Vi" + - "sibilityRuleB$\n\016com.google.apiB\020Annotati" + - "onsProtoP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.DescriptorProtos.getDescriptor(), - com.google.api.ErrorFormatProto.getDescriptor(), - com.google.api.HttpProto.getDescriptor(), - com.google.api.VisibilityProto.getDescriptor(), - }, assigner); - fileVisibility.internalInit(descriptor.getExtensions().get(0)); - apiVisibility.internalInit(descriptor.getExtensions().get(1)); - methodVisibility.internalInit(descriptor.getExtensions().get(2)); - http.internalInit(descriptor.getExtensions().get(3)); - messageVisibility.internalInit(descriptor.getExtensions().get(4)); - customError.internalInit(descriptor.getExtensions().get(5)); - fieldVisibility.internalInit(descriptor.getExtensions().get(6)); - enumVisibility.internalInit(descriptor.getExtensions().get(7)); - valueVisibility.internalInit(descriptor.getExtensions().get(8)); - com.google.protobuf.DescriptorProtos.getDescriptor(); - com.google.api.ErrorFormatProto.getDescriptor(); - com.google.api.HttpProto.getDescriptor(); - com.google.api.VisibilityProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Context.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Context.java deleted file mode 100644 index 1385a7b9ea50..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/Context.java +++ /dev/null @@ -1,779 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/context.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.Context} - * - *
      - * `Context` defines which contexts an API requests.
      - * Example:
      - *     context:
      - *       rules:
      - *       - selector: "*"
      - *         requested:
      - *         - google.rpc.context.ProjectContext
      - *         - google.rpc.context.OriginContext
      - * The above specifies that all methods in the API request
      - * `google.rpc.context.ProjectContext` and
      - * `google.rpc.context.OriginContext`.
      - * Available context types are defined in package
      - * `google.rpc.context`.
      - * 
      - */ -public final class Context extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.Context) - ContextOrBuilder { - // Use Context.newBuilder() to construct. - private Context(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Context() { - rules_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Context( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - rules_.add(input.readMessage(com.google.api.ContextRule.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = java.util.Collections.unmodifiableList(rules_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.ContextProto.internal_static_google_api_Context_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.ContextProto.internal_static_google_api_Context_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Context.class, com.google.api.Context.Builder.class); - } - - public static final int RULES_FIELD_NUMBER = 1; - private java.util.List rules_; - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -   * List of rules for context, applicable to methods.
      -   * 
      - */ - public java.util.List getRulesList() { - return rules_; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -   * List of rules for context, applicable to methods.
      -   * 
      - */ - public java.util.List - getRulesOrBuilderList() { - return rules_; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -   * List of rules for context, applicable to methods.
      -   * 
      - */ - public int getRulesCount() { - return rules_.size(); - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -   * List of rules for context, applicable to methods.
      -   * 
      - */ - public com.google.api.ContextRule getRules(int index) { - return rules_.get(index); - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -   * List of rules for context, applicable to methods.
      -   * 
      - */ - public com.google.api.ContextRuleOrBuilder getRulesOrBuilder( - int index) { - return rules_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < rules_.size(); i++) { - output.writeMessage(1, rules_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < rules_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, rules_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.Context parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Context parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Context parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Context parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Context parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Context parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.Context parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.Context parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.Context parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Context parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.Context prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.Context} - * - *
      -   * `Context` defines which contexts an API requests.
      -   * Example:
      -   *     context:
      -   *       rules:
      -   *       - selector: "*"
      -   *         requested:
      -   *         - google.rpc.context.ProjectContext
      -   *         - google.rpc.context.OriginContext
      -   * The above specifies that all methods in the API request
      -   * `google.rpc.context.ProjectContext` and
      -   * `google.rpc.context.OriginContext`.
      -   * Available context types are defined in package
      -   * `google.rpc.context`.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.Context) - com.google.api.ContextOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.ContextProto.internal_static_google_api_Context_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.ContextProto.internal_static_google_api_Context_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Context.class, com.google.api.Context.Builder.class); - } - - // Construct using com.google.api.Context.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getRulesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (rulesBuilder_ == null) { - rules_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - rulesBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.ContextProto.internal_static_google_api_Context_descriptor; - } - - public com.google.api.Context getDefaultInstanceForType() { - return com.google.api.Context.getDefaultInstance(); - } - - public com.google.api.Context build() { - com.google.api.Context result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.Context buildPartial() { - com.google.api.Context result = new com.google.api.Context(this); - int from_bitField0_ = bitField0_; - if (rulesBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = java.util.Collections.unmodifiableList(rules_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.rules_ = rules_; - } else { - result.rules_ = rulesBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.Context) { - return mergeFrom((com.google.api.Context)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.Context other) { - if (other == com.google.api.Context.getDefaultInstance()) return this; - if (rulesBuilder_ == null) { - if (!other.rules_.isEmpty()) { - if (rules_.isEmpty()) { - rules_ = other.rules_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureRulesIsMutable(); - rules_.addAll(other.rules_); - } - onChanged(); - } - } else { - if (!other.rules_.isEmpty()) { - if (rulesBuilder_.isEmpty()) { - rulesBuilder_.dispose(); - rulesBuilder_ = null; - rules_ = other.rules_; - bitField0_ = (bitField0_ & ~0x00000001); - rulesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getRulesFieldBuilder() : null; - } else { - rulesBuilder_.addAllMessages(other.rules_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.Context parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.Context) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List rules_ = - java.util.Collections.emptyList(); - private void ensureRulesIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = new java.util.ArrayList(rules_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.ContextRule, com.google.api.ContextRule.Builder, com.google.api.ContextRuleOrBuilder> rulesBuilder_; - - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public java.util.List getRulesList() { - if (rulesBuilder_ == null) { - return java.util.Collections.unmodifiableList(rules_); - } else { - return rulesBuilder_.getMessageList(); - } - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public int getRulesCount() { - if (rulesBuilder_ == null) { - return rules_.size(); - } else { - return rulesBuilder_.getCount(); - } - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public com.google.api.ContextRule getRules(int index) { - if (rulesBuilder_ == null) { - return rules_.get(index); - } else { - return rulesBuilder_.getMessage(index); - } - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public Builder setRules( - int index, com.google.api.ContextRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.set(index, value); - onChanged(); - } else { - rulesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public Builder setRules( - int index, com.google.api.ContextRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.set(index, builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public Builder addRules(com.google.api.ContextRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.add(value); - onChanged(); - } else { - rulesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public Builder addRules( - int index, com.google.api.ContextRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.add(index, value); - onChanged(); - } else { - rulesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public Builder addRules( - com.google.api.ContextRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.add(builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public Builder addRules( - int index, com.google.api.ContextRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.add(index, builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public Builder addAllRules( - java.lang.Iterable values) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, rules_); - onChanged(); - } else { - rulesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public Builder clearRules() { - if (rulesBuilder_ == null) { - rules_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - rulesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public Builder removeRules(int index) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.remove(index); - onChanged(); - } else { - rulesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public com.google.api.ContextRule.Builder getRulesBuilder( - int index) { - return getRulesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public com.google.api.ContextRuleOrBuilder getRulesOrBuilder( - int index) { - if (rulesBuilder_ == null) { - return rules_.get(index); } else { - return rulesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public java.util.List - getRulesOrBuilderList() { - if (rulesBuilder_ != null) { - return rulesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(rules_); - } - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public com.google.api.ContextRule.Builder addRulesBuilder() { - return getRulesFieldBuilder().addBuilder( - com.google.api.ContextRule.getDefaultInstance()); - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public com.google.api.ContextRule.Builder addRulesBuilder( - int index) { - return getRulesFieldBuilder().addBuilder( - index, com.google.api.ContextRule.getDefaultInstance()); - } - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -     * List of rules for context, applicable to methods.
      -     * 
      - */ - public java.util.List - getRulesBuilderList() { - return getRulesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.ContextRule, com.google.api.ContextRule.Builder, com.google.api.ContextRuleOrBuilder> - getRulesFieldBuilder() { - if (rulesBuilder_ == null) { - rulesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.api.ContextRule, com.google.api.ContextRule.Builder, com.google.api.ContextRuleOrBuilder>( - rules_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - rules_ = null; - } - return rulesBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.Context) - } - - // @@protoc_insertion_point(class_scope:google.api.Context) - private static final com.google.api.Context DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.Context(); - } - - public static com.google.api.Context getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Context parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Context(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.Context getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextOrBuilder.java deleted file mode 100644 index 97be9b0b3dd9..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextOrBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/context.proto - -package com.google.api; - -public interface ContextOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.Context) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -   * List of rules for context, applicable to methods.
      -   * 
      - */ - java.util.List - getRulesList(); - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -   * List of rules for context, applicable to methods.
      -   * 
      - */ - com.google.api.ContextRule getRules(int index); - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -   * List of rules for context, applicable to methods.
      -   * 
      - */ - int getRulesCount(); - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -   * List of rules for context, applicable to methods.
      -   * 
      - */ - java.util.List - getRulesOrBuilderList(); - /** - * repeated .google.api.ContextRule rules = 1; - * - *
      -   * List of rules for context, applicable to methods.
      -   * 
      - */ - com.google.api.ContextRuleOrBuilder getRulesOrBuilder( - int index); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextProto.java deleted file mode 100644 index 755c670fa8af..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextProto.java +++ /dev/null @@ -1,64 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/context.proto - -package com.google.api; - -public final class ContextProto { - private ContextProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_Context_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_Context_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_ContextRule_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_ContextRule_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\030google/api/context.proto\022\ngoogle.api\"1" + - "\n\007Context\022&\n\005rules\030\001 \003(\0132\027.google.api.Co" + - "ntextRule\"D\n\013ContextRule\022\020\n\010selector\030\001 \001" + - "(\t\022\021\n\trequested\030\002 \003(\t\022\020\n\010provided\030\003 \003(\tB" + - " \n\016com.google.apiB\014ContextProtoP\001b\006proto" + - "3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_google_api_Context_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_api_Context_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_Context_descriptor, - new java.lang.String[] { "Rules", }); - internal_static_google_api_ContextRule_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_google_api_ContextRule_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_ContextRule_descriptor, - new java.lang.String[] { "Selector", "Requested", "Provided", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRule.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRule.java deleted file mode 100644 index 9857e3bfdd24..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRule.java +++ /dev/null @@ -1,922 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/context.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.ContextRule} - * - *
      - * A context rule provides information about the context for an individual API
      - * element.
      - * 
      - */ -public final class ContextRule extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.ContextRule) - ContextRuleOrBuilder { - // Use ContextRule.newBuilder() to construct. - private ContextRule(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ContextRule() { - selector_ = ""; - requested_ = com.google.protobuf.LazyStringArrayList.EMPTY; - provided_ = com.google.protobuf.LazyStringArrayList.EMPTY; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ContextRule( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - selector_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - requested_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000002; - } - requested_.add(s); - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - provided_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000004; - } - provided_.add(s); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - requested_ = requested_.getUnmodifiableView(); - } - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - provided_ = provided_.getUnmodifiableView(); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.ContextProto.internal_static_google_api_ContextRule_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.ContextProto.internal_static_google_api_ContextRule_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.ContextRule.class, com.google.api.ContextRule.Builder.class); - } - - private int bitField0_; - public static final int SELECTOR_FIELD_NUMBER = 1; - private volatile java.lang.Object selector_; - /** - * optional string selector = 1; - * - *
      -   * Selects the methods to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - public java.lang.String getSelector() { - java.lang.Object ref = selector_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - selector_ = s; - return s; - } - } - /** - * optional string selector = 1; - * - *
      -   * Selects the methods to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSelectorBytes() { - java.lang.Object ref = selector_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - selector_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int REQUESTED_FIELD_NUMBER = 2; - private com.google.protobuf.LazyStringList requested_; - /** - * repeated string requested = 2; - * - *
      -   * A list of full type names of requested contexts.
      -   * 
      - */ - public com.google.protobuf.ProtocolStringList - getRequestedList() { - return requested_; - } - /** - * repeated string requested = 2; - * - *
      -   * A list of full type names of requested contexts.
      -   * 
      - */ - public int getRequestedCount() { - return requested_.size(); - } - /** - * repeated string requested = 2; - * - *
      -   * A list of full type names of requested contexts.
      -   * 
      - */ - public java.lang.String getRequested(int index) { - return requested_.get(index); - } - /** - * repeated string requested = 2; - * - *
      -   * A list of full type names of requested contexts.
      -   * 
      - */ - public com.google.protobuf.ByteString - getRequestedBytes(int index) { - return requested_.getByteString(index); - } - - public static final int PROVIDED_FIELD_NUMBER = 3; - private com.google.protobuf.LazyStringList provided_; - /** - * repeated string provided = 3; - * - *
      -   * A list of full type names of provided contexts.
      -   * 
      - */ - public com.google.protobuf.ProtocolStringList - getProvidedList() { - return provided_; - } - /** - * repeated string provided = 3; - * - *
      -   * A list of full type names of provided contexts.
      -   * 
      - */ - public int getProvidedCount() { - return provided_.size(); - } - /** - * repeated string provided = 3; - * - *
      -   * A list of full type names of provided contexts.
      -   * 
      - */ - public java.lang.String getProvided(int index) { - return provided_.get(index); - } - /** - * repeated string provided = 3; - * - *
      -   * A list of full type names of provided contexts.
      -   * 
      - */ - public com.google.protobuf.ByteString - getProvidedBytes(int index) { - return provided_.getByteString(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSelectorBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, selector_); - } - for (int i = 0; i < requested_.size(); i++) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, requested_.getRaw(i)); - } - for (int i = 0; i < provided_.size(); i++) { - com.google.protobuf.GeneratedMessage.writeString(output, 3, provided_.getRaw(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSelectorBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, selector_); - } - { - int dataSize = 0; - for (int i = 0; i < requested_.size(); i++) { - dataSize += computeStringSizeNoTag(requested_.getRaw(i)); - } - size += dataSize; - size += 1 * getRequestedList().size(); - } - { - int dataSize = 0; - for (int i = 0; i < provided_.size(); i++) { - dataSize += computeStringSizeNoTag(provided_.getRaw(i)); - } - size += dataSize; - size += 1 * getProvidedList().size(); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.ContextRule parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.ContextRule parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.ContextRule parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.ContextRule parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.ContextRule parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.ContextRule parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.ContextRule parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.ContextRule parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.ContextRule parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.ContextRule parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.ContextRule prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.ContextRule} - * - *
      -   * A context rule provides information about the context for an individual API
      -   * element.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.ContextRule) - com.google.api.ContextRuleOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.ContextProto.internal_static_google_api_ContextRule_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.ContextProto.internal_static_google_api_ContextRule_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.ContextRule.class, com.google.api.ContextRule.Builder.class); - } - - // Construct using com.google.api.ContextRule.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - selector_ = ""; - - requested_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - provided_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.ContextProto.internal_static_google_api_ContextRule_descriptor; - } - - public com.google.api.ContextRule getDefaultInstanceForType() { - return com.google.api.ContextRule.getDefaultInstance(); - } - - public com.google.api.ContextRule build() { - com.google.api.ContextRule result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.ContextRule buildPartial() { - com.google.api.ContextRule result = new com.google.api.ContextRule(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.selector_ = selector_; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - requested_ = requested_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.requested_ = requested_; - if (((bitField0_ & 0x00000004) == 0x00000004)) { - provided_ = provided_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.provided_ = provided_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.ContextRule) { - return mergeFrom((com.google.api.ContextRule)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.ContextRule other) { - if (other == com.google.api.ContextRule.getDefaultInstance()) return this; - if (!other.getSelector().isEmpty()) { - selector_ = other.selector_; - onChanged(); - } - if (!other.requested_.isEmpty()) { - if (requested_.isEmpty()) { - requested_ = other.requested_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureRequestedIsMutable(); - requested_.addAll(other.requested_); - } - onChanged(); - } - if (!other.provided_.isEmpty()) { - if (provided_.isEmpty()) { - provided_ = other.provided_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureProvidedIsMutable(); - provided_.addAll(other.provided_); - } - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.ContextRule parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.ContextRule) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object selector_ = ""; - /** - * optional string selector = 1; - * - *
      -     * Selects the methods to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public java.lang.String getSelector() { - java.lang.Object ref = selector_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - selector_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string selector = 1; - * - *
      -     * Selects the methods to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSelectorBytes() { - java.lang.Object ref = selector_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - selector_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string selector = 1; - * - *
      -     * Selects the methods to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder setSelector( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - selector_ = value; - onChanged(); - return this; - } - /** - * optional string selector = 1; - * - *
      -     * Selects the methods to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder clearSelector() { - - selector_ = getDefaultInstance().getSelector(); - onChanged(); - return this; - } - /** - * optional string selector = 1; - * - *
      -     * Selects the methods to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder setSelectorBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - selector_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.LazyStringList requested_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureRequestedIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - requested_ = new com.google.protobuf.LazyStringArrayList(requested_); - bitField0_ |= 0x00000002; - } - } - /** - * repeated string requested = 2; - * - *
      -     * A list of full type names of requested contexts.
      -     * 
      - */ - public com.google.protobuf.ProtocolStringList - getRequestedList() { - return requested_.getUnmodifiableView(); - } - /** - * repeated string requested = 2; - * - *
      -     * A list of full type names of requested contexts.
      -     * 
      - */ - public int getRequestedCount() { - return requested_.size(); - } - /** - * repeated string requested = 2; - * - *
      -     * A list of full type names of requested contexts.
      -     * 
      - */ - public java.lang.String getRequested(int index) { - return requested_.get(index); - } - /** - * repeated string requested = 2; - * - *
      -     * A list of full type names of requested contexts.
      -     * 
      - */ - public com.google.protobuf.ByteString - getRequestedBytes(int index) { - return requested_.getByteString(index); - } - /** - * repeated string requested = 2; - * - *
      -     * A list of full type names of requested contexts.
      -     * 
      - */ - public Builder setRequested( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureRequestedIsMutable(); - requested_.set(index, value); - onChanged(); - return this; - } - /** - * repeated string requested = 2; - * - *
      -     * A list of full type names of requested contexts.
      -     * 
      - */ - public Builder addRequested( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureRequestedIsMutable(); - requested_.add(value); - onChanged(); - return this; - } - /** - * repeated string requested = 2; - * - *
      -     * A list of full type names of requested contexts.
      -     * 
      - */ - public Builder addAllRequested( - java.lang.Iterable values) { - ensureRequestedIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, requested_); - onChanged(); - return this; - } - /** - * repeated string requested = 2; - * - *
      -     * A list of full type names of requested contexts.
      -     * 
      - */ - public Builder clearRequested() { - requested_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - * repeated string requested = 2; - * - *
      -     * A list of full type names of requested contexts.
      -     * 
      - */ - public Builder addRequestedBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureRequestedIsMutable(); - requested_.add(value); - onChanged(); - return this; - } - - private com.google.protobuf.LazyStringList provided_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureProvidedIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - provided_ = new com.google.protobuf.LazyStringArrayList(provided_); - bitField0_ |= 0x00000004; - } - } - /** - * repeated string provided = 3; - * - *
      -     * A list of full type names of provided contexts.
      -     * 
      - */ - public com.google.protobuf.ProtocolStringList - getProvidedList() { - return provided_.getUnmodifiableView(); - } - /** - * repeated string provided = 3; - * - *
      -     * A list of full type names of provided contexts.
      -     * 
      - */ - public int getProvidedCount() { - return provided_.size(); - } - /** - * repeated string provided = 3; - * - *
      -     * A list of full type names of provided contexts.
      -     * 
      - */ - public java.lang.String getProvided(int index) { - return provided_.get(index); - } - /** - * repeated string provided = 3; - * - *
      -     * A list of full type names of provided contexts.
      -     * 
      - */ - public com.google.protobuf.ByteString - getProvidedBytes(int index) { - return provided_.getByteString(index); - } - /** - * repeated string provided = 3; - * - *
      -     * A list of full type names of provided contexts.
      -     * 
      - */ - public Builder setProvided( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureProvidedIsMutable(); - provided_.set(index, value); - onChanged(); - return this; - } - /** - * repeated string provided = 3; - * - *
      -     * A list of full type names of provided contexts.
      -     * 
      - */ - public Builder addProvided( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureProvidedIsMutable(); - provided_.add(value); - onChanged(); - return this; - } - /** - * repeated string provided = 3; - * - *
      -     * A list of full type names of provided contexts.
      -     * 
      - */ - public Builder addAllProvided( - java.lang.Iterable values) { - ensureProvidedIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, provided_); - onChanged(); - return this; - } - /** - * repeated string provided = 3; - * - *
      -     * A list of full type names of provided contexts.
      -     * 
      - */ - public Builder clearProvided() { - provided_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - return this; - } - /** - * repeated string provided = 3; - * - *
      -     * A list of full type names of provided contexts.
      -     * 
      - */ - public Builder addProvidedBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureProvidedIsMutable(); - provided_.add(value); - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.ContextRule) - } - - // @@protoc_insertion_point(class_scope:google.api.ContextRule) - private static final com.google.api.ContextRule DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.ContextRule(); - } - - public static com.google.api.ContextRule getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ContextRule parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ContextRule(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.ContextRule getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRuleOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRuleOrBuilder.java deleted file mode 100644 index 3174e0295a35..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/ContextRuleOrBuilder.java +++ /dev/null @@ -1,99 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/context.proto - -package com.google.api; - -public interface ContextRuleOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.ContextRule) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string selector = 1; - * - *
      -   * Selects the methods to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - java.lang.String getSelector(); - /** - * optional string selector = 1; - * - *
      -   * Selects the methods to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - com.google.protobuf.ByteString - getSelectorBytes(); - - /** - * repeated string requested = 2; - * - *
      -   * A list of full type names of requested contexts.
      -   * 
      - */ - com.google.protobuf.ProtocolStringList - getRequestedList(); - /** - * repeated string requested = 2; - * - *
      -   * A list of full type names of requested contexts.
      -   * 
      - */ - int getRequestedCount(); - /** - * repeated string requested = 2; - * - *
      -   * A list of full type names of requested contexts.
      -   * 
      - */ - java.lang.String getRequested(int index); - /** - * repeated string requested = 2; - * - *
      -   * A list of full type names of requested contexts.
      -   * 
      - */ - com.google.protobuf.ByteString - getRequestedBytes(int index); - - /** - * repeated string provided = 3; - * - *
      -   * A list of full type names of provided contexts.
      -   * 
      - */ - com.google.protobuf.ProtocolStringList - getProvidedList(); - /** - * repeated string provided = 3; - * - *
      -   * A list of full type names of provided contexts.
      -   * 
      - */ - int getProvidedCount(); - /** - * repeated string provided = 3; - * - *
      -   * A list of full type names of provided contexts.
      -   * 
      - */ - java.lang.String getProvided(int index); - /** - * repeated string provided = 3; - * - *
      -   * A list of full type names of provided contexts.
      -   * 
      - */ - com.google.protobuf.ByteString - getProvidedBytes(int index); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomError.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomError.java deleted file mode 100644 index 9b9b004161b3..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomError.java +++ /dev/null @@ -1,1016 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/error.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.CustomError} - * - *
      - * Customize service error responses.  For example, list any service
      - * specific protobuf types that can appear in error detail lists of
      - * error responses.
      - * Example:
      - *     custom_error:
      - *       types:
      - *       - google.foo.v1.CustomError
      - *       - google.foo.v1.AnotherError
      - * (-- For internal Google service producers, instead of listing such
      - * custom error detail types in the YAML configuration file; Stubby
      - * annotation can be used.  Please, see //google/api/annotations.proto
      - * for more details. --)
      - * 
      - */ -public final class CustomError extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.CustomError) - CustomErrorOrBuilder { - // Use CustomError.newBuilder() to construct. - private CustomError(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private CustomError() { - rules_ = java.util.Collections.emptyList(); - types_ = com.google.protobuf.LazyStringArrayList.EMPTY; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private CustomError( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - rules_.add(input.readMessage(com.google.api.CustomErrorRule.parser(), extensionRegistry)); - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - types_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000002; - } - types_.add(s); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = java.util.Collections.unmodifiableList(rules_); - } - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - types_ = types_.getUnmodifiableView(); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.ErrorFormatProto.internal_static_google_api_CustomError_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.ErrorFormatProto.internal_static_google_api_CustomError_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.CustomError.class, com.google.api.CustomError.Builder.class); - } - - public static final int RULES_FIELD_NUMBER = 1; - private java.util.List rules_; - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -   * The list of custom error rules to select to which messages this should
      -   * apply.
      -   * 
      - */ - public java.util.List getRulesList() { - return rules_; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -   * The list of custom error rules to select to which messages this should
      -   * apply.
      -   * 
      - */ - public java.util.List - getRulesOrBuilderList() { - return rules_; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -   * The list of custom error rules to select to which messages this should
      -   * apply.
      -   * 
      - */ - public int getRulesCount() { - return rules_.size(); - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -   * The list of custom error rules to select to which messages this should
      -   * apply.
      -   * 
      - */ - public com.google.api.CustomErrorRule getRules(int index) { - return rules_.get(index); - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -   * The list of custom error rules to select to which messages this should
      -   * apply.
      -   * 
      - */ - public com.google.api.CustomErrorRuleOrBuilder getRulesOrBuilder( - int index) { - return rules_.get(index); - } - - public static final int TYPES_FIELD_NUMBER = 2; - private com.google.protobuf.LazyStringList types_; - /** - * repeated string types = 2; - * - *
      -   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -   * 
      - */ - public com.google.protobuf.ProtocolStringList - getTypesList() { - return types_; - } - /** - * repeated string types = 2; - * - *
      -   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -   * 
      - */ - public int getTypesCount() { - return types_.size(); - } - /** - * repeated string types = 2; - * - *
      -   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -   * 
      - */ - public java.lang.String getTypes(int index) { - return types_.get(index); - } - /** - * repeated string types = 2; - * - *
      -   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -   * 
      - */ - public com.google.protobuf.ByteString - getTypesBytes(int index) { - return types_.getByteString(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < rules_.size(); i++) { - output.writeMessage(1, rules_.get(i)); - } - for (int i = 0; i < types_.size(); i++) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, types_.getRaw(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < rules_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, rules_.get(i)); - } - { - int dataSize = 0; - for (int i = 0; i < types_.size(); i++) { - dataSize += computeStringSizeNoTag(types_.getRaw(i)); - } - size += dataSize; - size += 1 * getTypesList().size(); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.CustomError parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.CustomError parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.CustomError parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.CustomError parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.CustomError parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.CustomError parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.CustomError parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.CustomError parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.CustomError parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.CustomError parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.CustomError prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.CustomError} - * - *
      -   * Customize service error responses.  For example, list any service
      -   * specific protobuf types that can appear in error detail lists of
      -   * error responses.
      -   * Example:
      -   *     custom_error:
      -   *       types:
      -   *       - google.foo.v1.CustomError
      -   *       - google.foo.v1.AnotherError
      -   * (-- For internal Google service producers, instead of listing such
      -   * custom error detail types in the YAML configuration file; Stubby
      -   * annotation can be used.  Please, see //google/api/annotations.proto
      -   * for more details. --)
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.CustomError) - com.google.api.CustomErrorOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.ErrorFormatProto.internal_static_google_api_CustomError_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.ErrorFormatProto.internal_static_google_api_CustomError_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.CustomError.class, com.google.api.CustomError.Builder.class); - } - - // Construct using com.google.api.CustomError.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getRulesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (rulesBuilder_ == null) { - rules_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - rulesBuilder_.clear(); - } - types_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.ErrorFormatProto.internal_static_google_api_CustomError_descriptor; - } - - public com.google.api.CustomError getDefaultInstanceForType() { - return com.google.api.CustomError.getDefaultInstance(); - } - - public com.google.api.CustomError build() { - com.google.api.CustomError result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.CustomError buildPartial() { - com.google.api.CustomError result = new com.google.api.CustomError(this); - int from_bitField0_ = bitField0_; - if (rulesBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = java.util.Collections.unmodifiableList(rules_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.rules_ = rules_; - } else { - result.rules_ = rulesBuilder_.build(); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - types_ = types_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.types_ = types_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.CustomError) { - return mergeFrom((com.google.api.CustomError)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.CustomError other) { - if (other == com.google.api.CustomError.getDefaultInstance()) return this; - if (rulesBuilder_ == null) { - if (!other.rules_.isEmpty()) { - if (rules_.isEmpty()) { - rules_ = other.rules_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureRulesIsMutable(); - rules_.addAll(other.rules_); - } - onChanged(); - } - } else { - if (!other.rules_.isEmpty()) { - if (rulesBuilder_.isEmpty()) { - rulesBuilder_.dispose(); - rulesBuilder_ = null; - rules_ = other.rules_; - bitField0_ = (bitField0_ & ~0x00000001); - rulesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getRulesFieldBuilder() : null; - } else { - rulesBuilder_.addAllMessages(other.rules_); - } - } - } - if (!other.types_.isEmpty()) { - if (types_.isEmpty()) { - types_ = other.types_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureTypesIsMutable(); - types_.addAll(other.types_); - } - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.CustomError parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.CustomError) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List rules_ = - java.util.Collections.emptyList(); - private void ensureRulesIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = new java.util.ArrayList(rules_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.CustomErrorRule, com.google.api.CustomErrorRule.Builder, com.google.api.CustomErrorRuleOrBuilder> rulesBuilder_; - - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public java.util.List getRulesList() { - if (rulesBuilder_ == null) { - return java.util.Collections.unmodifiableList(rules_); - } else { - return rulesBuilder_.getMessageList(); - } - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public int getRulesCount() { - if (rulesBuilder_ == null) { - return rules_.size(); - } else { - return rulesBuilder_.getCount(); - } - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public com.google.api.CustomErrorRule getRules(int index) { - if (rulesBuilder_ == null) { - return rules_.get(index); - } else { - return rulesBuilder_.getMessage(index); - } - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public Builder setRules( - int index, com.google.api.CustomErrorRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.set(index, value); - onChanged(); - } else { - rulesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public Builder setRules( - int index, com.google.api.CustomErrorRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.set(index, builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public Builder addRules(com.google.api.CustomErrorRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.add(value); - onChanged(); - } else { - rulesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public Builder addRules( - int index, com.google.api.CustomErrorRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.add(index, value); - onChanged(); - } else { - rulesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public Builder addRules( - com.google.api.CustomErrorRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.add(builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public Builder addRules( - int index, com.google.api.CustomErrorRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.add(index, builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public Builder addAllRules( - java.lang.Iterable values) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, rules_); - onChanged(); - } else { - rulesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public Builder clearRules() { - if (rulesBuilder_ == null) { - rules_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - rulesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public Builder removeRules(int index) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.remove(index); - onChanged(); - } else { - rulesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public com.google.api.CustomErrorRule.Builder getRulesBuilder( - int index) { - return getRulesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public com.google.api.CustomErrorRuleOrBuilder getRulesOrBuilder( - int index) { - if (rulesBuilder_ == null) { - return rules_.get(index); } else { - return rulesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public java.util.List - getRulesOrBuilderList() { - if (rulesBuilder_ != null) { - return rulesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(rules_); - } - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public com.google.api.CustomErrorRule.Builder addRulesBuilder() { - return getRulesFieldBuilder().addBuilder( - com.google.api.CustomErrorRule.getDefaultInstance()); - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public com.google.api.CustomErrorRule.Builder addRulesBuilder( - int index) { - return getRulesFieldBuilder().addBuilder( - index, com.google.api.CustomErrorRule.getDefaultInstance()); - } - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -     * The list of custom error rules to select to which messages this should
      -     * apply.
      -     * 
      - */ - public java.util.List - getRulesBuilderList() { - return getRulesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.CustomErrorRule, com.google.api.CustomErrorRule.Builder, com.google.api.CustomErrorRuleOrBuilder> - getRulesFieldBuilder() { - if (rulesBuilder_ == null) { - rulesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.api.CustomErrorRule, com.google.api.CustomErrorRule.Builder, com.google.api.CustomErrorRuleOrBuilder>( - rules_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - rules_ = null; - } - return rulesBuilder_; - } - - private com.google.protobuf.LazyStringList types_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureTypesIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - types_ = new com.google.protobuf.LazyStringArrayList(types_); - bitField0_ |= 0x00000002; - } - } - /** - * repeated string types = 2; - * - *
      -     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -     * 
      - */ - public com.google.protobuf.ProtocolStringList - getTypesList() { - return types_.getUnmodifiableView(); - } - /** - * repeated string types = 2; - * - *
      -     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -     * 
      - */ - public int getTypesCount() { - return types_.size(); - } - /** - * repeated string types = 2; - * - *
      -     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -     * 
      - */ - public java.lang.String getTypes(int index) { - return types_.get(index); - } - /** - * repeated string types = 2; - * - *
      -     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -     * 
      - */ - public com.google.protobuf.ByteString - getTypesBytes(int index) { - return types_.getByteString(index); - } - /** - * repeated string types = 2; - * - *
      -     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -     * 
      - */ - public Builder setTypes( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureTypesIsMutable(); - types_.set(index, value); - onChanged(); - return this; - } - /** - * repeated string types = 2; - * - *
      -     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -     * 
      - */ - public Builder addTypes( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureTypesIsMutable(); - types_.add(value); - onChanged(); - return this; - } - /** - * repeated string types = 2; - * - *
      -     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -     * 
      - */ - public Builder addAllTypes( - java.lang.Iterable values) { - ensureTypesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, types_); - onChanged(); - return this; - } - /** - * repeated string types = 2; - * - *
      -     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -     * 
      - */ - public Builder clearTypes() { - types_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - * repeated string types = 2; - * - *
      -     * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -     * 
      - */ - public Builder addTypesBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureTypesIsMutable(); - types_.add(value); - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.CustomError) - } - - // @@protoc_insertion_point(class_scope:google.api.CustomError) - private static final com.google.api.CustomError DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.CustomError(); - } - - public static com.google.api.CustomError getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public CustomError parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new CustomError(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.CustomError getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorOrBuilder.java deleted file mode 100644 index 9e7fc1d0b94d..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorOrBuilder.java +++ /dev/null @@ -1,93 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/error.proto - -package com.google.api; - -public interface CustomErrorOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.CustomError) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -   * The list of custom error rules to select to which messages this should
      -   * apply.
      -   * 
      - */ - java.util.List - getRulesList(); - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -   * The list of custom error rules to select to which messages this should
      -   * apply.
      -   * 
      - */ - com.google.api.CustomErrorRule getRules(int index); - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -   * The list of custom error rules to select to which messages this should
      -   * apply.
      -   * 
      - */ - int getRulesCount(); - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -   * The list of custom error rules to select to which messages this should
      -   * apply.
      -   * 
      - */ - java.util.List - getRulesOrBuilderList(); - /** - * repeated .google.api.CustomErrorRule rules = 1; - * - *
      -   * The list of custom error rules to select to which messages this should
      -   * apply.
      -   * 
      - */ - com.google.api.CustomErrorRuleOrBuilder getRulesOrBuilder( - int index); - - /** - * repeated string types = 2; - * - *
      -   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -   * 
      - */ - com.google.protobuf.ProtocolStringList - getTypesList(); - /** - * repeated string types = 2; - * - *
      -   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -   * 
      - */ - int getTypesCount(); - /** - * repeated string types = 2; - * - *
      -   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -   * 
      - */ - java.lang.String getTypes(int index); - /** - * repeated string types = 2; - * - *
      -   * The list of custom error detail types, e.g. 'google.foo.v1.CustomError'.
      -   * 
      - */ - com.google.protobuf.ByteString - getTypesBytes(int index); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRule.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRule.java deleted file mode 100644 index 6f1333cb2e13..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRule.java +++ /dev/null @@ -1,627 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/error.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.CustomErrorRule} - * - *
      - * A custom error rule.
      - * 
      - */ -public final class CustomErrorRule extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.CustomErrorRule) - CustomErrorRuleOrBuilder { - // Use CustomErrorRule.newBuilder() to construct. - private CustomErrorRule(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private CustomErrorRule() { - selector_ = ""; - stubbyBridge_ = 0; - isErrorType_ = false; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private CustomErrorRule( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - selector_ = s; - break; - } - case 16: { - - stubbyBridge_ = input.readInt32(); - break; - } - case 24: { - - isErrorType_ = input.readBool(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.ErrorFormatProto.internal_static_google_api_CustomErrorRule_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.ErrorFormatProto.internal_static_google_api_CustomErrorRule_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.CustomErrorRule.class, com.google.api.CustomErrorRule.Builder.class); - } - - public static final int SELECTOR_FIELD_NUMBER = 1; - private volatile java.lang.Object selector_; - /** - * optional string selector = 1; - * - *
      -   * Selects messages to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - public java.lang.String getSelector() { - java.lang.Object ref = selector_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - selector_ = s; - return s; - } - } - /** - * optional string selector = 1; - * - *
      -   * Selects messages to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSelectorBytes() { - java.lang.Object ref = selector_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - selector_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int STUBBY_BRIDGE_FIELD_NUMBER = 2; - private int stubbyBridge_; - /** - * optional int32 stubby_bridge = 2 [deprecated = true]; - * - *
      -   * (--The Stubby bridge of the message.--)
      -   * 
      - */ - @java.lang.Deprecated public int getStubbyBridge() { - return stubbyBridge_; - } - - public static final int IS_ERROR_TYPE_FIELD_NUMBER = 3; - private boolean isErrorType_; - /** - * optional bool is_error_type = 3; - * - *
      -   * Mark this message as possible payload in error response.  Otherwise,
      -   * objects of this type will be filtered when they appear in error payload.
      -   * 
      - */ - public boolean getIsErrorType() { - return isErrorType_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSelectorBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, selector_); - } - if (stubbyBridge_ != 0) { - output.writeInt32(2, stubbyBridge_); - } - if (isErrorType_ != false) { - output.writeBool(3, isErrorType_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSelectorBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, selector_); - } - if (stubbyBridge_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, stubbyBridge_); - } - if (isErrorType_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(3, isErrorType_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.CustomErrorRule parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.CustomErrorRule parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.CustomErrorRule parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.CustomErrorRule parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.CustomErrorRule parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.CustomErrorRule parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.CustomErrorRule parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.CustomErrorRule parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.CustomErrorRule parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.CustomErrorRule parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.CustomErrorRule prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.CustomErrorRule} - * - *
      -   * A custom error rule.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.CustomErrorRule) - com.google.api.CustomErrorRuleOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.ErrorFormatProto.internal_static_google_api_CustomErrorRule_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.ErrorFormatProto.internal_static_google_api_CustomErrorRule_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.CustomErrorRule.class, com.google.api.CustomErrorRule.Builder.class); - } - - // Construct using com.google.api.CustomErrorRule.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - selector_ = ""; - - stubbyBridge_ = 0; - - isErrorType_ = false; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.ErrorFormatProto.internal_static_google_api_CustomErrorRule_descriptor; - } - - public com.google.api.CustomErrorRule getDefaultInstanceForType() { - return com.google.api.CustomErrorRule.getDefaultInstance(); - } - - public com.google.api.CustomErrorRule build() { - com.google.api.CustomErrorRule result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.CustomErrorRule buildPartial() { - com.google.api.CustomErrorRule result = new com.google.api.CustomErrorRule(this); - result.selector_ = selector_; - result.stubbyBridge_ = stubbyBridge_; - result.isErrorType_ = isErrorType_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.CustomErrorRule) { - return mergeFrom((com.google.api.CustomErrorRule)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.CustomErrorRule other) { - if (other == com.google.api.CustomErrorRule.getDefaultInstance()) return this; - if (!other.getSelector().isEmpty()) { - selector_ = other.selector_; - onChanged(); - } - if (other.getStubbyBridge() != 0) { - setStubbyBridge(other.getStubbyBridge()); - } - if (other.getIsErrorType() != false) { - setIsErrorType(other.getIsErrorType()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.CustomErrorRule parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.CustomErrorRule) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object selector_ = ""; - /** - * optional string selector = 1; - * - *
      -     * Selects messages to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public java.lang.String getSelector() { - java.lang.Object ref = selector_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - selector_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string selector = 1; - * - *
      -     * Selects messages to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSelectorBytes() { - java.lang.Object ref = selector_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - selector_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string selector = 1; - * - *
      -     * Selects messages to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder setSelector( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - selector_ = value; - onChanged(); - return this; - } - /** - * optional string selector = 1; - * - *
      -     * Selects messages to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder clearSelector() { - - selector_ = getDefaultInstance().getSelector(); - onChanged(); - return this; - } - /** - * optional string selector = 1; - * - *
      -     * Selects messages to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder setSelectorBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - selector_ = value; - onChanged(); - return this; - } - - private int stubbyBridge_ ; - /** - * optional int32 stubby_bridge = 2 [deprecated = true]; - * - *
      -     * (--The Stubby bridge of the message.--)
      -     * 
      - */ - @java.lang.Deprecated public int getStubbyBridge() { - return stubbyBridge_; - } - /** - * optional int32 stubby_bridge = 2 [deprecated = true]; - * - *
      -     * (--The Stubby bridge of the message.--)
      -     * 
      - */ - @java.lang.Deprecated public Builder setStubbyBridge(int value) { - - stubbyBridge_ = value; - onChanged(); - return this; - } - /** - * optional int32 stubby_bridge = 2 [deprecated = true]; - * - *
      -     * (--The Stubby bridge of the message.--)
      -     * 
      - */ - @java.lang.Deprecated public Builder clearStubbyBridge() { - - stubbyBridge_ = 0; - onChanged(); - return this; - } - - private boolean isErrorType_ ; - /** - * optional bool is_error_type = 3; - * - *
      -     * Mark this message as possible payload in error response.  Otherwise,
      -     * objects of this type will be filtered when they appear in error payload.
      -     * 
      - */ - public boolean getIsErrorType() { - return isErrorType_; - } - /** - * optional bool is_error_type = 3; - * - *
      -     * Mark this message as possible payload in error response.  Otherwise,
      -     * objects of this type will be filtered when they appear in error payload.
      -     * 
      - */ - public Builder setIsErrorType(boolean value) { - - isErrorType_ = value; - onChanged(); - return this; - } - /** - * optional bool is_error_type = 3; - * - *
      -     * Mark this message as possible payload in error response.  Otherwise,
      -     * objects of this type will be filtered when they appear in error payload.
      -     * 
      - */ - public Builder clearIsErrorType() { - - isErrorType_ = false; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.CustomErrorRule) - } - - // @@protoc_insertion_point(class_scope:google.api.CustomErrorRule) - private static final com.google.api.CustomErrorRule DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.CustomErrorRule(); - } - - public static com.google.api.CustomErrorRule getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public CustomErrorRule parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new CustomErrorRule(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.CustomErrorRule getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRuleOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRuleOrBuilder.java deleted file mode 100644 index a4746577b373..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomErrorRuleOrBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/error.proto - -package com.google.api; - -public interface CustomErrorRuleOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.CustomErrorRule) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string selector = 1; - * - *
      -   * Selects messages to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - java.lang.String getSelector(); - /** - * optional string selector = 1; - * - *
      -   * Selects messages to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - com.google.protobuf.ByteString - getSelectorBytes(); - - /** - * optional int32 stubby_bridge = 2 [deprecated = true]; - * - *
      -   * (--The Stubby bridge of the message.--)
      -   * 
      - */ - @java.lang.Deprecated int getStubbyBridge(); - - /** - * optional bool is_error_type = 3; - * - *
      -   * Mark this message as possible payload in error response.  Otherwise,
      -   * objects of this type will be filtered when they appear in error payload.
      -   * 
      - */ - boolean getIsErrorType(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPattern.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPattern.java deleted file mode 100644 index e3a51cd280c7..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPattern.java +++ /dev/null @@ -1,627 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.CustomHttpPattern} - * - *
      - * A custom pattern is used for defining custom HTTP verb.
      - * 
      - */ -public final class CustomHttpPattern extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.CustomHttpPattern) - CustomHttpPatternOrBuilder { - // Use CustomHttpPattern.newBuilder() to construct. - private CustomHttpPattern(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private CustomHttpPattern() { - kind_ = ""; - path_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private CustomHttpPattern( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - kind_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - path_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.HttpProto.internal_static_google_api_CustomHttpPattern_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.HttpProto.internal_static_google_api_CustomHttpPattern_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.CustomHttpPattern.class, com.google.api.CustomHttpPattern.Builder.class); - } - - public static final int KIND_FIELD_NUMBER = 1; - private volatile java.lang.Object kind_; - /** - * optional string kind = 1; - * - *
      -   * The name of this custom HTTP verb.
      -   * 
      - */ - public java.lang.String getKind() { - java.lang.Object ref = kind_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - kind_ = s; - return s; - } - } - /** - * optional string kind = 1; - * - *
      -   * The name of this custom HTTP verb.
      -   * 
      - */ - public com.google.protobuf.ByteString - getKindBytes() { - java.lang.Object ref = kind_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - kind_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PATH_FIELD_NUMBER = 2; - private volatile java.lang.Object path_; - /** - * optional string path = 2; - * - *
      -   * The path matched by this custom verb.
      -   * 
      - */ - public java.lang.String getPath() { - java.lang.Object ref = path_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - path_ = s; - return s; - } - } - /** - * optional string path = 2; - * - *
      -   * The path matched by this custom verb.
      -   * 
      - */ - public com.google.protobuf.ByteString - getPathBytes() { - java.lang.Object ref = path_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - path_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getKindBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, kind_); - } - if (!getPathBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, path_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getKindBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, kind_); - } - if (!getPathBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, path_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.CustomHttpPattern parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.CustomHttpPattern parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.CustomHttpPattern parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.CustomHttpPattern parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.CustomHttpPattern parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.CustomHttpPattern parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.CustomHttpPattern parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.CustomHttpPattern parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.CustomHttpPattern parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.CustomHttpPattern parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.CustomHttpPattern prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.CustomHttpPattern} - * - *
      -   * A custom pattern is used for defining custom HTTP verb.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.CustomHttpPattern) - com.google.api.CustomHttpPatternOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.HttpProto.internal_static_google_api_CustomHttpPattern_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.HttpProto.internal_static_google_api_CustomHttpPattern_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.CustomHttpPattern.class, com.google.api.CustomHttpPattern.Builder.class); - } - - // Construct using com.google.api.CustomHttpPattern.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - kind_ = ""; - - path_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.HttpProto.internal_static_google_api_CustomHttpPattern_descriptor; - } - - public com.google.api.CustomHttpPattern getDefaultInstanceForType() { - return com.google.api.CustomHttpPattern.getDefaultInstance(); - } - - public com.google.api.CustomHttpPattern build() { - com.google.api.CustomHttpPattern result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.CustomHttpPattern buildPartial() { - com.google.api.CustomHttpPattern result = new com.google.api.CustomHttpPattern(this); - result.kind_ = kind_; - result.path_ = path_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.CustomHttpPattern) { - return mergeFrom((com.google.api.CustomHttpPattern)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.CustomHttpPattern other) { - if (other == com.google.api.CustomHttpPattern.getDefaultInstance()) return this; - if (!other.getKind().isEmpty()) { - kind_ = other.kind_; - onChanged(); - } - if (!other.getPath().isEmpty()) { - path_ = other.path_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.CustomHttpPattern parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.CustomHttpPattern) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object kind_ = ""; - /** - * optional string kind = 1; - * - *
      -     * The name of this custom HTTP verb.
      -     * 
      - */ - public java.lang.String getKind() { - java.lang.Object ref = kind_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - kind_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string kind = 1; - * - *
      -     * The name of this custom HTTP verb.
      -     * 
      - */ - public com.google.protobuf.ByteString - getKindBytes() { - java.lang.Object ref = kind_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - kind_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string kind = 1; - * - *
      -     * The name of this custom HTTP verb.
      -     * 
      - */ - public Builder setKind( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - kind_ = value; - onChanged(); - return this; - } - /** - * optional string kind = 1; - * - *
      -     * The name of this custom HTTP verb.
      -     * 
      - */ - public Builder clearKind() { - - kind_ = getDefaultInstance().getKind(); - onChanged(); - return this; - } - /** - * optional string kind = 1; - * - *
      -     * The name of this custom HTTP verb.
      -     * 
      - */ - public Builder setKindBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - kind_ = value; - onChanged(); - return this; - } - - private java.lang.Object path_ = ""; - /** - * optional string path = 2; - * - *
      -     * The path matched by this custom verb.
      -     * 
      - */ - public java.lang.String getPath() { - java.lang.Object ref = path_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - path_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string path = 2; - * - *
      -     * The path matched by this custom verb.
      -     * 
      - */ - public com.google.protobuf.ByteString - getPathBytes() { - java.lang.Object ref = path_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - path_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string path = 2; - * - *
      -     * The path matched by this custom verb.
      -     * 
      - */ - public Builder setPath( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - path_ = value; - onChanged(); - return this; - } - /** - * optional string path = 2; - * - *
      -     * The path matched by this custom verb.
      -     * 
      - */ - public Builder clearPath() { - - path_ = getDefaultInstance().getPath(); - onChanged(); - return this; - } - /** - * optional string path = 2; - * - *
      -     * The path matched by this custom verb.
      -     * 
      - */ - public Builder setPathBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - path_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.CustomHttpPattern) - } - - // @@protoc_insertion_point(class_scope:google.api.CustomHttpPattern) - private static final com.google.api.CustomHttpPattern DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.CustomHttpPattern(); - } - - public static com.google.api.CustomHttpPattern getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public CustomHttpPattern parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new CustomHttpPattern(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.CustomHttpPattern getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPatternOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPatternOrBuilder.java deleted file mode 100644 index e45514be7749..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/CustomHttpPatternOrBuilder.java +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -public interface CustomHttpPatternOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.CustomHttpPattern) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string kind = 1; - * - *
      -   * The name of this custom HTTP verb.
      -   * 
      - */ - java.lang.String getKind(); - /** - * optional string kind = 1; - * - *
      -   * The name of this custom HTTP verb.
      -   * 
      - */ - com.google.protobuf.ByteString - getKindBytes(); - - /** - * optional string path = 2; - * - *
      -   * The path matched by this custom verb.
      -   * 
      - */ - java.lang.String getPath(); - /** - * optional string path = 2; - * - *
      -   * The path matched by this custom verb.
      -   * 
      - */ - com.google.protobuf.ByteString - getPathBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Documentation.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Documentation.java deleted file mode 100644 index 544435e99564..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/Documentation.java +++ /dev/null @@ -1,1816 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/documentation.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.Documentation} - * - *
      - * `Documentation` provides the information for describing a service.
      - * Example:
      - *     documentation:
      - *       summary: >
      - *         The Google Calendar API gives access
      - *         to most calendar features.
      - *       pages:
      - *       - name: Overview
      - *         content: (== include google/foo/overview.md ==)
      - *       - name: Tutorial
      - *         content: (== include google/foo/tutorial.md ==)
      - *         subpages;
      - *         - name: Java
      - *           content: (== include google/foo/tutorial_java.md ==)
      - *       rules:
      - *       - selector: google.calendar.Calendar.Get
      - *         description: >
      - *           ...
      - *       - selector: google.calendar.Calendar.Put
      - *         description: >
      - *           ...
      - * Documentation is provided in markdown syntax. In addition to
      - * standard markdown features, definition lists, tables and fenced
      - * code blocks are supported. Section headers can be provided and are
      - * interpreted relative to the section nesting of the context where
      - * a documentation fragment is embedded.
      - * Documentation from the IDL is merged with documentation defined
      - * via the config at normalization time, where documentation provided
      - * by config rules overrides IDL provided.
      - * A number of constructs specific to the API platform are supported
      - * in documentation text.
      - * In order to reference a proto element, the following
      - * notation can be used:
      - * <pre><code>&#91;display text]&#91;fully.qualified.proto.name]
      - * &#91;fully.qualified.proto.name]&#91;]</code></pre>
      - * Text can be excluded from doc using the following notation:
      - * <pre><code>&#40;-- internal comment --&#41;</code></pre>
      - * Comments can be made conditional using a visibility label. The below
      - * text will be only rendered if the `BETA` label is available:
      - * <pre><code>&#40;--BETA: comment for BETA users --&#41;</code></pre>
      - * A few directives are available in documentation. Note that
      - * directives must appear on a single line to be properly
      - * identified. The `include` directive includes a markdown file from
      - * an external source:
      - *     (== include path/to/file> ==)
      - * The `resource_for` directive marks a message to be the resource of
      - * a collection in REST view. If it is not specified, tools attempt
      - * to infer the resource from the operations in a collection:
      - *     (== resource_for v1.shelves.books ==)
      - * The directive `suppress_warning` is not directly effecting documentation
      - * and is documented together with service config validation.
      - * 
      - */ -public final class Documentation extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.Documentation) - DocumentationOrBuilder { - // Use Documentation.newBuilder() to construct. - private Documentation(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Documentation() { - summary_ = ""; - pages_ = java.util.Collections.emptyList(); - rules_ = java.util.Collections.emptyList(); - documentationRootUrl_ = ""; - overview_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Documentation( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - summary_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - overview_ = s; - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - rules_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - rules_.add(input.readMessage(com.google.api.DocumentationRule.parser(), extensionRegistry)); - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - documentationRootUrl_ = s; - break; - } - case 42: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - pages_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; - } - pages_.add(input.readMessage(com.google.api.Page.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - rules_ = java.util.Collections.unmodifiableList(rules_); - } - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - pages_ = java.util.Collections.unmodifiableList(pages_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.DocumentationProto.internal_static_google_api_Documentation_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.DocumentationProto.internal_static_google_api_Documentation_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Documentation.class, com.google.api.Documentation.Builder.class); - } - - private int bitField0_; - public static final int SUMMARY_FIELD_NUMBER = 1; - private volatile java.lang.Object summary_; - /** - * optional string summary = 1; - * - *
      -   * A short summary of what the service does. Can only be provided by
      -   * plain text.
      -   * 
      - */ - public java.lang.String getSummary() { - java.lang.Object ref = summary_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - summary_ = s; - return s; - } - } - /** - * optional string summary = 1; - * - *
      -   * A short summary of what the service does. Can only be provided by
      -   * plain text.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSummaryBytes() { - java.lang.Object ref = summary_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - summary_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PAGES_FIELD_NUMBER = 5; - private java.util.List pages_; - /** - * repeated .google.api.Page pages = 5; - * - *
      -   * The top level pages for the documentation set.
      -   * 
      - */ - public java.util.List getPagesList() { - return pages_; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -   * The top level pages for the documentation set.
      -   * 
      - */ - public java.util.List - getPagesOrBuilderList() { - return pages_; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -   * The top level pages for the documentation set.
      -   * 
      - */ - public int getPagesCount() { - return pages_.size(); - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -   * The top level pages for the documentation set.
      -   * 
      - */ - public com.google.api.Page getPages(int index) { - return pages_.get(index); - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -   * The top level pages for the documentation set.
      -   * 
      - */ - public com.google.api.PageOrBuilder getPagesOrBuilder( - int index) { - return pages_.get(index); - } - - public static final int RULES_FIELD_NUMBER = 3; - private java.util.List rules_; - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -   * Documentation rules for individual elements of the service.
      -   * 
      - */ - public java.util.List getRulesList() { - return rules_; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -   * Documentation rules for individual elements of the service.
      -   * 
      - */ - public java.util.List - getRulesOrBuilderList() { - return rules_; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -   * Documentation rules for individual elements of the service.
      -   * 
      - */ - public int getRulesCount() { - return rules_.size(); - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -   * Documentation rules for individual elements of the service.
      -   * 
      - */ - public com.google.api.DocumentationRule getRules(int index) { - return rules_.get(index); - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -   * Documentation rules for individual elements of the service.
      -   * 
      - */ - public com.google.api.DocumentationRuleOrBuilder getRulesOrBuilder( - int index) { - return rules_.get(index); - } - - public static final int DOCUMENTATION_ROOT_URL_FIELD_NUMBER = 4; - private volatile java.lang.Object documentationRootUrl_; - /** - * optional string documentation_root_url = 4; - * - *
      -   * The URL to the root of documentation.
      -   * 
      - */ - public java.lang.String getDocumentationRootUrl() { - java.lang.Object ref = documentationRootUrl_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - documentationRootUrl_ = s; - return s; - } - } - /** - * optional string documentation_root_url = 4; - * - *
      -   * The URL to the root of documentation.
      -   * 
      - */ - public com.google.protobuf.ByteString - getDocumentationRootUrlBytes() { - java.lang.Object ref = documentationRootUrl_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - documentationRootUrl_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int OVERVIEW_FIELD_NUMBER = 2; - private volatile java.lang.Object overview_; - /** - * optional string overview = 2; - * - *
      -   * Declares a single overview page. For example:
      -   *     documentation:
      -   *       summary: ...
      -   *       overview: (== include overview.md ==)
      -   * This is a shortcut for the following declaration (using pages style):
      -   *     documentation:
      -   *       summary: ...
      -   *       pages:
      -   *       - name: Overview
      -   *         content: (== include overview.md ==)
      -   * Note: you cannot specify both `overview` field and `pages` field.
      -   * 
      - */ - public java.lang.String getOverview() { - java.lang.Object ref = overview_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - overview_ = s; - return s; - } - } - /** - * optional string overview = 2; - * - *
      -   * Declares a single overview page. For example:
      -   *     documentation:
      -   *       summary: ...
      -   *       overview: (== include overview.md ==)
      -   * This is a shortcut for the following declaration (using pages style):
      -   *     documentation:
      -   *       summary: ...
      -   *       pages:
      -   *       - name: Overview
      -   *         content: (== include overview.md ==)
      -   * Note: you cannot specify both `overview` field and `pages` field.
      -   * 
      - */ - public com.google.protobuf.ByteString - getOverviewBytes() { - java.lang.Object ref = overview_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - overview_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSummaryBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, summary_); - } - if (!getOverviewBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, overview_); - } - for (int i = 0; i < rules_.size(); i++) { - output.writeMessage(3, rules_.get(i)); - } - if (!getDocumentationRootUrlBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 4, documentationRootUrl_); - } - for (int i = 0; i < pages_.size(); i++) { - output.writeMessage(5, pages_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSummaryBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, summary_); - } - if (!getOverviewBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, overview_); - } - for (int i = 0; i < rules_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, rules_.get(i)); - } - if (!getDocumentationRootUrlBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(4, documentationRootUrl_); - } - for (int i = 0; i < pages_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, pages_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.Documentation parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Documentation parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Documentation parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Documentation parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Documentation parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Documentation parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.Documentation parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.Documentation parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.Documentation parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Documentation parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.Documentation prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.Documentation} - * - *
      -   * `Documentation` provides the information for describing a service.
      -   * Example:
      -   *     documentation:
      -   *       summary: >
      -   *         The Google Calendar API gives access
      -   *         to most calendar features.
      -   *       pages:
      -   *       - name: Overview
      -   *         content: (== include google/foo/overview.md ==)
      -   *       - name: Tutorial
      -   *         content: (== include google/foo/tutorial.md ==)
      -   *         subpages;
      -   *         - name: Java
      -   *           content: (== include google/foo/tutorial_java.md ==)
      -   *       rules:
      -   *       - selector: google.calendar.Calendar.Get
      -   *         description: >
      -   *           ...
      -   *       - selector: google.calendar.Calendar.Put
      -   *         description: >
      -   *           ...
      -   * Documentation is provided in markdown syntax. In addition to
      -   * standard markdown features, definition lists, tables and fenced
      -   * code blocks are supported. Section headers can be provided and are
      -   * interpreted relative to the section nesting of the context where
      -   * a documentation fragment is embedded.
      -   * Documentation from the IDL is merged with documentation defined
      -   * via the config at normalization time, where documentation provided
      -   * by config rules overrides IDL provided.
      -   * A number of constructs specific to the API platform are supported
      -   * in documentation text.
      -   * In order to reference a proto element, the following
      -   * notation can be used:
      -   * <pre><code>&#91;display text]&#91;fully.qualified.proto.name]
      -   * &#91;fully.qualified.proto.name]&#91;]</code></pre>
      -   * Text can be excluded from doc using the following notation:
      -   * <pre><code>&#40;-- internal comment --&#41;</code></pre>
      -   * Comments can be made conditional using a visibility label. The below
      -   * text will be only rendered if the `BETA` label is available:
      -   * <pre><code>&#40;--BETA: comment for BETA users --&#41;</code></pre>
      -   * A few directives are available in documentation. Note that
      -   * directives must appear on a single line to be properly
      -   * identified. The `include` directive includes a markdown file from
      -   * an external source:
      -   *     (== include path/to/file> ==)
      -   * The `resource_for` directive marks a message to be the resource of
      -   * a collection in REST view. If it is not specified, tools attempt
      -   * to infer the resource from the operations in a collection:
      -   *     (== resource_for v1.shelves.books ==)
      -   * The directive `suppress_warning` is not directly effecting documentation
      -   * and is documented together with service config validation.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.Documentation) - com.google.api.DocumentationOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.DocumentationProto.internal_static_google_api_Documentation_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.DocumentationProto.internal_static_google_api_Documentation_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Documentation.class, com.google.api.Documentation.Builder.class); - } - - // Construct using com.google.api.Documentation.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getPagesFieldBuilder(); - getRulesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - summary_ = ""; - - if (pagesBuilder_ == null) { - pages_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - } else { - pagesBuilder_.clear(); - } - if (rulesBuilder_ == null) { - rules_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - } else { - rulesBuilder_.clear(); - } - documentationRootUrl_ = ""; - - overview_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.DocumentationProto.internal_static_google_api_Documentation_descriptor; - } - - public com.google.api.Documentation getDefaultInstanceForType() { - return com.google.api.Documentation.getDefaultInstance(); - } - - public com.google.api.Documentation build() { - com.google.api.Documentation result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.Documentation buildPartial() { - com.google.api.Documentation result = new com.google.api.Documentation(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.summary_ = summary_; - if (pagesBuilder_ == null) { - if (((bitField0_ & 0x00000002) == 0x00000002)) { - pages_ = java.util.Collections.unmodifiableList(pages_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.pages_ = pages_; - } else { - result.pages_ = pagesBuilder_.build(); - } - if (rulesBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004)) { - rules_ = java.util.Collections.unmodifiableList(rules_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.rules_ = rules_; - } else { - result.rules_ = rulesBuilder_.build(); - } - result.documentationRootUrl_ = documentationRootUrl_; - result.overview_ = overview_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.Documentation) { - return mergeFrom((com.google.api.Documentation)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.Documentation other) { - if (other == com.google.api.Documentation.getDefaultInstance()) return this; - if (!other.getSummary().isEmpty()) { - summary_ = other.summary_; - onChanged(); - } - if (pagesBuilder_ == null) { - if (!other.pages_.isEmpty()) { - if (pages_.isEmpty()) { - pages_ = other.pages_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensurePagesIsMutable(); - pages_.addAll(other.pages_); - } - onChanged(); - } - } else { - if (!other.pages_.isEmpty()) { - if (pagesBuilder_.isEmpty()) { - pagesBuilder_.dispose(); - pagesBuilder_ = null; - pages_ = other.pages_; - bitField0_ = (bitField0_ & ~0x00000002); - pagesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getPagesFieldBuilder() : null; - } else { - pagesBuilder_.addAllMessages(other.pages_); - } - } - } - if (rulesBuilder_ == null) { - if (!other.rules_.isEmpty()) { - if (rules_.isEmpty()) { - rules_ = other.rules_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureRulesIsMutable(); - rules_.addAll(other.rules_); - } - onChanged(); - } - } else { - if (!other.rules_.isEmpty()) { - if (rulesBuilder_.isEmpty()) { - rulesBuilder_.dispose(); - rulesBuilder_ = null; - rules_ = other.rules_; - bitField0_ = (bitField0_ & ~0x00000004); - rulesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getRulesFieldBuilder() : null; - } else { - rulesBuilder_.addAllMessages(other.rules_); - } - } - } - if (!other.getDocumentationRootUrl().isEmpty()) { - documentationRootUrl_ = other.documentationRootUrl_; - onChanged(); - } - if (!other.getOverview().isEmpty()) { - overview_ = other.overview_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.Documentation parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.Documentation) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object summary_ = ""; - /** - * optional string summary = 1; - * - *
      -     * A short summary of what the service does. Can only be provided by
      -     * plain text.
      -     * 
      - */ - public java.lang.String getSummary() { - java.lang.Object ref = summary_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - summary_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string summary = 1; - * - *
      -     * A short summary of what the service does. Can only be provided by
      -     * plain text.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSummaryBytes() { - java.lang.Object ref = summary_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - summary_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string summary = 1; - * - *
      -     * A short summary of what the service does. Can only be provided by
      -     * plain text.
      -     * 
      - */ - public Builder setSummary( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - summary_ = value; - onChanged(); - return this; - } - /** - * optional string summary = 1; - * - *
      -     * A short summary of what the service does. Can only be provided by
      -     * plain text.
      -     * 
      - */ - public Builder clearSummary() { - - summary_ = getDefaultInstance().getSummary(); - onChanged(); - return this; - } - /** - * optional string summary = 1; - * - *
      -     * A short summary of what the service does. Can only be provided by
      -     * plain text.
      -     * 
      - */ - public Builder setSummaryBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - summary_ = value; - onChanged(); - return this; - } - - private java.util.List pages_ = - java.util.Collections.emptyList(); - private void ensurePagesIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - pages_ = new java.util.ArrayList(pages_); - bitField0_ |= 0x00000002; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder> pagesBuilder_; - - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public java.util.List getPagesList() { - if (pagesBuilder_ == null) { - return java.util.Collections.unmodifiableList(pages_); - } else { - return pagesBuilder_.getMessageList(); - } - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public int getPagesCount() { - if (pagesBuilder_ == null) { - return pages_.size(); - } else { - return pagesBuilder_.getCount(); - } - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public com.google.api.Page getPages(int index) { - if (pagesBuilder_ == null) { - return pages_.get(index); - } else { - return pagesBuilder_.getMessage(index); - } - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public Builder setPages( - int index, com.google.api.Page value) { - if (pagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePagesIsMutable(); - pages_.set(index, value); - onChanged(); - } else { - pagesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public Builder setPages( - int index, com.google.api.Page.Builder builderForValue) { - if (pagesBuilder_ == null) { - ensurePagesIsMutable(); - pages_.set(index, builderForValue.build()); - onChanged(); - } else { - pagesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public Builder addPages(com.google.api.Page value) { - if (pagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePagesIsMutable(); - pages_.add(value); - onChanged(); - } else { - pagesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public Builder addPages( - int index, com.google.api.Page value) { - if (pagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePagesIsMutable(); - pages_.add(index, value); - onChanged(); - } else { - pagesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public Builder addPages( - com.google.api.Page.Builder builderForValue) { - if (pagesBuilder_ == null) { - ensurePagesIsMutable(); - pages_.add(builderForValue.build()); - onChanged(); - } else { - pagesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public Builder addPages( - int index, com.google.api.Page.Builder builderForValue) { - if (pagesBuilder_ == null) { - ensurePagesIsMutable(); - pages_.add(index, builderForValue.build()); - onChanged(); - } else { - pagesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public Builder addAllPages( - java.lang.Iterable values) { - if (pagesBuilder_ == null) { - ensurePagesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, pages_); - onChanged(); - } else { - pagesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public Builder clearPages() { - if (pagesBuilder_ == null) { - pages_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - } else { - pagesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public Builder removePages(int index) { - if (pagesBuilder_ == null) { - ensurePagesIsMutable(); - pages_.remove(index); - onChanged(); - } else { - pagesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public com.google.api.Page.Builder getPagesBuilder( - int index) { - return getPagesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public com.google.api.PageOrBuilder getPagesOrBuilder( - int index) { - if (pagesBuilder_ == null) { - return pages_.get(index); } else { - return pagesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public java.util.List - getPagesOrBuilderList() { - if (pagesBuilder_ != null) { - return pagesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(pages_); - } - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public com.google.api.Page.Builder addPagesBuilder() { - return getPagesFieldBuilder().addBuilder( - com.google.api.Page.getDefaultInstance()); - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public com.google.api.Page.Builder addPagesBuilder( - int index) { - return getPagesFieldBuilder().addBuilder( - index, com.google.api.Page.getDefaultInstance()); - } - /** - * repeated .google.api.Page pages = 5; - * - *
      -     * The top level pages for the documentation set.
      -     * 
      - */ - public java.util.List - getPagesBuilderList() { - return getPagesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder> - getPagesFieldBuilder() { - if (pagesBuilder_ == null) { - pagesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder>( - pages_, - ((bitField0_ & 0x00000002) == 0x00000002), - getParentForChildren(), - isClean()); - pages_ = null; - } - return pagesBuilder_; - } - - private java.util.List rules_ = - java.util.Collections.emptyList(); - private void ensureRulesIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - rules_ = new java.util.ArrayList(rules_); - bitField0_ |= 0x00000004; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.DocumentationRule, com.google.api.DocumentationRule.Builder, com.google.api.DocumentationRuleOrBuilder> rulesBuilder_; - - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public java.util.List getRulesList() { - if (rulesBuilder_ == null) { - return java.util.Collections.unmodifiableList(rules_); - } else { - return rulesBuilder_.getMessageList(); - } - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public int getRulesCount() { - if (rulesBuilder_ == null) { - return rules_.size(); - } else { - return rulesBuilder_.getCount(); - } - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public com.google.api.DocumentationRule getRules(int index) { - if (rulesBuilder_ == null) { - return rules_.get(index); - } else { - return rulesBuilder_.getMessage(index); - } - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public Builder setRules( - int index, com.google.api.DocumentationRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.set(index, value); - onChanged(); - } else { - rulesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public Builder setRules( - int index, com.google.api.DocumentationRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.set(index, builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public Builder addRules(com.google.api.DocumentationRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.add(value); - onChanged(); - } else { - rulesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public Builder addRules( - int index, com.google.api.DocumentationRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.add(index, value); - onChanged(); - } else { - rulesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public Builder addRules( - com.google.api.DocumentationRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.add(builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public Builder addRules( - int index, com.google.api.DocumentationRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.add(index, builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public Builder addAllRules( - java.lang.Iterable values) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, rules_); - onChanged(); - } else { - rulesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public Builder clearRules() { - if (rulesBuilder_ == null) { - rules_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - } else { - rulesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public Builder removeRules(int index) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.remove(index); - onChanged(); - } else { - rulesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public com.google.api.DocumentationRule.Builder getRulesBuilder( - int index) { - return getRulesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public com.google.api.DocumentationRuleOrBuilder getRulesOrBuilder( - int index) { - if (rulesBuilder_ == null) { - return rules_.get(index); } else { - return rulesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public java.util.List - getRulesOrBuilderList() { - if (rulesBuilder_ != null) { - return rulesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(rules_); - } - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public com.google.api.DocumentationRule.Builder addRulesBuilder() { - return getRulesFieldBuilder().addBuilder( - com.google.api.DocumentationRule.getDefaultInstance()); - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public com.google.api.DocumentationRule.Builder addRulesBuilder( - int index) { - return getRulesFieldBuilder().addBuilder( - index, com.google.api.DocumentationRule.getDefaultInstance()); - } - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -     * Documentation rules for individual elements of the service.
      -     * 
      - */ - public java.util.List - getRulesBuilderList() { - return getRulesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.DocumentationRule, com.google.api.DocumentationRule.Builder, com.google.api.DocumentationRuleOrBuilder> - getRulesFieldBuilder() { - if (rulesBuilder_ == null) { - rulesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.api.DocumentationRule, com.google.api.DocumentationRule.Builder, com.google.api.DocumentationRuleOrBuilder>( - rules_, - ((bitField0_ & 0x00000004) == 0x00000004), - getParentForChildren(), - isClean()); - rules_ = null; - } - return rulesBuilder_; - } - - private java.lang.Object documentationRootUrl_ = ""; - /** - * optional string documentation_root_url = 4; - * - *
      -     * The URL to the root of documentation.
      -     * 
      - */ - public java.lang.String getDocumentationRootUrl() { - java.lang.Object ref = documentationRootUrl_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - documentationRootUrl_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string documentation_root_url = 4; - * - *
      -     * The URL to the root of documentation.
      -     * 
      - */ - public com.google.protobuf.ByteString - getDocumentationRootUrlBytes() { - java.lang.Object ref = documentationRootUrl_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - documentationRootUrl_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string documentation_root_url = 4; - * - *
      -     * The URL to the root of documentation.
      -     * 
      - */ - public Builder setDocumentationRootUrl( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - documentationRootUrl_ = value; - onChanged(); - return this; - } - /** - * optional string documentation_root_url = 4; - * - *
      -     * The URL to the root of documentation.
      -     * 
      - */ - public Builder clearDocumentationRootUrl() { - - documentationRootUrl_ = getDefaultInstance().getDocumentationRootUrl(); - onChanged(); - return this; - } - /** - * optional string documentation_root_url = 4; - * - *
      -     * The URL to the root of documentation.
      -     * 
      - */ - public Builder setDocumentationRootUrlBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - documentationRootUrl_ = value; - onChanged(); - return this; - } - - private java.lang.Object overview_ = ""; - /** - * optional string overview = 2; - * - *
      -     * Declares a single overview page. For example:
      -     *     documentation:
      -     *       summary: ...
      -     *       overview: (== include overview.md ==)
      -     * This is a shortcut for the following declaration (using pages style):
      -     *     documentation:
      -     *       summary: ...
      -     *       pages:
      -     *       - name: Overview
      -     *         content: (== include overview.md ==)
      -     * Note: you cannot specify both `overview` field and `pages` field.
      -     * 
      - */ - public java.lang.String getOverview() { - java.lang.Object ref = overview_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - overview_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string overview = 2; - * - *
      -     * Declares a single overview page. For example:
      -     *     documentation:
      -     *       summary: ...
      -     *       overview: (== include overview.md ==)
      -     * This is a shortcut for the following declaration (using pages style):
      -     *     documentation:
      -     *       summary: ...
      -     *       pages:
      -     *       - name: Overview
      -     *         content: (== include overview.md ==)
      -     * Note: you cannot specify both `overview` field and `pages` field.
      -     * 
      - */ - public com.google.protobuf.ByteString - getOverviewBytes() { - java.lang.Object ref = overview_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - overview_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string overview = 2; - * - *
      -     * Declares a single overview page. For example:
      -     *     documentation:
      -     *       summary: ...
      -     *       overview: (== include overview.md ==)
      -     * This is a shortcut for the following declaration (using pages style):
      -     *     documentation:
      -     *       summary: ...
      -     *       pages:
      -     *       - name: Overview
      -     *         content: (== include overview.md ==)
      -     * Note: you cannot specify both `overview` field and `pages` field.
      -     * 
      - */ - public Builder setOverview( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - overview_ = value; - onChanged(); - return this; - } - /** - * optional string overview = 2; - * - *
      -     * Declares a single overview page. For example:
      -     *     documentation:
      -     *       summary: ...
      -     *       overview: (== include overview.md ==)
      -     * This is a shortcut for the following declaration (using pages style):
      -     *     documentation:
      -     *       summary: ...
      -     *       pages:
      -     *       - name: Overview
      -     *         content: (== include overview.md ==)
      -     * Note: you cannot specify both `overview` field and `pages` field.
      -     * 
      - */ - public Builder clearOverview() { - - overview_ = getDefaultInstance().getOverview(); - onChanged(); - return this; - } - /** - * optional string overview = 2; - * - *
      -     * Declares a single overview page. For example:
      -     *     documentation:
      -     *       summary: ...
      -     *       overview: (== include overview.md ==)
      -     * This is a shortcut for the following declaration (using pages style):
      -     *     documentation:
      -     *       summary: ...
      -     *       pages:
      -     *       - name: Overview
      -     *         content: (== include overview.md ==)
      -     * Note: you cannot specify both `overview` field and `pages` field.
      -     * 
      - */ - public Builder setOverviewBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - overview_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.Documentation) - } - - // @@protoc_insertion_point(class_scope:google.api.Documentation) - private static final com.google.api.Documentation DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.Documentation(); - } - - public static com.google.api.Documentation getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Documentation parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Documentation(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.Documentation getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationOrBuilder.java deleted file mode 100644 index 96368c4a792b..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationOrBuilder.java +++ /dev/null @@ -1,173 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/documentation.proto - -package com.google.api; - -public interface DocumentationOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.Documentation) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string summary = 1; - * - *
      -   * A short summary of what the service does. Can only be provided by
      -   * plain text.
      -   * 
      - */ - java.lang.String getSummary(); - /** - * optional string summary = 1; - * - *
      -   * A short summary of what the service does. Can only be provided by
      -   * plain text.
      -   * 
      - */ - com.google.protobuf.ByteString - getSummaryBytes(); - - /** - * repeated .google.api.Page pages = 5; - * - *
      -   * The top level pages for the documentation set.
      -   * 
      - */ - java.util.List - getPagesList(); - /** - * repeated .google.api.Page pages = 5; - * - *
      -   * The top level pages for the documentation set.
      -   * 
      - */ - com.google.api.Page getPages(int index); - /** - * repeated .google.api.Page pages = 5; - * - *
      -   * The top level pages for the documentation set.
      -   * 
      - */ - int getPagesCount(); - /** - * repeated .google.api.Page pages = 5; - * - *
      -   * The top level pages for the documentation set.
      -   * 
      - */ - java.util.List - getPagesOrBuilderList(); - /** - * repeated .google.api.Page pages = 5; - * - *
      -   * The top level pages for the documentation set.
      -   * 
      - */ - com.google.api.PageOrBuilder getPagesOrBuilder( - int index); - - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -   * Documentation rules for individual elements of the service.
      -   * 
      - */ - java.util.List - getRulesList(); - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -   * Documentation rules for individual elements of the service.
      -   * 
      - */ - com.google.api.DocumentationRule getRules(int index); - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -   * Documentation rules for individual elements of the service.
      -   * 
      - */ - int getRulesCount(); - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -   * Documentation rules for individual elements of the service.
      -   * 
      - */ - java.util.List - getRulesOrBuilderList(); - /** - * repeated .google.api.DocumentationRule rules = 3; - * - *
      -   * Documentation rules for individual elements of the service.
      -   * 
      - */ - com.google.api.DocumentationRuleOrBuilder getRulesOrBuilder( - int index); - - /** - * optional string documentation_root_url = 4; - * - *
      -   * The URL to the root of documentation.
      -   * 
      - */ - java.lang.String getDocumentationRootUrl(); - /** - * optional string documentation_root_url = 4; - * - *
      -   * The URL to the root of documentation.
      -   * 
      - */ - com.google.protobuf.ByteString - getDocumentationRootUrlBytes(); - - /** - * optional string overview = 2; - * - *
      -   * Declares a single overview page. For example:
      -   *     documentation:
      -   *       summary: ...
      -   *       overview: (== include overview.md ==)
      -   * This is a shortcut for the following declaration (using pages style):
      -   *     documentation:
      -   *       summary: ...
      -   *       pages:
      -   *       - name: Overview
      -   *         content: (== include overview.md ==)
      -   * Note: you cannot specify both `overview` field and `pages` field.
      -   * 
      - */ - java.lang.String getOverview(); - /** - * optional string overview = 2; - * - *
      -   * Declares a single overview page. For example:
      -   *     documentation:
      -   *       summary: ...
      -   *       overview: (== include overview.md ==)
      -   * This is a shortcut for the following declaration (using pages style):
      -   *     documentation:
      -   *       summary: ...
      -   *       pages:
      -   *       - name: Overview
      -   *         content: (== include overview.md ==)
      -   * Note: you cannot specify both `overview` field and `pages` field.
      -   * 
      - */ - com.google.protobuf.ByteString - getOverviewBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationProto.java deleted file mode 100644 index f31f29d4752c..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationProto.java +++ /dev/null @@ -1,79 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/documentation.proto - -package com.google.api; - -public final class DocumentationProto { - private DocumentationProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_Documentation_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_Documentation_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_DocumentationRule_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_DocumentationRule_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_Page_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_Page_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\036google/api/documentation.proto\022\ngoogle" + - ".api\"\241\001\n\rDocumentation\022\017\n\007summary\030\001 \001(\t\022" + - "\037\n\005pages\030\005 \003(\0132\020.google.api.Page\022,\n\005rule" + - "s\030\003 \003(\0132\035.google.api.DocumentationRule\022\036" + - "\n\026documentation_root_url\030\004 \001(\t\022\020\n\010overvi" + - "ew\030\002 \001(\t\":\n\021DocumentationRule\022\020\n\010selecto" + - "r\030\001 \001(\t\022\023\n\013description\030\002 \001(\t\"I\n\004Page\022\014\n\004" + - "name\030\001 \001(\t\022\017\n\007content\030\002 \001(\t\022\"\n\010subpages\030" + - "\003 \003(\0132\020.google.api.PageB&\n\016com.google.ap" + - "iB\022DocumentationProtoP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_google_api_Documentation_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_api_Documentation_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_Documentation_descriptor, - new java.lang.String[] { "Summary", "Pages", "Rules", "DocumentationRootUrl", "Overview", }); - internal_static_google_api_DocumentationRule_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_google_api_DocumentationRule_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_DocumentationRule_descriptor, - new java.lang.String[] { "Selector", "Description", }); - internal_static_google_api_Page_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_google_api_Page_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_Page_descriptor, - new java.lang.String[] { "Name", "Content", "Subpages", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRule.java b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRule.java deleted file mode 100644 index 5f9b9853026b..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRule.java +++ /dev/null @@ -1,662 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/documentation.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.DocumentationRule} - * - *
      - * A documentation rule provides information about individual API elements.
      - * 
      - */ -public final class DocumentationRule extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.DocumentationRule) - DocumentationRuleOrBuilder { - // Use DocumentationRule.newBuilder() to construct. - private DocumentationRule(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private DocumentationRule() { - selector_ = ""; - description_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private DocumentationRule( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - selector_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - description_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.DocumentationProto.internal_static_google_api_DocumentationRule_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.DocumentationProto.internal_static_google_api_DocumentationRule_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.DocumentationRule.class, com.google.api.DocumentationRule.Builder.class); - } - - public static final int SELECTOR_FIELD_NUMBER = 1; - private volatile java.lang.Object selector_; - /** - * optional string selector = 1; - * - *
      -   * The selector is a comma-separated list of pattern. Each parttern is a
      -   * qualified name of the element which may end in "*", indicating a wildcard.
      -   * Wildcards are only allowed at the end and for a whole component of the
      -   * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      -   * specify a default for all applicable elements, the whole pattern "*"
      -   * is used.
      -   * 
      - */ - public java.lang.String getSelector() { - java.lang.Object ref = selector_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - selector_ = s; - return s; - } - } - /** - * optional string selector = 1; - * - *
      -   * The selector is a comma-separated list of pattern. Each parttern is a
      -   * qualified name of the element which may end in "*", indicating a wildcard.
      -   * Wildcards are only allowed at the end and for a whole component of the
      -   * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      -   * specify a default for all applicable elements, the whole pattern "*"
      -   * is used.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSelectorBytes() { - java.lang.Object ref = selector_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - selector_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DESCRIPTION_FIELD_NUMBER = 2; - private volatile java.lang.Object description_; - /** - * optional string description = 2; - * - *
      -   * Description of the selected API(s).
      -   * 
      - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } - } - /** - * optional string description = 2; - * - *
      -   * Description of the selected API(s).
      -   * 
      - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSelectorBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, selector_); - } - if (!getDescriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, description_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSelectorBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, selector_); - } - if (!getDescriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, description_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.DocumentationRule parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.DocumentationRule parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.DocumentationRule parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.DocumentationRule parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.DocumentationRule parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.DocumentationRule parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.DocumentationRule parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.DocumentationRule parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.DocumentationRule parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.DocumentationRule parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.DocumentationRule prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.DocumentationRule} - * - *
      -   * A documentation rule provides information about individual API elements.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.DocumentationRule) - com.google.api.DocumentationRuleOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.DocumentationProto.internal_static_google_api_DocumentationRule_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.DocumentationProto.internal_static_google_api_DocumentationRule_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.DocumentationRule.class, com.google.api.DocumentationRule.Builder.class); - } - - // Construct using com.google.api.DocumentationRule.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - selector_ = ""; - - description_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.DocumentationProto.internal_static_google_api_DocumentationRule_descriptor; - } - - public com.google.api.DocumentationRule getDefaultInstanceForType() { - return com.google.api.DocumentationRule.getDefaultInstance(); - } - - public com.google.api.DocumentationRule build() { - com.google.api.DocumentationRule result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.DocumentationRule buildPartial() { - com.google.api.DocumentationRule result = new com.google.api.DocumentationRule(this); - result.selector_ = selector_; - result.description_ = description_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.DocumentationRule) { - return mergeFrom((com.google.api.DocumentationRule)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.DocumentationRule other) { - if (other == com.google.api.DocumentationRule.getDefaultInstance()) return this; - if (!other.getSelector().isEmpty()) { - selector_ = other.selector_; - onChanged(); - } - if (!other.getDescription().isEmpty()) { - description_ = other.description_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.DocumentationRule parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.DocumentationRule) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object selector_ = ""; - /** - * optional string selector = 1; - * - *
      -     * The selector is a comma-separated list of pattern. Each parttern is a
      -     * qualified name of the element which may end in "*", indicating a wildcard.
      -     * Wildcards are only allowed at the end and for a whole component of the
      -     * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      -     * specify a default for all applicable elements, the whole pattern "*"
      -     * is used.
      -     * 
      - */ - public java.lang.String getSelector() { - java.lang.Object ref = selector_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - selector_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string selector = 1; - * - *
      -     * The selector is a comma-separated list of pattern. Each parttern is a
      -     * qualified name of the element which may end in "*", indicating a wildcard.
      -     * Wildcards are only allowed at the end and for a whole component of the
      -     * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      -     * specify a default for all applicable elements, the whole pattern "*"
      -     * is used.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSelectorBytes() { - java.lang.Object ref = selector_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - selector_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string selector = 1; - * - *
      -     * The selector is a comma-separated list of pattern. Each parttern is a
      -     * qualified name of the element which may end in "*", indicating a wildcard.
      -     * Wildcards are only allowed at the end and for a whole component of the
      -     * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      -     * specify a default for all applicable elements, the whole pattern "*"
      -     * is used.
      -     * 
      - */ - public Builder setSelector( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - selector_ = value; - onChanged(); - return this; - } - /** - * optional string selector = 1; - * - *
      -     * The selector is a comma-separated list of pattern. Each parttern is a
      -     * qualified name of the element which may end in "*", indicating a wildcard.
      -     * Wildcards are only allowed at the end and for a whole component of the
      -     * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      -     * specify a default for all applicable elements, the whole pattern "*"
      -     * is used.
      -     * 
      - */ - public Builder clearSelector() { - - selector_ = getDefaultInstance().getSelector(); - onChanged(); - return this; - } - /** - * optional string selector = 1; - * - *
      -     * The selector is a comma-separated list of pattern. Each parttern is a
      -     * qualified name of the element which may end in "*", indicating a wildcard.
      -     * Wildcards are only allowed at the end and for a whole component of the
      -     * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      -     * specify a default for all applicable elements, the whole pattern "*"
      -     * is used.
      -     * 
      - */ - public Builder setSelectorBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - selector_ = value; - onChanged(); - return this; - } - - private java.lang.Object description_ = ""; - /** - * optional string description = 2; - * - *
      -     * Description of the selected API(s).
      -     * 
      - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string description = 2; - * - *
      -     * Description of the selected API(s).
      -     * 
      - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string description = 2; - * - *
      -     * Description of the selected API(s).
      -     * 
      - */ - public Builder setDescription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - description_ = value; - onChanged(); - return this; - } - /** - * optional string description = 2; - * - *
      -     * Description of the selected API(s).
      -     * 
      - */ - public Builder clearDescription() { - - description_ = getDefaultInstance().getDescription(); - onChanged(); - return this; - } - /** - * optional string description = 2; - * - *
      -     * Description of the selected API(s).
      -     * 
      - */ - public Builder setDescriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - description_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.DocumentationRule) - } - - // @@protoc_insertion_point(class_scope:google.api.DocumentationRule) - private static final com.google.api.DocumentationRule DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.DocumentationRule(); - } - - public static com.google.api.DocumentationRule getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public DocumentationRule parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new DocumentationRule(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.DocumentationRule getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRuleOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRuleOrBuilder.java deleted file mode 100644 index 859e1afd25af..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/DocumentationRuleOrBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/documentation.proto - -package com.google.api; - -public interface DocumentationRuleOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.DocumentationRule) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string selector = 1; - * - *
      -   * The selector is a comma-separated list of pattern. Each parttern is a
      -   * qualified name of the element which may end in "*", indicating a wildcard.
      -   * Wildcards are only allowed at the end and for a whole component of the
      -   * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      -   * specify a default for all applicable elements, the whole pattern "*"
      -   * is used.
      -   * 
      - */ - java.lang.String getSelector(); - /** - * optional string selector = 1; - * - *
      -   * The selector is a comma-separated list of pattern. Each parttern is a
      -   * qualified name of the element which may end in "*", indicating a wildcard.
      -   * Wildcards are only allowed at the end and for a whole component of the
      -   * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
      -   * specify a default for all applicable elements, the whole pattern "*"
      -   * is used.
      -   * 
      - */ - com.google.protobuf.ByteString - getSelectorBytes(); - - /** - * optional string description = 2; - * - *
      -   * Description of the selected API(s).
      -   * 
      - */ - java.lang.String getDescription(); - /** - * optional string description = 2; - * - *
      -   * Description of the selected API(s).
      -   * 
      - */ - com.google.protobuf.ByteString - getDescriptionBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ErrorFormatProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ErrorFormatProto.java deleted file mode 100644 index c1cbe4a2c182..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/ErrorFormatProto.java +++ /dev/null @@ -1,65 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/error.proto - -package com.google.api; - -public final class ErrorFormatProto { - private ErrorFormatProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_CustomError_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_CustomError_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_CustomErrorRule_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_CustomErrorRule_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\026google/api/error.proto\022\ngoogle.api\"H\n\013" + - "CustomError\022*\n\005rules\030\001 \003(\0132\033.google.api." + - "CustomErrorRule\022\r\n\005types\030\002 \003(\t\"U\n\017Custom" + - "ErrorRule\022\020\n\010selector\030\001 \001(\t\022\031\n\rstubby_br" + - "idge\030\002 \001(\005B\002\030\001\022\025\n\ris_error_type\030\003 \001(\010B\'\n" + - "\016com.google.apiB\020ErrorFormatProtoP\001\370\001\001b\006" + - "proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_google_api_CustomError_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_api_CustomError_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_CustomError_descriptor, - new java.lang.String[] { "Rules", "Types", }); - internal_static_google_api_CustomErrorRule_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_google_api_CustomErrorRule_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_CustomErrorRule_descriptor, - new java.lang.String[] { "Selector", "StubbyBridge", "IsErrorType", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Http.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Http.java deleted file mode 100644 index b382bc022260..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/Http.java +++ /dev/null @@ -1,759 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.Http} - * - *
      - * Defines the HTTP configuration for a service. It contains a list of
      - * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
      - * to one or more HTTP REST API methods.
      - * 
      - */ -public final class Http extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.Http) - HttpOrBuilder { - // Use Http.newBuilder() to construct. - private Http(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Http() { - rules_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Http( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - rules_.add(input.readMessage(com.google.api.HttpRule.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = java.util.Collections.unmodifiableList(rules_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.HttpProto.internal_static_google_api_Http_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.HttpProto.internal_static_google_api_Http_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Http.class, com.google.api.Http.Builder.class); - } - - public static final int RULES_FIELD_NUMBER = 1; - private java.util.List rules_; - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -   * A list of HTTP rules for configuring the HTTP REST API methods.
      -   * 
      - */ - public java.util.List getRulesList() { - return rules_; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -   * A list of HTTP rules for configuring the HTTP REST API methods.
      -   * 
      - */ - public java.util.List - getRulesOrBuilderList() { - return rules_; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -   * A list of HTTP rules for configuring the HTTP REST API methods.
      -   * 
      - */ - public int getRulesCount() { - return rules_.size(); - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -   * A list of HTTP rules for configuring the HTTP REST API methods.
      -   * 
      - */ - public com.google.api.HttpRule getRules(int index) { - return rules_.get(index); - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -   * A list of HTTP rules for configuring the HTTP REST API methods.
      -   * 
      - */ - public com.google.api.HttpRuleOrBuilder getRulesOrBuilder( - int index) { - return rules_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < rules_.size(); i++) { - output.writeMessage(1, rules_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < rules_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, rules_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.Http parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Http parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Http parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Http parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Http parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Http parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.Http parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.Http parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.Http parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Http parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.Http prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.Http} - * - *
      -   * Defines the HTTP configuration for a service. It contains a list of
      -   * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
      -   * to one or more HTTP REST API methods.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.Http) - com.google.api.HttpOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.HttpProto.internal_static_google_api_Http_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.HttpProto.internal_static_google_api_Http_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Http.class, com.google.api.Http.Builder.class); - } - - // Construct using com.google.api.Http.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getRulesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (rulesBuilder_ == null) { - rules_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - rulesBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.HttpProto.internal_static_google_api_Http_descriptor; - } - - public com.google.api.Http getDefaultInstanceForType() { - return com.google.api.Http.getDefaultInstance(); - } - - public com.google.api.Http build() { - com.google.api.Http result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.Http buildPartial() { - com.google.api.Http result = new com.google.api.Http(this); - int from_bitField0_ = bitField0_; - if (rulesBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = java.util.Collections.unmodifiableList(rules_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.rules_ = rules_; - } else { - result.rules_ = rulesBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.Http) { - return mergeFrom((com.google.api.Http)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.Http other) { - if (other == com.google.api.Http.getDefaultInstance()) return this; - if (rulesBuilder_ == null) { - if (!other.rules_.isEmpty()) { - if (rules_.isEmpty()) { - rules_ = other.rules_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureRulesIsMutable(); - rules_.addAll(other.rules_); - } - onChanged(); - } - } else { - if (!other.rules_.isEmpty()) { - if (rulesBuilder_.isEmpty()) { - rulesBuilder_.dispose(); - rulesBuilder_ = null; - rules_ = other.rules_; - bitField0_ = (bitField0_ & ~0x00000001); - rulesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getRulesFieldBuilder() : null; - } else { - rulesBuilder_.addAllMessages(other.rules_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.Http parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.Http) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List rules_ = - java.util.Collections.emptyList(); - private void ensureRulesIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = new java.util.ArrayList(rules_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder> rulesBuilder_; - - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public java.util.List getRulesList() { - if (rulesBuilder_ == null) { - return java.util.Collections.unmodifiableList(rules_); - } else { - return rulesBuilder_.getMessageList(); - } - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public int getRulesCount() { - if (rulesBuilder_ == null) { - return rules_.size(); - } else { - return rulesBuilder_.getCount(); - } - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public com.google.api.HttpRule getRules(int index) { - if (rulesBuilder_ == null) { - return rules_.get(index); - } else { - return rulesBuilder_.getMessage(index); - } - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public Builder setRules( - int index, com.google.api.HttpRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.set(index, value); - onChanged(); - } else { - rulesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public Builder setRules( - int index, com.google.api.HttpRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.set(index, builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public Builder addRules(com.google.api.HttpRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.add(value); - onChanged(); - } else { - rulesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public Builder addRules( - int index, com.google.api.HttpRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.add(index, value); - onChanged(); - } else { - rulesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public Builder addRules( - com.google.api.HttpRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.add(builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public Builder addRules( - int index, com.google.api.HttpRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.add(index, builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public Builder addAllRules( - java.lang.Iterable values) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, rules_); - onChanged(); - } else { - rulesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public Builder clearRules() { - if (rulesBuilder_ == null) { - rules_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - rulesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public Builder removeRules(int index) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.remove(index); - onChanged(); - } else { - rulesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public com.google.api.HttpRule.Builder getRulesBuilder( - int index) { - return getRulesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public com.google.api.HttpRuleOrBuilder getRulesOrBuilder( - int index) { - if (rulesBuilder_ == null) { - return rules_.get(index); } else { - return rulesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public java.util.List - getRulesOrBuilderList() { - if (rulesBuilder_ != null) { - return rulesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(rules_); - } - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public com.google.api.HttpRule.Builder addRulesBuilder() { - return getRulesFieldBuilder().addBuilder( - com.google.api.HttpRule.getDefaultInstance()); - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public com.google.api.HttpRule.Builder addRulesBuilder( - int index) { - return getRulesFieldBuilder().addBuilder( - index, com.google.api.HttpRule.getDefaultInstance()); - } - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -     * A list of HTTP rules for configuring the HTTP REST API methods.
      -     * 
      - */ - public java.util.List - getRulesBuilderList() { - return getRulesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder> - getRulesFieldBuilder() { - if (rulesBuilder_ == null) { - rulesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder>( - rules_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - rules_ = null; - } - return rulesBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.Http) - } - - // @@protoc_insertion_point(class_scope:google.api.Http) - private static final com.google.api.Http DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.Http(); - } - - public static com.google.api.Http getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Http parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Http(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.Http getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpOrBuilder.java deleted file mode 100644 index 22192448d7ee..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpOrBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -public interface HttpOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.Http) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -   * A list of HTTP rules for configuring the HTTP REST API methods.
      -   * 
      - */ - java.util.List - getRulesList(); - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -   * A list of HTTP rules for configuring the HTTP REST API methods.
      -   * 
      - */ - com.google.api.HttpRule getRules(int index); - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -   * A list of HTTP rules for configuring the HTTP REST API methods.
      -   * 
      - */ - int getRulesCount(); - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -   * A list of HTTP rules for configuring the HTTP REST API methods.
      -   * 
      - */ - java.util.List - getRulesOrBuilderList(); - /** - * repeated .google.api.HttpRule rules = 1; - * - *
      -   * A list of HTTP rules for configuring the HTTP REST API methods.
      -   * 
      - */ - com.google.api.HttpRuleOrBuilder getRulesOrBuilder( - int index); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpProto.java deleted file mode 100644 index 7ef3d1fdaa97..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpProto.java +++ /dev/null @@ -1,106 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -public final class HttpProto { - private HttpProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_Http_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_Http_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_HttpRule_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_HttpRule_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_CustomHttpPattern_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_CustomHttpPattern_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_MediaUpload_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_MediaUpload_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_MediaDownload_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_MediaDownload_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\025google/api/http.proto\022\ngoogle.api\"+\n\004H" + - "ttp\022#\n\005rules\030\001 \003(\0132\024.google.api.HttpRule" + - "\"\314\002\n\010HttpRule\022\020\n\010selector\030\001 \001(\t\022\r\n\003get\030\002" + - " \001(\tH\000\022\r\n\003put\030\003 \001(\tH\000\022\016\n\004post\030\004 \001(\tH\000\022\020\n" + - "\006delete\030\005 \001(\tH\000\022\017\n\005patch\030\006 \001(\tH\000\022/\n\006cust" + - "om\030\010 \001(\0132\035.google.api.CustomHttpPatternH" + - "\000\022\014\n\004body\030\007 \001(\t\022-\n\014media_upload\030\t \001(\0132\027." + - "google.api.MediaUpload\0221\n\016media_download" + - "\030\n \001(\0132\031.google.api.MediaDownload\0221\n\023add" + - "itional_bindings\030\013 \003(\0132\024.google.api.Http", - "RuleB\t\n\007pattern\"/\n\021CustomHttpPattern\022\014\n\004" + - "kind\030\001 \001(\t\022\014\n\004path\030\002 \001(\t\"\036\n\013MediaUpload\022" + - "\017\n\007enabled\030\003 \001(\010\" \n\rMediaDownload\022\017\n\007ena" + - "bled\030\001 \001(\010B \n\016com.google.apiB\tHttpProtoP" + - "\001\370\001\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_google_api_Http_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_api_Http_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_Http_descriptor, - new java.lang.String[] { "Rules", }); - internal_static_google_api_HttpRule_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_google_api_HttpRule_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_HttpRule_descriptor, - new java.lang.String[] { "Selector", "Get", "Put", "Post", "Delete", "Patch", "Custom", "Body", "MediaUpload", "MediaDownload", "AdditionalBindings", "Pattern", }); - internal_static_google_api_CustomHttpPattern_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_google_api_CustomHttpPattern_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_CustomHttpPattern_descriptor, - new java.lang.String[] { "Kind", "Path", }); - internal_static_google_api_MediaUpload_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_google_api_MediaUpload_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_MediaUpload_descriptor, - new java.lang.String[] { "Enabled", }); - internal_static_google_api_MediaDownload_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_google_api_MediaDownload_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_MediaDownload_descriptor, - new java.lang.String[] { "Enabled", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRule.java b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRule.java deleted file mode 100644 index e37c48096fdd..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRule.java +++ /dev/null @@ -1,3069 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.HttpRule} - * - *
      - * `HttpRule` defines the mapping of an RPC method to one or more HTTP
      - * REST APIs.  The mapping determines what portions of the request
      - * message are populated from the path, query parameters, or body of
      - * the HTTP request.  The mapping is typically specified as an
      - * `google.api.http` annotation, see "google/api/annotations.proto"
      - * for details.
      - * The mapping consists of a field specifying the path template and
      - * method kind.  The path template can refer to fields in the request
      - * message, as in the example below which describes a REST GET
      - * operation on a resource collection of messages:
      - * ```proto
      - * service Messaging {
      - *   rpc GetMessage(GetMessageRequest) returns (Message) {
      - *     option (google.api.http).get = "/v1/messages/{message_id}";
      - *   }
      - * }
      - * message GetMessageRequest {
      - *   string message_id = 1; // mapped to the URL
      - * }
      - * message Message {
      - *   string text = 1; // content of the resource
      - * }
      - * ```
      - * This definition enables an automatic, bidrectional mapping of HTTP
      - * JSON to RPC. Example:
      - * HTTP | RPC
      - * -----|-----
      - * `GET /v1/messages/123456`  | `GetMessage(message_id: "123456")`
      - * In general, not only fields but also field paths can be referenced
      - * from a path pattern. Fields mapped to the path pattern cannot be
      - * repeated and must have a primitive (non-message) type.
      - * Any fields in the request message which are not bound by the path
      - * pattern automatically become (optional) HTTP query
      - * parameters. Assume the following definition of the request message:
      - * ```proto
      - * message GetMessageRequest {
      - *   string message_id = 1; // mapped to the URL
      - *   int64 revision = 2;    // becomes a parameter
      - * }
      - * ```
      - * This enables a HTTP JSON to RPC mapping as below:
      - * HTTP | RPC
      - * -----|-----
      - * `GET /v1/messages/123456?revision=2` | `GetMessage(message_id: "123456" revision: 2)`
      - * Note that fields which are mapped to HTTP parameters must have a
      - * primitive type or a repeated primitive type. Message types are not
      - * allowed. In the case of a repeated type, the parameter can be
      - * repeated in the URL, as in `...?param=A&param=B`.
      - * For HTTP method kinds which allow a request body, the `body` field
      - * specifies the mapping. Consider a REST update method on the
      - * message resource collection:
      - * ```proto
      - * service Messaging {
      - *   rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
      - *     option (google.api.http) = {
      - *       put: "/v1/messages/{message_id}"
      - *       body: "message"
      - *   }
      - * }
      - * message UpdateMessageRequest {
      - *   string message_id = 1; // mapped to the URL
      - *   Message message = 2;   // mapped to the body
      - * }
      - * ```
      - * The following HTTP JSON to RPC mapping is enabled, where the
      - * representation of the JSON in the request body is determined by
      - * protos JSON encoding:
      - * HTTP | RPC
      - * -----|-----
      - * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
      - * The special name `*` can be used in the body mapping to define that
      - * every field not bound by the path template should be mapped to the
      - * request body.  This enables the following alternative definition of
      - * the update method:
      - * ```proto
      - * service Messaging {
      - *   rpc UpdateMessage(Message) returns (Message) {
      - *     option (google.api.http) = {
      - *       put: "/v1/messages/{message_id}"
      - *       body: "*"
      - *   }
      - * }
      - * message Message {
      - *   string message_id = 2;
      - *   string text = 2;
      - * }
      - * ```
      - * The following HTTP JSON to RPC mapping is enabled:
      - * HTTP | RPC
      - * -----|-----
      - * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`
      - * Note that when using `*` in the body mapping, it is not possible to
      - * have HTTP parameters, as all fields not bound by the path end in
      - * the body. This makes this option more rarely used in practice of
      - * defining REST APIs. The common usage of `*` is in custom methods
      - * which don't use the URL at all for transferring data.
      - * It is possible to define multiple HTTP methods for one RPC by using
      - * the `additional_bindings` option. Example:
      - * ```proto
      - * service Messaging {
      - *   rpc GetMessage(GetMessageRequest) returns (Message) {
      - *     option (google.api.http) = {
      - *       get: "/v1/messages/{message_id}"
      - *       additional_bindings {
      - *         get: "/v1/users/{user_id}/messages/{message_id}"
      - *       }
      - *   }
      - * }
      - * message GetMessageRequest {
      - *   string message_id = 1;
      - *   string user_id = 2;
      - * }
      - * ```
      - * This enables the following two alternative HTTP JSON to RPC
      - * mappings:
      - * HTTP | RPC
      - * -----|-----
      - * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
      - * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`
      - * # Rules for HTTP mapping
      - * The rules for mapping HTTP path, query parameters, and body fields
      - * to the request message are as follows:
      - * 1. The `body` field specifies either `*` or a field path, or is
      - *    omitted. If omitted, it assumes there is no HTTP body.
      - * 2. Leaf fields (recursive expansion of nested messages in the
      - *    request) can be classified into three types:
      - *     (a) Matched in the URL template.
      - *     (b) Covered by body (if body is `*`, everything except (a) fields;
      - *         else everything under the body field)
      - *     (c) All other fields.
      - * 3. URL query parameters found in the HTTP request are mapped to (c) fields.
      - * 4. Any body sent with an HTTP request can contain only (b) fields.
      - * The syntax of the path template is as follows:
      - *     Template = "/" Segments [ Verb ] ;
      - *     Segments = Segment { "/" Segment } ;
      - *     Segment  = "*" | "**" | LITERAL | Variable ;
      - *     Variable = "{" FieldPath [ "=" Segments ] "}" ;
      - *     FieldPath = IDENT { "." IDENT } ;
      - *     Verb     = ":" LITERAL ;
      - * The syntax `*` matches a single path segment. It follows the semantics of
      - * [RFC 6570](https://tools.ietf.org/html.rfc6570) Section 3.2.2 Simple String
      - * Expansion.
      - * The syntax `**` matches zero or more path segments. It follows the semantics
      - * of [RFC 6570](https://tools.ietf.org/html.rfc6570) Section 3.2.3 Reserved
      - * Expansion.
      - * The syntax `LITERAL` matches literal text in the URL path.
      - * The syntax `Variable` matches the entire path as specified by its template;
      - * this nested template must not contain further variables. If a variable
      - * matches a single path segment, its template may be omitted, e.g. `{var}`
      - * is equivalent to `{var=*}`.
      - * NOTE: the field paths in variables and in the `body` must not refer to
      - * repeated fields or map fields.
      - * Use CustomHttpPattern to specify any HTTP method that is not included in the
      - * `pattern` field, such as HEAD, or "*" to leave the HTTP method unspecified for
      - * a given URL path rule. The wild-card rule is useful for services that provide
      - * content to Web (HTML) clients.
      - * 
      - */ -public final class HttpRule extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.HttpRule) - HttpRuleOrBuilder { - // Use HttpRule.newBuilder() to construct. - private HttpRule(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private HttpRule() { - selector_ = ""; - body_ = ""; - additionalBindings_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private HttpRule( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - selector_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - patternCase_ = 2; - pattern_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - patternCase_ = 3; - pattern_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - patternCase_ = 4; - pattern_ = s; - break; - } - case 42: { - String s = input.readStringRequireUtf8(); - patternCase_ = 5; - pattern_ = s; - break; - } - case 50: { - String s = input.readStringRequireUtf8(); - patternCase_ = 6; - pattern_ = s; - break; - } - case 58: { - String s = input.readStringRequireUtf8(); - - body_ = s; - break; - } - case 66: { - com.google.api.CustomHttpPattern.Builder subBuilder = null; - if (patternCase_ == 8) { - subBuilder = ((com.google.api.CustomHttpPattern) pattern_).toBuilder(); - } - pattern_ = - input.readMessage(com.google.api.CustomHttpPattern.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((com.google.api.CustomHttpPattern) pattern_); - pattern_ = subBuilder.buildPartial(); - } - patternCase_ = 8; - break; - } - case 74: { - com.google.api.MediaUpload.Builder subBuilder = null; - if (mediaUpload_ != null) { - subBuilder = mediaUpload_.toBuilder(); - } - mediaUpload_ = input.readMessage(com.google.api.MediaUpload.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(mediaUpload_); - mediaUpload_ = subBuilder.buildPartial(); - } - - break; - } - case 82: { - com.google.api.MediaDownload.Builder subBuilder = null; - if (mediaDownload_ != null) { - subBuilder = mediaDownload_.toBuilder(); - } - mediaDownload_ = input.readMessage(com.google.api.MediaDownload.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(mediaDownload_); - mediaDownload_ = subBuilder.buildPartial(); - } - - break; - } - case 90: { - if (!((mutable_bitField0_ & 0x00000400) == 0x00000400)) { - additionalBindings_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000400; - } - additionalBindings_.add(input.readMessage(com.google.api.HttpRule.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000400) == 0x00000400)) { - additionalBindings_ = java.util.Collections.unmodifiableList(additionalBindings_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.HttpProto.internal_static_google_api_HttpRule_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.HttpProto.internal_static_google_api_HttpRule_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.HttpRule.class, com.google.api.HttpRule.Builder.class); - } - - private int bitField0_; - private int patternCase_ = 0; - private java.lang.Object pattern_; - public enum PatternCase - implements com.google.protobuf.Internal.EnumLite { - GET(2), - PUT(3), - POST(4), - DELETE(5), - PATCH(6), - CUSTOM(8), - PATTERN_NOT_SET(0); - private int value = 0; - private PatternCase(int value) { - this.value = value; - } - public static PatternCase valueOf(int value) { - switch (value) { - case 2: return GET; - case 3: return PUT; - case 4: return POST; - case 5: return DELETE; - case 6: return PATCH; - case 8: return CUSTOM; - case 0: return PATTERN_NOT_SET; - default: throw new java.lang.IllegalArgumentException( - "Value is undefined for this oneof enum."); - } - } - public int getNumber() { - return this.value; - } - }; - - public PatternCase - getPatternCase() { - return PatternCase.valueOf( - patternCase_); - } - - public static final int SELECTOR_FIELD_NUMBER = 1; - private volatile java.lang.Object selector_; - /** - * optional string selector = 1; - * - *
      -   * Selects methods to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - public java.lang.String getSelector() { - java.lang.Object ref = selector_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - selector_ = s; - return s; - } - } - /** - * optional string selector = 1; - * - *
      -   * Selects methods to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSelectorBytes() { - java.lang.Object ref = selector_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - selector_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int GET_FIELD_NUMBER = 2; - /** - * optional string get = 2; - * - *
      -   * Used for listing and getting information about resources.
      -   * 
      - */ - public java.lang.String getGet() { - java.lang.Object ref = ""; - if (patternCase_ == 2) { - ref = pattern_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (patternCase_ == 2) { - pattern_ = s; - } - return s; - } - } - /** - * optional string get = 2; - * - *
      -   * Used for listing and getting information about resources.
      -   * 
      - */ - public com.google.protobuf.ByteString - getGetBytes() { - java.lang.Object ref = ""; - if (patternCase_ == 2) { - ref = pattern_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (patternCase_ == 2) { - pattern_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PUT_FIELD_NUMBER = 3; - /** - * optional string put = 3; - * - *
      -   * Used for updating a resource.
      -   * 
      - */ - public java.lang.String getPut() { - java.lang.Object ref = ""; - if (patternCase_ == 3) { - ref = pattern_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (patternCase_ == 3) { - pattern_ = s; - } - return s; - } - } - /** - * optional string put = 3; - * - *
      -   * Used for updating a resource.
      -   * 
      - */ - public com.google.protobuf.ByteString - getPutBytes() { - java.lang.Object ref = ""; - if (patternCase_ == 3) { - ref = pattern_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (patternCase_ == 3) { - pattern_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int POST_FIELD_NUMBER = 4; - /** - * optional string post = 4; - * - *
      -   * Used for creating a resource.
      -   * 
      - */ - public java.lang.String getPost() { - java.lang.Object ref = ""; - if (patternCase_ == 4) { - ref = pattern_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (patternCase_ == 4) { - pattern_ = s; - } - return s; - } - } - /** - * optional string post = 4; - * - *
      -   * Used for creating a resource.
      -   * 
      - */ - public com.google.protobuf.ByteString - getPostBytes() { - java.lang.Object ref = ""; - if (patternCase_ == 4) { - ref = pattern_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (patternCase_ == 4) { - pattern_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DELETE_FIELD_NUMBER = 5; - /** - * optional string delete = 5; - * - *
      -   * Used for deleting a resource.
      -   * 
      - */ - public java.lang.String getDelete() { - java.lang.Object ref = ""; - if (patternCase_ == 5) { - ref = pattern_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (patternCase_ == 5) { - pattern_ = s; - } - return s; - } - } - /** - * optional string delete = 5; - * - *
      -   * Used for deleting a resource.
      -   * 
      - */ - public com.google.protobuf.ByteString - getDeleteBytes() { - java.lang.Object ref = ""; - if (patternCase_ == 5) { - ref = pattern_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (patternCase_ == 5) { - pattern_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PATCH_FIELD_NUMBER = 6; - /** - * optional string patch = 6; - * - *
      -   * Used for updating a resource.
      -   * 
      - */ - public java.lang.String getPatch() { - java.lang.Object ref = ""; - if (patternCase_ == 6) { - ref = pattern_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (patternCase_ == 6) { - pattern_ = s; - } - return s; - } - } - /** - * optional string patch = 6; - * - *
      -   * Used for updating a resource.
      -   * 
      - */ - public com.google.protobuf.ByteString - getPatchBytes() { - java.lang.Object ref = ""; - if (patternCase_ == 6) { - ref = pattern_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (patternCase_ == 6) { - pattern_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int CUSTOM_FIELD_NUMBER = 8; - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -   * Custom pattern is used for defining custom verbs.
      -   * 
      - */ - public com.google.api.CustomHttpPattern getCustom() { - if (patternCase_ == 8) { - return (com.google.api.CustomHttpPattern) pattern_; - } - return com.google.api.CustomHttpPattern.getDefaultInstance(); - } - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -   * Custom pattern is used for defining custom verbs.
      -   * 
      - */ - public com.google.api.CustomHttpPatternOrBuilder getCustomOrBuilder() { - if (patternCase_ == 8) { - return (com.google.api.CustomHttpPattern) pattern_; - } - return com.google.api.CustomHttpPattern.getDefaultInstance(); - } - - public static final int BODY_FIELD_NUMBER = 7; - private volatile java.lang.Object body_; - /** - * optional string body = 7; - * - *
      -   * The name of the request field whose value is mapped to the HTTP body, or
      -   * `*` for mapping all fields not captured by the path pattern to the HTTP
      -   * body. NOTE: the referred field must not be a repeated field.
      -   * 
      - */ - public java.lang.String getBody() { - java.lang.Object ref = body_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - body_ = s; - return s; - } - } - /** - * optional string body = 7; - * - *
      -   * The name of the request field whose value is mapped to the HTTP body, or
      -   * `*` for mapping all fields not captured by the path pattern to the HTTP
      -   * body. NOTE: the referred field must not be a repeated field.
      -   * 
      - */ - public com.google.protobuf.ByteString - getBodyBytes() { - java.lang.Object ref = body_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - body_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int MEDIA_UPLOAD_FIELD_NUMBER = 9; - private com.google.api.MediaUpload mediaUpload_; - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - public boolean hasMediaUpload() { - return mediaUpload_ != null; - } - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - public com.google.api.MediaUpload getMediaUpload() { - return mediaUpload_ == null ? com.google.api.MediaUpload.getDefaultInstance() : mediaUpload_; - } - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - public com.google.api.MediaUploadOrBuilder getMediaUploadOrBuilder() { - return getMediaUpload(); - } - - public static final int MEDIA_DOWNLOAD_FIELD_NUMBER = 10; - private com.google.api.MediaDownload mediaDownload_; - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - public boolean hasMediaDownload() { - return mediaDownload_ != null; - } - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - public com.google.api.MediaDownload getMediaDownload() { - return mediaDownload_ == null ? com.google.api.MediaDownload.getDefaultInstance() : mediaDownload_; - } - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - public com.google.api.MediaDownloadOrBuilder getMediaDownloadOrBuilder() { - return getMediaDownload(); - } - - public static final int ADDITIONAL_BINDINGS_FIELD_NUMBER = 11; - private java.util.List additionalBindings_; - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -   * Additional HTTP bindings for the selector. Nested bindings must
      -   * not contain an `additional_bindings` field themselves (that is,
      -   * the nesting may only be one level deep).
      -   * 
      - */ - public java.util.List getAdditionalBindingsList() { - return additionalBindings_; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -   * Additional HTTP bindings for the selector. Nested bindings must
      -   * not contain an `additional_bindings` field themselves (that is,
      -   * the nesting may only be one level deep).
      -   * 
      - */ - public java.util.List - getAdditionalBindingsOrBuilderList() { - return additionalBindings_; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -   * Additional HTTP bindings for the selector. Nested bindings must
      -   * not contain an `additional_bindings` field themselves (that is,
      -   * the nesting may only be one level deep).
      -   * 
      - */ - public int getAdditionalBindingsCount() { - return additionalBindings_.size(); - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -   * Additional HTTP bindings for the selector. Nested bindings must
      -   * not contain an `additional_bindings` field themselves (that is,
      -   * the nesting may only be one level deep).
      -   * 
      - */ - public com.google.api.HttpRule getAdditionalBindings(int index) { - return additionalBindings_.get(index); - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -   * Additional HTTP bindings for the selector. Nested bindings must
      -   * not contain an `additional_bindings` field themselves (that is,
      -   * the nesting may only be one level deep).
      -   * 
      - */ - public com.google.api.HttpRuleOrBuilder getAdditionalBindingsOrBuilder( - int index) { - return additionalBindings_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSelectorBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, selector_); - } - if (patternCase_ == 2) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, pattern_); - } - if (patternCase_ == 3) { - com.google.protobuf.GeneratedMessage.writeString(output, 3, pattern_); - } - if (patternCase_ == 4) { - com.google.protobuf.GeneratedMessage.writeString(output, 4, pattern_); - } - if (patternCase_ == 5) { - com.google.protobuf.GeneratedMessage.writeString(output, 5, pattern_); - } - if (patternCase_ == 6) { - com.google.protobuf.GeneratedMessage.writeString(output, 6, pattern_); - } - if (!getBodyBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 7, body_); - } - if (patternCase_ == 8) { - output.writeMessage(8, (com.google.api.CustomHttpPattern) pattern_); - } - if (mediaUpload_ != null) { - output.writeMessage(9, getMediaUpload()); - } - if (mediaDownload_ != null) { - output.writeMessage(10, getMediaDownload()); - } - for (int i = 0; i < additionalBindings_.size(); i++) { - output.writeMessage(11, additionalBindings_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSelectorBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, selector_); - } - if (patternCase_ == 2) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, pattern_); - } - if (patternCase_ == 3) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pattern_); - } - if (patternCase_ == 4) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(4, pattern_); - } - if (patternCase_ == 5) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(5, pattern_); - } - if (patternCase_ == 6) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(6, pattern_); - } - if (!getBodyBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(7, body_); - } - if (patternCase_ == 8) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(8, (com.google.api.CustomHttpPattern) pattern_); - } - if (mediaUpload_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(9, getMediaUpload()); - } - if (mediaDownload_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(10, getMediaDownload()); - } - for (int i = 0; i < additionalBindings_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(11, additionalBindings_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.HttpRule parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.HttpRule parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.HttpRule parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.HttpRule parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.HttpRule parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.HttpRule parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.HttpRule parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.HttpRule parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.HttpRule parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.HttpRule parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.HttpRule prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.HttpRule} - * - *
      -   * `HttpRule` defines the mapping of an RPC method to one or more HTTP
      -   * REST APIs.  The mapping determines what portions of the request
      -   * message are populated from the path, query parameters, or body of
      -   * the HTTP request.  The mapping is typically specified as an
      -   * `google.api.http` annotation, see "google/api/annotations.proto"
      -   * for details.
      -   * The mapping consists of a field specifying the path template and
      -   * method kind.  The path template can refer to fields in the request
      -   * message, as in the example below which describes a REST GET
      -   * operation on a resource collection of messages:
      -   * ```proto
      -   * service Messaging {
      -   *   rpc GetMessage(GetMessageRequest) returns (Message) {
      -   *     option (google.api.http).get = "/v1/messages/{message_id}";
      -   *   }
      -   * }
      -   * message GetMessageRequest {
      -   *   string message_id = 1; // mapped to the URL
      -   * }
      -   * message Message {
      -   *   string text = 1; // content of the resource
      -   * }
      -   * ```
      -   * This definition enables an automatic, bidrectional mapping of HTTP
      -   * JSON to RPC. Example:
      -   * HTTP | RPC
      -   * -----|-----
      -   * `GET /v1/messages/123456`  | `GetMessage(message_id: "123456")`
      -   * In general, not only fields but also field paths can be referenced
      -   * from a path pattern. Fields mapped to the path pattern cannot be
      -   * repeated and must have a primitive (non-message) type.
      -   * Any fields in the request message which are not bound by the path
      -   * pattern automatically become (optional) HTTP query
      -   * parameters. Assume the following definition of the request message:
      -   * ```proto
      -   * message GetMessageRequest {
      -   *   string message_id = 1; // mapped to the URL
      -   *   int64 revision = 2;    // becomes a parameter
      -   * }
      -   * ```
      -   * This enables a HTTP JSON to RPC mapping as below:
      -   * HTTP | RPC
      -   * -----|-----
      -   * `GET /v1/messages/123456?revision=2` | `GetMessage(message_id: "123456" revision: 2)`
      -   * Note that fields which are mapped to HTTP parameters must have a
      -   * primitive type or a repeated primitive type. Message types are not
      -   * allowed. In the case of a repeated type, the parameter can be
      -   * repeated in the URL, as in `...?param=A&param=B`.
      -   * For HTTP method kinds which allow a request body, the `body` field
      -   * specifies the mapping. Consider a REST update method on the
      -   * message resource collection:
      -   * ```proto
      -   * service Messaging {
      -   *   rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
      -   *     option (google.api.http) = {
      -   *       put: "/v1/messages/{message_id}"
      -   *       body: "message"
      -   *   }
      -   * }
      -   * message UpdateMessageRequest {
      -   *   string message_id = 1; // mapped to the URL
      -   *   Message message = 2;   // mapped to the body
      -   * }
      -   * ```
      -   * The following HTTP JSON to RPC mapping is enabled, where the
      -   * representation of the JSON in the request body is determined by
      -   * protos JSON encoding:
      -   * HTTP | RPC
      -   * -----|-----
      -   * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
      -   * The special name `*` can be used in the body mapping to define that
      -   * every field not bound by the path template should be mapped to the
      -   * request body.  This enables the following alternative definition of
      -   * the update method:
      -   * ```proto
      -   * service Messaging {
      -   *   rpc UpdateMessage(Message) returns (Message) {
      -   *     option (google.api.http) = {
      -   *       put: "/v1/messages/{message_id}"
      -   *       body: "*"
      -   *   }
      -   * }
      -   * message Message {
      -   *   string message_id = 2;
      -   *   string text = 2;
      -   * }
      -   * ```
      -   * The following HTTP JSON to RPC mapping is enabled:
      -   * HTTP | RPC
      -   * -----|-----
      -   * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`
      -   * Note that when using `*` in the body mapping, it is not possible to
      -   * have HTTP parameters, as all fields not bound by the path end in
      -   * the body. This makes this option more rarely used in practice of
      -   * defining REST APIs. The common usage of `*` is in custom methods
      -   * which don't use the URL at all for transferring data.
      -   * It is possible to define multiple HTTP methods for one RPC by using
      -   * the `additional_bindings` option. Example:
      -   * ```proto
      -   * service Messaging {
      -   *   rpc GetMessage(GetMessageRequest) returns (Message) {
      -   *     option (google.api.http) = {
      -   *       get: "/v1/messages/{message_id}"
      -   *       additional_bindings {
      -   *         get: "/v1/users/{user_id}/messages/{message_id}"
      -   *       }
      -   *   }
      -   * }
      -   * message GetMessageRequest {
      -   *   string message_id = 1;
      -   *   string user_id = 2;
      -   * }
      -   * ```
      -   * This enables the following two alternative HTTP JSON to RPC
      -   * mappings:
      -   * HTTP | RPC
      -   * -----|-----
      -   * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
      -   * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`
      -   * # Rules for HTTP mapping
      -   * The rules for mapping HTTP path, query parameters, and body fields
      -   * to the request message are as follows:
      -   * 1. The `body` field specifies either `*` or a field path, or is
      -   *    omitted. If omitted, it assumes there is no HTTP body.
      -   * 2. Leaf fields (recursive expansion of nested messages in the
      -   *    request) can be classified into three types:
      -   *     (a) Matched in the URL template.
      -   *     (b) Covered by body (if body is `*`, everything except (a) fields;
      -   *         else everything under the body field)
      -   *     (c) All other fields.
      -   * 3. URL query parameters found in the HTTP request are mapped to (c) fields.
      -   * 4. Any body sent with an HTTP request can contain only (b) fields.
      -   * The syntax of the path template is as follows:
      -   *     Template = "/" Segments [ Verb ] ;
      -   *     Segments = Segment { "/" Segment } ;
      -   *     Segment  = "*" | "**" | LITERAL | Variable ;
      -   *     Variable = "{" FieldPath [ "=" Segments ] "}" ;
      -   *     FieldPath = IDENT { "." IDENT } ;
      -   *     Verb     = ":" LITERAL ;
      -   * The syntax `*` matches a single path segment. It follows the semantics of
      -   * [RFC 6570](https://tools.ietf.org/html.rfc6570) Section 3.2.2 Simple String
      -   * Expansion.
      -   * The syntax `**` matches zero or more path segments. It follows the semantics
      -   * of [RFC 6570](https://tools.ietf.org/html.rfc6570) Section 3.2.3 Reserved
      -   * Expansion.
      -   * The syntax `LITERAL` matches literal text in the URL path.
      -   * The syntax `Variable` matches the entire path as specified by its template;
      -   * this nested template must not contain further variables. If a variable
      -   * matches a single path segment, its template may be omitted, e.g. `{var}`
      -   * is equivalent to `{var=*}`.
      -   * NOTE: the field paths in variables and in the `body` must not refer to
      -   * repeated fields or map fields.
      -   * Use CustomHttpPattern to specify any HTTP method that is not included in the
      -   * `pattern` field, such as HEAD, or "*" to leave the HTTP method unspecified for
      -   * a given URL path rule. The wild-card rule is useful for services that provide
      -   * content to Web (HTML) clients.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.HttpRule) - com.google.api.HttpRuleOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.HttpProto.internal_static_google_api_HttpRule_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.HttpProto.internal_static_google_api_HttpRule_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.HttpRule.class, com.google.api.HttpRule.Builder.class); - } - - // Construct using com.google.api.HttpRule.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getAdditionalBindingsFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - selector_ = ""; - - body_ = ""; - - if (mediaUploadBuilder_ == null) { - mediaUpload_ = null; - } else { - mediaUpload_ = null; - mediaUploadBuilder_ = null; - } - if (mediaDownloadBuilder_ == null) { - mediaDownload_ = null; - } else { - mediaDownload_ = null; - mediaDownloadBuilder_ = null; - } - if (additionalBindingsBuilder_ == null) { - additionalBindings_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000400); - } else { - additionalBindingsBuilder_.clear(); - } - patternCase_ = 0; - pattern_ = null; - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.HttpProto.internal_static_google_api_HttpRule_descriptor; - } - - public com.google.api.HttpRule getDefaultInstanceForType() { - return com.google.api.HttpRule.getDefaultInstance(); - } - - public com.google.api.HttpRule build() { - com.google.api.HttpRule result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.HttpRule buildPartial() { - com.google.api.HttpRule result = new com.google.api.HttpRule(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.selector_ = selector_; - if (patternCase_ == 2) { - result.pattern_ = pattern_; - } - if (patternCase_ == 3) { - result.pattern_ = pattern_; - } - if (patternCase_ == 4) { - result.pattern_ = pattern_; - } - if (patternCase_ == 5) { - result.pattern_ = pattern_; - } - if (patternCase_ == 6) { - result.pattern_ = pattern_; - } - if (patternCase_ == 8) { - if (customBuilder_ == null) { - result.pattern_ = pattern_; - } else { - result.pattern_ = customBuilder_.build(); - } - } - result.body_ = body_; - if (mediaUploadBuilder_ == null) { - result.mediaUpload_ = mediaUpload_; - } else { - result.mediaUpload_ = mediaUploadBuilder_.build(); - } - if (mediaDownloadBuilder_ == null) { - result.mediaDownload_ = mediaDownload_; - } else { - result.mediaDownload_ = mediaDownloadBuilder_.build(); - } - if (additionalBindingsBuilder_ == null) { - if (((bitField0_ & 0x00000400) == 0x00000400)) { - additionalBindings_ = java.util.Collections.unmodifiableList(additionalBindings_); - bitField0_ = (bitField0_ & ~0x00000400); - } - result.additionalBindings_ = additionalBindings_; - } else { - result.additionalBindings_ = additionalBindingsBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - result.patternCase_ = patternCase_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.HttpRule) { - return mergeFrom((com.google.api.HttpRule)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.HttpRule other) { - if (other == com.google.api.HttpRule.getDefaultInstance()) return this; - if (!other.getSelector().isEmpty()) { - selector_ = other.selector_; - onChanged(); - } - if (!other.getBody().isEmpty()) { - body_ = other.body_; - onChanged(); - } - if (other.hasMediaUpload()) { - mergeMediaUpload(other.getMediaUpload()); - } - if (other.hasMediaDownload()) { - mergeMediaDownload(other.getMediaDownload()); - } - if (additionalBindingsBuilder_ == null) { - if (!other.additionalBindings_.isEmpty()) { - if (additionalBindings_.isEmpty()) { - additionalBindings_ = other.additionalBindings_; - bitField0_ = (bitField0_ & ~0x00000400); - } else { - ensureAdditionalBindingsIsMutable(); - additionalBindings_.addAll(other.additionalBindings_); - } - onChanged(); - } - } else { - if (!other.additionalBindings_.isEmpty()) { - if (additionalBindingsBuilder_.isEmpty()) { - additionalBindingsBuilder_.dispose(); - additionalBindingsBuilder_ = null; - additionalBindings_ = other.additionalBindings_; - bitField0_ = (bitField0_ & ~0x00000400); - additionalBindingsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getAdditionalBindingsFieldBuilder() : null; - } else { - additionalBindingsBuilder_.addAllMessages(other.additionalBindings_); - } - } - } - switch (other.getPatternCase()) { - case GET: { - patternCase_ = 2; - pattern_ = other.pattern_; - onChanged(); - break; - } - case PUT: { - patternCase_ = 3; - pattern_ = other.pattern_; - onChanged(); - break; - } - case POST: { - patternCase_ = 4; - pattern_ = other.pattern_; - onChanged(); - break; - } - case DELETE: { - patternCase_ = 5; - pattern_ = other.pattern_; - onChanged(); - break; - } - case PATCH: { - patternCase_ = 6; - pattern_ = other.pattern_; - onChanged(); - break; - } - case CUSTOM: { - mergeCustom(other.getCustom()); - break; - } - case PATTERN_NOT_SET: { - break; - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.HttpRule parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.HttpRule) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int patternCase_ = 0; - private java.lang.Object pattern_; - public PatternCase - getPatternCase() { - return PatternCase.valueOf( - patternCase_); - } - - public Builder clearPattern() { - patternCase_ = 0; - pattern_ = null; - onChanged(); - return this; - } - - private int bitField0_; - - private java.lang.Object selector_ = ""; - /** - * optional string selector = 1; - * - *
      -     * Selects methods to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public java.lang.String getSelector() { - java.lang.Object ref = selector_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - selector_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string selector = 1; - * - *
      -     * Selects methods to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSelectorBytes() { - java.lang.Object ref = selector_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - selector_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string selector = 1; - * - *
      -     * Selects methods to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder setSelector( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - selector_ = value; - onChanged(); - return this; - } - /** - * optional string selector = 1; - * - *
      -     * Selects methods to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder clearSelector() { - - selector_ = getDefaultInstance().getSelector(); - onChanged(); - return this; - } - /** - * optional string selector = 1; - * - *
      -     * Selects methods to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder setSelectorBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - selector_ = value; - onChanged(); - return this; - } - - /** - * optional string get = 2; - * - *
      -     * Used for listing and getting information about resources.
      -     * 
      - */ - public java.lang.String getGet() { - java.lang.Object ref = ""; - if (patternCase_ == 2) { - ref = pattern_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (patternCase_ == 2) { - pattern_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string get = 2; - * - *
      -     * Used for listing and getting information about resources.
      -     * 
      - */ - public com.google.protobuf.ByteString - getGetBytes() { - java.lang.Object ref = ""; - if (patternCase_ == 2) { - ref = pattern_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (patternCase_ == 2) { - pattern_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string get = 2; - * - *
      -     * Used for listing and getting information about resources.
      -     * 
      - */ - public Builder setGet( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - patternCase_ = 2; - pattern_ = value; - onChanged(); - return this; - } - /** - * optional string get = 2; - * - *
      -     * Used for listing and getting information about resources.
      -     * 
      - */ - public Builder clearGet() { - if (patternCase_ == 2) { - patternCase_ = 0; - pattern_ = null; - onChanged(); - } - return this; - } - /** - * optional string get = 2; - * - *
      -     * Used for listing and getting information about resources.
      -     * 
      - */ - public Builder setGetBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - patternCase_ = 2; - pattern_ = value; - onChanged(); - return this; - } - - /** - * optional string put = 3; - * - *
      -     * Used for updating a resource.
      -     * 
      - */ - public java.lang.String getPut() { - java.lang.Object ref = ""; - if (patternCase_ == 3) { - ref = pattern_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (patternCase_ == 3) { - pattern_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string put = 3; - * - *
      -     * Used for updating a resource.
      -     * 
      - */ - public com.google.protobuf.ByteString - getPutBytes() { - java.lang.Object ref = ""; - if (patternCase_ == 3) { - ref = pattern_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (patternCase_ == 3) { - pattern_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string put = 3; - * - *
      -     * Used for updating a resource.
      -     * 
      - */ - public Builder setPut( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - patternCase_ = 3; - pattern_ = value; - onChanged(); - return this; - } - /** - * optional string put = 3; - * - *
      -     * Used for updating a resource.
      -     * 
      - */ - public Builder clearPut() { - if (patternCase_ == 3) { - patternCase_ = 0; - pattern_ = null; - onChanged(); - } - return this; - } - /** - * optional string put = 3; - * - *
      -     * Used for updating a resource.
      -     * 
      - */ - public Builder setPutBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - patternCase_ = 3; - pattern_ = value; - onChanged(); - return this; - } - - /** - * optional string post = 4; - * - *
      -     * Used for creating a resource.
      -     * 
      - */ - public java.lang.String getPost() { - java.lang.Object ref = ""; - if (patternCase_ == 4) { - ref = pattern_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (patternCase_ == 4) { - pattern_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string post = 4; - * - *
      -     * Used for creating a resource.
      -     * 
      - */ - public com.google.protobuf.ByteString - getPostBytes() { - java.lang.Object ref = ""; - if (patternCase_ == 4) { - ref = pattern_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (patternCase_ == 4) { - pattern_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string post = 4; - * - *
      -     * Used for creating a resource.
      -     * 
      - */ - public Builder setPost( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - patternCase_ = 4; - pattern_ = value; - onChanged(); - return this; - } - /** - * optional string post = 4; - * - *
      -     * Used for creating a resource.
      -     * 
      - */ - public Builder clearPost() { - if (patternCase_ == 4) { - patternCase_ = 0; - pattern_ = null; - onChanged(); - } - return this; - } - /** - * optional string post = 4; - * - *
      -     * Used for creating a resource.
      -     * 
      - */ - public Builder setPostBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - patternCase_ = 4; - pattern_ = value; - onChanged(); - return this; - } - - /** - * optional string delete = 5; - * - *
      -     * Used for deleting a resource.
      -     * 
      - */ - public java.lang.String getDelete() { - java.lang.Object ref = ""; - if (patternCase_ == 5) { - ref = pattern_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (patternCase_ == 5) { - pattern_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string delete = 5; - * - *
      -     * Used for deleting a resource.
      -     * 
      - */ - public com.google.protobuf.ByteString - getDeleteBytes() { - java.lang.Object ref = ""; - if (patternCase_ == 5) { - ref = pattern_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (patternCase_ == 5) { - pattern_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string delete = 5; - * - *
      -     * Used for deleting a resource.
      -     * 
      - */ - public Builder setDelete( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - patternCase_ = 5; - pattern_ = value; - onChanged(); - return this; - } - /** - * optional string delete = 5; - * - *
      -     * Used for deleting a resource.
      -     * 
      - */ - public Builder clearDelete() { - if (patternCase_ == 5) { - patternCase_ = 0; - pattern_ = null; - onChanged(); - } - return this; - } - /** - * optional string delete = 5; - * - *
      -     * Used for deleting a resource.
      -     * 
      - */ - public Builder setDeleteBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - patternCase_ = 5; - pattern_ = value; - onChanged(); - return this; - } - - /** - * optional string patch = 6; - * - *
      -     * Used for updating a resource.
      -     * 
      - */ - public java.lang.String getPatch() { - java.lang.Object ref = ""; - if (patternCase_ == 6) { - ref = pattern_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (patternCase_ == 6) { - pattern_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string patch = 6; - * - *
      -     * Used for updating a resource.
      -     * 
      - */ - public com.google.protobuf.ByteString - getPatchBytes() { - java.lang.Object ref = ""; - if (patternCase_ == 6) { - ref = pattern_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (patternCase_ == 6) { - pattern_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string patch = 6; - * - *
      -     * Used for updating a resource.
      -     * 
      - */ - public Builder setPatch( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - patternCase_ = 6; - pattern_ = value; - onChanged(); - return this; - } - /** - * optional string patch = 6; - * - *
      -     * Used for updating a resource.
      -     * 
      - */ - public Builder clearPatch() { - if (patternCase_ == 6) { - patternCase_ = 0; - pattern_ = null; - onChanged(); - } - return this; - } - /** - * optional string patch = 6; - * - *
      -     * Used for updating a resource.
      -     * 
      - */ - public Builder setPatchBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - patternCase_ = 6; - pattern_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.SingleFieldBuilder< - com.google.api.CustomHttpPattern, com.google.api.CustomHttpPattern.Builder, com.google.api.CustomHttpPatternOrBuilder> customBuilder_; - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -     * Custom pattern is used for defining custom verbs.
      -     * 
      - */ - public com.google.api.CustomHttpPattern getCustom() { - if (customBuilder_ == null) { - if (patternCase_ == 8) { - return (com.google.api.CustomHttpPattern) pattern_; - } - return com.google.api.CustomHttpPattern.getDefaultInstance(); - } else { - if (patternCase_ == 8) { - return customBuilder_.getMessage(); - } - return com.google.api.CustomHttpPattern.getDefaultInstance(); - } - } - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -     * Custom pattern is used for defining custom verbs.
      -     * 
      - */ - public Builder setCustom(com.google.api.CustomHttpPattern value) { - if (customBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - pattern_ = value; - onChanged(); - } else { - customBuilder_.setMessage(value); - } - patternCase_ = 8; - return this; - } - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -     * Custom pattern is used for defining custom verbs.
      -     * 
      - */ - public Builder setCustom( - com.google.api.CustomHttpPattern.Builder builderForValue) { - if (customBuilder_ == null) { - pattern_ = builderForValue.build(); - onChanged(); - } else { - customBuilder_.setMessage(builderForValue.build()); - } - patternCase_ = 8; - return this; - } - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -     * Custom pattern is used for defining custom verbs.
      -     * 
      - */ - public Builder mergeCustom(com.google.api.CustomHttpPattern value) { - if (customBuilder_ == null) { - if (patternCase_ == 8 && - pattern_ != com.google.api.CustomHttpPattern.getDefaultInstance()) { - pattern_ = com.google.api.CustomHttpPattern.newBuilder((com.google.api.CustomHttpPattern) pattern_) - .mergeFrom(value).buildPartial(); - } else { - pattern_ = value; - } - onChanged(); - } else { - if (patternCase_ == 8) { - customBuilder_.mergeFrom(value); - } - customBuilder_.setMessage(value); - } - patternCase_ = 8; - return this; - } - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -     * Custom pattern is used for defining custom verbs.
      -     * 
      - */ - public Builder clearCustom() { - if (customBuilder_ == null) { - if (patternCase_ == 8) { - patternCase_ = 0; - pattern_ = null; - onChanged(); - } - } else { - if (patternCase_ == 8) { - patternCase_ = 0; - pattern_ = null; - } - customBuilder_.clear(); - } - return this; - } - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -     * Custom pattern is used for defining custom verbs.
      -     * 
      - */ - public com.google.api.CustomHttpPattern.Builder getCustomBuilder() { - return getCustomFieldBuilder().getBuilder(); - } - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -     * Custom pattern is used for defining custom verbs.
      -     * 
      - */ - public com.google.api.CustomHttpPatternOrBuilder getCustomOrBuilder() { - if ((patternCase_ == 8) && (customBuilder_ != null)) { - return customBuilder_.getMessageOrBuilder(); - } else { - if (patternCase_ == 8) { - return (com.google.api.CustomHttpPattern) pattern_; - } - return com.google.api.CustomHttpPattern.getDefaultInstance(); - } - } - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -     * Custom pattern is used for defining custom verbs.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.api.CustomHttpPattern, com.google.api.CustomHttpPattern.Builder, com.google.api.CustomHttpPatternOrBuilder> - getCustomFieldBuilder() { - if (customBuilder_ == null) { - if (!(patternCase_ == 8)) { - pattern_ = com.google.api.CustomHttpPattern.getDefaultInstance(); - } - customBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.api.CustomHttpPattern, com.google.api.CustomHttpPattern.Builder, com.google.api.CustomHttpPatternOrBuilder>( - (com.google.api.CustomHttpPattern) pattern_, - getParentForChildren(), - isClean()); - pattern_ = null; - } - patternCase_ = 8; - onChanged();; - return customBuilder_; - } - - private java.lang.Object body_ = ""; - /** - * optional string body = 7; - * - *
      -     * The name of the request field whose value is mapped to the HTTP body, or
      -     * `*` for mapping all fields not captured by the path pattern to the HTTP
      -     * body. NOTE: the referred field must not be a repeated field.
      -     * 
      - */ - public java.lang.String getBody() { - java.lang.Object ref = body_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - body_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string body = 7; - * - *
      -     * The name of the request field whose value is mapped to the HTTP body, or
      -     * `*` for mapping all fields not captured by the path pattern to the HTTP
      -     * body. NOTE: the referred field must not be a repeated field.
      -     * 
      - */ - public com.google.protobuf.ByteString - getBodyBytes() { - java.lang.Object ref = body_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - body_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string body = 7; - * - *
      -     * The name of the request field whose value is mapped to the HTTP body, or
      -     * `*` for mapping all fields not captured by the path pattern to the HTTP
      -     * body. NOTE: the referred field must not be a repeated field.
      -     * 
      - */ - public Builder setBody( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - body_ = value; - onChanged(); - return this; - } - /** - * optional string body = 7; - * - *
      -     * The name of the request field whose value is mapped to the HTTP body, or
      -     * `*` for mapping all fields not captured by the path pattern to the HTTP
      -     * body. NOTE: the referred field must not be a repeated field.
      -     * 
      - */ - public Builder clearBody() { - - body_ = getDefaultInstance().getBody(); - onChanged(); - return this; - } - /** - * optional string body = 7; - * - *
      -     * The name of the request field whose value is mapped to the HTTP body, or
      -     * `*` for mapping all fields not captured by the path pattern to the HTTP
      -     * body. NOTE: the referred field must not be a repeated field.
      -     * 
      - */ - public Builder setBodyBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - body_ = value; - onChanged(); - return this; - } - - private com.google.api.MediaUpload mediaUpload_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.api.MediaUpload, com.google.api.MediaUpload.Builder, com.google.api.MediaUploadOrBuilder> mediaUploadBuilder_; - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public boolean hasMediaUpload() { - return mediaUploadBuilder_ != null || mediaUpload_ != null; - } - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public com.google.api.MediaUpload getMediaUpload() { - if (mediaUploadBuilder_ == null) { - return mediaUpload_ == null ? com.google.api.MediaUpload.getDefaultInstance() : mediaUpload_; - } else { - return mediaUploadBuilder_.getMessage(); - } - } - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public Builder setMediaUpload(com.google.api.MediaUpload value) { - if (mediaUploadBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - mediaUpload_ = value; - onChanged(); - } else { - mediaUploadBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public Builder setMediaUpload( - com.google.api.MediaUpload.Builder builderForValue) { - if (mediaUploadBuilder_ == null) { - mediaUpload_ = builderForValue.build(); - onChanged(); - } else { - mediaUploadBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public Builder mergeMediaUpload(com.google.api.MediaUpload value) { - if (mediaUploadBuilder_ == null) { - if (mediaUpload_ != null) { - mediaUpload_ = - com.google.api.MediaUpload.newBuilder(mediaUpload_).mergeFrom(value).buildPartial(); - } else { - mediaUpload_ = value; - } - onChanged(); - } else { - mediaUploadBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public Builder clearMediaUpload() { - if (mediaUploadBuilder_ == null) { - mediaUpload_ = null; - onChanged(); - } else { - mediaUpload_ = null; - mediaUploadBuilder_ = null; - } - - return this; - } - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public com.google.api.MediaUpload.Builder getMediaUploadBuilder() { - - onChanged(); - return getMediaUploadFieldBuilder().getBuilder(); - } - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public com.google.api.MediaUploadOrBuilder getMediaUploadOrBuilder() { - if (mediaUploadBuilder_ != null) { - return mediaUploadBuilder_.getMessageOrBuilder(); - } else { - return mediaUpload_ == null ? - com.google.api.MediaUpload.getDefaultInstance() : mediaUpload_; - } - } - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.api.MediaUpload, com.google.api.MediaUpload.Builder, com.google.api.MediaUploadOrBuilder> - getMediaUploadFieldBuilder() { - if (mediaUploadBuilder_ == null) { - mediaUploadBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.api.MediaUpload, com.google.api.MediaUpload.Builder, com.google.api.MediaUploadOrBuilder>( - getMediaUpload(), - getParentForChildren(), - isClean()); - mediaUpload_ = null; - } - return mediaUploadBuilder_; - } - - private com.google.api.MediaDownload mediaDownload_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.api.MediaDownload, com.google.api.MediaDownload.Builder, com.google.api.MediaDownloadOrBuilder> mediaDownloadBuilder_; - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public boolean hasMediaDownload() { - return mediaDownloadBuilder_ != null || mediaDownload_ != null; - } - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public com.google.api.MediaDownload getMediaDownload() { - if (mediaDownloadBuilder_ == null) { - return mediaDownload_ == null ? com.google.api.MediaDownload.getDefaultInstance() : mediaDownload_; - } else { - return mediaDownloadBuilder_.getMessage(); - } - } - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public Builder setMediaDownload(com.google.api.MediaDownload value) { - if (mediaDownloadBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - mediaDownload_ = value; - onChanged(); - } else { - mediaDownloadBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public Builder setMediaDownload( - com.google.api.MediaDownload.Builder builderForValue) { - if (mediaDownloadBuilder_ == null) { - mediaDownload_ = builderForValue.build(); - onChanged(); - } else { - mediaDownloadBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public Builder mergeMediaDownload(com.google.api.MediaDownload value) { - if (mediaDownloadBuilder_ == null) { - if (mediaDownload_ != null) { - mediaDownload_ = - com.google.api.MediaDownload.newBuilder(mediaDownload_).mergeFrom(value).buildPartial(); - } else { - mediaDownload_ = value; - } - onChanged(); - } else { - mediaDownloadBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public Builder clearMediaDownload() { - if (mediaDownloadBuilder_ == null) { - mediaDownload_ = null; - onChanged(); - } else { - mediaDownload_ = null; - mediaDownloadBuilder_ = null; - } - - return this; - } - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public com.google.api.MediaDownload.Builder getMediaDownloadBuilder() { - - onChanged(); - return getMediaDownloadFieldBuilder().getBuilder(); - } - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - public com.google.api.MediaDownloadOrBuilder getMediaDownloadOrBuilder() { - if (mediaDownloadBuilder_ != null) { - return mediaDownloadBuilder_.getMessageOrBuilder(); - } else { - return mediaDownload_ == null ? - com.google.api.MediaDownload.getDefaultInstance() : mediaDownload_; - } - } - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -     * Do not use this. For media support, add instead
      -     * [][google.bytestream.RestByteStream] as an API to your
      -     * configuration.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.api.MediaDownload, com.google.api.MediaDownload.Builder, com.google.api.MediaDownloadOrBuilder> - getMediaDownloadFieldBuilder() { - if (mediaDownloadBuilder_ == null) { - mediaDownloadBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.api.MediaDownload, com.google.api.MediaDownload.Builder, com.google.api.MediaDownloadOrBuilder>( - getMediaDownload(), - getParentForChildren(), - isClean()); - mediaDownload_ = null; - } - return mediaDownloadBuilder_; - } - - private java.util.List additionalBindings_ = - java.util.Collections.emptyList(); - private void ensureAdditionalBindingsIsMutable() { - if (!((bitField0_ & 0x00000400) == 0x00000400)) { - additionalBindings_ = new java.util.ArrayList(additionalBindings_); - bitField0_ |= 0x00000400; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder> additionalBindingsBuilder_; - - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public java.util.List getAdditionalBindingsList() { - if (additionalBindingsBuilder_ == null) { - return java.util.Collections.unmodifiableList(additionalBindings_); - } else { - return additionalBindingsBuilder_.getMessageList(); - } - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public int getAdditionalBindingsCount() { - if (additionalBindingsBuilder_ == null) { - return additionalBindings_.size(); - } else { - return additionalBindingsBuilder_.getCount(); - } - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public com.google.api.HttpRule getAdditionalBindings(int index) { - if (additionalBindingsBuilder_ == null) { - return additionalBindings_.get(index); - } else { - return additionalBindingsBuilder_.getMessage(index); - } - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public Builder setAdditionalBindings( - int index, com.google.api.HttpRule value) { - if (additionalBindingsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureAdditionalBindingsIsMutable(); - additionalBindings_.set(index, value); - onChanged(); - } else { - additionalBindingsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public Builder setAdditionalBindings( - int index, com.google.api.HttpRule.Builder builderForValue) { - if (additionalBindingsBuilder_ == null) { - ensureAdditionalBindingsIsMutable(); - additionalBindings_.set(index, builderForValue.build()); - onChanged(); - } else { - additionalBindingsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public Builder addAdditionalBindings(com.google.api.HttpRule value) { - if (additionalBindingsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureAdditionalBindingsIsMutable(); - additionalBindings_.add(value); - onChanged(); - } else { - additionalBindingsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public Builder addAdditionalBindings( - int index, com.google.api.HttpRule value) { - if (additionalBindingsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureAdditionalBindingsIsMutable(); - additionalBindings_.add(index, value); - onChanged(); - } else { - additionalBindingsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public Builder addAdditionalBindings( - com.google.api.HttpRule.Builder builderForValue) { - if (additionalBindingsBuilder_ == null) { - ensureAdditionalBindingsIsMutable(); - additionalBindings_.add(builderForValue.build()); - onChanged(); - } else { - additionalBindingsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public Builder addAdditionalBindings( - int index, com.google.api.HttpRule.Builder builderForValue) { - if (additionalBindingsBuilder_ == null) { - ensureAdditionalBindingsIsMutable(); - additionalBindings_.add(index, builderForValue.build()); - onChanged(); - } else { - additionalBindingsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public Builder addAllAdditionalBindings( - java.lang.Iterable values) { - if (additionalBindingsBuilder_ == null) { - ensureAdditionalBindingsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, additionalBindings_); - onChanged(); - } else { - additionalBindingsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public Builder clearAdditionalBindings() { - if (additionalBindingsBuilder_ == null) { - additionalBindings_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000400); - onChanged(); - } else { - additionalBindingsBuilder_.clear(); - } - return this; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public Builder removeAdditionalBindings(int index) { - if (additionalBindingsBuilder_ == null) { - ensureAdditionalBindingsIsMutable(); - additionalBindings_.remove(index); - onChanged(); - } else { - additionalBindingsBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public com.google.api.HttpRule.Builder getAdditionalBindingsBuilder( - int index) { - return getAdditionalBindingsFieldBuilder().getBuilder(index); - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public com.google.api.HttpRuleOrBuilder getAdditionalBindingsOrBuilder( - int index) { - if (additionalBindingsBuilder_ == null) { - return additionalBindings_.get(index); } else { - return additionalBindingsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public java.util.List - getAdditionalBindingsOrBuilderList() { - if (additionalBindingsBuilder_ != null) { - return additionalBindingsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(additionalBindings_); - } - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public com.google.api.HttpRule.Builder addAdditionalBindingsBuilder() { - return getAdditionalBindingsFieldBuilder().addBuilder( - com.google.api.HttpRule.getDefaultInstance()); - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public com.google.api.HttpRule.Builder addAdditionalBindingsBuilder( - int index) { - return getAdditionalBindingsFieldBuilder().addBuilder( - index, com.google.api.HttpRule.getDefaultInstance()); - } - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -     * Additional HTTP bindings for the selector. Nested bindings must
      -     * not contain an `additional_bindings` field themselves (that is,
      -     * the nesting may only be one level deep).
      -     * 
      - */ - public java.util.List - getAdditionalBindingsBuilderList() { - return getAdditionalBindingsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder> - getAdditionalBindingsFieldBuilder() { - if (additionalBindingsBuilder_ == null) { - additionalBindingsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.api.HttpRule, com.google.api.HttpRule.Builder, com.google.api.HttpRuleOrBuilder>( - additionalBindings_, - ((bitField0_ & 0x00000400) == 0x00000400), - getParentForChildren(), - isClean()); - additionalBindings_ = null; - } - return additionalBindingsBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.HttpRule) - } - - // @@protoc_insertion_point(class_scope:google.api.HttpRule) - private static final com.google.api.HttpRule DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.HttpRule(); - } - - public static com.google.api.HttpRule getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public HttpRule parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new HttpRule(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.HttpRule getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRuleOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRuleOrBuilder.java deleted file mode 100644 index 9a29370416a8..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/HttpRuleOrBuilder.java +++ /dev/null @@ -1,276 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -public interface HttpRuleOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.HttpRule) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string selector = 1; - * - *
      -   * Selects methods to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - java.lang.String getSelector(); - /** - * optional string selector = 1; - * - *
      -   * Selects methods to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - com.google.protobuf.ByteString - getSelectorBytes(); - - /** - * optional string get = 2; - * - *
      -   * Used for listing and getting information about resources.
      -   * 
      - */ - java.lang.String getGet(); - /** - * optional string get = 2; - * - *
      -   * Used for listing and getting information about resources.
      -   * 
      - */ - com.google.protobuf.ByteString - getGetBytes(); - - /** - * optional string put = 3; - * - *
      -   * Used for updating a resource.
      -   * 
      - */ - java.lang.String getPut(); - /** - * optional string put = 3; - * - *
      -   * Used for updating a resource.
      -   * 
      - */ - com.google.protobuf.ByteString - getPutBytes(); - - /** - * optional string post = 4; - * - *
      -   * Used for creating a resource.
      -   * 
      - */ - java.lang.String getPost(); - /** - * optional string post = 4; - * - *
      -   * Used for creating a resource.
      -   * 
      - */ - com.google.protobuf.ByteString - getPostBytes(); - - /** - * optional string delete = 5; - * - *
      -   * Used for deleting a resource.
      -   * 
      - */ - java.lang.String getDelete(); - /** - * optional string delete = 5; - * - *
      -   * Used for deleting a resource.
      -   * 
      - */ - com.google.protobuf.ByteString - getDeleteBytes(); - - /** - * optional string patch = 6; - * - *
      -   * Used for updating a resource.
      -   * 
      - */ - java.lang.String getPatch(); - /** - * optional string patch = 6; - * - *
      -   * Used for updating a resource.
      -   * 
      - */ - com.google.protobuf.ByteString - getPatchBytes(); - - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -   * Custom pattern is used for defining custom verbs.
      -   * 
      - */ - com.google.api.CustomHttpPattern getCustom(); - /** - * optional .google.api.CustomHttpPattern custom = 8; - * - *
      -   * Custom pattern is used for defining custom verbs.
      -   * 
      - */ - com.google.api.CustomHttpPatternOrBuilder getCustomOrBuilder(); - - /** - * optional string body = 7; - * - *
      -   * The name of the request field whose value is mapped to the HTTP body, or
      -   * `*` for mapping all fields not captured by the path pattern to the HTTP
      -   * body. NOTE: the referred field must not be a repeated field.
      -   * 
      - */ - java.lang.String getBody(); - /** - * optional string body = 7; - * - *
      -   * The name of the request field whose value is mapped to the HTTP body, or
      -   * `*` for mapping all fields not captured by the path pattern to the HTTP
      -   * body. NOTE: the referred field must not be a repeated field.
      -   * 
      - */ - com.google.protobuf.ByteString - getBodyBytes(); - - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - boolean hasMediaUpload(); - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - com.google.api.MediaUpload getMediaUpload(); - /** - * optional .google.api.MediaUpload media_upload = 9; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - com.google.api.MediaUploadOrBuilder getMediaUploadOrBuilder(); - - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - boolean hasMediaDownload(); - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - com.google.api.MediaDownload getMediaDownload(); - /** - * optional .google.api.MediaDownload media_download = 10; - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - com.google.api.MediaDownloadOrBuilder getMediaDownloadOrBuilder(); - - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -   * Additional HTTP bindings for the selector. Nested bindings must
      -   * not contain an `additional_bindings` field themselves (that is,
      -   * the nesting may only be one level deep).
      -   * 
      - */ - java.util.List - getAdditionalBindingsList(); - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -   * Additional HTTP bindings for the selector. Nested bindings must
      -   * not contain an `additional_bindings` field themselves (that is,
      -   * the nesting may only be one level deep).
      -   * 
      - */ - com.google.api.HttpRule getAdditionalBindings(int index); - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -   * Additional HTTP bindings for the selector. Nested bindings must
      -   * not contain an `additional_bindings` field themselves (that is,
      -   * the nesting may only be one level deep).
      -   * 
      - */ - int getAdditionalBindingsCount(); - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -   * Additional HTTP bindings for the selector. Nested bindings must
      -   * not contain an `additional_bindings` field themselves (that is,
      -   * the nesting may only be one level deep).
      -   * 
      - */ - java.util.List - getAdditionalBindingsOrBuilderList(); - /** - * repeated .google.api.HttpRule additional_bindings = 11; - * - *
      -   * Additional HTTP bindings for the selector. Nested bindings must
      -   * not contain an `additional_bindings` field themselves (that is,
      -   * the nesting may only be one level deep).
      -   * 
      - */ - com.google.api.HttpRuleOrBuilder getAdditionalBindingsOrBuilder( - int index); - - public com.google.api.HttpRule.PatternCase getPatternCase(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownload.java b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownload.java deleted file mode 100644 index 7134429cae8e..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownload.java +++ /dev/null @@ -1,399 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.MediaDownload} - * - *
      - * Do not use this. For media support, add instead
      - * [][google.bytestream.RestByteStream] as an API to your
      - * configuration.
      - * 
      - */ -public final class MediaDownload extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.MediaDownload) - MediaDownloadOrBuilder { - // Use MediaDownload.newBuilder() to construct. - private MediaDownload(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private MediaDownload() { - enabled_ = false; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private MediaDownload( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 8: { - - enabled_ = input.readBool(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.HttpProto.internal_static_google_api_MediaDownload_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.HttpProto.internal_static_google_api_MediaDownload_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.MediaDownload.class, com.google.api.MediaDownload.Builder.class); - } - - public static final int ENABLED_FIELD_NUMBER = 1; - private boolean enabled_; - /** - * optional bool enabled = 1; - * - *
      -   * Whether download is enabled.
      -   * 
      - */ - public boolean getEnabled() { - return enabled_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (enabled_ != false) { - output.writeBool(1, enabled_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (enabled_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(1, enabled_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.MediaDownload parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.MediaDownload parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.MediaDownload parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.MediaDownload parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.MediaDownload parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.MediaDownload parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.MediaDownload parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.MediaDownload parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.MediaDownload parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.MediaDownload parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.MediaDownload prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.MediaDownload} - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.MediaDownload) - com.google.api.MediaDownloadOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.HttpProto.internal_static_google_api_MediaDownload_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.HttpProto.internal_static_google_api_MediaDownload_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.MediaDownload.class, com.google.api.MediaDownload.Builder.class); - } - - // Construct using com.google.api.MediaDownload.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - enabled_ = false; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.HttpProto.internal_static_google_api_MediaDownload_descriptor; - } - - public com.google.api.MediaDownload getDefaultInstanceForType() { - return com.google.api.MediaDownload.getDefaultInstance(); - } - - public com.google.api.MediaDownload build() { - com.google.api.MediaDownload result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.MediaDownload buildPartial() { - com.google.api.MediaDownload result = new com.google.api.MediaDownload(this); - result.enabled_ = enabled_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.MediaDownload) { - return mergeFrom((com.google.api.MediaDownload)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.MediaDownload other) { - if (other == com.google.api.MediaDownload.getDefaultInstance()) return this; - if (other.getEnabled() != false) { - setEnabled(other.getEnabled()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.MediaDownload parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.MediaDownload) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private boolean enabled_ ; - /** - * optional bool enabled = 1; - * - *
      -     * Whether download is enabled.
      -     * 
      - */ - public boolean getEnabled() { - return enabled_; - } - /** - * optional bool enabled = 1; - * - *
      -     * Whether download is enabled.
      -     * 
      - */ - public Builder setEnabled(boolean value) { - - enabled_ = value; - onChanged(); - return this; - } - /** - * optional bool enabled = 1; - * - *
      -     * Whether download is enabled.
      -     * 
      - */ - public Builder clearEnabled() { - - enabled_ = false; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.MediaDownload) - } - - // @@protoc_insertion_point(class_scope:google.api.MediaDownload) - private static final com.google.api.MediaDownload DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.MediaDownload(); - } - - public static com.google.api.MediaDownload getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public MediaDownload parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new MediaDownload(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.MediaDownload getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownloadOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownloadOrBuilder.java deleted file mode 100644 index e07a3988c7fe..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaDownloadOrBuilder.java +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -public interface MediaDownloadOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.MediaDownload) - com.google.protobuf.MessageOrBuilder { - - /** - * optional bool enabled = 1; - * - *
      -   * Whether download is enabled.
      -   * 
      - */ - boolean getEnabled(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUpload.java b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUpload.java deleted file mode 100644 index 856b2954dcea..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUpload.java +++ /dev/null @@ -1,399 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.MediaUpload} - * - *
      - * Do not use this. For media support, add instead
      - * [][google.bytestream.RestByteStream] as an API to your
      - * configuration.
      - * 
      - */ -public final class MediaUpload extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.MediaUpload) - MediaUploadOrBuilder { - // Use MediaUpload.newBuilder() to construct. - private MediaUpload(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private MediaUpload() { - enabled_ = false; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private MediaUpload( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 24: { - - enabled_ = input.readBool(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.HttpProto.internal_static_google_api_MediaUpload_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.HttpProto.internal_static_google_api_MediaUpload_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.MediaUpload.class, com.google.api.MediaUpload.Builder.class); - } - - public static final int ENABLED_FIELD_NUMBER = 3; - private boolean enabled_; - /** - * optional bool enabled = 3; - * - *
      -   * Whether upload is enabled.
      -   * 
      - */ - public boolean getEnabled() { - return enabled_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (enabled_ != false) { - output.writeBool(3, enabled_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (enabled_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(3, enabled_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.MediaUpload parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.MediaUpload parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.MediaUpload parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.MediaUpload parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.MediaUpload parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.MediaUpload parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.MediaUpload parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.MediaUpload parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.MediaUpload parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.MediaUpload parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.MediaUpload prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.MediaUpload} - * - *
      -   * Do not use this. For media support, add instead
      -   * [][google.bytestream.RestByteStream] as an API to your
      -   * configuration.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.MediaUpload) - com.google.api.MediaUploadOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.HttpProto.internal_static_google_api_MediaUpload_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.HttpProto.internal_static_google_api_MediaUpload_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.MediaUpload.class, com.google.api.MediaUpload.Builder.class); - } - - // Construct using com.google.api.MediaUpload.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - enabled_ = false; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.HttpProto.internal_static_google_api_MediaUpload_descriptor; - } - - public com.google.api.MediaUpload getDefaultInstanceForType() { - return com.google.api.MediaUpload.getDefaultInstance(); - } - - public com.google.api.MediaUpload build() { - com.google.api.MediaUpload result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.MediaUpload buildPartial() { - com.google.api.MediaUpload result = new com.google.api.MediaUpload(this); - result.enabled_ = enabled_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.MediaUpload) { - return mergeFrom((com.google.api.MediaUpload)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.MediaUpload other) { - if (other == com.google.api.MediaUpload.getDefaultInstance()) return this; - if (other.getEnabled() != false) { - setEnabled(other.getEnabled()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.MediaUpload parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.MediaUpload) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private boolean enabled_ ; - /** - * optional bool enabled = 3; - * - *
      -     * Whether upload is enabled.
      -     * 
      - */ - public boolean getEnabled() { - return enabled_; - } - /** - * optional bool enabled = 3; - * - *
      -     * Whether upload is enabled.
      -     * 
      - */ - public Builder setEnabled(boolean value) { - - enabled_ = value; - onChanged(); - return this; - } - /** - * optional bool enabled = 3; - * - *
      -     * Whether upload is enabled.
      -     * 
      - */ - public Builder clearEnabled() { - - enabled_ = false; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.MediaUpload) - } - - // @@protoc_insertion_point(class_scope:google.api.MediaUpload) - private static final com.google.api.MediaUpload DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.MediaUpload(); - } - - public static com.google.api.MediaUpload getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public MediaUpload parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new MediaUpload(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.MediaUpload getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUploadOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUploadOrBuilder.java deleted file mode 100644 index a3c55034ce00..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/MediaUploadOrBuilder.java +++ /dev/null @@ -1,18 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/http.proto - -package com.google.api; - -public interface MediaUploadOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.MediaUpload) - com.google.protobuf.MessageOrBuilder { - - /** - * optional bool enabled = 3; - * - *
      -   * Whether upload is enabled.
      -   * 
      - */ - boolean getEnabled(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Page.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Page.java deleted file mode 100644 index 0ed13fb48cf4..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/Page.java +++ /dev/null @@ -1,1176 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/documentation.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.Page} - * - *
      - * Represents a documentation page. A page can contain subpages to represent
      - * nested documentation set structure.
      - * 
      - */ -public final class Page extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.Page) - PageOrBuilder { - // Use Page.newBuilder() to construct. - private Page(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Page() { - name_ = ""; - content_ = ""; - subpages_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Page( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - name_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - content_ = s; - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - subpages_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - subpages_.add(input.readMessage(com.google.api.Page.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - subpages_ = java.util.Collections.unmodifiableList(subpages_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.DocumentationProto.internal_static_google_api_Page_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.DocumentationProto.internal_static_google_api_Page_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Page.class, com.google.api.Page.Builder.class); - } - - private int bitField0_; - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * optional string name = 1; - * - *
      -   * The name of the page. It will be used as an identity of the page to
      -   * generate URI of the page, text of the link to this page in navigation,
      -   * etc. The full page name (start from the root page name to this page
      -   * concatenated with `.`) can be used as reference to the page in your
      -   * documentation. For example:
      -   *     pages:
      -   *     - name: Tutorial
      -   *       content: (== include tutorial.md ==)
      -   *       subpages:
      -   *       - name: Java
      -   *         content: (== include tutorial_java.md ==)
      -   * You can reference `Java` page using Markdown reference link syntax:
      -   * `[Java][Tutorial.Java]`.
      -   * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * optional string name = 1; - * - *
      -   * The name of the page. It will be used as an identity of the page to
      -   * generate URI of the page, text of the link to this page in navigation,
      -   * etc. The full page name (start from the root page name to this page
      -   * concatenated with `.`) can be used as reference to the page in your
      -   * documentation. For example:
      -   *     pages:
      -   *     - name: Tutorial
      -   *       content: (== include tutorial.md ==)
      -   *       subpages:
      -   *       - name: Java
      -   *         content: (== include tutorial_java.md ==)
      -   * You can reference `Java` page using Markdown reference link syntax:
      -   * `[Java][Tutorial.Java]`.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int CONTENT_FIELD_NUMBER = 2; - private volatile java.lang.Object content_; - /** - * optional string content = 2; - * - *
      -   * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      -   * to include content from a Markdown file.
      -   * 
      - */ - public java.lang.String getContent() { - java.lang.Object ref = content_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - content_ = s; - return s; - } - } - /** - * optional string content = 2; - * - *
      -   * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      -   * to include content from a Markdown file.
      -   * 
      - */ - public com.google.protobuf.ByteString - getContentBytes() { - java.lang.Object ref = content_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - content_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SUBPAGES_FIELD_NUMBER = 3; - private java.util.List subpages_; - /** - * repeated .google.api.Page subpages = 3; - * - *
      -   * Subpages of this page. The order of subpages specified here will be
      -   * honored in the generated docset.
      -   * 
      - */ - public java.util.List getSubpagesList() { - return subpages_; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -   * Subpages of this page. The order of subpages specified here will be
      -   * honored in the generated docset.
      -   * 
      - */ - public java.util.List - getSubpagesOrBuilderList() { - return subpages_; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -   * Subpages of this page. The order of subpages specified here will be
      -   * honored in the generated docset.
      -   * 
      - */ - public int getSubpagesCount() { - return subpages_.size(); - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -   * Subpages of this page. The order of subpages specified here will be
      -   * honored in the generated docset.
      -   * 
      - */ - public com.google.api.Page getSubpages(int index) { - return subpages_.get(index); - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -   * Subpages of this page. The order of subpages specified here will be
      -   * honored in the generated docset.
      -   * 
      - */ - public com.google.api.PageOrBuilder getSubpagesOrBuilder( - int index) { - return subpages_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); - } - if (!getContentBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, content_); - } - for (int i = 0; i < subpages_.size(); i++) { - output.writeMessage(3, subpages_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); - } - if (!getContentBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, content_); - } - for (int i = 0; i < subpages_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, subpages_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.Page parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Page parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Page parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Page parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Page parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Page parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.Page parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.Page parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.Page parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Page parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.Page prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.Page} - * - *
      -   * Represents a documentation page. A page can contain subpages to represent
      -   * nested documentation set structure.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.Page) - com.google.api.PageOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.DocumentationProto.internal_static_google_api_Page_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.DocumentationProto.internal_static_google_api_Page_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Page.class, com.google.api.Page.Builder.class); - } - - // Construct using com.google.api.Page.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getSubpagesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - name_ = ""; - - content_ = ""; - - if (subpagesBuilder_ == null) { - subpages_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - } else { - subpagesBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.DocumentationProto.internal_static_google_api_Page_descriptor; - } - - public com.google.api.Page getDefaultInstanceForType() { - return com.google.api.Page.getDefaultInstance(); - } - - public com.google.api.Page build() { - com.google.api.Page result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.Page buildPartial() { - com.google.api.Page result = new com.google.api.Page(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.name_ = name_; - result.content_ = content_; - if (subpagesBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004)) { - subpages_ = java.util.Collections.unmodifiableList(subpages_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.subpages_ = subpages_; - } else { - result.subpages_ = subpagesBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.Page) { - return mergeFrom((com.google.api.Page)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.Page other) { - if (other == com.google.api.Page.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (!other.getContent().isEmpty()) { - content_ = other.content_; - onChanged(); - } - if (subpagesBuilder_ == null) { - if (!other.subpages_.isEmpty()) { - if (subpages_.isEmpty()) { - subpages_ = other.subpages_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureSubpagesIsMutable(); - subpages_.addAll(other.subpages_); - } - onChanged(); - } - } else { - if (!other.subpages_.isEmpty()) { - if (subpagesBuilder_.isEmpty()) { - subpagesBuilder_.dispose(); - subpagesBuilder_ = null; - subpages_ = other.subpages_; - bitField0_ = (bitField0_ & ~0x00000004); - subpagesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getSubpagesFieldBuilder() : null; - } else { - subpagesBuilder_.addAllMessages(other.subpages_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.Page parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.Page) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object name_ = ""; - /** - * optional string name = 1; - * - *
      -     * The name of the page. It will be used as an identity of the page to
      -     * generate URI of the page, text of the link to this page in navigation,
      -     * etc. The full page name (start from the root page name to this page
      -     * concatenated with `.`) can be used as reference to the page in your
      -     * documentation. For example:
      -     *     pages:
      -     *     - name: Tutorial
      -     *       content: (== include tutorial.md ==)
      -     *       subpages:
      -     *       - name: Java
      -     *         content: (== include tutorial_java.md ==)
      -     * You can reference `Java` page using Markdown reference link syntax:
      -     * `[Java][Tutorial.Java]`.
      -     * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the page. It will be used as an identity of the page to
      -     * generate URI of the page, text of the link to this page in navigation,
      -     * etc. The full page name (start from the root page name to this page
      -     * concatenated with `.`) can be used as reference to the page in your
      -     * documentation. For example:
      -     *     pages:
      -     *     - name: Tutorial
      -     *       content: (== include tutorial.md ==)
      -     *       subpages:
      -     *       - name: Java
      -     *         content: (== include tutorial_java.md ==)
      -     * You can reference `Java` page using Markdown reference link syntax:
      -     * `[Java][Tutorial.Java]`.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the page. It will be used as an identity of the page to
      -     * generate URI of the page, text of the link to this page in navigation,
      -     * etc. The full page name (start from the root page name to this page
      -     * concatenated with `.`) can be used as reference to the page in your
      -     * documentation. For example:
      -     *     pages:
      -     *     - name: Tutorial
      -     *       content: (== include tutorial.md ==)
      -     *       subpages:
      -     *       - name: Java
      -     *         content: (== include tutorial_java.md ==)
      -     * You can reference `Java` page using Markdown reference link syntax:
      -     * `[Java][Tutorial.Java]`.
      -     * 
      - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the page. It will be used as an identity of the page to
      -     * generate URI of the page, text of the link to this page in navigation,
      -     * etc. The full page name (start from the root page name to this page
      -     * concatenated with `.`) can be used as reference to the page in your
      -     * documentation. For example:
      -     *     pages:
      -     *     - name: Tutorial
      -     *       content: (== include tutorial.md ==)
      -     *       subpages:
      -     *       - name: Java
      -     *         content: (== include tutorial_java.md ==)
      -     * You can reference `Java` page using Markdown reference link syntax:
      -     * `[Java][Tutorial.Java]`.
      -     * 
      - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the page. It will be used as an identity of the page to
      -     * generate URI of the page, text of the link to this page in navigation,
      -     * etc. The full page name (start from the root page name to this page
      -     * concatenated with `.`) can be used as reference to the page in your
      -     * documentation. For example:
      -     *     pages:
      -     *     - name: Tutorial
      -     *       content: (== include tutorial.md ==)
      -     *       subpages:
      -     *       - name: Java
      -     *         content: (== include tutorial_java.md ==)
      -     * You can reference `Java` page using Markdown reference link syntax:
      -     * `[Java][Tutorial.Java]`.
      -     * 
      - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private java.lang.Object content_ = ""; - /** - * optional string content = 2; - * - *
      -     * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      -     * to include content from a Markdown file.
      -     * 
      - */ - public java.lang.String getContent() { - java.lang.Object ref = content_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - content_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string content = 2; - * - *
      -     * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      -     * to include content from a Markdown file.
      -     * 
      - */ - public com.google.protobuf.ByteString - getContentBytes() { - java.lang.Object ref = content_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - content_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string content = 2; - * - *
      -     * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      -     * to include content from a Markdown file.
      -     * 
      - */ - public Builder setContent( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - content_ = value; - onChanged(); - return this; - } - /** - * optional string content = 2; - * - *
      -     * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      -     * to include content from a Markdown file.
      -     * 
      - */ - public Builder clearContent() { - - content_ = getDefaultInstance().getContent(); - onChanged(); - return this; - } - /** - * optional string content = 2; - * - *
      -     * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      -     * to include content from a Markdown file.
      -     * 
      - */ - public Builder setContentBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - content_ = value; - onChanged(); - return this; - } - - private java.util.List subpages_ = - java.util.Collections.emptyList(); - private void ensureSubpagesIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - subpages_ = new java.util.ArrayList(subpages_); - bitField0_ |= 0x00000004; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder> subpagesBuilder_; - - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public java.util.List getSubpagesList() { - if (subpagesBuilder_ == null) { - return java.util.Collections.unmodifiableList(subpages_); - } else { - return subpagesBuilder_.getMessageList(); - } - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public int getSubpagesCount() { - if (subpagesBuilder_ == null) { - return subpages_.size(); - } else { - return subpagesBuilder_.getCount(); - } - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public com.google.api.Page getSubpages(int index) { - if (subpagesBuilder_ == null) { - return subpages_.get(index); - } else { - return subpagesBuilder_.getMessage(index); - } - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public Builder setSubpages( - int index, com.google.api.Page value) { - if (subpagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubpagesIsMutable(); - subpages_.set(index, value); - onChanged(); - } else { - subpagesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public Builder setSubpages( - int index, com.google.api.Page.Builder builderForValue) { - if (subpagesBuilder_ == null) { - ensureSubpagesIsMutable(); - subpages_.set(index, builderForValue.build()); - onChanged(); - } else { - subpagesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public Builder addSubpages(com.google.api.Page value) { - if (subpagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubpagesIsMutable(); - subpages_.add(value); - onChanged(); - } else { - subpagesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public Builder addSubpages( - int index, com.google.api.Page value) { - if (subpagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubpagesIsMutable(); - subpages_.add(index, value); - onChanged(); - } else { - subpagesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public Builder addSubpages( - com.google.api.Page.Builder builderForValue) { - if (subpagesBuilder_ == null) { - ensureSubpagesIsMutable(); - subpages_.add(builderForValue.build()); - onChanged(); - } else { - subpagesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public Builder addSubpages( - int index, com.google.api.Page.Builder builderForValue) { - if (subpagesBuilder_ == null) { - ensureSubpagesIsMutable(); - subpages_.add(index, builderForValue.build()); - onChanged(); - } else { - subpagesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public Builder addAllSubpages( - java.lang.Iterable values) { - if (subpagesBuilder_ == null) { - ensureSubpagesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, subpages_); - onChanged(); - } else { - subpagesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public Builder clearSubpages() { - if (subpagesBuilder_ == null) { - subpages_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - } else { - subpagesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public Builder removeSubpages(int index) { - if (subpagesBuilder_ == null) { - ensureSubpagesIsMutable(); - subpages_.remove(index); - onChanged(); - } else { - subpagesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public com.google.api.Page.Builder getSubpagesBuilder( - int index) { - return getSubpagesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public com.google.api.PageOrBuilder getSubpagesOrBuilder( - int index) { - if (subpagesBuilder_ == null) { - return subpages_.get(index); } else { - return subpagesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public java.util.List - getSubpagesOrBuilderList() { - if (subpagesBuilder_ != null) { - return subpagesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(subpages_); - } - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public com.google.api.Page.Builder addSubpagesBuilder() { - return getSubpagesFieldBuilder().addBuilder( - com.google.api.Page.getDefaultInstance()); - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public com.google.api.Page.Builder addSubpagesBuilder( - int index) { - return getSubpagesFieldBuilder().addBuilder( - index, com.google.api.Page.getDefaultInstance()); - } - /** - * repeated .google.api.Page subpages = 3; - * - *
      -     * Subpages of this page. The order of subpages specified here will be
      -     * honored in the generated docset.
      -     * 
      - */ - public java.util.List - getSubpagesBuilderList() { - return getSubpagesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder> - getSubpagesFieldBuilder() { - if (subpagesBuilder_ == null) { - subpagesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.api.Page, com.google.api.Page.Builder, com.google.api.PageOrBuilder>( - subpages_, - ((bitField0_ & 0x00000004) == 0x00000004), - getParentForChildren(), - isClean()); - subpages_ = null; - } - return subpagesBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.Page) - } - - // @@protoc_insertion_point(class_scope:google.api.Page) - private static final com.google.api.Page DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.Page(); - } - - public static com.google.api.Page getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Page parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Page(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.Page getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/PageOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/PageOrBuilder.java deleted file mode 100644 index 5a566c4ad030..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/PageOrBuilder.java +++ /dev/null @@ -1,120 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/documentation.proto - -package com.google.api; - -public interface PageOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.Page) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string name = 1; - * - *
      -   * The name of the page. It will be used as an identity of the page to
      -   * generate URI of the page, text of the link to this page in navigation,
      -   * etc. The full page name (start from the root page name to this page
      -   * concatenated with `.`) can be used as reference to the page in your
      -   * documentation. For example:
      -   *     pages:
      -   *     - name: Tutorial
      -   *       content: (== include tutorial.md ==)
      -   *       subpages:
      -   *       - name: Java
      -   *         content: (== include tutorial_java.md ==)
      -   * You can reference `Java` page using Markdown reference link syntax:
      -   * `[Java][Tutorial.Java]`.
      -   * 
      - */ - java.lang.String getName(); - /** - * optional string name = 1; - * - *
      -   * The name of the page. It will be used as an identity of the page to
      -   * generate URI of the page, text of the link to this page in navigation,
      -   * etc. The full page name (start from the root page name to this page
      -   * concatenated with `.`) can be used as reference to the page in your
      -   * documentation. For example:
      -   *     pages:
      -   *     - name: Tutorial
      -   *       content: (== include tutorial.md ==)
      -   *       subpages:
      -   *       - name: Java
      -   *         content: (== include tutorial_java.md ==)
      -   * You can reference `Java` page using Markdown reference link syntax:
      -   * `[Java][Tutorial.Java]`.
      -   * 
      - */ - com.google.protobuf.ByteString - getNameBytes(); - - /** - * optional string content = 2; - * - *
      -   * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      -   * to include content from a Markdown file.
      -   * 
      - */ - java.lang.String getContent(); - /** - * optional string content = 2; - * - *
      -   * The Markdown content of the page. You can use `&#40;== include {path} ==&#41;`
      -   * to include content from a Markdown file.
      -   * 
      - */ - com.google.protobuf.ByteString - getContentBytes(); - - /** - * repeated .google.api.Page subpages = 3; - * - *
      -   * Subpages of this page. The order of subpages specified here will be
      -   * honored in the generated docset.
      -   * 
      - */ - java.util.List - getSubpagesList(); - /** - * repeated .google.api.Page subpages = 3; - * - *
      -   * Subpages of this page. The order of subpages specified here will be
      -   * honored in the generated docset.
      -   * 
      - */ - com.google.api.Page getSubpages(int index); - /** - * repeated .google.api.Page subpages = 3; - * - *
      -   * Subpages of this page. The order of subpages specified here will be
      -   * honored in the generated docset.
      -   * 
      - */ - int getSubpagesCount(); - /** - * repeated .google.api.Page subpages = 3; - * - *
      -   * Subpages of this page. The order of subpages specified here will be
      -   * honored in the generated docset.
      -   * 
      - */ - java.util.List - getSubpagesOrBuilderList(); - /** - * repeated .google.api.Page subpages = 3; - * - *
      -   * Subpages of this page. The order of subpages specified here will be
      -   * honored in the generated docset.
      -   * 
      - */ - com.google.api.PageOrBuilder getSubpagesOrBuilder( - int index); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Service.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Service.java deleted file mode 100644 index 1ba6c8e37d79..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/Service.java +++ /dev/null @@ -1,4591 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/service.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.Service} - * - *
      - * (== page basics ==)
      - * `Service` is the root object of the configuration schema. It
      - * describes basic information like the name of the service and the
      - * exposed API interfaces, and delegates other aspects to configuration
      - * sub-sections.
      - * Example:
      - *     type: google.api.Service
      - *     config_version: 1
      - *     name: calendar.googleapis.com
      - *     title: Google Calendar API
      - *     apis:
      - *     - name: google.calendar.Calendar
      - *     visibility:
      - *       rules:
      - *       - selector: "*"
      - *         restriction: TRUSTED_TESTER
      - *     backend:
      - *       rules:
      - *       - selector: "*"
      - *         address: calendar-prod-backend.gslb.googleapis.com
      - * 
      - */ -public final class Service extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.Service) - ServiceOrBuilder { - // Use Service.newBuilder() to construct. - private Service(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Service() { - name_ = ""; - title_ = ""; - producerProjectId_ = ""; - apis_ = java.util.Collections.emptyList(); - types_ = java.util.Collections.emptyList(); - enums_ = java.util.Collections.emptyList(); - systemTypes_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Service( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - name_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - title_ = s; - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - apis_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; - } - apis_.add(input.readMessage(com.google.protobuf.Api.parser(), extensionRegistry)); - break; - } - case 34: { - if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - types_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000020; - } - types_.add(input.readMessage(com.google.protobuf.Type.parser(), extensionRegistry)); - break; - } - case 42: { - if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - enums_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000040; - } - enums_.add(input.readMessage(com.google.protobuf.Enum.parser(), extensionRegistry)); - break; - } - case 50: { - com.google.api.Documentation.Builder subBuilder = null; - if (documentation_ != null) { - subBuilder = documentation_.toBuilder(); - } - documentation_ = input.readMessage(com.google.api.Documentation.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(documentation_); - documentation_ = subBuilder.buildPartial(); - } - - break; - } - case 58: { - com.google.api.Visibility.Builder subBuilder = null; - if (visibility_ != null) { - subBuilder = visibility_.toBuilder(); - } - visibility_ = input.readMessage(com.google.api.Visibility.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(visibility_); - visibility_ = subBuilder.buildPartial(); - } - - break; - } - case 74: { - com.google.api.Http.Builder subBuilder = null; - if (http_ != null) { - subBuilder = http_.toBuilder(); - } - http_ = input.readMessage(com.google.api.Http.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(http_); - http_ = subBuilder.buildPartial(); - } - - break; - } - case 98: { - com.google.api.Context.Builder subBuilder = null; - if (context_ != null) { - subBuilder = context_.toBuilder(); - } - context_ = input.readMessage(com.google.api.Context.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(context_); - context_ = subBuilder.buildPartial(); - } - - break; - } - case 130: { - com.google.api.CustomError.Builder subBuilder = null; - if (customError_ != null) { - subBuilder = customError_.toBuilder(); - } - customError_ = input.readMessage(com.google.api.CustomError.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(customError_); - customError_ = subBuilder.buildPartial(); - } - - break; - } - case 162: { - com.google.protobuf.UInt32Value.Builder subBuilder = null; - if (configVersion_ != null) { - subBuilder = configVersion_.toBuilder(); - } - configVersion_ = input.readMessage(com.google.protobuf.UInt32Value.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(configVersion_); - configVersion_ = subBuilder.buildPartial(); - } - - break; - } - case 178: { - String s = input.readStringRequireUtf8(); - - producerProjectId_ = s; - break; - } - case 802: { - com.google.protobuf.Any.Builder subBuilder = null; - if (derivedData_ != null) { - subBuilder = derivedData_.toBuilder(); - } - derivedData_ = input.readMessage(com.google.protobuf.Any.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(derivedData_); - derivedData_ = subBuilder.buildPartial(); - } - - break; - } - case 818: { - if (!((mutable_bitField0_ & 0x00002000) == 0x00002000)) { - systemTypes_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00002000; - } - systemTypes_.add(input.readMessage(com.google.protobuf.Type.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - apis_ = java.util.Collections.unmodifiableList(apis_); - } - if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - types_ = java.util.Collections.unmodifiableList(types_); - } - if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - enums_ = java.util.Collections.unmodifiableList(enums_); - } - if (((mutable_bitField0_ & 0x00002000) == 0x00002000)) { - systemTypes_ = java.util.Collections.unmodifiableList(systemTypes_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.ServiceProto.internal_static_google_api_Service_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.ServiceProto.internal_static_google_api_Service_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Service.class, com.google.api.Service.Builder.class); - } - - private int bitField0_; - public static final int CONFIG_VERSION_FIELD_NUMBER = 20; - private com.google.protobuf.UInt32Value configVersion_; - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -   * The version of the service configuration. The config version may
      -   * influence interpretation of the configuration, for example
      -   * determine defaults. This is documented together with applicable
      -   * options. The current default for the config version itself is `1`.
      -   * 
      - */ - public boolean hasConfigVersion() { - return configVersion_ != null; - } - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -   * The version of the service configuration. The config version may
      -   * influence interpretation of the configuration, for example
      -   * determine defaults. This is documented together with applicable
      -   * options. The current default for the config version itself is `1`.
      -   * 
      - */ - public com.google.protobuf.UInt32Value getConfigVersion() { - return configVersion_ == null ? com.google.protobuf.UInt32Value.getDefaultInstance() : configVersion_; - } - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -   * The version of the service configuration. The config version may
      -   * influence interpretation of the configuration, for example
      -   * determine defaults. This is documented together with applicable
      -   * options. The current default for the config version itself is `1`.
      -   * 
      - */ - public com.google.protobuf.UInt32ValueOrBuilder getConfigVersionOrBuilder() { - return getConfigVersion(); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * optional string name = 1; - * - *
      -   * The DNS address at which this service is available,
      -   * e.g. `calendar.googleapis.com`.
      -   * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * optional string name = 1; - * - *
      -   * The DNS address at which this service is available,
      -   * e.g. `calendar.googleapis.com`.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TITLE_FIELD_NUMBER = 2; - private volatile java.lang.Object title_; - /** - * optional string title = 2; - * - *
      -   * The product title associated with this service.
      -   * 
      - */ - public java.lang.String getTitle() { - java.lang.Object ref = title_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - title_ = s; - return s; - } - } - /** - * optional string title = 2; - * - *
      -   * The product title associated with this service.
      -   * 
      - */ - public com.google.protobuf.ByteString - getTitleBytes() { - java.lang.Object ref = title_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - title_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PRODUCER_PROJECT_ID_FIELD_NUMBER = 22; - private volatile java.lang.Object producerProjectId_; - /** - * optional string producer_project_id = 22; - * - *
      -   * The id of the Google developer project that owns the service.
      -   * Members of this project can manage the service configuration,
      -   * manage consumption of the service, etc.
      -   * 
      - */ - public java.lang.String getProducerProjectId() { - java.lang.Object ref = producerProjectId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - producerProjectId_ = s; - return s; - } - } - /** - * optional string producer_project_id = 22; - * - *
      -   * The id of the Google developer project that owns the service.
      -   * Members of this project can manage the service configuration,
      -   * manage consumption of the service, etc.
      -   * 
      - */ - public com.google.protobuf.ByteString - getProducerProjectIdBytes() { - java.lang.Object ref = producerProjectId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - producerProjectId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int APIS_FIELD_NUMBER = 3; - private java.util.List apis_; - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -   * A list of API interfaces exported by this service. Only the `name` field
      -   * of the [google.protobuf.Api][] needs to be provided by the configuration
      -   * author, as the remaining fields will be derived from the IDL during the
      -   * normalization process. It is an error to specify an API interface here
      -   * which cannot be resolved against the associated IDL files.
      -   * 
      - */ - public java.util.List getApisList() { - return apis_; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -   * A list of API interfaces exported by this service. Only the `name` field
      -   * of the [google.protobuf.Api][] needs to be provided by the configuration
      -   * author, as the remaining fields will be derived from the IDL during the
      -   * normalization process. It is an error to specify an API interface here
      -   * which cannot be resolved against the associated IDL files.
      -   * 
      - */ - public java.util.List - getApisOrBuilderList() { - return apis_; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -   * A list of API interfaces exported by this service. Only the `name` field
      -   * of the [google.protobuf.Api][] needs to be provided by the configuration
      -   * author, as the remaining fields will be derived from the IDL during the
      -   * normalization process. It is an error to specify an API interface here
      -   * which cannot be resolved against the associated IDL files.
      -   * 
      - */ - public int getApisCount() { - return apis_.size(); - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -   * A list of API interfaces exported by this service. Only the `name` field
      -   * of the [google.protobuf.Api][] needs to be provided by the configuration
      -   * author, as the remaining fields will be derived from the IDL during the
      -   * normalization process. It is an error to specify an API interface here
      -   * which cannot be resolved against the associated IDL files.
      -   * 
      - */ - public com.google.protobuf.Api getApis(int index) { - return apis_.get(index); - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -   * A list of API interfaces exported by this service. Only the `name` field
      -   * of the [google.protobuf.Api][] needs to be provided by the configuration
      -   * author, as the remaining fields will be derived from the IDL during the
      -   * normalization process. It is an error to specify an API interface here
      -   * which cannot be resolved against the associated IDL files.
      -   * 
      - */ - public com.google.protobuf.ApiOrBuilder getApisOrBuilder( - int index) { - return apis_.get(index); - } - - public static final int TYPES_FIELD_NUMBER = 4; - private java.util.List types_; - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -   * A list of all proto message types included in this API service.
      -   * Types referenced directly or indirectly by the `apis` are
      -   * automatically included.  Messages which are not referenced but
      -   * shall be included, such as types used by the `google.protobuf.Any` type,
      -   * should be listed here by name. Example:
      -   *     types:
      -   *     - name: google.protobuf.Int32
      -   * 
      - */ - public java.util.List getTypesList() { - return types_; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -   * A list of all proto message types included in this API service.
      -   * Types referenced directly or indirectly by the `apis` are
      -   * automatically included.  Messages which are not referenced but
      -   * shall be included, such as types used by the `google.protobuf.Any` type,
      -   * should be listed here by name. Example:
      -   *     types:
      -   *     - name: google.protobuf.Int32
      -   * 
      - */ - public java.util.List - getTypesOrBuilderList() { - return types_; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -   * A list of all proto message types included in this API service.
      -   * Types referenced directly or indirectly by the `apis` are
      -   * automatically included.  Messages which are not referenced but
      -   * shall be included, such as types used by the `google.protobuf.Any` type,
      -   * should be listed here by name. Example:
      -   *     types:
      -   *     - name: google.protobuf.Int32
      -   * 
      - */ - public int getTypesCount() { - return types_.size(); - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -   * A list of all proto message types included in this API service.
      -   * Types referenced directly or indirectly by the `apis` are
      -   * automatically included.  Messages which are not referenced but
      -   * shall be included, such as types used by the `google.protobuf.Any` type,
      -   * should be listed here by name. Example:
      -   *     types:
      -   *     - name: google.protobuf.Int32
      -   * 
      - */ - public com.google.protobuf.Type getTypes(int index) { - return types_.get(index); - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -   * A list of all proto message types included in this API service.
      -   * Types referenced directly or indirectly by the `apis` are
      -   * automatically included.  Messages which are not referenced but
      -   * shall be included, such as types used by the `google.protobuf.Any` type,
      -   * should be listed here by name. Example:
      -   *     types:
      -   *     - name: google.protobuf.Int32
      -   * 
      - */ - public com.google.protobuf.TypeOrBuilder getTypesOrBuilder( - int index) { - return types_.get(index); - } - - public static final int ENUMS_FIELD_NUMBER = 5; - private java.util.List enums_; - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -   * A list of all enum types included in this API service.  Enums
      -   * referenced directly or indirectly by the `apis` are automatically
      -   * included.  Enums which are not referenced but shall be included
      -   * should be listed here by name. Example:
      -   *     enums:
      -   *     - name: google.someapi.v1.SomeEnum
      -   * 
      - */ - public java.util.List getEnumsList() { - return enums_; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -   * A list of all enum types included in this API service.  Enums
      -   * referenced directly or indirectly by the `apis` are automatically
      -   * included.  Enums which are not referenced but shall be included
      -   * should be listed here by name. Example:
      -   *     enums:
      -   *     - name: google.someapi.v1.SomeEnum
      -   * 
      - */ - public java.util.List - getEnumsOrBuilderList() { - return enums_; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -   * A list of all enum types included in this API service.  Enums
      -   * referenced directly or indirectly by the `apis` are automatically
      -   * included.  Enums which are not referenced but shall be included
      -   * should be listed here by name. Example:
      -   *     enums:
      -   *     - name: google.someapi.v1.SomeEnum
      -   * 
      - */ - public int getEnumsCount() { - return enums_.size(); - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -   * A list of all enum types included in this API service.  Enums
      -   * referenced directly or indirectly by the `apis` are automatically
      -   * included.  Enums which are not referenced but shall be included
      -   * should be listed here by name. Example:
      -   *     enums:
      -   *     - name: google.someapi.v1.SomeEnum
      -   * 
      - */ - public com.google.protobuf.Enum getEnums(int index) { - return enums_.get(index); - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -   * A list of all enum types included in this API service.  Enums
      -   * referenced directly or indirectly by the `apis` are automatically
      -   * included.  Enums which are not referenced but shall be included
      -   * should be listed here by name. Example:
      -   *     enums:
      -   *     - name: google.someapi.v1.SomeEnum
      -   * 
      - */ - public com.google.protobuf.EnumOrBuilder getEnumsOrBuilder( - int index) { - return enums_.get(index); - } - - public static final int DOCUMENTATION_FIELD_NUMBER = 6; - private com.google.api.Documentation documentation_; - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -   * Additional API documentation.
      -   * 
      - */ - public boolean hasDocumentation() { - return documentation_ != null; - } - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -   * Additional API documentation.
      -   * 
      - */ - public com.google.api.Documentation getDocumentation() { - return documentation_ == null ? com.google.api.Documentation.getDefaultInstance() : documentation_; - } - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -   * Additional API documentation.
      -   * 
      - */ - public com.google.api.DocumentationOrBuilder getDocumentationOrBuilder() { - return getDocumentation(); - } - - public static final int VISIBILITY_FIELD_NUMBER = 7; - private com.google.api.Visibility visibility_; - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -   * API visibility configuration.
      -   * 
      - */ - public boolean hasVisibility() { - return visibility_ != null; - } - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -   * API visibility configuration.
      -   * 
      - */ - public com.google.api.Visibility getVisibility() { - return visibility_ == null ? com.google.api.Visibility.getDefaultInstance() : visibility_; - } - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -   * API visibility configuration.
      -   * 
      - */ - public com.google.api.VisibilityOrBuilder getVisibilityOrBuilder() { - return getVisibility(); - } - - public static final int HTTP_FIELD_NUMBER = 9; - private com.google.api.Http http_; - /** - * optional .google.api.Http http = 9; - * - *
      -   * HTTP configuration.
      -   * 
      - */ - public boolean hasHttp() { - return http_ != null; - } - /** - * optional .google.api.Http http = 9; - * - *
      -   * HTTP configuration.
      -   * 
      - */ - public com.google.api.Http getHttp() { - return http_ == null ? com.google.api.Http.getDefaultInstance() : http_; - } - /** - * optional .google.api.Http http = 9; - * - *
      -   * HTTP configuration.
      -   * 
      - */ - public com.google.api.HttpOrBuilder getHttpOrBuilder() { - return getHttp(); - } - - public static final int CONTEXT_FIELD_NUMBER = 12; - private com.google.api.Context context_; - /** - * optional .google.api.Context context = 12; - * - *
      -   * Context configuration.
      -   * 
      - */ - public boolean hasContext() { - return context_ != null; - } - /** - * optional .google.api.Context context = 12; - * - *
      -   * Context configuration.
      -   * 
      - */ - public com.google.api.Context getContext() { - return context_ == null ? com.google.api.Context.getDefaultInstance() : context_; - } - /** - * optional .google.api.Context context = 12; - * - *
      -   * Context configuration.
      -   * 
      - */ - public com.google.api.ContextOrBuilder getContextOrBuilder() { - return getContext(); - } - - public static final int CUSTOM_ERROR_FIELD_NUMBER = 16; - private com.google.api.CustomError customError_; - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -   * Custom error configuration.
      -   * 
      - */ - public boolean hasCustomError() { - return customError_ != null; - } - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -   * Custom error configuration.
      -   * 
      - */ - public com.google.api.CustomError getCustomError() { - return customError_ == null ? com.google.api.CustomError.getDefaultInstance() : customError_; - } - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -   * Custom error configuration.
      -   * 
      - */ - public com.google.api.CustomErrorOrBuilder getCustomErrorOrBuilder() { - return getCustomError(); - } - - public static final int DERIVED_DATA_FIELD_NUMBER = 100; - private com.google.protobuf.Any derivedData_; - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -   * Service attributes derived by the configuration toolchain, for
      -   * use at runtime.  Type is defined in
      -   * `//google/internal/api/derived_service.proto`.
      -   * 
      - */ - public boolean hasDerivedData() { - return derivedData_ != null; - } - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -   * Service attributes derived by the configuration toolchain, for
      -   * use at runtime.  Type is defined in
      -   * `//google/internal/api/derived_service.proto`.
      -   * 
      - */ - public com.google.protobuf.Any getDerivedData() { - return derivedData_ == null ? com.google.protobuf.Any.getDefaultInstance() : derivedData_; - } - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -   * Service attributes derived by the configuration toolchain, for
      -   * use at runtime.  Type is defined in
      -   * `//google/internal/api/derived_service.proto`.
      -   * 
      - */ - public com.google.protobuf.AnyOrBuilder getDerivedDataOrBuilder() { - return getDerivedData(); - } - - public static final int SYSTEM_TYPES_FIELD_NUMBER = 102; - private java.util.List systemTypes_; - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -   * A list of all proto message types included in this API service.
      -   * It serves similar purpose as [google.api.Service.types], except that
      -   * these types are not needed by user-defined APIs. Therefore, they will not
      -   * show up in the generated discovery doc. This field should only be used
      -   * to define system APIs in ESF.
      -   * 
      - */ - public java.util.List getSystemTypesList() { - return systemTypes_; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -   * A list of all proto message types included in this API service.
      -   * It serves similar purpose as [google.api.Service.types], except that
      -   * these types are not needed by user-defined APIs. Therefore, they will not
      -   * show up in the generated discovery doc. This field should only be used
      -   * to define system APIs in ESF.
      -   * 
      - */ - public java.util.List - getSystemTypesOrBuilderList() { - return systemTypes_; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -   * A list of all proto message types included in this API service.
      -   * It serves similar purpose as [google.api.Service.types], except that
      -   * these types are not needed by user-defined APIs. Therefore, they will not
      -   * show up in the generated discovery doc. This field should only be used
      -   * to define system APIs in ESF.
      -   * 
      - */ - public int getSystemTypesCount() { - return systemTypes_.size(); - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -   * A list of all proto message types included in this API service.
      -   * It serves similar purpose as [google.api.Service.types], except that
      -   * these types are not needed by user-defined APIs. Therefore, they will not
      -   * show up in the generated discovery doc. This field should only be used
      -   * to define system APIs in ESF.
      -   * 
      - */ - public com.google.protobuf.Type getSystemTypes(int index) { - return systemTypes_.get(index); - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -   * A list of all proto message types included in this API service.
      -   * It serves similar purpose as [google.api.Service.types], except that
      -   * these types are not needed by user-defined APIs. Therefore, they will not
      -   * show up in the generated discovery doc. This field should only be used
      -   * to define system APIs in ESF.
      -   * 
      - */ - public com.google.protobuf.TypeOrBuilder getSystemTypesOrBuilder( - int index) { - return systemTypes_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); - } - if (!getTitleBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, title_); - } - for (int i = 0; i < apis_.size(); i++) { - output.writeMessage(3, apis_.get(i)); - } - for (int i = 0; i < types_.size(); i++) { - output.writeMessage(4, types_.get(i)); - } - for (int i = 0; i < enums_.size(); i++) { - output.writeMessage(5, enums_.get(i)); - } - if (documentation_ != null) { - output.writeMessage(6, getDocumentation()); - } - if (visibility_ != null) { - output.writeMessage(7, getVisibility()); - } - if (http_ != null) { - output.writeMessage(9, getHttp()); - } - if (context_ != null) { - output.writeMessage(12, getContext()); - } - if (customError_ != null) { - output.writeMessage(16, getCustomError()); - } - if (configVersion_ != null) { - output.writeMessage(20, getConfigVersion()); - } - if (!getProducerProjectIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 22, producerProjectId_); - } - if (derivedData_ != null) { - output.writeMessage(100, getDerivedData()); - } - for (int i = 0; i < systemTypes_.size(); i++) { - output.writeMessage(102, systemTypes_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); - } - if (!getTitleBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, title_); - } - for (int i = 0; i < apis_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, apis_.get(i)); - } - for (int i = 0; i < types_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, types_.get(i)); - } - for (int i = 0; i < enums_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, enums_.get(i)); - } - if (documentation_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, getDocumentation()); - } - if (visibility_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(7, getVisibility()); - } - if (http_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(9, getHttp()); - } - if (context_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(12, getContext()); - } - if (customError_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(16, getCustomError()); - } - if (configVersion_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(20, getConfigVersion()); - } - if (!getProducerProjectIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(22, producerProjectId_); - } - if (derivedData_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(100, getDerivedData()); - } - for (int i = 0; i < systemTypes_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(102, systemTypes_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.Service parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Service parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Service parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Service parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Service parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Service parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.Service parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.Service parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.Service parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Service parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.Service prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.Service} - * - *
      -   * (== page basics ==)
      -   * `Service` is the root object of the configuration schema. It
      -   * describes basic information like the name of the service and the
      -   * exposed API interfaces, and delegates other aspects to configuration
      -   * sub-sections.
      -   * Example:
      -   *     type: google.api.Service
      -   *     config_version: 1
      -   *     name: calendar.googleapis.com
      -   *     title: Google Calendar API
      -   *     apis:
      -   *     - name: google.calendar.Calendar
      -   *     visibility:
      -   *       rules:
      -   *       - selector: "*"
      -   *         restriction: TRUSTED_TESTER
      -   *     backend:
      -   *       rules:
      -   *       - selector: "*"
      -   *         address: calendar-prod-backend.gslb.googleapis.com
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.Service) - com.google.api.ServiceOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.ServiceProto.internal_static_google_api_Service_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.ServiceProto.internal_static_google_api_Service_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Service.class, com.google.api.Service.Builder.class); - } - - // Construct using com.google.api.Service.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getApisFieldBuilder(); - getTypesFieldBuilder(); - getEnumsFieldBuilder(); - getSystemTypesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (configVersionBuilder_ == null) { - configVersion_ = null; - } else { - configVersion_ = null; - configVersionBuilder_ = null; - } - name_ = ""; - - title_ = ""; - - producerProjectId_ = ""; - - if (apisBuilder_ == null) { - apis_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - } else { - apisBuilder_.clear(); - } - if (typesBuilder_ == null) { - types_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000020); - } else { - typesBuilder_.clear(); - } - if (enumsBuilder_ == null) { - enums_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000040); - } else { - enumsBuilder_.clear(); - } - if (documentationBuilder_ == null) { - documentation_ = null; - } else { - documentation_ = null; - documentationBuilder_ = null; - } - if (visibilityBuilder_ == null) { - visibility_ = null; - } else { - visibility_ = null; - visibilityBuilder_ = null; - } - if (httpBuilder_ == null) { - http_ = null; - } else { - http_ = null; - httpBuilder_ = null; - } - if (contextBuilder_ == null) { - context_ = null; - } else { - context_ = null; - contextBuilder_ = null; - } - if (customErrorBuilder_ == null) { - customError_ = null; - } else { - customError_ = null; - customErrorBuilder_ = null; - } - if (derivedDataBuilder_ == null) { - derivedData_ = null; - } else { - derivedData_ = null; - derivedDataBuilder_ = null; - } - if (systemTypesBuilder_ == null) { - systemTypes_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00002000); - } else { - systemTypesBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.ServiceProto.internal_static_google_api_Service_descriptor; - } - - public com.google.api.Service getDefaultInstanceForType() { - return com.google.api.Service.getDefaultInstance(); - } - - public com.google.api.Service build() { - com.google.api.Service result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.Service buildPartial() { - com.google.api.Service result = new com.google.api.Service(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (configVersionBuilder_ == null) { - result.configVersion_ = configVersion_; - } else { - result.configVersion_ = configVersionBuilder_.build(); - } - result.name_ = name_; - result.title_ = title_; - result.producerProjectId_ = producerProjectId_; - if (apisBuilder_ == null) { - if (((bitField0_ & 0x00000010) == 0x00000010)) { - apis_ = java.util.Collections.unmodifiableList(apis_); - bitField0_ = (bitField0_ & ~0x00000010); - } - result.apis_ = apis_; - } else { - result.apis_ = apisBuilder_.build(); - } - if (typesBuilder_ == null) { - if (((bitField0_ & 0x00000020) == 0x00000020)) { - types_ = java.util.Collections.unmodifiableList(types_); - bitField0_ = (bitField0_ & ~0x00000020); - } - result.types_ = types_; - } else { - result.types_ = typesBuilder_.build(); - } - if (enumsBuilder_ == null) { - if (((bitField0_ & 0x00000040) == 0x00000040)) { - enums_ = java.util.Collections.unmodifiableList(enums_); - bitField0_ = (bitField0_ & ~0x00000040); - } - result.enums_ = enums_; - } else { - result.enums_ = enumsBuilder_.build(); - } - if (documentationBuilder_ == null) { - result.documentation_ = documentation_; - } else { - result.documentation_ = documentationBuilder_.build(); - } - if (visibilityBuilder_ == null) { - result.visibility_ = visibility_; - } else { - result.visibility_ = visibilityBuilder_.build(); - } - if (httpBuilder_ == null) { - result.http_ = http_; - } else { - result.http_ = httpBuilder_.build(); - } - if (contextBuilder_ == null) { - result.context_ = context_; - } else { - result.context_ = contextBuilder_.build(); - } - if (customErrorBuilder_ == null) { - result.customError_ = customError_; - } else { - result.customError_ = customErrorBuilder_.build(); - } - if (derivedDataBuilder_ == null) { - result.derivedData_ = derivedData_; - } else { - result.derivedData_ = derivedDataBuilder_.build(); - } - if (systemTypesBuilder_ == null) { - if (((bitField0_ & 0x00002000) == 0x00002000)) { - systemTypes_ = java.util.Collections.unmodifiableList(systemTypes_); - bitField0_ = (bitField0_ & ~0x00002000); - } - result.systemTypes_ = systemTypes_; - } else { - result.systemTypes_ = systemTypesBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.Service) { - return mergeFrom((com.google.api.Service)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.Service other) { - if (other == com.google.api.Service.getDefaultInstance()) return this; - if (other.hasConfigVersion()) { - mergeConfigVersion(other.getConfigVersion()); - } - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (!other.getTitle().isEmpty()) { - title_ = other.title_; - onChanged(); - } - if (!other.getProducerProjectId().isEmpty()) { - producerProjectId_ = other.producerProjectId_; - onChanged(); - } - if (apisBuilder_ == null) { - if (!other.apis_.isEmpty()) { - if (apis_.isEmpty()) { - apis_ = other.apis_; - bitField0_ = (bitField0_ & ~0x00000010); - } else { - ensureApisIsMutable(); - apis_.addAll(other.apis_); - } - onChanged(); - } - } else { - if (!other.apis_.isEmpty()) { - if (apisBuilder_.isEmpty()) { - apisBuilder_.dispose(); - apisBuilder_ = null; - apis_ = other.apis_; - bitField0_ = (bitField0_ & ~0x00000010); - apisBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getApisFieldBuilder() : null; - } else { - apisBuilder_.addAllMessages(other.apis_); - } - } - } - if (typesBuilder_ == null) { - if (!other.types_.isEmpty()) { - if (types_.isEmpty()) { - types_ = other.types_; - bitField0_ = (bitField0_ & ~0x00000020); - } else { - ensureTypesIsMutable(); - types_.addAll(other.types_); - } - onChanged(); - } - } else { - if (!other.types_.isEmpty()) { - if (typesBuilder_.isEmpty()) { - typesBuilder_.dispose(); - typesBuilder_ = null; - types_ = other.types_; - bitField0_ = (bitField0_ & ~0x00000020); - typesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getTypesFieldBuilder() : null; - } else { - typesBuilder_.addAllMessages(other.types_); - } - } - } - if (enumsBuilder_ == null) { - if (!other.enums_.isEmpty()) { - if (enums_.isEmpty()) { - enums_ = other.enums_; - bitField0_ = (bitField0_ & ~0x00000040); - } else { - ensureEnumsIsMutable(); - enums_.addAll(other.enums_); - } - onChanged(); - } - } else { - if (!other.enums_.isEmpty()) { - if (enumsBuilder_.isEmpty()) { - enumsBuilder_.dispose(); - enumsBuilder_ = null; - enums_ = other.enums_; - bitField0_ = (bitField0_ & ~0x00000040); - enumsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getEnumsFieldBuilder() : null; - } else { - enumsBuilder_.addAllMessages(other.enums_); - } - } - } - if (other.hasDocumentation()) { - mergeDocumentation(other.getDocumentation()); - } - if (other.hasVisibility()) { - mergeVisibility(other.getVisibility()); - } - if (other.hasHttp()) { - mergeHttp(other.getHttp()); - } - if (other.hasContext()) { - mergeContext(other.getContext()); - } - if (other.hasCustomError()) { - mergeCustomError(other.getCustomError()); - } - if (other.hasDerivedData()) { - mergeDerivedData(other.getDerivedData()); - } - if (systemTypesBuilder_ == null) { - if (!other.systemTypes_.isEmpty()) { - if (systemTypes_.isEmpty()) { - systemTypes_ = other.systemTypes_; - bitField0_ = (bitField0_ & ~0x00002000); - } else { - ensureSystemTypesIsMutable(); - systemTypes_.addAll(other.systemTypes_); - } - onChanged(); - } - } else { - if (!other.systemTypes_.isEmpty()) { - if (systemTypesBuilder_.isEmpty()) { - systemTypesBuilder_.dispose(); - systemTypesBuilder_ = null; - systemTypes_ = other.systemTypes_; - bitField0_ = (bitField0_ & ~0x00002000); - systemTypesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getSystemTypesFieldBuilder() : null; - } else { - systemTypesBuilder_.addAllMessages(other.systemTypes_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.Service parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.Service) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private com.google.protobuf.UInt32Value configVersion_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.UInt32Value, com.google.protobuf.UInt32Value.Builder, com.google.protobuf.UInt32ValueOrBuilder> configVersionBuilder_; - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -     * The version of the service configuration. The config version may
      -     * influence interpretation of the configuration, for example
      -     * determine defaults. This is documented together with applicable
      -     * options. The current default for the config version itself is `1`.
      -     * 
      - */ - public boolean hasConfigVersion() { - return configVersionBuilder_ != null || configVersion_ != null; - } - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -     * The version of the service configuration. The config version may
      -     * influence interpretation of the configuration, for example
      -     * determine defaults. This is documented together with applicable
      -     * options. The current default for the config version itself is `1`.
      -     * 
      - */ - public com.google.protobuf.UInt32Value getConfigVersion() { - if (configVersionBuilder_ == null) { - return configVersion_ == null ? com.google.protobuf.UInt32Value.getDefaultInstance() : configVersion_; - } else { - return configVersionBuilder_.getMessage(); - } - } - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -     * The version of the service configuration. The config version may
      -     * influence interpretation of the configuration, for example
      -     * determine defaults. This is documented together with applicable
      -     * options. The current default for the config version itself is `1`.
      -     * 
      - */ - public Builder setConfigVersion(com.google.protobuf.UInt32Value value) { - if (configVersionBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - configVersion_ = value; - onChanged(); - } else { - configVersionBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -     * The version of the service configuration. The config version may
      -     * influence interpretation of the configuration, for example
      -     * determine defaults. This is documented together with applicable
      -     * options. The current default for the config version itself is `1`.
      -     * 
      - */ - public Builder setConfigVersion( - com.google.protobuf.UInt32Value.Builder builderForValue) { - if (configVersionBuilder_ == null) { - configVersion_ = builderForValue.build(); - onChanged(); - } else { - configVersionBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -     * The version of the service configuration. The config version may
      -     * influence interpretation of the configuration, for example
      -     * determine defaults. This is documented together with applicable
      -     * options. The current default for the config version itself is `1`.
      -     * 
      - */ - public Builder mergeConfigVersion(com.google.protobuf.UInt32Value value) { - if (configVersionBuilder_ == null) { - if (configVersion_ != null) { - configVersion_ = - com.google.protobuf.UInt32Value.newBuilder(configVersion_).mergeFrom(value).buildPartial(); - } else { - configVersion_ = value; - } - onChanged(); - } else { - configVersionBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -     * The version of the service configuration. The config version may
      -     * influence interpretation of the configuration, for example
      -     * determine defaults. This is documented together with applicable
      -     * options. The current default for the config version itself is `1`.
      -     * 
      - */ - public Builder clearConfigVersion() { - if (configVersionBuilder_ == null) { - configVersion_ = null; - onChanged(); - } else { - configVersion_ = null; - configVersionBuilder_ = null; - } - - return this; - } - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -     * The version of the service configuration. The config version may
      -     * influence interpretation of the configuration, for example
      -     * determine defaults. This is documented together with applicable
      -     * options. The current default for the config version itself is `1`.
      -     * 
      - */ - public com.google.protobuf.UInt32Value.Builder getConfigVersionBuilder() { - - onChanged(); - return getConfigVersionFieldBuilder().getBuilder(); - } - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -     * The version of the service configuration. The config version may
      -     * influence interpretation of the configuration, for example
      -     * determine defaults. This is documented together with applicable
      -     * options. The current default for the config version itself is `1`.
      -     * 
      - */ - public com.google.protobuf.UInt32ValueOrBuilder getConfigVersionOrBuilder() { - if (configVersionBuilder_ != null) { - return configVersionBuilder_.getMessageOrBuilder(); - } else { - return configVersion_ == null ? - com.google.protobuf.UInt32Value.getDefaultInstance() : configVersion_; - } - } - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -     * The version of the service configuration. The config version may
      -     * influence interpretation of the configuration, for example
      -     * determine defaults. This is documented together with applicable
      -     * options. The current default for the config version itself is `1`.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.UInt32Value, com.google.protobuf.UInt32Value.Builder, com.google.protobuf.UInt32ValueOrBuilder> - getConfigVersionFieldBuilder() { - if (configVersionBuilder_ == null) { - configVersionBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.UInt32Value, com.google.protobuf.UInt32Value.Builder, com.google.protobuf.UInt32ValueOrBuilder>( - getConfigVersion(), - getParentForChildren(), - isClean()); - configVersion_ = null; - } - return configVersionBuilder_; - } - - private java.lang.Object name_ = ""; - /** - * optional string name = 1; - * - *
      -     * The DNS address at which this service is available,
      -     * e.g. `calendar.googleapis.com`.
      -     * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The DNS address at which this service is available,
      -     * e.g. `calendar.googleapis.com`.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The DNS address at which this service is available,
      -     * e.g. `calendar.googleapis.com`.
      -     * 
      - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The DNS address at which this service is available,
      -     * e.g. `calendar.googleapis.com`.
      -     * 
      - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The DNS address at which this service is available,
      -     * e.g. `calendar.googleapis.com`.
      -     * 
      - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private java.lang.Object title_ = ""; - /** - * optional string title = 2; - * - *
      -     * The product title associated with this service.
      -     * 
      - */ - public java.lang.String getTitle() { - java.lang.Object ref = title_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - title_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string title = 2; - * - *
      -     * The product title associated with this service.
      -     * 
      - */ - public com.google.protobuf.ByteString - getTitleBytes() { - java.lang.Object ref = title_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - title_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string title = 2; - * - *
      -     * The product title associated with this service.
      -     * 
      - */ - public Builder setTitle( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - title_ = value; - onChanged(); - return this; - } - /** - * optional string title = 2; - * - *
      -     * The product title associated with this service.
      -     * 
      - */ - public Builder clearTitle() { - - title_ = getDefaultInstance().getTitle(); - onChanged(); - return this; - } - /** - * optional string title = 2; - * - *
      -     * The product title associated with this service.
      -     * 
      - */ - public Builder setTitleBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - title_ = value; - onChanged(); - return this; - } - - private java.lang.Object producerProjectId_ = ""; - /** - * optional string producer_project_id = 22; - * - *
      -     * The id of the Google developer project that owns the service.
      -     * Members of this project can manage the service configuration,
      -     * manage consumption of the service, etc.
      -     * 
      - */ - public java.lang.String getProducerProjectId() { - java.lang.Object ref = producerProjectId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - producerProjectId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string producer_project_id = 22; - * - *
      -     * The id of the Google developer project that owns the service.
      -     * Members of this project can manage the service configuration,
      -     * manage consumption of the service, etc.
      -     * 
      - */ - public com.google.protobuf.ByteString - getProducerProjectIdBytes() { - java.lang.Object ref = producerProjectId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - producerProjectId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string producer_project_id = 22; - * - *
      -     * The id of the Google developer project that owns the service.
      -     * Members of this project can manage the service configuration,
      -     * manage consumption of the service, etc.
      -     * 
      - */ - public Builder setProducerProjectId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - producerProjectId_ = value; - onChanged(); - return this; - } - /** - * optional string producer_project_id = 22; - * - *
      -     * The id of the Google developer project that owns the service.
      -     * Members of this project can manage the service configuration,
      -     * manage consumption of the service, etc.
      -     * 
      - */ - public Builder clearProducerProjectId() { - - producerProjectId_ = getDefaultInstance().getProducerProjectId(); - onChanged(); - return this; - } - /** - * optional string producer_project_id = 22; - * - *
      -     * The id of the Google developer project that owns the service.
      -     * Members of this project can manage the service configuration,
      -     * manage consumption of the service, etc.
      -     * 
      - */ - public Builder setProducerProjectIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - producerProjectId_ = value; - onChanged(); - return this; - } - - private java.util.List apis_ = - java.util.Collections.emptyList(); - private void ensureApisIsMutable() { - if (!((bitField0_ & 0x00000010) == 0x00000010)) { - apis_ = new java.util.ArrayList(apis_); - bitField0_ |= 0x00000010; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Api, com.google.protobuf.Api.Builder, com.google.protobuf.ApiOrBuilder> apisBuilder_; - - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public java.util.List getApisList() { - if (apisBuilder_ == null) { - return java.util.Collections.unmodifiableList(apis_); - } else { - return apisBuilder_.getMessageList(); - } - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public int getApisCount() { - if (apisBuilder_ == null) { - return apis_.size(); - } else { - return apisBuilder_.getCount(); - } - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public com.google.protobuf.Api getApis(int index) { - if (apisBuilder_ == null) { - return apis_.get(index); - } else { - return apisBuilder_.getMessage(index); - } - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public Builder setApis( - int index, com.google.protobuf.Api value) { - if (apisBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureApisIsMutable(); - apis_.set(index, value); - onChanged(); - } else { - apisBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public Builder setApis( - int index, com.google.protobuf.Api.Builder builderForValue) { - if (apisBuilder_ == null) { - ensureApisIsMutable(); - apis_.set(index, builderForValue.build()); - onChanged(); - } else { - apisBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public Builder addApis(com.google.protobuf.Api value) { - if (apisBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureApisIsMutable(); - apis_.add(value); - onChanged(); - } else { - apisBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public Builder addApis( - int index, com.google.protobuf.Api value) { - if (apisBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureApisIsMutable(); - apis_.add(index, value); - onChanged(); - } else { - apisBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public Builder addApis( - com.google.protobuf.Api.Builder builderForValue) { - if (apisBuilder_ == null) { - ensureApisIsMutable(); - apis_.add(builderForValue.build()); - onChanged(); - } else { - apisBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public Builder addApis( - int index, com.google.protobuf.Api.Builder builderForValue) { - if (apisBuilder_ == null) { - ensureApisIsMutable(); - apis_.add(index, builderForValue.build()); - onChanged(); - } else { - apisBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public Builder addAllApis( - java.lang.Iterable values) { - if (apisBuilder_ == null) { - ensureApisIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, apis_); - onChanged(); - } else { - apisBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public Builder clearApis() { - if (apisBuilder_ == null) { - apis_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - onChanged(); - } else { - apisBuilder_.clear(); - } - return this; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public Builder removeApis(int index) { - if (apisBuilder_ == null) { - ensureApisIsMutable(); - apis_.remove(index); - onChanged(); - } else { - apisBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public com.google.protobuf.Api.Builder getApisBuilder( - int index) { - return getApisFieldBuilder().getBuilder(index); - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public com.google.protobuf.ApiOrBuilder getApisOrBuilder( - int index) { - if (apisBuilder_ == null) { - return apis_.get(index); } else { - return apisBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public java.util.List - getApisOrBuilderList() { - if (apisBuilder_ != null) { - return apisBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(apis_); - } - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public com.google.protobuf.Api.Builder addApisBuilder() { - return getApisFieldBuilder().addBuilder( - com.google.protobuf.Api.getDefaultInstance()); - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public com.google.protobuf.Api.Builder addApisBuilder( - int index) { - return getApisFieldBuilder().addBuilder( - index, com.google.protobuf.Api.getDefaultInstance()); - } - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -     * A list of API interfaces exported by this service. Only the `name` field
      -     * of the [google.protobuf.Api][] needs to be provided by the configuration
      -     * author, as the remaining fields will be derived from the IDL during the
      -     * normalization process. It is an error to specify an API interface here
      -     * which cannot be resolved against the associated IDL files.
      -     * 
      - */ - public java.util.List - getApisBuilderList() { - return getApisFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Api, com.google.protobuf.Api.Builder, com.google.protobuf.ApiOrBuilder> - getApisFieldBuilder() { - if (apisBuilder_ == null) { - apisBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Api, com.google.protobuf.Api.Builder, com.google.protobuf.ApiOrBuilder>( - apis_, - ((bitField0_ & 0x00000010) == 0x00000010), - getParentForChildren(), - isClean()); - apis_ = null; - } - return apisBuilder_; - } - - private java.util.List types_ = - java.util.Collections.emptyList(); - private void ensureTypesIsMutable() { - if (!((bitField0_ & 0x00000020) == 0x00000020)) { - types_ = new java.util.ArrayList(types_); - bitField0_ |= 0x00000020; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder> typesBuilder_; - - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public java.util.List getTypesList() { - if (typesBuilder_ == null) { - return java.util.Collections.unmodifiableList(types_); - } else { - return typesBuilder_.getMessageList(); - } - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public int getTypesCount() { - if (typesBuilder_ == null) { - return types_.size(); - } else { - return typesBuilder_.getCount(); - } - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public com.google.protobuf.Type getTypes(int index) { - if (typesBuilder_ == null) { - return types_.get(index); - } else { - return typesBuilder_.getMessage(index); - } - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public Builder setTypes( - int index, com.google.protobuf.Type value) { - if (typesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTypesIsMutable(); - types_.set(index, value); - onChanged(); - } else { - typesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public Builder setTypes( - int index, com.google.protobuf.Type.Builder builderForValue) { - if (typesBuilder_ == null) { - ensureTypesIsMutable(); - types_.set(index, builderForValue.build()); - onChanged(); - } else { - typesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public Builder addTypes(com.google.protobuf.Type value) { - if (typesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTypesIsMutable(); - types_.add(value); - onChanged(); - } else { - typesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public Builder addTypes( - int index, com.google.protobuf.Type value) { - if (typesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTypesIsMutable(); - types_.add(index, value); - onChanged(); - } else { - typesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public Builder addTypes( - com.google.protobuf.Type.Builder builderForValue) { - if (typesBuilder_ == null) { - ensureTypesIsMutable(); - types_.add(builderForValue.build()); - onChanged(); - } else { - typesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public Builder addTypes( - int index, com.google.protobuf.Type.Builder builderForValue) { - if (typesBuilder_ == null) { - ensureTypesIsMutable(); - types_.add(index, builderForValue.build()); - onChanged(); - } else { - typesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public Builder addAllTypes( - java.lang.Iterable values) { - if (typesBuilder_ == null) { - ensureTypesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, types_); - onChanged(); - } else { - typesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public Builder clearTypes() { - if (typesBuilder_ == null) { - types_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000020); - onChanged(); - } else { - typesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public Builder removeTypes(int index) { - if (typesBuilder_ == null) { - ensureTypesIsMutable(); - types_.remove(index); - onChanged(); - } else { - typesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public com.google.protobuf.Type.Builder getTypesBuilder( - int index) { - return getTypesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public com.google.protobuf.TypeOrBuilder getTypesOrBuilder( - int index) { - if (typesBuilder_ == null) { - return types_.get(index); } else { - return typesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public java.util.List - getTypesOrBuilderList() { - if (typesBuilder_ != null) { - return typesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(types_); - } - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public com.google.protobuf.Type.Builder addTypesBuilder() { - return getTypesFieldBuilder().addBuilder( - com.google.protobuf.Type.getDefaultInstance()); - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public com.google.protobuf.Type.Builder addTypesBuilder( - int index) { - return getTypesFieldBuilder().addBuilder( - index, com.google.protobuf.Type.getDefaultInstance()); - } - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -     * A list of all proto message types included in this API service.
      -     * Types referenced directly or indirectly by the `apis` are
      -     * automatically included.  Messages which are not referenced but
      -     * shall be included, such as types used by the `google.protobuf.Any` type,
      -     * should be listed here by name. Example:
      -     *     types:
      -     *     - name: google.protobuf.Int32
      -     * 
      - */ - public java.util.List - getTypesBuilderList() { - return getTypesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder> - getTypesFieldBuilder() { - if (typesBuilder_ == null) { - typesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder>( - types_, - ((bitField0_ & 0x00000020) == 0x00000020), - getParentForChildren(), - isClean()); - types_ = null; - } - return typesBuilder_; - } - - private java.util.List enums_ = - java.util.Collections.emptyList(); - private void ensureEnumsIsMutable() { - if (!((bitField0_ & 0x00000040) == 0x00000040)) { - enums_ = new java.util.ArrayList(enums_); - bitField0_ |= 0x00000040; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Enum, com.google.protobuf.Enum.Builder, com.google.protobuf.EnumOrBuilder> enumsBuilder_; - - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public java.util.List getEnumsList() { - if (enumsBuilder_ == null) { - return java.util.Collections.unmodifiableList(enums_); - } else { - return enumsBuilder_.getMessageList(); - } - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public int getEnumsCount() { - if (enumsBuilder_ == null) { - return enums_.size(); - } else { - return enumsBuilder_.getCount(); - } - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public com.google.protobuf.Enum getEnums(int index) { - if (enumsBuilder_ == null) { - return enums_.get(index); - } else { - return enumsBuilder_.getMessage(index); - } - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public Builder setEnums( - int index, com.google.protobuf.Enum value) { - if (enumsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureEnumsIsMutable(); - enums_.set(index, value); - onChanged(); - } else { - enumsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public Builder setEnums( - int index, com.google.protobuf.Enum.Builder builderForValue) { - if (enumsBuilder_ == null) { - ensureEnumsIsMutable(); - enums_.set(index, builderForValue.build()); - onChanged(); - } else { - enumsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public Builder addEnums(com.google.protobuf.Enum value) { - if (enumsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureEnumsIsMutable(); - enums_.add(value); - onChanged(); - } else { - enumsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public Builder addEnums( - int index, com.google.protobuf.Enum value) { - if (enumsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureEnumsIsMutable(); - enums_.add(index, value); - onChanged(); - } else { - enumsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public Builder addEnums( - com.google.protobuf.Enum.Builder builderForValue) { - if (enumsBuilder_ == null) { - ensureEnumsIsMutable(); - enums_.add(builderForValue.build()); - onChanged(); - } else { - enumsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public Builder addEnums( - int index, com.google.protobuf.Enum.Builder builderForValue) { - if (enumsBuilder_ == null) { - ensureEnumsIsMutable(); - enums_.add(index, builderForValue.build()); - onChanged(); - } else { - enumsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public Builder addAllEnums( - java.lang.Iterable values) { - if (enumsBuilder_ == null) { - ensureEnumsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, enums_); - onChanged(); - } else { - enumsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public Builder clearEnums() { - if (enumsBuilder_ == null) { - enums_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000040); - onChanged(); - } else { - enumsBuilder_.clear(); - } - return this; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public Builder removeEnums(int index) { - if (enumsBuilder_ == null) { - ensureEnumsIsMutable(); - enums_.remove(index); - onChanged(); - } else { - enumsBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public com.google.protobuf.Enum.Builder getEnumsBuilder( - int index) { - return getEnumsFieldBuilder().getBuilder(index); - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public com.google.protobuf.EnumOrBuilder getEnumsOrBuilder( - int index) { - if (enumsBuilder_ == null) { - return enums_.get(index); } else { - return enumsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public java.util.List - getEnumsOrBuilderList() { - if (enumsBuilder_ != null) { - return enumsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(enums_); - } - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public com.google.protobuf.Enum.Builder addEnumsBuilder() { - return getEnumsFieldBuilder().addBuilder( - com.google.protobuf.Enum.getDefaultInstance()); - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public com.google.protobuf.Enum.Builder addEnumsBuilder( - int index) { - return getEnumsFieldBuilder().addBuilder( - index, com.google.protobuf.Enum.getDefaultInstance()); - } - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -     * A list of all enum types included in this API service.  Enums
      -     * referenced directly or indirectly by the `apis` are automatically
      -     * included.  Enums which are not referenced but shall be included
      -     * should be listed here by name. Example:
      -     *     enums:
      -     *     - name: google.someapi.v1.SomeEnum
      -     * 
      - */ - public java.util.List - getEnumsBuilderList() { - return getEnumsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Enum, com.google.protobuf.Enum.Builder, com.google.protobuf.EnumOrBuilder> - getEnumsFieldBuilder() { - if (enumsBuilder_ == null) { - enumsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Enum, com.google.protobuf.Enum.Builder, com.google.protobuf.EnumOrBuilder>( - enums_, - ((bitField0_ & 0x00000040) == 0x00000040), - getParentForChildren(), - isClean()); - enums_ = null; - } - return enumsBuilder_; - } - - private com.google.api.Documentation documentation_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.api.Documentation, com.google.api.Documentation.Builder, com.google.api.DocumentationOrBuilder> documentationBuilder_; - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -     * Additional API documentation.
      -     * 
      - */ - public boolean hasDocumentation() { - return documentationBuilder_ != null || documentation_ != null; - } - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -     * Additional API documentation.
      -     * 
      - */ - public com.google.api.Documentation getDocumentation() { - if (documentationBuilder_ == null) { - return documentation_ == null ? com.google.api.Documentation.getDefaultInstance() : documentation_; - } else { - return documentationBuilder_.getMessage(); - } - } - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -     * Additional API documentation.
      -     * 
      - */ - public Builder setDocumentation(com.google.api.Documentation value) { - if (documentationBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - documentation_ = value; - onChanged(); - } else { - documentationBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -     * Additional API documentation.
      -     * 
      - */ - public Builder setDocumentation( - com.google.api.Documentation.Builder builderForValue) { - if (documentationBuilder_ == null) { - documentation_ = builderForValue.build(); - onChanged(); - } else { - documentationBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -     * Additional API documentation.
      -     * 
      - */ - public Builder mergeDocumentation(com.google.api.Documentation value) { - if (documentationBuilder_ == null) { - if (documentation_ != null) { - documentation_ = - com.google.api.Documentation.newBuilder(documentation_).mergeFrom(value).buildPartial(); - } else { - documentation_ = value; - } - onChanged(); - } else { - documentationBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -     * Additional API documentation.
      -     * 
      - */ - public Builder clearDocumentation() { - if (documentationBuilder_ == null) { - documentation_ = null; - onChanged(); - } else { - documentation_ = null; - documentationBuilder_ = null; - } - - return this; - } - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -     * Additional API documentation.
      -     * 
      - */ - public com.google.api.Documentation.Builder getDocumentationBuilder() { - - onChanged(); - return getDocumentationFieldBuilder().getBuilder(); - } - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -     * Additional API documentation.
      -     * 
      - */ - public com.google.api.DocumentationOrBuilder getDocumentationOrBuilder() { - if (documentationBuilder_ != null) { - return documentationBuilder_.getMessageOrBuilder(); - } else { - return documentation_ == null ? - com.google.api.Documentation.getDefaultInstance() : documentation_; - } - } - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -     * Additional API documentation.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.api.Documentation, com.google.api.Documentation.Builder, com.google.api.DocumentationOrBuilder> - getDocumentationFieldBuilder() { - if (documentationBuilder_ == null) { - documentationBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.api.Documentation, com.google.api.Documentation.Builder, com.google.api.DocumentationOrBuilder>( - getDocumentation(), - getParentForChildren(), - isClean()); - documentation_ = null; - } - return documentationBuilder_; - } - - private com.google.api.Visibility visibility_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.api.Visibility, com.google.api.Visibility.Builder, com.google.api.VisibilityOrBuilder> visibilityBuilder_; - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -     * API visibility configuration.
      -     * 
      - */ - public boolean hasVisibility() { - return visibilityBuilder_ != null || visibility_ != null; - } - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -     * API visibility configuration.
      -     * 
      - */ - public com.google.api.Visibility getVisibility() { - if (visibilityBuilder_ == null) { - return visibility_ == null ? com.google.api.Visibility.getDefaultInstance() : visibility_; - } else { - return visibilityBuilder_.getMessage(); - } - } - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -     * API visibility configuration.
      -     * 
      - */ - public Builder setVisibility(com.google.api.Visibility value) { - if (visibilityBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - visibility_ = value; - onChanged(); - } else { - visibilityBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -     * API visibility configuration.
      -     * 
      - */ - public Builder setVisibility( - com.google.api.Visibility.Builder builderForValue) { - if (visibilityBuilder_ == null) { - visibility_ = builderForValue.build(); - onChanged(); - } else { - visibilityBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -     * API visibility configuration.
      -     * 
      - */ - public Builder mergeVisibility(com.google.api.Visibility value) { - if (visibilityBuilder_ == null) { - if (visibility_ != null) { - visibility_ = - com.google.api.Visibility.newBuilder(visibility_).mergeFrom(value).buildPartial(); - } else { - visibility_ = value; - } - onChanged(); - } else { - visibilityBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -     * API visibility configuration.
      -     * 
      - */ - public Builder clearVisibility() { - if (visibilityBuilder_ == null) { - visibility_ = null; - onChanged(); - } else { - visibility_ = null; - visibilityBuilder_ = null; - } - - return this; - } - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -     * API visibility configuration.
      -     * 
      - */ - public com.google.api.Visibility.Builder getVisibilityBuilder() { - - onChanged(); - return getVisibilityFieldBuilder().getBuilder(); - } - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -     * API visibility configuration.
      -     * 
      - */ - public com.google.api.VisibilityOrBuilder getVisibilityOrBuilder() { - if (visibilityBuilder_ != null) { - return visibilityBuilder_.getMessageOrBuilder(); - } else { - return visibility_ == null ? - com.google.api.Visibility.getDefaultInstance() : visibility_; - } - } - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -     * API visibility configuration.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.api.Visibility, com.google.api.Visibility.Builder, com.google.api.VisibilityOrBuilder> - getVisibilityFieldBuilder() { - if (visibilityBuilder_ == null) { - visibilityBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.api.Visibility, com.google.api.Visibility.Builder, com.google.api.VisibilityOrBuilder>( - getVisibility(), - getParentForChildren(), - isClean()); - visibility_ = null; - } - return visibilityBuilder_; - } - - private com.google.api.Http http_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.api.Http, com.google.api.Http.Builder, com.google.api.HttpOrBuilder> httpBuilder_; - /** - * optional .google.api.Http http = 9; - * - *
      -     * HTTP configuration.
      -     * 
      - */ - public boolean hasHttp() { - return httpBuilder_ != null || http_ != null; - } - /** - * optional .google.api.Http http = 9; - * - *
      -     * HTTP configuration.
      -     * 
      - */ - public com.google.api.Http getHttp() { - if (httpBuilder_ == null) { - return http_ == null ? com.google.api.Http.getDefaultInstance() : http_; - } else { - return httpBuilder_.getMessage(); - } - } - /** - * optional .google.api.Http http = 9; - * - *
      -     * HTTP configuration.
      -     * 
      - */ - public Builder setHttp(com.google.api.Http value) { - if (httpBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - http_ = value; - onChanged(); - } else { - httpBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.api.Http http = 9; - * - *
      -     * HTTP configuration.
      -     * 
      - */ - public Builder setHttp( - com.google.api.Http.Builder builderForValue) { - if (httpBuilder_ == null) { - http_ = builderForValue.build(); - onChanged(); - } else { - httpBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.api.Http http = 9; - * - *
      -     * HTTP configuration.
      -     * 
      - */ - public Builder mergeHttp(com.google.api.Http value) { - if (httpBuilder_ == null) { - if (http_ != null) { - http_ = - com.google.api.Http.newBuilder(http_).mergeFrom(value).buildPartial(); - } else { - http_ = value; - } - onChanged(); - } else { - httpBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.api.Http http = 9; - * - *
      -     * HTTP configuration.
      -     * 
      - */ - public Builder clearHttp() { - if (httpBuilder_ == null) { - http_ = null; - onChanged(); - } else { - http_ = null; - httpBuilder_ = null; - } - - return this; - } - /** - * optional .google.api.Http http = 9; - * - *
      -     * HTTP configuration.
      -     * 
      - */ - public com.google.api.Http.Builder getHttpBuilder() { - - onChanged(); - return getHttpFieldBuilder().getBuilder(); - } - /** - * optional .google.api.Http http = 9; - * - *
      -     * HTTP configuration.
      -     * 
      - */ - public com.google.api.HttpOrBuilder getHttpOrBuilder() { - if (httpBuilder_ != null) { - return httpBuilder_.getMessageOrBuilder(); - } else { - return http_ == null ? - com.google.api.Http.getDefaultInstance() : http_; - } - } - /** - * optional .google.api.Http http = 9; - * - *
      -     * HTTP configuration.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.api.Http, com.google.api.Http.Builder, com.google.api.HttpOrBuilder> - getHttpFieldBuilder() { - if (httpBuilder_ == null) { - httpBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.api.Http, com.google.api.Http.Builder, com.google.api.HttpOrBuilder>( - getHttp(), - getParentForChildren(), - isClean()); - http_ = null; - } - return httpBuilder_; - } - - private com.google.api.Context context_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.api.Context, com.google.api.Context.Builder, com.google.api.ContextOrBuilder> contextBuilder_; - /** - * optional .google.api.Context context = 12; - * - *
      -     * Context configuration.
      -     * 
      - */ - public boolean hasContext() { - return contextBuilder_ != null || context_ != null; - } - /** - * optional .google.api.Context context = 12; - * - *
      -     * Context configuration.
      -     * 
      - */ - public com.google.api.Context getContext() { - if (contextBuilder_ == null) { - return context_ == null ? com.google.api.Context.getDefaultInstance() : context_; - } else { - return contextBuilder_.getMessage(); - } - } - /** - * optional .google.api.Context context = 12; - * - *
      -     * Context configuration.
      -     * 
      - */ - public Builder setContext(com.google.api.Context value) { - if (contextBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - context_ = value; - onChanged(); - } else { - contextBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.api.Context context = 12; - * - *
      -     * Context configuration.
      -     * 
      - */ - public Builder setContext( - com.google.api.Context.Builder builderForValue) { - if (contextBuilder_ == null) { - context_ = builderForValue.build(); - onChanged(); - } else { - contextBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.api.Context context = 12; - * - *
      -     * Context configuration.
      -     * 
      - */ - public Builder mergeContext(com.google.api.Context value) { - if (contextBuilder_ == null) { - if (context_ != null) { - context_ = - com.google.api.Context.newBuilder(context_).mergeFrom(value).buildPartial(); - } else { - context_ = value; - } - onChanged(); - } else { - contextBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.api.Context context = 12; - * - *
      -     * Context configuration.
      -     * 
      - */ - public Builder clearContext() { - if (contextBuilder_ == null) { - context_ = null; - onChanged(); - } else { - context_ = null; - contextBuilder_ = null; - } - - return this; - } - /** - * optional .google.api.Context context = 12; - * - *
      -     * Context configuration.
      -     * 
      - */ - public com.google.api.Context.Builder getContextBuilder() { - - onChanged(); - return getContextFieldBuilder().getBuilder(); - } - /** - * optional .google.api.Context context = 12; - * - *
      -     * Context configuration.
      -     * 
      - */ - public com.google.api.ContextOrBuilder getContextOrBuilder() { - if (contextBuilder_ != null) { - return contextBuilder_.getMessageOrBuilder(); - } else { - return context_ == null ? - com.google.api.Context.getDefaultInstance() : context_; - } - } - /** - * optional .google.api.Context context = 12; - * - *
      -     * Context configuration.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.api.Context, com.google.api.Context.Builder, com.google.api.ContextOrBuilder> - getContextFieldBuilder() { - if (contextBuilder_ == null) { - contextBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.api.Context, com.google.api.Context.Builder, com.google.api.ContextOrBuilder>( - getContext(), - getParentForChildren(), - isClean()); - context_ = null; - } - return contextBuilder_; - } - - private com.google.api.CustomError customError_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.api.CustomError, com.google.api.CustomError.Builder, com.google.api.CustomErrorOrBuilder> customErrorBuilder_; - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -     * Custom error configuration.
      -     * 
      - */ - public boolean hasCustomError() { - return customErrorBuilder_ != null || customError_ != null; - } - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -     * Custom error configuration.
      -     * 
      - */ - public com.google.api.CustomError getCustomError() { - if (customErrorBuilder_ == null) { - return customError_ == null ? com.google.api.CustomError.getDefaultInstance() : customError_; - } else { - return customErrorBuilder_.getMessage(); - } - } - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -     * Custom error configuration.
      -     * 
      - */ - public Builder setCustomError(com.google.api.CustomError value) { - if (customErrorBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - customError_ = value; - onChanged(); - } else { - customErrorBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -     * Custom error configuration.
      -     * 
      - */ - public Builder setCustomError( - com.google.api.CustomError.Builder builderForValue) { - if (customErrorBuilder_ == null) { - customError_ = builderForValue.build(); - onChanged(); - } else { - customErrorBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -     * Custom error configuration.
      -     * 
      - */ - public Builder mergeCustomError(com.google.api.CustomError value) { - if (customErrorBuilder_ == null) { - if (customError_ != null) { - customError_ = - com.google.api.CustomError.newBuilder(customError_).mergeFrom(value).buildPartial(); - } else { - customError_ = value; - } - onChanged(); - } else { - customErrorBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -     * Custom error configuration.
      -     * 
      - */ - public Builder clearCustomError() { - if (customErrorBuilder_ == null) { - customError_ = null; - onChanged(); - } else { - customError_ = null; - customErrorBuilder_ = null; - } - - return this; - } - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -     * Custom error configuration.
      -     * 
      - */ - public com.google.api.CustomError.Builder getCustomErrorBuilder() { - - onChanged(); - return getCustomErrorFieldBuilder().getBuilder(); - } - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -     * Custom error configuration.
      -     * 
      - */ - public com.google.api.CustomErrorOrBuilder getCustomErrorOrBuilder() { - if (customErrorBuilder_ != null) { - return customErrorBuilder_.getMessageOrBuilder(); - } else { - return customError_ == null ? - com.google.api.CustomError.getDefaultInstance() : customError_; - } - } - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -     * Custom error configuration.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.api.CustomError, com.google.api.CustomError.Builder, com.google.api.CustomErrorOrBuilder> - getCustomErrorFieldBuilder() { - if (customErrorBuilder_ == null) { - customErrorBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.api.CustomError, com.google.api.CustomError.Builder, com.google.api.CustomErrorOrBuilder>( - getCustomError(), - getParentForChildren(), - isClean()); - customError_ = null; - } - return customErrorBuilder_; - } - - private com.google.protobuf.Any derivedData_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> derivedDataBuilder_; - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -     * Service attributes derived by the configuration toolchain, for
      -     * use at runtime.  Type is defined in
      -     * `//google/internal/api/derived_service.proto`.
      -     * 
      - */ - public boolean hasDerivedData() { - return derivedDataBuilder_ != null || derivedData_ != null; - } - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -     * Service attributes derived by the configuration toolchain, for
      -     * use at runtime.  Type is defined in
      -     * `//google/internal/api/derived_service.proto`.
      -     * 
      - */ - public com.google.protobuf.Any getDerivedData() { - if (derivedDataBuilder_ == null) { - return derivedData_ == null ? com.google.protobuf.Any.getDefaultInstance() : derivedData_; - } else { - return derivedDataBuilder_.getMessage(); - } - } - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -     * Service attributes derived by the configuration toolchain, for
      -     * use at runtime.  Type is defined in
      -     * `//google/internal/api/derived_service.proto`.
      -     * 
      - */ - public Builder setDerivedData(com.google.protobuf.Any value) { - if (derivedDataBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - derivedData_ = value; - onChanged(); - } else { - derivedDataBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -     * Service attributes derived by the configuration toolchain, for
      -     * use at runtime.  Type is defined in
      -     * `//google/internal/api/derived_service.proto`.
      -     * 
      - */ - public Builder setDerivedData( - com.google.protobuf.Any.Builder builderForValue) { - if (derivedDataBuilder_ == null) { - derivedData_ = builderForValue.build(); - onChanged(); - } else { - derivedDataBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -     * Service attributes derived by the configuration toolchain, for
      -     * use at runtime.  Type is defined in
      -     * `//google/internal/api/derived_service.proto`.
      -     * 
      - */ - public Builder mergeDerivedData(com.google.protobuf.Any value) { - if (derivedDataBuilder_ == null) { - if (derivedData_ != null) { - derivedData_ = - com.google.protobuf.Any.newBuilder(derivedData_).mergeFrom(value).buildPartial(); - } else { - derivedData_ = value; - } - onChanged(); - } else { - derivedDataBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -     * Service attributes derived by the configuration toolchain, for
      -     * use at runtime.  Type is defined in
      -     * `//google/internal/api/derived_service.proto`.
      -     * 
      - */ - public Builder clearDerivedData() { - if (derivedDataBuilder_ == null) { - derivedData_ = null; - onChanged(); - } else { - derivedData_ = null; - derivedDataBuilder_ = null; - } - - return this; - } - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -     * Service attributes derived by the configuration toolchain, for
      -     * use at runtime.  Type is defined in
      -     * `//google/internal/api/derived_service.proto`.
      -     * 
      - */ - public com.google.protobuf.Any.Builder getDerivedDataBuilder() { - - onChanged(); - return getDerivedDataFieldBuilder().getBuilder(); - } - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -     * Service attributes derived by the configuration toolchain, for
      -     * use at runtime.  Type is defined in
      -     * `//google/internal/api/derived_service.proto`.
      -     * 
      - */ - public com.google.protobuf.AnyOrBuilder getDerivedDataOrBuilder() { - if (derivedDataBuilder_ != null) { - return derivedDataBuilder_.getMessageOrBuilder(); - } else { - return derivedData_ == null ? - com.google.protobuf.Any.getDefaultInstance() : derivedData_; - } - } - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -     * Service attributes derived by the configuration toolchain, for
      -     * use at runtime.  Type is defined in
      -     * `//google/internal/api/derived_service.proto`.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> - getDerivedDataFieldBuilder() { - if (derivedDataBuilder_ == null) { - derivedDataBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>( - getDerivedData(), - getParentForChildren(), - isClean()); - derivedData_ = null; - } - return derivedDataBuilder_; - } - - private java.util.List systemTypes_ = - java.util.Collections.emptyList(); - private void ensureSystemTypesIsMutable() { - if (!((bitField0_ & 0x00002000) == 0x00002000)) { - systemTypes_ = new java.util.ArrayList(systemTypes_); - bitField0_ |= 0x00002000; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder> systemTypesBuilder_; - - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public java.util.List getSystemTypesList() { - if (systemTypesBuilder_ == null) { - return java.util.Collections.unmodifiableList(systemTypes_); - } else { - return systemTypesBuilder_.getMessageList(); - } - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public int getSystemTypesCount() { - if (systemTypesBuilder_ == null) { - return systemTypes_.size(); - } else { - return systemTypesBuilder_.getCount(); - } - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public com.google.protobuf.Type getSystemTypes(int index) { - if (systemTypesBuilder_ == null) { - return systemTypes_.get(index); - } else { - return systemTypesBuilder_.getMessage(index); - } - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public Builder setSystemTypes( - int index, com.google.protobuf.Type value) { - if (systemTypesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSystemTypesIsMutable(); - systemTypes_.set(index, value); - onChanged(); - } else { - systemTypesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public Builder setSystemTypes( - int index, com.google.protobuf.Type.Builder builderForValue) { - if (systemTypesBuilder_ == null) { - ensureSystemTypesIsMutable(); - systemTypes_.set(index, builderForValue.build()); - onChanged(); - } else { - systemTypesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public Builder addSystemTypes(com.google.protobuf.Type value) { - if (systemTypesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSystemTypesIsMutable(); - systemTypes_.add(value); - onChanged(); - } else { - systemTypesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public Builder addSystemTypes( - int index, com.google.protobuf.Type value) { - if (systemTypesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSystemTypesIsMutable(); - systemTypes_.add(index, value); - onChanged(); - } else { - systemTypesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public Builder addSystemTypes( - com.google.protobuf.Type.Builder builderForValue) { - if (systemTypesBuilder_ == null) { - ensureSystemTypesIsMutable(); - systemTypes_.add(builderForValue.build()); - onChanged(); - } else { - systemTypesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public Builder addSystemTypes( - int index, com.google.protobuf.Type.Builder builderForValue) { - if (systemTypesBuilder_ == null) { - ensureSystemTypesIsMutable(); - systemTypes_.add(index, builderForValue.build()); - onChanged(); - } else { - systemTypesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public Builder addAllSystemTypes( - java.lang.Iterable values) { - if (systemTypesBuilder_ == null) { - ensureSystemTypesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, systemTypes_); - onChanged(); - } else { - systemTypesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public Builder clearSystemTypes() { - if (systemTypesBuilder_ == null) { - systemTypes_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00002000); - onChanged(); - } else { - systemTypesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public Builder removeSystemTypes(int index) { - if (systemTypesBuilder_ == null) { - ensureSystemTypesIsMutable(); - systemTypes_.remove(index); - onChanged(); - } else { - systemTypesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public com.google.protobuf.Type.Builder getSystemTypesBuilder( - int index) { - return getSystemTypesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public com.google.protobuf.TypeOrBuilder getSystemTypesOrBuilder( - int index) { - if (systemTypesBuilder_ == null) { - return systemTypes_.get(index); } else { - return systemTypesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public java.util.List - getSystemTypesOrBuilderList() { - if (systemTypesBuilder_ != null) { - return systemTypesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(systemTypes_); - } - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public com.google.protobuf.Type.Builder addSystemTypesBuilder() { - return getSystemTypesFieldBuilder().addBuilder( - com.google.protobuf.Type.getDefaultInstance()); - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public com.google.protobuf.Type.Builder addSystemTypesBuilder( - int index) { - return getSystemTypesFieldBuilder().addBuilder( - index, com.google.protobuf.Type.getDefaultInstance()); - } - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -     * A list of all proto message types included in this API service.
      -     * It serves similar purpose as [google.api.Service.types], except that
      -     * these types are not needed by user-defined APIs. Therefore, they will not
      -     * show up in the generated discovery doc. This field should only be used
      -     * to define system APIs in ESF.
      -     * 
      - */ - public java.util.List - getSystemTypesBuilderList() { - return getSystemTypesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder> - getSystemTypesFieldBuilder() { - if (systemTypesBuilder_ == null) { - systemTypesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Type, com.google.protobuf.Type.Builder, com.google.protobuf.TypeOrBuilder>( - systemTypes_, - ((bitField0_ & 0x00002000) == 0x00002000), - getParentForChildren(), - isClean()); - systemTypes_ = null; - } - return systemTypesBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.Service) - } - - // @@protoc_insertion_point(class_scope:google.api.Service) - private static final com.google.api.Service DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.Service(); - } - - public static com.google.api.Service getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Service parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Service(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.Service getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceOrBuilder.java deleted file mode 100644 index f3a729e886a7..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceOrBuilder.java +++ /dev/null @@ -1,530 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/service.proto - -package com.google.api; - -public interface ServiceOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.Service) - com.google.protobuf.MessageOrBuilder { - - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -   * The version of the service configuration. The config version may
      -   * influence interpretation of the configuration, for example
      -   * determine defaults. This is documented together with applicable
      -   * options. The current default for the config version itself is `1`.
      -   * 
      - */ - boolean hasConfigVersion(); - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -   * The version of the service configuration. The config version may
      -   * influence interpretation of the configuration, for example
      -   * determine defaults. This is documented together with applicable
      -   * options. The current default for the config version itself is `1`.
      -   * 
      - */ - com.google.protobuf.UInt32Value getConfigVersion(); - /** - * optional .google.protobuf.UInt32Value config_version = 20; - * - *
      -   * The version of the service configuration. The config version may
      -   * influence interpretation of the configuration, for example
      -   * determine defaults. This is documented together with applicable
      -   * options. The current default for the config version itself is `1`.
      -   * 
      - */ - com.google.protobuf.UInt32ValueOrBuilder getConfigVersionOrBuilder(); - - /** - * optional string name = 1; - * - *
      -   * The DNS address at which this service is available,
      -   * e.g. `calendar.googleapis.com`.
      -   * 
      - */ - java.lang.String getName(); - /** - * optional string name = 1; - * - *
      -   * The DNS address at which this service is available,
      -   * e.g. `calendar.googleapis.com`.
      -   * 
      - */ - com.google.protobuf.ByteString - getNameBytes(); - - /** - * optional string title = 2; - * - *
      -   * The product title associated with this service.
      -   * 
      - */ - java.lang.String getTitle(); - /** - * optional string title = 2; - * - *
      -   * The product title associated with this service.
      -   * 
      - */ - com.google.protobuf.ByteString - getTitleBytes(); - - /** - * optional string producer_project_id = 22; - * - *
      -   * The id of the Google developer project that owns the service.
      -   * Members of this project can manage the service configuration,
      -   * manage consumption of the service, etc.
      -   * 
      - */ - java.lang.String getProducerProjectId(); - /** - * optional string producer_project_id = 22; - * - *
      -   * The id of the Google developer project that owns the service.
      -   * Members of this project can manage the service configuration,
      -   * manage consumption of the service, etc.
      -   * 
      - */ - com.google.protobuf.ByteString - getProducerProjectIdBytes(); - - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -   * A list of API interfaces exported by this service. Only the `name` field
      -   * of the [google.protobuf.Api][] needs to be provided by the configuration
      -   * author, as the remaining fields will be derived from the IDL during the
      -   * normalization process. It is an error to specify an API interface here
      -   * which cannot be resolved against the associated IDL files.
      -   * 
      - */ - java.util.List - getApisList(); - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -   * A list of API interfaces exported by this service. Only the `name` field
      -   * of the [google.protobuf.Api][] needs to be provided by the configuration
      -   * author, as the remaining fields will be derived from the IDL during the
      -   * normalization process. It is an error to specify an API interface here
      -   * which cannot be resolved against the associated IDL files.
      -   * 
      - */ - com.google.protobuf.Api getApis(int index); - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -   * A list of API interfaces exported by this service. Only the `name` field
      -   * of the [google.protobuf.Api][] needs to be provided by the configuration
      -   * author, as the remaining fields will be derived from the IDL during the
      -   * normalization process. It is an error to specify an API interface here
      -   * which cannot be resolved against the associated IDL files.
      -   * 
      - */ - int getApisCount(); - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -   * A list of API interfaces exported by this service. Only the `name` field
      -   * of the [google.protobuf.Api][] needs to be provided by the configuration
      -   * author, as the remaining fields will be derived from the IDL during the
      -   * normalization process. It is an error to specify an API interface here
      -   * which cannot be resolved against the associated IDL files.
      -   * 
      - */ - java.util.List - getApisOrBuilderList(); - /** - * repeated .google.protobuf.Api apis = 3; - * - *
      -   * A list of API interfaces exported by this service. Only the `name` field
      -   * of the [google.protobuf.Api][] needs to be provided by the configuration
      -   * author, as the remaining fields will be derived from the IDL during the
      -   * normalization process. It is an error to specify an API interface here
      -   * which cannot be resolved against the associated IDL files.
      -   * 
      - */ - com.google.protobuf.ApiOrBuilder getApisOrBuilder( - int index); - - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -   * A list of all proto message types included in this API service.
      -   * Types referenced directly or indirectly by the `apis` are
      -   * automatically included.  Messages which are not referenced but
      -   * shall be included, such as types used by the `google.protobuf.Any` type,
      -   * should be listed here by name. Example:
      -   *     types:
      -   *     - name: google.protobuf.Int32
      -   * 
      - */ - java.util.List - getTypesList(); - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -   * A list of all proto message types included in this API service.
      -   * Types referenced directly or indirectly by the `apis` are
      -   * automatically included.  Messages which are not referenced but
      -   * shall be included, such as types used by the `google.protobuf.Any` type,
      -   * should be listed here by name. Example:
      -   *     types:
      -   *     - name: google.protobuf.Int32
      -   * 
      - */ - com.google.protobuf.Type getTypes(int index); - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -   * A list of all proto message types included in this API service.
      -   * Types referenced directly or indirectly by the `apis` are
      -   * automatically included.  Messages which are not referenced but
      -   * shall be included, such as types used by the `google.protobuf.Any` type,
      -   * should be listed here by name. Example:
      -   *     types:
      -   *     - name: google.protobuf.Int32
      -   * 
      - */ - int getTypesCount(); - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -   * A list of all proto message types included in this API service.
      -   * Types referenced directly or indirectly by the `apis` are
      -   * automatically included.  Messages which are not referenced but
      -   * shall be included, such as types used by the `google.protobuf.Any` type,
      -   * should be listed here by name. Example:
      -   *     types:
      -   *     - name: google.protobuf.Int32
      -   * 
      - */ - java.util.List - getTypesOrBuilderList(); - /** - * repeated .google.protobuf.Type types = 4; - * - *
      -   * A list of all proto message types included in this API service.
      -   * Types referenced directly or indirectly by the `apis` are
      -   * automatically included.  Messages which are not referenced but
      -   * shall be included, such as types used by the `google.protobuf.Any` type,
      -   * should be listed here by name. Example:
      -   *     types:
      -   *     - name: google.protobuf.Int32
      -   * 
      - */ - com.google.protobuf.TypeOrBuilder getTypesOrBuilder( - int index); - - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -   * A list of all enum types included in this API service.  Enums
      -   * referenced directly or indirectly by the `apis` are automatically
      -   * included.  Enums which are not referenced but shall be included
      -   * should be listed here by name. Example:
      -   *     enums:
      -   *     - name: google.someapi.v1.SomeEnum
      -   * 
      - */ - java.util.List - getEnumsList(); - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -   * A list of all enum types included in this API service.  Enums
      -   * referenced directly or indirectly by the `apis` are automatically
      -   * included.  Enums which are not referenced but shall be included
      -   * should be listed here by name. Example:
      -   *     enums:
      -   *     - name: google.someapi.v1.SomeEnum
      -   * 
      - */ - com.google.protobuf.Enum getEnums(int index); - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -   * A list of all enum types included in this API service.  Enums
      -   * referenced directly or indirectly by the `apis` are automatically
      -   * included.  Enums which are not referenced but shall be included
      -   * should be listed here by name. Example:
      -   *     enums:
      -   *     - name: google.someapi.v1.SomeEnum
      -   * 
      - */ - int getEnumsCount(); - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -   * A list of all enum types included in this API service.  Enums
      -   * referenced directly or indirectly by the `apis` are automatically
      -   * included.  Enums which are not referenced but shall be included
      -   * should be listed here by name. Example:
      -   *     enums:
      -   *     - name: google.someapi.v1.SomeEnum
      -   * 
      - */ - java.util.List - getEnumsOrBuilderList(); - /** - * repeated .google.protobuf.Enum enums = 5; - * - *
      -   * A list of all enum types included in this API service.  Enums
      -   * referenced directly or indirectly by the `apis` are automatically
      -   * included.  Enums which are not referenced but shall be included
      -   * should be listed here by name. Example:
      -   *     enums:
      -   *     - name: google.someapi.v1.SomeEnum
      -   * 
      - */ - com.google.protobuf.EnumOrBuilder getEnumsOrBuilder( - int index); - - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -   * Additional API documentation.
      -   * 
      - */ - boolean hasDocumentation(); - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -   * Additional API documentation.
      -   * 
      - */ - com.google.api.Documentation getDocumentation(); - /** - * optional .google.api.Documentation documentation = 6; - * - *
      -   * Additional API documentation.
      -   * 
      - */ - com.google.api.DocumentationOrBuilder getDocumentationOrBuilder(); - - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -   * API visibility configuration.
      -   * 
      - */ - boolean hasVisibility(); - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -   * API visibility configuration.
      -   * 
      - */ - com.google.api.Visibility getVisibility(); - /** - * optional .google.api.Visibility visibility = 7; - * - *
      -   * API visibility configuration.
      -   * 
      - */ - com.google.api.VisibilityOrBuilder getVisibilityOrBuilder(); - - /** - * optional .google.api.Http http = 9; - * - *
      -   * HTTP configuration.
      -   * 
      - */ - boolean hasHttp(); - /** - * optional .google.api.Http http = 9; - * - *
      -   * HTTP configuration.
      -   * 
      - */ - com.google.api.Http getHttp(); - /** - * optional .google.api.Http http = 9; - * - *
      -   * HTTP configuration.
      -   * 
      - */ - com.google.api.HttpOrBuilder getHttpOrBuilder(); - - /** - * optional .google.api.Context context = 12; - * - *
      -   * Context configuration.
      -   * 
      - */ - boolean hasContext(); - /** - * optional .google.api.Context context = 12; - * - *
      -   * Context configuration.
      -   * 
      - */ - com.google.api.Context getContext(); - /** - * optional .google.api.Context context = 12; - * - *
      -   * Context configuration.
      -   * 
      - */ - com.google.api.ContextOrBuilder getContextOrBuilder(); - - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -   * Custom error configuration.
      -   * 
      - */ - boolean hasCustomError(); - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -   * Custom error configuration.
      -   * 
      - */ - com.google.api.CustomError getCustomError(); - /** - * optional .google.api.CustomError custom_error = 16; - * - *
      -   * Custom error configuration.
      -   * 
      - */ - com.google.api.CustomErrorOrBuilder getCustomErrorOrBuilder(); - - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -   * Service attributes derived by the configuration toolchain, for
      -   * use at runtime.  Type is defined in
      -   * `//google/internal/api/derived_service.proto`.
      -   * 
      - */ - boolean hasDerivedData(); - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -   * Service attributes derived by the configuration toolchain, for
      -   * use at runtime.  Type is defined in
      -   * `//google/internal/api/derived_service.proto`.
      -   * 
      - */ - com.google.protobuf.Any getDerivedData(); - /** - * optional .google.protobuf.Any derived_data = 100; - * - *
      -   * Service attributes derived by the configuration toolchain, for
      -   * use at runtime.  Type is defined in
      -   * `//google/internal/api/derived_service.proto`.
      -   * 
      - */ - com.google.protobuf.AnyOrBuilder getDerivedDataOrBuilder(); - - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -   * A list of all proto message types included in this API service.
      -   * It serves similar purpose as [google.api.Service.types], except that
      -   * these types are not needed by user-defined APIs. Therefore, they will not
      -   * show up in the generated discovery doc. This field should only be used
      -   * to define system APIs in ESF.
      -   * 
      - */ - java.util.List - getSystemTypesList(); - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -   * A list of all proto message types included in this API service.
      -   * It serves similar purpose as [google.api.Service.types], except that
      -   * these types are not needed by user-defined APIs. Therefore, they will not
      -   * show up in the generated discovery doc. This field should only be used
      -   * to define system APIs in ESF.
      -   * 
      - */ - com.google.protobuf.Type getSystemTypes(int index); - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -   * A list of all proto message types included in this API service.
      -   * It serves similar purpose as [google.api.Service.types], except that
      -   * these types are not needed by user-defined APIs. Therefore, they will not
      -   * show up in the generated discovery doc. This field should only be used
      -   * to define system APIs in ESF.
      -   * 
      - */ - int getSystemTypesCount(); - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -   * A list of all proto message types included in this API service.
      -   * It serves similar purpose as [google.api.Service.types], except that
      -   * these types are not needed by user-defined APIs. Therefore, they will not
      -   * show up in the generated discovery doc. This field should only be used
      -   * to define system APIs in ESF.
      -   * 
      - */ - java.util.List - getSystemTypesOrBuilderList(); - /** - * repeated .google.protobuf.Type system_types = 102; - * - *
      -   * A list of all proto message types included in this API service.
      -   * It serves similar purpose as [google.api.Service.types], except that
      -   * these types are not needed by user-defined APIs. Therefore, they will not
      -   * show up in the generated discovery doc. This field should only be used
      -   * to define system APIs in ESF.
      -   * 
      - */ - com.google.protobuf.TypeOrBuilder getSystemTypesOrBuilder( - int index); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceProto.java deleted file mode 100644 index fa6c564c7644..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/ServiceProto.java +++ /dev/null @@ -1,95 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/service.proto - -package com.google.api; - -public final class ServiceProto { - private ServiceProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_Service_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_Service_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\030google/api/service.proto\022\ngoogle.api\032\031" + - "google/protobuf/any.proto\032\031google/protob" + - "uf/api.proto\032\032google/protobuf/type.proto" + - "\032\036google/protobuf/wrappers.proto\032\034google" + - "/api/annotations.proto\032\030google/api/conte" + - "xt.proto\032\036google/api/documentation.proto" + - "\032\026google/api/error.proto\032\025google/api/htt" + - "p.proto\032\033google/api/visibility.proto\"\253\004\n" + - "\007Service\0224\n\016config_version\030\024 \001(\0132\034.googl" + - "e.protobuf.UInt32Value\022\014\n\004name\030\001 \001(\t\022\r\n\005", - "title\030\002 \001(\t\022\033\n\023producer_project_id\030\026 \001(\t" + - "\022\"\n\004apis\030\003 \003(\0132\024.google.protobuf.Api\022$\n\005" + - "types\030\004 \003(\0132\025.google.protobuf.Type\022$\n\005en" + - "ums\030\005 \003(\0132\025.google.protobuf.Enum\0220\n\rdocu" + - "mentation\030\006 \001(\0132\031.google.api.Documentati" + - "on\022*\n\nvisibility\030\007 \001(\0132\026.google.api.Visi" + - "bility\022\036\n\004http\030\t \001(\0132\020.google.api.Http\022$" + - "\n\007context\030\014 \001(\0132\023.google.api.Context\022-\n\014" + - "custom_error\030\020 \001(\0132\027.google.api.CustomEr" + - "ror\022@\n\014derived_data\030d \001(\0132\024.google.proto", - "buf.AnyB\024\372\322\344\223\002\016\022\014GOOGLE_TOOLS\022+\n\014system_" + - "types\030f \003(\0132\025.google.protobuf.TypeB \n\016co" + - "m.google.apiB\014ServiceProtoP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.AnyProto.getDescriptor(), - com.google.protobuf.ApiProto.getDescriptor(), - com.google.protobuf.TypeProto.getDescriptor(), - com.google.protobuf.WrappersProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), - com.google.api.ContextProto.getDescriptor(), - com.google.api.DocumentationProto.getDescriptor(), - com.google.api.ErrorFormatProto.getDescriptor(), - com.google.api.HttpProto.getDescriptor(), - com.google.api.VisibilityProto.getDescriptor(), - }, assigner); - internal_static_google_api_Service_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_api_Service_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_Service_descriptor, - new java.lang.String[] { "ConfigVersion", "Name", "Title", "ProducerProjectId", "Apis", "Types", "Enums", "Documentation", "Visibility", "Http", "Context", "CustomError", "DerivedData", "SystemTypes", }); - com.google.protobuf.ExtensionRegistry registry = - com.google.protobuf.ExtensionRegistry.newInstance(); - registry.add(com.google.api.AnnotationsProto.fieldVisibility); - com.google.protobuf.Descriptors.FileDescriptor - .internalUpdateFileDescriptor(descriptor, registry); - com.google.protobuf.AnyProto.getDescriptor(); - com.google.protobuf.ApiProto.getDescriptor(); - com.google.protobuf.TypeProto.getDescriptor(); - com.google.protobuf.WrappersProto.getDescriptor(); - com.google.api.AnnotationsProto.getDescriptor(); - com.google.api.ContextProto.getDescriptor(); - com.google.api.DocumentationProto.getDescriptor(); - com.google.api.ErrorFormatProto.getDescriptor(); - com.google.api.HttpProto.getDescriptor(); - com.google.api.VisibilityProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/Visibility.java b/gcloud-java-gax/generated/src/main/java/com/google/api/Visibility.java deleted file mode 100644 index 2ef3f2b0442d..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/Visibility.java +++ /dev/null @@ -1,1370 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/visibility.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.Visibility} - * - *
      - * `Visibility` defines restrictions for the visibility of service
      - * elements.  Restrictions are specified using visibility labels
      - * (e.g., TRUSTED_TESTER) that are elsewhere linked to users and projects.
      - * User and projects can have access to more than one visibility label. The
      - * effective visibility for multiple labels is the union of each label's
      - * elements, plus any unrestricted elements. You must list any supported label
      - * combinations in `label_combinations`.
      - * If an element and its parents have no restrictions, visibility is
      - * unconditionally granted.
      - * Example:
      - *     visibility:
      - *       label_combinations:
      - *       - GOOGLE_INTERNAL, TRUSTED_TESTER
      - *       rules:
      - *       - selector: google.calendar.Calendar.EnhancedSearch
      - *         restriction: TRUSTED_TESTER
      - *       - selector: google.calendar.Calendar.Delegate
      - *         restriction: GOOGLE_INTERNAL
      - * Here, all methods are publicly visible except for the restricted methods
      - * EnhancedSearch and Delegate. In addition, since `label_combinations`
      - * lists both GOOGLE_INTERNAL and TRUSTED_TESTER, users and projects can be
      - * given access to a combined visibility with both EnhancedSearch and Delegate.
      - * 
      - */ -public final class Visibility extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.Visibility) - VisibilityOrBuilder { - // Use Visibility.newBuilder() to construct. - private Visibility(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Visibility() { - rules_ = java.util.Collections.emptyList(); - labelCombinations_ = com.google.protobuf.LazyStringArrayList.EMPTY; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Visibility( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - rules_.add(input.readMessage(com.google.api.VisibilityRule.parser(), extensionRegistry)); - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - labelCombinations_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000002; - } - labelCombinations_.add(s); - break; - } - case 26: { - com.google.protobuf.BoolValue.Builder subBuilder = null; - if (enforceRuntimeVisibility_ != null) { - subBuilder = enforceRuntimeVisibility_.toBuilder(); - } - enforceRuntimeVisibility_ = input.readMessage(com.google.protobuf.BoolValue.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(enforceRuntimeVisibility_); - enforceRuntimeVisibility_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = java.util.Collections.unmodifiableList(rules_); - } - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - labelCombinations_ = labelCombinations_.getUnmodifiableView(); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.VisibilityProto.internal_static_google_api_Visibility_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.VisibilityProto.internal_static_google_api_Visibility_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Visibility.class, com.google.api.Visibility.Builder.class); - } - - private int bitField0_; - public static final int RULES_FIELD_NUMBER = 1; - private java.util.List rules_; - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -   * A list of visibility rules providing visibility configuration for
      -   * individual API elements.
      -   * 
      - */ - public java.util.List getRulesList() { - return rules_; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -   * A list of visibility rules providing visibility configuration for
      -   * individual API elements.
      -   * 
      - */ - public java.util.List - getRulesOrBuilderList() { - return rules_; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -   * A list of visibility rules providing visibility configuration for
      -   * individual API elements.
      -   * 
      - */ - public int getRulesCount() { - return rules_.size(); - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -   * A list of visibility rules providing visibility configuration for
      -   * individual API elements.
      -   * 
      - */ - public com.google.api.VisibilityRule getRules(int index) { - return rules_.get(index); - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -   * A list of visibility rules providing visibility configuration for
      -   * individual API elements.
      -   * 
      - */ - public com.google.api.VisibilityRuleOrBuilder getRulesOrBuilder( - int index) { - return rules_.get(index); - } - - public static final int LABEL_COMBINATIONS_FIELD_NUMBER = 2; - private com.google.protobuf.LazyStringList labelCombinations_; - /** - * repeated string label_combinations = 2; - * - *
      -   * Lists valid label combinations for this service in comma-delimited form.
      -   * This lets users and projects see the union of these labels' elements.
      -   * Removing a label combination can be a breaking change, as clients with
      -   * access to the combination will now see non-restricted elements only.
      -   * 
      - */ - public com.google.protobuf.ProtocolStringList - getLabelCombinationsList() { - return labelCombinations_; - } - /** - * repeated string label_combinations = 2; - * - *
      -   * Lists valid label combinations for this service in comma-delimited form.
      -   * This lets users and projects see the union of these labels' elements.
      -   * Removing a label combination can be a breaking change, as clients with
      -   * access to the combination will now see non-restricted elements only.
      -   * 
      - */ - public int getLabelCombinationsCount() { - return labelCombinations_.size(); - } - /** - * repeated string label_combinations = 2; - * - *
      -   * Lists valid label combinations for this service in comma-delimited form.
      -   * This lets users and projects see the union of these labels' elements.
      -   * Removing a label combination can be a breaking change, as clients with
      -   * access to the combination will now see non-restricted elements only.
      -   * 
      - */ - public java.lang.String getLabelCombinations(int index) { - return labelCombinations_.get(index); - } - /** - * repeated string label_combinations = 2; - * - *
      -   * Lists valid label combinations for this service in comma-delimited form.
      -   * This lets users and projects see the union of these labels' elements.
      -   * Removing a label combination can be a breaking change, as clients with
      -   * access to the combination will now see non-restricted elements only.
      -   * 
      - */ - public com.google.protobuf.ByteString - getLabelCombinationsBytes(int index) { - return labelCombinations_.getByteString(index); - } - - public static final int ENFORCE_RUNTIME_VISIBILITY_FIELD_NUMBER = 3; - private com.google.protobuf.BoolValue enforceRuntimeVisibility_; - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility rules are enforced at runtime for requests to
      -   * all APIs and methods.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is false.
      -   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -   * overrides this setting for the APIs or methods asscoiated with the rule.
      -   * 
      - */ - public boolean hasEnforceRuntimeVisibility() { - return enforceRuntimeVisibility_ != null; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility rules are enforced at runtime for requests to
      -   * all APIs and methods.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is false.
      -   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -   * overrides this setting for the APIs or methods asscoiated with the rule.
      -   * 
      - */ - public com.google.protobuf.BoolValue getEnforceRuntimeVisibility() { - return enforceRuntimeVisibility_ == null ? com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility rules are enforced at runtime for requests to
      -   * all APIs and methods.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is false.
      -   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -   * overrides this setting for the APIs or methods asscoiated with the rule.
      -   * 
      - */ - public com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder() { - return getEnforceRuntimeVisibility(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < rules_.size(); i++) { - output.writeMessage(1, rules_.get(i)); - } - for (int i = 0; i < labelCombinations_.size(); i++) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, labelCombinations_.getRaw(i)); - } - if (enforceRuntimeVisibility_ != null) { - output.writeMessage(3, getEnforceRuntimeVisibility()); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < rules_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, rules_.get(i)); - } - { - int dataSize = 0; - for (int i = 0; i < labelCombinations_.size(); i++) { - dataSize += computeStringSizeNoTag(labelCombinations_.getRaw(i)); - } - size += dataSize; - size += 1 * getLabelCombinationsList().size(); - } - if (enforceRuntimeVisibility_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, getEnforceRuntimeVisibility()); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.Visibility parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Visibility parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Visibility parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.Visibility parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.Visibility parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Visibility parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.Visibility parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.Visibility parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.Visibility parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.Visibility parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.Visibility prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.Visibility} - * - *
      -   * `Visibility` defines restrictions for the visibility of service
      -   * elements.  Restrictions are specified using visibility labels
      -   * (e.g., TRUSTED_TESTER) that are elsewhere linked to users and projects.
      -   * User and projects can have access to more than one visibility label. The
      -   * effective visibility for multiple labels is the union of each label's
      -   * elements, plus any unrestricted elements. You must list any supported label
      -   * combinations in `label_combinations`.
      -   * If an element and its parents have no restrictions, visibility is
      -   * unconditionally granted.
      -   * Example:
      -   *     visibility:
      -   *       label_combinations:
      -   *       - GOOGLE_INTERNAL, TRUSTED_TESTER
      -   *       rules:
      -   *       - selector: google.calendar.Calendar.EnhancedSearch
      -   *         restriction: TRUSTED_TESTER
      -   *       - selector: google.calendar.Calendar.Delegate
      -   *         restriction: GOOGLE_INTERNAL
      -   * Here, all methods are publicly visible except for the restricted methods
      -   * EnhancedSearch and Delegate. In addition, since `label_combinations`
      -   * lists both GOOGLE_INTERNAL and TRUSTED_TESTER, users and projects can be
      -   * given access to a combined visibility with both EnhancedSearch and Delegate.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.Visibility) - com.google.api.VisibilityOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.VisibilityProto.internal_static_google_api_Visibility_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.VisibilityProto.internal_static_google_api_Visibility_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.Visibility.class, com.google.api.Visibility.Builder.class); - } - - // Construct using com.google.api.Visibility.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getRulesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (rulesBuilder_ == null) { - rules_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - rulesBuilder_.clear(); - } - labelCombinations_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - if (enforceRuntimeVisibilityBuilder_ == null) { - enforceRuntimeVisibility_ = null; - } else { - enforceRuntimeVisibility_ = null; - enforceRuntimeVisibilityBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.VisibilityProto.internal_static_google_api_Visibility_descriptor; - } - - public com.google.api.Visibility getDefaultInstanceForType() { - return com.google.api.Visibility.getDefaultInstance(); - } - - public com.google.api.Visibility build() { - com.google.api.Visibility result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.Visibility buildPartial() { - com.google.api.Visibility result = new com.google.api.Visibility(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (rulesBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = java.util.Collections.unmodifiableList(rules_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.rules_ = rules_; - } else { - result.rules_ = rulesBuilder_.build(); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - labelCombinations_ = labelCombinations_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.labelCombinations_ = labelCombinations_; - if (enforceRuntimeVisibilityBuilder_ == null) { - result.enforceRuntimeVisibility_ = enforceRuntimeVisibility_; - } else { - result.enforceRuntimeVisibility_ = enforceRuntimeVisibilityBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.Visibility) { - return mergeFrom((com.google.api.Visibility)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.Visibility other) { - if (other == com.google.api.Visibility.getDefaultInstance()) return this; - if (rulesBuilder_ == null) { - if (!other.rules_.isEmpty()) { - if (rules_.isEmpty()) { - rules_ = other.rules_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureRulesIsMutable(); - rules_.addAll(other.rules_); - } - onChanged(); - } - } else { - if (!other.rules_.isEmpty()) { - if (rulesBuilder_.isEmpty()) { - rulesBuilder_.dispose(); - rulesBuilder_ = null; - rules_ = other.rules_; - bitField0_ = (bitField0_ & ~0x00000001); - rulesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getRulesFieldBuilder() : null; - } else { - rulesBuilder_.addAllMessages(other.rules_); - } - } - } - if (!other.labelCombinations_.isEmpty()) { - if (labelCombinations_.isEmpty()) { - labelCombinations_ = other.labelCombinations_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureLabelCombinationsIsMutable(); - labelCombinations_.addAll(other.labelCombinations_); - } - onChanged(); - } - if (other.hasEnforceRuntimeVisibility()) { - mergeEnforceRuntimeVisibility(other.getEnforceRuntimeVisibility()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.Visibility parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.Visibility) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List rules_ = - java.util.Collections.emptyList(); - private void ensureRulesIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - rules_ = new java.util.ArrayList(rules_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.VisibilityRule, com.google.api.VisibilityRule.Builder, com.google.api.VisibilityRuleOrBuilder> rulesBuilder_; - - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public java.util.List getRulesList() { - if (rulesBuilder_ == null) { - return java.util.Collections.unmodifiableList(rules_); - } else { - return rulesBuilder_.getMessageList(); - } - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public int getRulesCount() { - if (rulesBuilder_ == null) { - return rules_.size(); - } else { - return rulesBuilder_.getCount(); - } - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public com.google.api.VisibilityRule getRules(int index) { - if (rulesBuilder_ == null) { - return rules_.get(index); - } else { - return rulesBuilder_.getMessage(index); - } - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public Builder setRules( - int index, com.google.api.VisibilityRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.set(index, value); - onChanged(); - } else { - rulesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public Builder setRules( - int index, com.google.api.VisibilityRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.set(index, builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public Builder addRules(com.google.api.VisibilityRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.add(value); - onChanged(); - } else { - rulesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public Builder addRules( - int index, com.google.api.VisibilityRule value) { - if (rulesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureRulesIsMutable(); - rules_.add(index, value); - onChanged(); - } else { - rulesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public Builder addRules( - com.google.api.VisibilityRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.add(builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public Builder addRules( - int index, com.google.api.VisibilityRule.Builder builderForValue) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.add(index, builderForValue.build()); - onChanged(); - } else { - rulesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public Builder addAllRules( - java.lang.Iterable values) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, rules_); - onChanged(); - } else { - rulesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public Builder clearRules() { - if (rulesBuilder_ == null) { - rules_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - rulesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public Builder removeRules(int index) { - if (rulesBuilder_ == null) { - ensureRulesIsMutable(); - rules_.remove(index); - onChanged(); - } else { - rulesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public com.google.api.VisibilityRule.Builder getRulesBuilder( - int index) { - return getRulesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public com.google.api.VisibilityRuleOrBuilder getRulesOrBuilder( - int index) { - if (rulesBuilder_ == null) { - return rules_.get(index); } else { - return rulesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public java.util.List - getRulesOrBuilderList() { - if (rulesBuilder_ != null) { - return rulesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(rules_); - } - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public com.google.api.VisibilityRule.Builder addRulesBuilder() { - return getRulesFieldBuilder().addBuilder( - com.google.api.VisibilityRule.getDefaultInstance()); - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public com.google.api.VisibilityRule.Builder addRulesBuilder( - int index) { - return getRulesFieldBuilder().addBuilder( - index, com.google.api.VisibilityRule.getDefaultInstance()); - } - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -     * A list of visibility rules providing visibility configuration for
      -     * individual API elements.
      -     * 
      - */ - public java.util.List - getRulesBuilderList() { - return getRulesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.api.VisibilityRule, com.google.api.VisibilityRule.Builder, com.google.api.VisibilityRuleOrBuilder> - getRulesFieldBuilder() { - if (rulesBuilder_ == null) { - rulesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.api.VisibilityRule, com.google.api.VisibilityRule.Builder, com.google.api.VisibilityRuleOrBuilder>( - rules_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - rules_ = null; - } - return rulesBuilder_; - } - - private com.google.protobuf.LazyStringList labelCombinations_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureLabelCombinationsIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - labelCombinations_ = new com.google.protobuf.LazyStringArrayList(labelCombinations_); - bitField0_ |= 0x00000002; - } - } - /** - * repeated string label_combinations = 2; - * - *
      -     * Lists valid label combinations for this service in comma-delimited form.
      -     * This lets users and projects see the union of these labels' elements.
      -     * Removing a label combination can be a breaking change, as clients with
      -     * access to the combination will now see non-restricted elements only.
      -     * 
      - */ - public com.google.protobuf.ProtocolStringList - getLabelCombinationsList() { - return labelCombinations_.getUnmodifiableView(); - } - /** - * repeated string label_combinations = 2; - * - *
      -     * Lists valid label combinations for this service in comma-delimited form.
      -     * This lets users and projects see the union of these labels' elements.
      -     * Removing a label combination can be a breaking change, as clients with
      -     * access to the combination will now see non-restricted elements only.
      -     * 
      - */ - public int getLabelCombinationsCount() { - return labelCombinations_.size(); - } - /** - * repeated string label_combinations = 2; - * - *
      -     * Lists valid label combinations for this service in comma-delimited form.
      -     * This lets users and projects see the union of these labels' elements.
      -     * Removing a label combination can be a breaking change, as clients with
      -     * access to the combination will now see non-restricted elements only.
      -     * 
      - */ - public java.lang.String getLabelCombinations(int index) { - return labelCombinations_.get(index); - } - /** - * repeated string label_combinations = 2; - * - *
      -     * Lists valid label combinations for this service in comma-delimited form.
      -     * This lets users and projects see the union of these labels' elements.
      -     * Removing a label combination can be a breaking change, as clients with
      -     * access to the combination will now see non-restricted elements only.
      -     * 
      - */ - public com.google.protobuf.ByteString - getLabelCombinationsBytes(int index) { - return labelCombinations_.getByteString(index); - } - /** - * repeated string label_combinations = 2; - * - *
      -     * Lists valid label combinations for this service in comma-delimited form.
      -     * This lets users and projects see the union of these labels' elements.
      -     * Removing a label combination can be a breaking change, as clients with
      -     * access to the combination will now see non-restricted elements only.
      -     * 
      - */ - public Builder setLabelCombinations( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureLabelCombinationsIsMutable(); - labelCombinations_.set(index, value); - onChanged(); - return this; - } - /** - * repeated string label_combinations = 2; - * - *
      -     * Lists valid label combinations for this service in comma-delimited form.
      -     * This lets users and projects see the union of these labels' elements.
      -     * Removing a label combination can be a breaking change, as clients with
      -     * access to the combination will now see non-restricted elements only.
      -     * 
      - */ - public Builder addLabelCombinations( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureLabelCombinationsIsMutable(); - labelCombinations_.add(value); - onChanged(); - return this; - } - /** - * repeated string label_combinations = 2; - * - *
      -     * Lists valid label combinations for this service in comma-delimited form.
      -     * This lets users and projects see the union of these labels' elements.
      -     * Removing a label combination can be a breaking change, as clients with
      -     * access to the combination will now see non-restricted elements only.
      -     * 
      - */ - public Builder addAllLabelCombinations( - java.lang.Iterable values) { - ensureLabelCombinationsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, labelCombinations_); - onChanged(); - return this; - } - /** - * repeated string label_combinations = 2; - * - *
      -     * Lists valid label combinations for this service in comma-delimited form.
      -     * This lets users and projects see the union of these labels' elements.
      -     * Removing a label combination can be a breaking change, as clients with
      -     * access to the combination will now see non-restricted elements only.
      -     * 
      - */ - public Builder clearLabelCombinations() { - labelCombinations_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - * repeated string label_combinations = 2; - * - *
      -     * Lists valid label combinations for this service in comma-delimited form.
      -     * This lets users and projects see the union of these labels' elements.
      -     * Removing a label combination can be a breaking change, as clients with
      -     * access to the combination will now see non-restricted elements only.
      -     * 
      - */ - public Builder addLabelCombinationsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureLabelCombinationsIsMutable(); - labelCombinations_.add(value); - onChanged(); - return this; - } - - private com.google.protobuf.BoolValue enforceRuntimeVisibility_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder> enforceRuntimeVisibilityBuilder_; - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility rules are enforced at runtime for requests to
      -     * all APIs and methods.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is false.
      -     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -     * overrides this setting for the APIs or methods asscoiated with the rule.
      -     * 
      - */ - public boolean hasEnforceRuntimeVisibility() { - return enforceRuntimeVisibilityBuilder_ != null || enforceRuntimeVisibility_ != null; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility rules are enforced at runtime for requests to
      -     * all APIs and methods.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is false.
      -     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -     * overrides this setting for the APIs or methods asscoiated with the rule.
      -     * 
      - */ - public com.google.protobuf.BoolValue getEnforceRuntimeVisibility() { - if (enforceRuntimeVisibilityBuilder_ == null) { - return enforceRuntimeVisibility_ == null ? com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; - } else { - return enforceRuntimeVisibilityBuilder_.getMessage(); - } - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility rules are enforced at runtime for requests to
      -     * all APIs and methods.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is false.
      -     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -     * overrides this setting for the APIs or methods asscoiated with the rule.
      -     * 
      - */ - public Builder setEnforceRuntimeVisibility(com.google.protobuf.BoolValue value) { - if (enforceRuntimeVisibilityBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - enforceRuntimeVisibility_ = value; - onChanged(); - } else { - enforceRuntimeVisibilityBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility rules are enforced at runtime for requests to
      -     * all APIs and methods.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is false.
      -     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -     * overrides this setting for the APIs or methods asscoiated with the rule.
      -     * 
      - */ - public Builder setEnforceRuntimeVisibility( - com.google.protobuf.BoolValue.Builder builderForValue) { - if (enforceRuntimeVisibilityBuilder_ == null) { - enforceRuntimeVisibility_ = builderForValue.build(); - onChanged(); - } else { - enforceRuntimeVisibilityBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility rules are enforced at runtime for requests to
      -     * all APIs and methods.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is false.
      -     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -     * overrides this setting for the APIs or methods asscoiated with the rule.
      -     * 
      - */ - public Builder mergeEnforceRuntimeVisibility(com.google.protobuf.BoolValue value) { - if (enforceRuntimeVisibilityBuilder_ == null) { - if (enforceRuntimeVisibility_ != null) { - enforceRuntimeVisibility_ = - com.google.protobuf.BoolValue.newBuilder(enforceRuntimeVisibility_).mergeFrom(value).buildPartial(); - } else { - enforceRuntimeVisibility_ = value; - } - onChanged(); - } else { - enforceRuntimeVisibilityBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility rules are enforced at runtime for requests to
      -     * all APIs and methods.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is false.
      -     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -     * overrides this setting for the APIs or methods asscoiated with the rule.
      -     * 
      - */ - public Builder clearEnforceRuntimeVisibility() { - if (enforceRuntimeVisibilityBuilder_ == null) { - enforceRuntimeVisibility_ = null; - onChanged(); - } else { - enforceRuntimeVisibility_ = null; - enforceRuntimeVisibilityBuilder_ = null; - } - - return this; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility rules are enforced at runtime for requests to
      -     * all APIs and methods.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is false.
      -     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -     * overrides this setting for the APIs or methods asscoiated with the rule.
      -     * 
      - */ - public com.google.protobuf.BoolValue.Builder getEnforceRuntimeVisibilityBuilder() { - - onChanged(); - return getEnforceRuntimeVisibilityFieldBuilder().getBuilder(); - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility rules are enforced at runtime for requests to
      -     * all APIs and methods.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is false.
      -     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -     * overrides this setting for the APIs or methods asscoiated with the rule.
      -     * 
      - */ - public com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder() { - if (enforceRuntimeVisibilityBuilder_ != null) { - return enforceRuntimeVisibilityBuilder_.getMessageOrBuilder(); - } else { - return enforceRuntimeVisibility_ == null ? - com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; - } - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility rules are enforced at runtime for requests to
      -     * all APIs and methods.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is false.
      -     * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -     * overrides this setting for the APIs or methods asscoiated with the rule.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder> - getEnforceRuntimeVisibilityFieldBuilder() { - if (enforceRuntimeVisibilityBuilder_ == null) { - enforceRuntimeVisibilityBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder>( - getEnforceRuntimeVisibility(), - getParentForChildren(), - isClean()); - enforceRuntimeVisibility_ = null; - } - return enforceRuntimeVisibilityBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.Visibility) - } - - // @@protoc_insertion_point(class_scope:google.api.Visibility) - private static final com.google.api.Visibility DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.Visibility(); - } - - public static com.google.api.Visibility getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Visibility parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Visibility(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.Visibility getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityOrBuilder.java deleted file mode 100644 index 1c8cb2bca4b8..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityOrBuilder.java +++ /dev/null @@ -1,148 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/visibility.proto - -package com.google.api; - -public interface VisibilityOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.Visibility) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -   * A list of visibility rules providing visibility configuration for
      -   * individual API elements.
      -   * 
      - */ - java.util.List - getRulesList(); - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -   * A list of visibility rules providing visibility configuration for
      -   * individual API elements.
      -   * 
      - */ - com.google.api.VisibilityRule getRules(int index); - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -   * A list of visibility rules providing visibility configuration for
      -   * individual API elements.
      -   * 
      - */ - int getRulesCount(); - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -   * A list of visibility rules providing visibility configuration for
      -   * individual API elements.
      -   * 
      - */ - java.util.List - getRulesOrBuilderList(); - /** - * repeated .google.api.VisibilityRule rules = 1; - * - *
      -   * A list of visibility rules providing visibility configuration for
      -   * individual API elements.
      -   * 
      - */ - com.google.api.VisibilityRuleOrBuilder getRulesOrBuilder( - int index); - - /** - * repeated string label_combinations = 2; - * - *
      -   * Lists valid label combinations for this service in comma-delimited form.
      -   * This lets users and projects see the union of these labels' elements.
      -   * Removing a label combination can be a breaking change, as clients with
      -   * access to the combination will now see non-restricted elements only.
      -   * 
      - */ - com.google.protobuf.ProtocolStringList - getLabelCombinationsList(); - /** - * repeated string label_combinations = 2; - * - *
      -   * Lists valid label combinations for this service in comma-delimited form.
      -   * This lets users and projects see the union of these labels' elements.
      -   * Removing a label combination can be a breaking change, as clients with
      -   * access to the combination will now see non-restricted elements only.
      -   * 
      - */ - int getLabelCombinationsCount(); - /** - * repeated string label_combinations = 2; - * - *
      -   * Lists valid label combinations for this service in comma-delimited form.
      -   * This lets users and projects see the union of these labels' elements.
      -   * Removing a label combination can be a breaking change, as clients with
      -   * access to the combination will now see non-restricted elements only.
      -   * 
      - */ - java.lang.String getLabelCombinations(int index); - /** - * repeated string label_combinations = 2; - * - *
      -   * Lists valid label combinations for this service in comma-delimited form.
      -   * This lets users and projects see the union of these labels' elements.
      -   * Removing a label combination can be a breaking change, as clients with
      -   * access to the combination will now see non-restricted elements only.
      -   * 
      - */ - com.google.protobuf.ByteString - getLabelCombinationsBytes(int index); - - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility rules are enforced at runtime for requests to
      -   * all APIs and methods.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is false.
      -   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -   * overrides this setting for the APIs or methods asscoiated with the rule.
      -   * 
      - */ - boolean hasEnforceRuntimeVisibility(); - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility rules are enforced at runtime for requests to
      -   * all APIs and methods.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is false.
      -   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -   * overrides this setting for the APIs or methods asscoiated with the rule.
      -   * 
      - */ - com.google.protobuf.BoolValue getEnforceRuntimeVisibility(); - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility rules are enforced at runtime for requests to
      -   * all APIs and methods.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is false.
      -   * Note, the `enforce_runtime_visibility` specified in a visibility rule
      -   * overrides this setting for the APIs or methods asscoiated with the rule.
      -   * 
      - */ - com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityProto.java b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityProto.java deleted file mode 100644 index 75f797d990e2..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityProto.java +++ /dev/null @@ -1,70 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/visibility.proto - -package com.google.api; - -public final class VisibilityProto { - private VisibilityProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_Visibility_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_Visibility_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_api_VisibilityRule_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_api_VisibilityRule_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\033google/api/visibility.proto\022\ngoogle.ap" + - "i\032\036google/protobuf/wrappers.proto\"\223\001\n\nVi" + - "sibility\022)\n\005rules\030\001 \003(\0132\032.google.api.Vis" + - "ibilityRule\022\032\n\022label_combinations\030\002 \003(\t\022" + - ">\n\032enforce_runtime_visibility\030\003 \001(\0132\032.go" + - "ogle.protobuf.BoolValue\"w\n\016VisibilityRul" + - "e\022\020\n\010selector\030\001 \001(\t\022\023\n\013restriction\030\002 \001(\t" + - "\022>\n\032enforce_runtime_visibility\030\003 \001(\0132\032.g" + - "oogle.protobuf.BoolValueB&\n\016com.google.a" + - "piB\017VisibilityProtoP\001\370\001\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.WrappersProto.getDescriptor(), - }, assigner); - internal_static_google_api_Visibility_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_api_Visibility_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_Visibility_descriptor, - new java.lang.String[] { "Rules", "LabelCombinations", "EnforceRuntimeVisibility", }); - internal_static_google_api_VisibilityRule_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_google_api_VisibilityRule_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_api_VisibilityRule_descriptor, - new java.lang.String[] { "Selector", "Restriction", "EnforceRuntimeVisibility", }); - com.google.protobuf.WrappersProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRule.java b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRule.java deleted file mode 100644 index 1fcc76384b70..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRule.java +++ /dev/null @@ -1,998 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/visibility.proto - -package com.google.api; - -/** - * Protobuf type {@code google.api.VisibilityRule} - * - *
      - * A visibility rule provides visibility configuration for an individual API
      - * element.
      - * 
      - */ -public final class VisibilityRule extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.api.VisibilityRule) - VisibilityRuleOrBuilder { - // Use VisibilityRule.newBuilder() to construct. - private VisibilityRule(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private VisibilityRule() { - selector_ = ""; - restriction_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private VisibilityRule( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - selector_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - restriction_ = s; - break; - } - case 26: { - com.google.protobuf.BoolValue.Builder subBuilder = null; - if (enforceRuntimeVisibility_ != null) { - subBuilder = enforceRuntimeVisibility_.toBuilder(); - } - enforceRuntimeVisibility_ = input.readMessage(com.google.protobuf.BoolValue.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(enforceRuntimeVisibility_); - enforceRuntimeVisibility_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.VisibilityProto.internal_static_google_api_VisibilityRule_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.VisibilityProto.internal_static_google_api_VisibilityRule_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.VisibilityRule.class, com.google.api.VisibilityRule.Builder.class); - } - - public static final int SELECTOR_FIELD_NUMBER = 1; - private volatile java.lang.Object selector_; - /** - * optional string selector = 1; - * - *
      -   * Selects methods, messages, fields, enums, etc. to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - public java.lang.String getSelector() { - java.lang.Object ref = selector_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - selector_ = s; - return s; - } - } - /** - * optional string selector = 1; - * - *
      -   * Selects methods, messages, fields, enums, etc. to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSelectorBytes() { - java.lang.Object ref = selector_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - selector_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RESTRICTION_FIELD_NUMBER = 2; - private volatile java.lang.Object restriction_; - /** - * optional string restriction = 2; - * - *
      -   * Lists the visibility labels for this rule. Any of the listed labels grants
      -   * visibility to the element.
      -   * If a rule has multiple labels, removing one of the labels but not all of
      -   * them can break clients.
      -   * Example:
      -   *     visibility:
      -   *       rules:
      -   *       - selector: google.calendar.Calendar.EnhancedSearch
      -   *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      -   * Removing GOOGLE_INTERNAL from this restriction will break clients that
      -   * rely on this method and only had access to it through GOOGLE_INTERNAL.
      -   * 
      - */ - public java.lang.String getRestriction() { - java.lang.Object ref = restriction_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - restriction_ = s; - return s; - } - } - /** - * optional string restriction = 2; - * - *
      -   * Lists the visibility labels for this rule. Any of the listed labels grants
      -   * visibility to the element.
      -   * If a rule has multiple labels, removing one of the labels but not all of
      -   * them can break clients.
      -   * Example:
      -   *     visibility:
      -   *       rules:
      -   *       - selector: google.calendar.Calendar.EnhancedSearch
      -   *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      -   * Removing GOOGLE_INTERNAL from this restriction will break clients that
      -   * rely on this method and only had access to it through GOOGLE_INTERNAL.
      -   * 
      - */ - public com.google.protobuf.ByteString - getRestrictionBytes() { - java.lang.Object ref = restriction_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - restriction_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int ENFORCE_RUNTIME_VISIBILITY_FIELD_NUMBER = 3; - private com.google.protobuf.BoolValue enforceRuntimeVisibility_; - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility is enforced at runtime for requests to an API
      -   * method. This setting has meaning only when the selector applies to a method
      -   * or an API.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is determined by the value of
      -   * [google.api.Visibility.enforce_runtime_visibility][].
      -   * 
      - */ - public boolean hasEnforceRuntimeVisibility() { - return enforceRuntimeVisibility_ != null; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility is enforced at runtime for requests to an API
      -   * method. This setting has meaning only when the selector applies to a method
      -   * or an API.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is determined by the value of
      -   * [google.api.Visibility.enforce_runtime_visibility][].
      -   * 
      - */ - public com.google.protobuf.BoolValue getEnforceRuntimeVisibility() { - return enforceRuntimeVisibility_ == null ? com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility is enforced at runtime for requests to an API
      -   * method. This setting has meaning only when the selector applies to a method
      -   * or an API.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is determined by the value of
      -   * [google.api.Visibility.enforce_runtime_visibility][].
      -   * 
      - */ - public com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder() { - return getEnforceRuntimeVisibility(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSelectorBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, selector_); - } - if (!getRestrictionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, restriction_); - } - if (enforceRuntimeVisibility_ != null) { - output.writeMessage(3, getEnforceRuntimeVisibility()); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSelectorBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, selector_); - } - if (!getRestrictionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, restriction_); - } - if (enforceRuntimeVisibility_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, getEnforceRuntimeVisibility()); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.api.VisibilityRule parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.VisibilityRule parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.VisibilityRule parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.api.VisibilityRule parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.api.VisibilityRule parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.VisibilityRule parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.api.VisibilityRule parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.api.VisibilityRule parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.api.VisibilityRule parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.api.VisibilityRule parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.api.VisibilityRule prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.api.VisibilityRule} - * - *
      -   * A visibility rule provides visibility configuration for an individual API
      -   * element.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.api.VisibilityRule) - com.google.api.VisibilityRuleOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.api.VisibilityProto.internal_static_google_api_VisibilityRule_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.api.VisibilityProto.internal_static_google_api_VisibilityRule_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.api.VisibilityRule.class, com.google.api.VisibilityRule.Builder.class); - } - - // Construct using com.google.api.VisibilityRule.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - selector_ = ""; - - restriction_ = ""; - - if (enforceRuntimeVisibilityBuilder_ == null) { - enforceRuntimeVisibility_ = null; - } else { - enforceRuntimeVisibility_ = null; - enforceRuntimeVisibilityBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.api.VisibilityProto.internal_static_google_api_VisibilityRule_descriptor; - } - - public com.google.api.VisibilityRule getDefaultInstanceForType() { - return com.google.api.VisibilityRule.getDefaultInstance(); - } - - public com.google.api.VisibilityRule build() { - com.google.api.VisibilityRule result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.api.VisibilityRule buildPartial() { - com.google.api.VisibilityRule result = new com.google.api.VisibilityRule(this); - result.selector_ = selector_; - result.restriction_ = restriction_; - if (enforceRuntimeVisibilityBuilder_ == null) { - result.enforceRuntimeVisibility_ = enforceRuntimeVisibility_; - } else { - result.enforceRuntimeVisibility_ = enforceRuntimeVisibilityBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.api.VisibilityRule) { - return mergeFrom((com.google.api.VisibilityRule)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.api.VisibilityRule other) { - if (other == com.google.api.VisibilityRule.getDefaultInstance()) return this; - if (!other.getSelector().isEmpty()) { - selector_ = other.selector_; - onChanged(); - } - if (!other.getRestriction().isEmpty()) { - restriction_ = other.restriction_; - onChanged(); - } - if (other.hasEnforceRuntimeVisibility()) { - mergeEnforceRuntimeVisibility(other.getEnforceRuntimeVisibility()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.api.VisibilityRule parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.api.VisibilityRule) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object selector_ = ""; - /** - * optional string selector = 1; - * - *
      -     * Selects methods, messages, fields, enums, etc. to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public java.lang.String getSelector() { - java.lang.Object ref = selector_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - selector_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string selector = 1; - * - *
      -     * Selects methods, messages, fields, enums, etc. to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSelectorBytes() { - java.lang.Object ref = selector_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - selector_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string selector = 1; - * - *
      -     * Selects methods, messages, fields, enums, etc. to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder setSelector( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - selector_ = value; - onChanged(); - return this; - } - /** - * optional string selector = 1; - * - *
      -     * Selects methods, messages, fields, enums, etc. to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder clearSelector() { - - selector_ = getDefaultInstance().getSelector(); - onChanged(); - return this; - } - /** - * optional string selector = 1; - * - *
      -     * Selects methods, messages, fields, enums, etc. to which this rule applies.
      -     * Refer to [selector][DocumentationRule.selector] for syntax details.
      -     * 
      - */ - public Builder setSelectorBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - selector_ = value; - onChanged(); - return this; - } - - private java.lang.Object restriction_ = ""; - /** - * optional string restriction = 2; - * - *
      -     * Lists the visibility labels for this rule. Any of the listed labels grants
      -     * visibility to the element.
      -     * If a rule has multiple labels, removing one of the labels but not all of
      -     * them can break clients.
      -     * Example:
      -     *     visibility:
      -     *       rules:
      -     *       - selector: google.calendar.Calendar.EnhancedSearch
      -     *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      -     * Removing GOOGLE_INTERNAL from this restriction will break clients that
      -     * rely on this method and only had access to it through GOOGLE_INTERNAL.
      -     * 
      - */ - public java.lang.String getRestriction() { - java.lang.Object ref = restriction_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - restriction_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string restriction = 2; - * - *
      -     * Lists the visibility labels for this rule. Any of the listed labels grants
      -     * visibility to the element.
      -     * If a rule has multiple labels, removing one of the labels but not all of
      -     * them can break clients.
      -     * Example:
      -     *     visibility:
      -     *       rules:
      -     *       - selector: google.calendar.Calendar.EnhancedSearch
      -     *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      -     * Removing GOOGLE_INTERNAL from this restriction will break clients that
      -     * rely on this method and only had access to it through GOOGLE_INTERNAL.
      -     * 
      - */ - public com.google.protobuf.ByteString - getRestrictionBytes() { - java.lang.Object ref = restriction_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - restriction_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string restriction = 2; - * - *
      -     * Lists the visibility labels for this rule. Any of the listed labels grants
      -     * visibility to the element.
      -     * If a rule has multiple labels, removing one of the labels but not all of
      -     * them can break clients.
      -     * Example:
      -     *     visibility:
      -     *       rules:
      -     *       - selector: google.calendar.Calendar.EnhancedSearch
      -     *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      -     * Removing GOOGLE_INTERNAL from this restriction will break clients that
      -     * rely on this method and only had access to it through GOOGLE_INTERNAL.
      -     * 
      - */ - public Builder setRestriction( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - restriction_ = value; - onChanged(); - return this; - } - /** - * optional string restriction = 2; - * - *
      -     * Lists the visibility labels for this rule. Any of the listed labels grants
      -     * visibility to the element.
      -     * If a rule has multiple labels, removing one of the labels but not all of
      -     * them can break clients.
      -     * Example:
      -     *     visibility:
      -     *       rules:
      -     *       - selector: google.calendar.Calendar.EnhancedSearch
      -     *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      -     * Removing GOOGLE_INTERNAL from this restriction will break clients that
      -     * rely on this method and only had access to it through GOOGLE_INTERNAL.
      -     * 
      - */ - public Builder clearRestriction() { - - restriction_ = getDefaultInstance().getRestriction(); - onChanged(); - return this; - } - /** - * optional string restriction = 2; - * - *
      -     * Lists the visibility labels for this rule. Any of the listed labels grants
      -     * visibility to the element.
      -     * If a rule has multiple labels, removing one of the labels but not all of
      -     * them can break clients.
      -     * Example:
      -     *     visibility:
      -     *       rules:
      -     *       - selector: google.calendar.Calendar.EnhancedSearch
      -     *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      -     * Removing GOOGLE_INTERNAL from this restriction will break clients that
      -     * rely on this method and only had access to it through GOOGLE_INTERNAL.
      -     * 
      - */ - public Builder setRestrictionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - restriction_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.BoolValue enforceRuntimeVisibility_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder> enforceRuntimeVisibilityBuilder_; - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility is enforced at runtime for requests to an API
      -     * method. This setting has meaning only when the selector applies to a method
      -     * or an API.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is determined by the value of
      -     * [google.api.Visibility.enforce_runtime_visibility][].
      -     * 
      - */ - public boolean hasEnforceRuntimeVisibility() { - return enforceRuntimeVisibilityBuilder_ != null || enforceRuntimeVisibility_ != null; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility is enforced at runtime for requests to an API
      -     * method. This setting has meaning only when the selector applies to a method
      -     * or an API.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is determined by the value of
      -     * [google.api.Visibility.enforce_runtime_visibility][].
      -     * 
      - */ - public com.google.protobuf.BoolValue getEnforceRuntimeVisibility() { - if (enforceRuntimeVisibilityBuilder_ == null) { - return enforceRuntimeVisibility_ == null ? com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; - } else { - return enforceRuntimeVisibilityBuilder_.getMessage(); - } - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility is enforced at runtime for requests to an API
      -     * method. This setting has meaning only when the selector applies to a method
      -     * or an API.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is determined by the value of
      -     * [google.api.Visibility.enforce_runtime_visibility][].
      -     * 
      - */ - public Builder setEnforceRuntimeVisibility(com.google.protobuf.BoolValue value) { - if (enforceRuntimeVisibilityBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - enforceRuntimeVisibility_ = value; - onChanged(); - } else { - enforceRuntimeVisibilityBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility is enforced at runtime for requests to an API
      -     * method. This setting has meaning only when the selector applies to a method
      -     * or an API.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is determined by the value of
      -     * [google.api.Visibility.enforce_runtime_visibility][].
      -     * 
      - */ - public Builder setEnforceRuntimeVisibility( - com.google.protobuf.BoolValue.Builder builderForValue) { - if (enforceRuntimeVisibilityBuilder_ == null) { - enforceRuntimeVisibility_ = builderForValue.build(); - onChanged(); - } else { - enforceRuntimeVisibilityBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility is enforced at runtime for requests to an API
      -     * method. This setting has meaning only when the selector applies to a method
      -     * or an API.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is determined by the value of
      -     * [google.api.Visibility.enforce_runtime_visibility][].
      -     * 
      - */ - public Builder mergeEnforceRuntimeVisibility(com.google.protobuf.BoolValue value) { - if (enforceRuntimeVisibilityBuilder_ == null) { - if (enforceRuntimeVisibility_ != null) { - enforceRuntimeVisibility_ = - com.google.protobuf.BoolValue.newBuilder(enforceRuntimeVisibility_).mergeFrom(value).buildPartial(); - } else { - enforceRuntimeVisibility_ = value; - } - onChanged(); - } else { - enforceRuntimeVisibilityBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility is enforced at runtime for requests to an API
      -     * method. This setting has meaning only when the selector applies to a method
      -     * or an API.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is determined by the value of
      -     * [google.api.Visibility.enforce_runtime_visibility][].
      -     * 
      - */ - public Builder clearEnforceRuntimeVisibility() { - if (enforceRuntimeVisibilityBuilder_ == null) { - enforceRuntimeVisibility_ = null; - onChanged(); - } else { - enforceRuntimeVisibility_ = null; - enforceRuntimeVisibilityBuilder_ = null; - } - - return this; - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility is enforced at runtime for requests to an API
      -     * method. This setting has meaning only when the selector applies to a method
      -     * or an API.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is determined by the value of
      -     * [google.api.Visibility.enforce_runtime_visibility][].
      -     * 
      - */ - public com.google.protobuf.BoolValue.Builder getEnforceRuntimeVisibilityBuilder() { - - onChanged(); - return getEnforceRuntimeVisibilityFieldBuilder().getBuilder(); - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility is enforced at runtime for requests to an API
      -     * method. This setting has meaning only when the selector applies to a method
      -     * or an API.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is determined by the value of
      -     * [google.api.Visibility.enforce_runtime_visibility][].
      -     * 
      - */ - public com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder() { - if (enforceRuntimeVisibilityBuilder_ != null) { - return enforceRuntimeVisibilityBuilder_.getMessageOrBuilder(); - } else { - return enforceRuntimeVisibility_ == null ? - com.google.protobuf.BoolValue.getDefaultInstance() : enforceRuntimeVisibility_; - } - } - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -     * Controls whether visibility is enforced at runtime for requests to an API
      -     * method. This setting has meaning only when the selector applies to a method
      -     * or an API.
      -     * If true, requests without method visibility will receive a
      -     * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -     * the response messages. The default is determined by the value of
      -     * [google.api.Visibility.enforce_runtime_visibility][].
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder> - getEnforceRuntimeVisibilityFieldBuilder() { - if (enforceRuntimeVisibilityBuilder_ == null) { - enforceRuntimeVisibilityBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.BoolValue, com.google.protobuf.BoolValue.Builder, com.google.protobuf.BoolValueOrBuilder>( - getEnforceRuntimeVisibility(), - getParentForChildren(), - isClean()); - enforceRuntimeVisibility_ = null; - } - return enforceRuntimeVisibilityBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.api.VisibilityRule) - } - - // @@protoc_insertion_point(class_scope:google.api.VisibilityRule) - private static final com.google.api.VisibilityRule DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.api.VisibilityRule(); - } - - public static com.google.api.VisibilityRule getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public VisibilityRule parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new VisibilityRule(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.api.VisibilityRule getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRuleOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRuleOrBuilder.java deleted file mode 100644 index 130f46c58ada..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/api/VisibilityRuleOrBuilder.java +++ /dev/null @@ -1,110 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/api/visibility.proto - -package com.google.api; - -public interface VisibilityRuleOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.api.VisibilityRule) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string selector = 1; - * - *
      -   * Selects methods, messages, fields, enums, etc. to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - java.lang.String getSelector(); - /** - * optional string selector = 1; - * - *
      -   * Selects methods, messages, fields, enums, etc. to which this rule applies.
      -   * Refer to [selector][DocumentationRule.selector] for syntax details.
      -   * 
      - */ - com.google.protobuf.ByteString - getSelectorBytes(); - - /** - * optional string restriction = 2; - * - *
      -   * Lists the visibility labels for this rule. Any of the listed labels grants
      -   * visibility to the element.
      -   * If a rule has multiple labels, removing one of the labels but not all of
      -   * them can break clients.
      -   * Example:
      -   *     visibility:
      -   *       rules:
      -   *       - selector: google.calendar.Calendar.EnhancedSearch
      -   *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      -   * Removing GOOGLE_INTERNAL from this restriction will break clients that
      -   * rely on this method and only had access to it through GOOGLE_INTERNAL.
      -   * 
      - */ - java.lang.String getRestriction(); - /** - * optional string restriction = 2; - * - *
      -   * Lists the visibility labels for this rule. Any of the listed labels grants
      -   * visibility to the element.
      -   * If a rule has multiple labels, removing one of the labels but not all of
      -   * them can break clients.
      -   * Example:
      -   *     visibility:
      -   *       rules:
      -   *       - selector: google.calendar.Calendar.EnhancedSearch
      -   *         restriction: GOOGLE_INTERNAL, TRUSTED_TESTER
      -   * Removing GOOGLE_INTERNAL from this restriction will break clients that
      -   * rely on this method and only had access to it through GOOGLE_INTERNAL.
      -   * 
      - */ - com.google.protobuf.ByteString - getRestrictionBytes(); - - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility is enforced at runtime for requests to an API
      -   * method. This setting has meaning only when the selector applies to a method
      -   * or an API.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is determined by the value of
      -   * [google.api.Visibility.enforce_runtime_visibility][].
      -   * 
      - */ - boolean hasEnforceRuntimeVisibility(); - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility is enforced at runtime for requests to an API
      -   * method. This setting has meaning only when the selector applies to a method
      -   * or an API.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is determined by the value of
      -   * [google.api.Visibility.enforce_runtime_visibility][].
      -   * 
      - */ - com.google.protobuf.BoolValue getEnforceRuntimeVisibility(); - /** - * optional .google.protobuf.BoolValue enforce_runtime_visibility = 3; - * - *
      -   * Controls whether visibility is enforced at runtime for requests to an API
      -   * method. This setting has meaning only when the selector applies to a method
      -   * or an API.
      -   * If true, requests without method visibility will receive a
      -   * NOT_FOUND error, and any non-visible fields will be scrubbed from
      -   * the response messages. The default is determined by the value of
      -   * [google.api.Visibility.enforce_runtime_visibility][].
      -   * 
      - */ - com.google.protobuf.BoolValueOrBuilder getEnforceRuntimeVisibilityOrBuilder(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequest.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequest.java deleted file mode 100644 index fe7f54b5b58f..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequest.java +++ /dev/null @@ -1,476 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -/** - * Protobuf type {@code google.longrunning.CancelOperationRequest} - * - *
      - * The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
      - * 
      - */ -public final class CancelOperationRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.longrunning.CancelOperationRequest) - CancelOperationRequestOrBuilder { - // Use CancelOperationRequest.newBuilder() to construct. - private CancelOperationRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private CancelOperationRequest() { - name_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private CancelOperationRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - name_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_CancelOperationRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_CancelOperationRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.CancelOperationRequest.class, com.google.longrunning.CancelOperationRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource to be cancelled.
      -   * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource to be cancelled.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.longrunning.CancelOperationRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.CancelOperationRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.CancelOperationRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.CancelOperationRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.CancelOperationRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.CancelOperationRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.longrunning.CancelOperationRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.longrunning.CancelOperationRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.longrunning.CancelOperationRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.CancelOperationRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.longrunning.CancelOperationRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.longrunning.CancelOperationRequest} - * - *
      -   * The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation].
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.longrunning.CancelOperationRequest) - com.google.longrunning.CancelOperationRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_CancelOperationRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_CancelOperationRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.CancelOperationRequest.class, com.google.longrunning.CancelOperationRequest.Builder.class); - } - - // Construct using com.google.longrunning.CancelOperationRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - name_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_CancelOperationRequest_descriptor; - } - - public com.google.longrunning.CancelOperationRequest getDefaultInstanceForType() { - return com.google.longrunning.CancelOperationRequest.getDefaultInstance(); - } - - public com.google.longrunning.CancelOperationRequest build() { - com.google.longrunning.CancelOperationRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.longrunning.CancelOperationRequest buildPartial() { - com.google.longrunning.CancelOperationRequest result = new com.google.longrunning.CancelOperationRequest(this); - result.name_ = name_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.longrunning.CancelOperationRequest) { - return mergeFrom((com.google.longrunning.CancelOperationRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.longrunning.CancelOperationRequest other) { - if (other == com.google.longrunning.CancelOperationRequest.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.longrunning.CancelOperationRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.longrunning.CancelOperationRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object name_ = ""; - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource to be cancelled.
      -     * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource to be cancelled.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource to be cancelled.
      -     * 
      - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource to be cancelled.
      -     * 
      - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource to be cancelled.
      -     * 
      - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.longrunning.CancelOperationRequest) - } - - // @@protoc_insertion_point(class_scope:google.longrunning.CancelOperationRequest) - private static final com.google.longrunning.CancelOperationRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.longrunning.CancelOperationRequest(); - } - - public static com.google.longrunning.CancelOperationRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public CancelOperationRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new CancelOperationRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.longrunning.CancelOperationRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequestOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequestOrBuilder.java deleted file mode 100644 index 86004606c35d..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/CancelOperationRequestOrBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -public interface CancelOperationRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.longrunning.CancelOperationRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource to be cancelled.
      -   * 
      - */ - java.lang.String getName(); - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource to be cancelled.
      -   * 
      - */ - com.google.protobuf.ByteString - getNameBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequest.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequest.java deleted file mode 100644 index d10d1e3300aa..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequest.java +++ /dev/null @@ -1,476 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -/** - * Protobuf type {@code google.longrunning.DeleteOperationRequest} - * - *
      - * The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
      - * 
      - */ -public final class DeleteOperationRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.longrunning.DeleteOperationRequest) - DeleteOperationRequestOrBuilder { - // Use DeleteOperationRequest.newBuilder() to construct. - private DeleteOperationRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private DeleteOperationRequest() { - name_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private DeleteOperationRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - name_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_DeleteOperationRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_DeleteOperationRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.DeleteOperationRequest.class, com.google.longrunning.DeleteOperationRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource to be deleted.
      -   * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource to be deleted.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.longrunning.DeleteOperationRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.DeleteOperationRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.DeleteOperationRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.DeleteOperationRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.DeleteOperationRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.DeleteOperationRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.longrunning.DeleteOperationRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.longrunning.DeleteOperationRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.longrunning.DeleteOperationRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.DeleteOperationRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.longrunning.DeleteOperationRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.longrunning.DeleteOperationRequest} - * - *
      -   * The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation].
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.longrunning.DeleteOperationRequest) - com.google.longrunning.DeleteOperationRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_DeleteOperationRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_DeleteOperationRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.DeleteOperationRequest.class, com.google.longrunning.DeleteOperationRequest.Builder.class); - } - - // Construct using com.google.longrunning.DeleteOperationRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - name_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_DeleteOperationRequest_descriptor; - } - - public com.google.longrunning.DeleteOperationRequest getDefaultInstanceForType() { - return com.google.longrunning.DeleteOperationRequest.getDefaultInstance(); - } - - public com.google.longrunning.DeleteOperationRequest build() { - com.google.longrunning.DeleteOperationRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.longrunning.DeleteOperationRequest buildPartial() { - com.google.longrunning.DeleteOperationRequest result = new com.google.longrunning.DeleteOperationRequest(this); - result.name_ = name_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.longrunning.DeleteOperationRequest) { - return mergeFrom((com.google.longrunning.DeleteOperationRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.longrunning.DeleteOperationRequest other) { - if (other == com.google.longrunning.DeleteOperationRequest.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.longrunning.DeleteOperationRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.longrunning.DeleteOperationRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object name_ = ""; - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource to be deleted.
      -     * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource to be deleted.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource to be deleted.
      -     * 
      - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource to be deleted.
      -     * 
      - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource to be deleted.
      -     * 
      - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.longrunning.DeleteOperationRequest) - } - - // @@protoc_insertion_point(class_scope:google.longrunning.DeleteOperationRequest) - private static final com.google.longrunning.DeleteOperationRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.longrunning.DeleteOperationRequest(); - } - - public static com.google.longrunning.DeleteOperationRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public DeleteOperationRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new DeleteOperationRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.longrunning.DeleteOperationRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequestOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequestOrBuilder.java deleted file mode 100644 index 16f7c82c171a..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/DeleteOperationRequestOrBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -public interface DeleteOperationRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.longrunning.DeleteOperationRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource to be deleted.
      -   * 
      - */ - java.lang.String getName(); - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource to be deleted.
      -   * 
      - */ - com.google.protobuf.ByteString - getNameBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequest.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequest.java deleted file mode 100644 index 111563850c1a..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequest.java +++ /dev/null @@ -1,476 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -/** - * Protobuf type {@code google.longrunning.GetOperationRequest} - * - *
      - * The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation].
      - * 
      - */ -public final class GetOperationRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.longrunning.GetOperationRequest) - GetOperationRequestOrBuilder { - // Use GetOperationRequest.newBuilder() to construct. - private GetOperationRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private GetOperationRequest() { - name_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private GetOperationRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - name_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_GetOperationRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_GetOperationRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.GetOperationRequest.class, com.google.longrunning.GetOperationRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource.
      -   * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.longrunning.GetOperationRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.GetOperationRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.GetOperationRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.GetOperationRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.GetOperationRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.GetOperationRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.longrunning.GetOperationRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.longrunning.GetOperationRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.longrunning.GetOperationRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.GetOperationRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.longrunning.GetOperationRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.longrunning.GetOperationRequest} - * - *
      -   * The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation].
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.longrunning.GetOperationRequest) - com.google.longrunning.GetOperationRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_GetOperationRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_GetOperationRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.GetOperationRequest.class, com.google.longrunning.GetOperationRequest.Builder.class); - } - - // Construct using com.google.longrunning.GetOperationRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - name_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_GetOperationRequest_descriptor; - } - - public com.google.longrunning.GetOperationRequest getDefaultInstanceForType() { - return com.google.longrunning.GetOperationRequest.getDefaultInstance(); - } - - public com.google.longrunning.GetOperationRequest build() { - com.google.longrunning.GetOperationRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.longrunning.GetOperationRequest buildPartial() { - com.google.longrunning.GetOperationRequest result = new com.google.longrunning.GetOperationRequest(this); - result.name_ = name_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.longrunning.GetOperationRequest) { - return mergeFrom((com.google.longrunning.GetOperationRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.longrunning.GetOperationRequest other) { - if (other == com.google.longrunning.GetOperationRequest.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.longrunning.GetOperationRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.longrunning.GetOperationRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object name_ = ""; - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource.
      -     * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource.
      -     * 
      - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource.
      -     * 
      - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource.
      -     * 
      - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.longrunning.GetOperationRequest) - } - - // @@protoc_insertion_point(class_scope:google.longrunning.GetOperationRequest) - private static final com.google.longrunning.GetOperationRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.longrunning.GetOperationRequest(); - } - - public static com.google.longrunning.GetOperationRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public GetOperationRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new GetOperationRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.longrunning.GetOperationRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequestOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequestOrBuilder.java deleted file mode 100644 index 099a7072cd23..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/GetOperationRequestOrBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -public interface GetOperationRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.longrunning.GetOperationRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource.
      -   * 
      - */ - java.lang.String getName(); - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource.
      -   * 
      - */ - com.google.protobuf.ByteString - getNameBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequest.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequest.java deleted file mode 100644 index 12a996ead622..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequest.java +++ /dev/null @@ -1,848 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -/** - * Protobuf type {@code google.longrunning.ListOperationsRequest} - * - *
      - * The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
      - * 
      - */ -public final class ListOperationsRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.longrunning.ListOperationsRequest) - ListOperationsRequestOrBuilder { - // Use ListOperationsRequest.newBuilder() to construct. - private ListOperationsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ListOperationsRequest() { - name_ = ""; - filter_ = ""; - pageSize_ = 0; - pageToken_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ListOperationsRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - filter_ = s; - break; - } - case 16: { - - pageSize_ = input.readInt32(); - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - pageToken_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - name_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.ListOperationsRequest.class, com.google.longrunning.ListOperationsRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 4; - private volatile java.lang.Object name_; - /** - * optional string name = 4; - * - *
      -   * The name of the operation collection.
      -   * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * optional string name = 4; - * - *
      -   * The name of the operation collection.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int FILTER_FIELD_NUMBER = 1; - private volatile java.lang.Object filter_; - /** - * optional string filter = 1; - * - *
      -   * The standard List filter.
      -   * 
      - */ - public java.lang.String getFilter() { - java.lang.Object ref = filter_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - filter_ = s; - return s; - } - } - /** - * optional string filter = 1; - * - *
      -   * The standard List filter.
      -   * 
      - */ - public com.google.protobuf.ByteString - getFilterBytes() { - java.lang.Object ref = filter_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - filter_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PAGE_SIZE_FIELD_NUMBER = 2; - private int pageSize_; - /** - * optional int32 page_size = 2; - * - *
      -   * The standard List page size.
      -   * 
      - */ - public int getPageSize() { - return pageSize_; - } - - public static final int PAGE_TOKEN_FIELD_NUMBER = 3; - private volatile java.lang.Object pageToken_; - /** - * optional string page_token = 3; - * - *
      -   * The standard List page token.
      -   * 
      - */ - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } - } - /** - * optional string page_token = 3; - * - *
      -   * The standard List page token.
      -   * 
      - */ - public com.google.protobuf.ByteString - getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getFilterBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, filter_); - } - if (pageSize_ != 0) { - output.writeInt32(2, pageSize_); - } - if (!getPageTokenBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 3, pageToken_); - } - if (!getNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 4, name_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getFilterBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, filter_); - } - if (pageSize_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, pageSize_); - } - if (!getPageTokenBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pageToken_); - } - if (!getNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(4, name_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.longrunning.ListOperationsRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.ListOperationsRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.ListOperationsRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.ListOperationsRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.ListOperationsRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.ListOperationsRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.longrunning.ListOperationsRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.longrunning.ListOperationsRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.longrunning.ListOperationsRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.ListOperationsRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.longrunning.ListOperationsRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.longrunning.ListOperationsRequest} - * - *
      -   * The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.longrunning.ListOperationsRequest) - com.google.longrunning.ListOperationsRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.ListOperationsRequest.class, com.google.longrunning.ListOperationsRequest.Builder.class); - } - - // Construct using com.google.longrunning.ListOperationsRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - name_ = ""; - - filter_ = ""; - - pageSize_ = 0; - - pageToken_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsRequest_descriptor; - } - - public com.google.longrunning.ListOperationsRequest getDefaultInstanceForType() { - return com.google.longrunning.ListOperationsRequest.getDefaultInstance(); - } - - public com.google.longrunning.ListOperationsRequest build() { - com.google.longrunning.ListOperationsRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.longrunning.ListOperationsRequest buildPartial() { - com.google.longrunning.ListOperationsRequest result = new com.google.longrunning.ListOperationsRequest(this); - result.name_ = name_; - result.filter_ = filter_; - result.pageSize_ = pageSize_; - result.pageToken_ = pageToken_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.longrunning.ListOperationsRequest) { - return mergeFrom((com.google.longrunning.ListOperationsRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.longrunning.ListOperationsRequest other) { - if (other == com.google.longrunning.ListOperationsRequest.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (!other.getFilter().isEmpty()) { - filter_ = other.filter_; - onChanged(); - } - if (other.getPageSize() != 0) { - setPageSize(other.getPageSize()); - } - if (!other.getPageToken().isEmpty()) { - pageToken_ = other.pageToken_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.longrunning.ListOperationsRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.longrunning.ListOperationsRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object name_ = ""; - /** - * optional string name = 4; - * - *
      -     * The name of the operation collection.
      -     * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string name = 4; - * - *
      -     * The name of the operation collection.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string name = 4; - * - *
      -     * The name of the operation collection.
      -     * 
      - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * optional string name = 4; - * - *
      -     * The name of the operation collection.
      -     * 
      - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * optional string name = 4; - * - *
      -     * The name of the operation collection.
      -     * 
      - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private java.lang.Object filter_ = ""; - /** - * optional string filter = 1; - * - *
      -     * The standard List filter.
      -     * 
      - */ - public java.lang.String getFilter() { - java.lang.Object ref = filter_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - filter_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string filter = 1; - * - *
      -     * The standard List filter.
      -     * 
      - */ - public com.google.protobuf.ByteString - getFilterBytes() { - java.lang.Object ref = filter_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - filter_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string filter = 1; - * - *
      -     * The standard List filter.
      -     * 
      - */ - public Builder setFilter( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - filter_ = value; - onChanged(); - return this; - } - /** - * optional string filter = 1; - * - *
      -     * The standard List filter.
      -     * 
      - */ - public Builder clearFilter() { - - filter_ = getDefaultInstance().getFilter(); - onChanged(); - return this; - } - /** - * optional string filter = 1; - * - *
      -     * The standard List filter.
      -     * 
      - */ - public Builder setFilterBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - filter_ = value; - onChanged(); - return this; - } - - private int pageSize_ ; - /** - * optional int32 page_size = 2; - * - *
      -     * The standard List page size.
      -     * 
      - */ - public int getPageSize() { - return pageSize_; - } - /** - * optional int32 page_size = 2; - * - *
      -     * The standard List page size.
      -     * 
      - */ - public Builder setPageSize(int value) { - - pageSize_ = value; - onChanged(); - return this; - } - /** - * optional int32 page_size = 2; - * - *
      -     * The standard List page size.
      -     * 
      - */ - public Builder clearPageSize() { - - pageSize_ = 0; - onChanged(); - return this; - } - - private java.lang.Object pageToken_ = ""; - /** - * optional string page_token = 3; - * - *
      -     * The standard List page token.
      -     * 
      - */ - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string page_token = 3; - * - *
      -     * The standard List page token.
      -     * 
      - */ - public com.google.protobuf.ByteString - getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string page_token = 3; - * - *
      -     * The standard List page token.
      -     * 
      - */ - public Builder setPageToken( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - pageToken_ = value; - onChanged(); - return this; - } - /** - * optional string page_token = 3; - * - *
      -     * The standard List page token.
      -     * 
      - */ - public Builder clearPageToken() { - - pageToken_ = getDefaultInstance().getPageToken(); - onChanged(); - return this; - } - /** - * optional string page_token = 3; - * - *
      -     * The standard List page token.
      -     * 
      - */ - public Builder setPageTokenBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pageToken_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.longrunning.ListOperationsRequest) - } - - // @@protoc_insertion_point(class_scope:google.longrunning.ListOperationsRequest) - private static final com.google.longrunning.ListOperationsRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.longrunning.ListOperationsRequest(); - } - - public static com.google.longrunning.ListOperationsRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ListOperationsRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ListOperationsRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.longrunning.ListOperationsRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequestOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequestOrBuilder.java deleted file mode 100644 index 4d16f4b037d3..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsRequestOrBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -public interface ListOperationsRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.longrunning.ListOperationsRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string name = 4; - * - *
      -   * The name of the operation collection.
      -   * 
      - */ - java.lang.String getName(); - /** - * optional string name = 4; - * - *
      -   * The name of the operation collection.
      -   * 
      - */ - com.google.protobuf.ByteString - getNameBytes(); - - /** - * optional string filter = 1; - * - *
      -   * The standard List filter.
      -   * 
      - */ - java.lang.String getFilter(); - /** - * optional string filter = 1; - * - *
      -   * The standard List filter.
      -   * 
      - */ - com.google.protobuf.ByteString - getFilterBytes(); - - /** - * optional int32 page_size = 2; - * - *
      -   * The standard List page size.
      -   * 
      - */ - int getPageSize(); - - /** - * optional string page_token = 3; - * - *
      -   * The standard List page token.
      -   * 
      - */ - java.lang.String getPageToken(); - /** - * optional string page_token = 3; - * - *
      -   * The standard List page token.
      -   * 
      - */ - com.google.protobuf.ByteString - getPageTokenBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponse.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponse.java deleted file mode 100644 index 7d329933d9e6..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponse.java +++ /dev/null @@ -1,909 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -/** - * Protobuf type {@code google.longrunning.ListOperationsResponse} - * - *
      - * The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
      - * 
      - */ -public final class ListOperationsResponse extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.longrunning.ListOperationsResponse) - ListOperationsResponseOrBuilder { - // Use ListOperationsResponse.newBuilder() to construct. - private ListOperationsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ListOperationsResponse() { - operations_ = java.util.Collections.emptyList(); - nextPageToken_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ListOperationsResponse( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - operations_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - operations_.add(input.readMessage(com.google.longrunning.Operation.parser(), extensionRegistry)); - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - nextPageToken_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - operations_ = java.util.Collections.unmodifiableList(operations_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.ListOperationsResponse.class, com.google.longrunning.ListOperationsResponse.Builder.class); - } - - private int bitField0_; - public static final int OPERATIONS_FIELD_NUMBER = 1; - private java.util.List operations_; - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -   * A list of operations that match the specified filter in the request.
      -   * 
      - */ - public java.util.List getOperationsList() { - return operations_; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -   * A list of operations that match the specified filter in the request.
      -   * 
      - */ - public java.util.List - getOperationsOrBuilderList() { - return operations_; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -   * A list of operations that match the specified filter in the request.
      -   * 
      - */ - public int getOperationsCount() { - return operations_.size(); - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -   * A list of operations that match the specified filter in the request.
      -   * 
      - */ - public com.google.longrunning.Operation getOperations(int index) { - return operations_.get(index); - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -   * A list of operations that match the specified filter in the request.
      -   * 
      - */ - public com.google.longrunning.OperationOrBuilder getOperationsOrBuilder( - int index) { - return operations_.get(index); - } - - public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; - private volatile java.lang.Object nextPageToken_; - /** - * optional string next_page_token = 2; - * - *
      -   * The standard List next-page token.
      -   * 
      - */ - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } - } - /** - * optional string next_page_token = 2; - * - *
      -   * The standard List next-page token.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < operations_.size(); i++) { - output.writeMessage(1, operations_.get(i)); - } - if (!getNextPageTokenBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < operations_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, operations_.get(i)); - } - if (!getNextPageTokenBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.longrunning.ListOperationsResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.ListOperationsResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.ListOperationsResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.ListOperationsResponse parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.ListOperationsResponse parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.ListOperationsResponse parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.longrunning.ListOperationsResponse parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.longrunning.ListOperationsResponse parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.longrunning.ListOperationsResponse parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.ListOperationsResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.longrunning.ListOperationsResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.longrunning.ListOperationsResponse} - * - *
      -   * The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations].
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.longrunning.ListOperationsResponse) - com.google.longrunning.ListOperationsResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.ListOperationsResponse.class, com.google.longrunning.ListOperationsResponse.Builder.class); - } - - // Construct using com.google.longrunning.ListOperationsResponse.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getOperationsFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (operationsBuilder_ == null) { - operations_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - operationsBuilder_.clear(); - } - nextPageToken_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_ListOperationsResponse_descriptor; - } - - public com.google.longrunning.ListOperationsResponse getDefaultInstanceForType() { - return com.google.longrunning.ListOperationsResponse.getDefaultInstance(); - } - - public com.google.longrunning.ListOperationsResponse build() { - com.google.longrunning.ListOperationsResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.longrunning.ListOperationsResponse buildPartial() { - com.google.longrunning.ListOperationsResponse result = new com.google.longrunning.ListOperationsResponse(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (operationsBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - operations_ = java.util.Collections.unmodifiableList(operations_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.operations_ = operations_; - } else { - result.operations_ = operationsBuilder_.build(); - } - result.nextPageToken_ = nextPageToken_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.longrunning.ListOperationsResponse) { - return mergeFrom((com.google.longrunning.ListOperationsResponse)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.longrunning.ListOperationsResponse other) { - if (other == com.google.longrunning.ListOperationsResponse.getDefaultInstance()) return this; - if (operationsBuilder_ == null) { - if (!other.operations_.isEmpty()) { - if (operations_.isEmpty()) { - operations_ = other.operations_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureOperationsIsMutable(); - operations_.addAll(other.operations_); - } - onChanged(); - } - } else { - if (!other.operations_.isEmpty()) { - if (operationsBuilder_.isEmpty()) { - operationsBuilder_.dispose(); - operationsBuilder_ = null; - operations_ = other.operations_; - bitField0_ = (bitField0_ & ~0x00000001); - operationsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getOperationsFieldBuilder() : null; - } else { - operationsBuilder_.addAllMessages(other.operations_); - } - } - } - if (!other.getNextPageToken().isEmpty()) { - nextPageToken_ = other.nextPageToken_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.longrunning.ListOperationsResponse parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.longrunning.ListOperationsResponse) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List operations_ = - java.util.Collections.emptyList(); - private void ensureOperationsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - operations_ = new java.util.ArrayList(operations_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.longrunning.Operation, com.google.longrunning.Operation.Builder, com.google.longrunning.OperationOrBuilder> operationsBuilder_; - - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public java.util.List getOperationsList() { - if (operationsBuilder_ == null) { - return java.util.Collections.unmodifiableList(operations_); - } else { - return operationsBuilder_.getMessageList(); - } - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public int getOperationsCount() { - if (operationsBuilder_ == null) { - return operations_.size(); - } else { - return operationsBuilder_.getCount(); - } - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public com.google.longrunning.Operation getOperations(int index) { - if (operationsBuilder_ == null) { - return operations_.get(index); - } else { - return operationsBuilder_.getMessage(index); - } - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public Builder setOperations( - int index, com.google.longrunning.Operation value) { - if (operationsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureOperationsIsMutable(); - operations_.set(index, value); - onChanged(); - } else { - operationsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public Builder setOperations( - int index, com.google.longrunning.Operation.Builder builderForValue) { - if (operationsBuilder_ == null) { - ensureOperationsIsMutable(); - operations_.set(index, builderForValue.build()); - onChanged(); - } else { - operationsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public Builder addOperations(com.google.longrunning.Operation value) { - if (operationsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureOperationsIsMutable(); - operations_.add(value); - onChanged(); - } else { - operationsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public Builder addOperations( - int index, com.google.longrunning.Operation value) { - if (operationsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureOperationsIsMutable(); - operations_.add(index, value); - onChanged(); - } else { - operationsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public Builder addOperations( - com.google.longrunning.Operation.Builder builderForValue) { - if (operationsBuilder_ == null) { - ensureOperationsIsMutable(); - operations_.add(builderForValue.build()); - onChanged(); - } else { - operationsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public Builder addOperations( - int index, com.google.longrunning.Operation.Builder builderForValue) { - if (operationsBuilder_ == null) { - ensureOperationsIsMutable(); - operations_.add(index, builderForValue.build()); - onChanged(); - } else { - operationsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public Builder addAllOperations( - java.lang.Iterable values) { - if (operationsBuilder_ == null) { - ensureOperationsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, operations_); - onChanged(); - } else { - operationsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public Builder clearOperations() { - if (operationsBuilder_ == null) { - operations_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - operationsBuilder_.clear(); - } - return this; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public Builder removeOperations(int index) { - if (operationsBuilder_ == null) { - ensureOperationsIsMutable(); - operations_.remove(index); - onChanged(); - } else { - operationsBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public com.google.longrunning.Operation.Builder getOperationsBuilder( - int index) { - return getOperationsFieldBuilder().getBuilder(index); - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public com.google.longrunning.OperationOrBuilder getOperationsOrBuilder( - int index) { - if (operationsBuilder_ == null) { - return operations_.get(index); } else { - return operationsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public java.util.List - getOperationsOrBuilderList() { - if (operationsBuilder_ != null) { - return operationsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(operations_); - } - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public com.google.longrunning.Operation.Builder addOperationsBuilder() { - return getOperationsFieldBuilder().addBuilder( - com.google.longrunning.Operation.getDefaultInstance()); - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public com.google.longrunning.Operation.Builder addOperationsBuilder( - int index) { - return getOperationsFieldBuilder().addBuilder( - index, com.google.longrunning.Operation.getDefaultInstance()); - } - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -     * A list of operations that match the specified filter in the request.
      -     * 
      - */ - public java.util.List - getOperationsBuilderList() { - return getOperationsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.longrunning.Operation, com.google.longrunning.Operation.Builder, com.google.longrunning.OperationOrBuilder> - getOperationsFieldBuilder() { - if (operationsBuilder_ == null) { - operationsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.longrunning.Operation, com.google.longrunning.Operation.Builder, com.google.longrunning.OperationOrBuilder>( - operations_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - operations_ = null; - } - return operationsBuilder_; - } - - private java.lang.Object nextPageToken_ = ""; - /** - * optional string next_page_token = 2; - * - *
      -     * The standard List next-page token.
      -     * 
      - */ - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string next_page_token = 2; - * - *
      -     * The standard List next-page token.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string next_page_token = 2; - * - *
      -     * The standard List next-page token.
      -     * 
      - */ - public Builder setNextPageToken( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - nextPageToken_ = value; - onChanged(); - return this; - } - /** - * optional string next_page_token = 2; - * - *
      -     * The standard List next-page token.
      -     * 
      - */ - public Builder clearNextPageToken() { - - nextPageToken_ = getDefaultInstance().getNextPageToken(); - onChanged(); - return this; - } - /** - * optional string next_page_token = 2; - * - *
      -     * The standard List next-page token.
      -     * 
      - */ - public Builder setNextPageTokenBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - nextPageToken_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.longrunning.ListOperationsResponse) - } - - // @@protoc_insertion_point(class_scope:google.longrunning.ListOperationsResponse) - private static final com.google.longrunning.ListOperationsResponse DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.longrunning.ListOperationsResponse(); - } - - public static com.google.longrunning.ListOperationsResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ListOperationsResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ListOperationsResponse(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.longrunning.ListOperationsResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponseOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponseOrBuilder.java deleted file mode 100644 index 8e2c047294a5..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/ListOperationsResponseOrBuilder.java +++ /dev/null @@ -1,71 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -public interface ListOperationsResponseOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.longrunning.ListOperationsResponse) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -   * A list of operations that match the specified filter in the request.
      -   * 
      - */ - java.util.List - getOperationsList(); - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -   * A list of operations that match the specified filter in the request.
      -   * 
      - */ - com.google.longrunning.Operation getOperations(int index); - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -   * A list of operations that match the specified filter in the request.
      -   * 
      - */ - int getOperationsCount(); - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -   * A list of operations that match the specified filter in the request.
      -   * 
      - */ - java.util.List - getOperationsOrBuilderList(); - /** - * repeated .google.longrunning.Operation operations = 1; - * - *
      -   * A list of operations that match the specified filter in the request.
      -   * 
      - */ - com.google.longrunning.OperationOrBuilder getOperationsOrBuilder( - int index); - - /** - * optional string next_page_token = 2; - * - *
      -   * The standard List next-page token.
      -   * 
      - */ - java.lang.String getNextPageToken(); - /** - * optional string next_page_token = 2; - * - *
      -   * The standard List next-page token.
      -   * 
      - */ - com.google.protobuf.ByteString - getNextPageTokenBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/Operation.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/Operation.java deleted file mode 100644 index 750f3a657b25..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/Operation.java +++ /dev/null @@ -1,1383 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -/** - * Protobuf type {@code google.longrunning.Operation} - * - *
      - * This resource represents a long-running operation that is the result of a
      - * network API call.
      - * 
      - */ -public final class Operation extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.longrunning.Operation) - OperationOrBuilder { - // Use Operation.newBuilder() to construct. - private Operation(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Operation() { - name_ = ""; - done_ = false; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Operation( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - name_ = s; - break; - } - case 18: { - com.google.protobuf.Any.Builder subBuilder = null; - if (metadata_ != null) { - subBuilder = metadata_.toBuilder(); - } - metadata_ = input.readMessage(com.google.protobuf.Any.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(metadata_); - metadata_ = subBuilder.buildPartial(); - } - - break; - } - case 24: { - - done_ = input.readBool(); - break; - } - case 34: { - com.google.rpc.Status.Builder subBuilder = null; - if (resultCase_ == 4) { - subBuilder = ((com.google.rpc.Status) result_).toBuilder(); - } - result_ = - input.readMessage(com.google.rpc.Status.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((com.google.rpc.Status) result_); - result_ = subBuilder.buildPartial(); - } - resultCase_ = 4; - break; - } - case 42: { - com.google.protobuf.Any.Builder subBuilder = null; - if (resultCase_ == 5) { - subBuilder = ((com.google.protobuf.Any) result_).toBuilder(); - } - result_ = - input.readMessage(com.google.protobuf.Any.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((com.google.protobuf.Any) result_); - result_ = subBuilder.buildPartial(); - } - resultCase_ = 5; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_Operation_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_Operation_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.Operation.class, com.google.longrunning.Operation.Builder.class); - } - - private int resultCase_ = 0; - private java.lang.Object result_; - public enum ResultCase - implements com.google.protobuf.Internal.EnumLite { - ERROR(4), - RESPONSE(5), - RESULT_NOT_SET(0); - private int value = 0; - private ResultCase(int value) { - this.value = value; - } - public static ResultCase valueOf(int value) { - switch (value) { - case 4: return ERROR; - case 5: return RESPONSE; - case 0: return RESULT_NOT_SET; - default: throw new java.lang.IllegalArgumentException( - "Value is undefined for this oneof enum."); - } - } - public int getNumber() { - return this.value; - } - }; - - public ResultCase - getResultCase() { - return ResultCase.valueOf( - resultCase_); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource, which is only unique within the same
      -   * service that originally returns it.
      -   * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource, which is only unique within the same
      -   * service that originally returns it.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int METADATA_FIELD_NUMBER = 2; - private com.google.protobuf.Any metadata_; - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -   * Some service-specific metadata associated with the operation.  It typically
      -   * contains progress information and common metadata such as create time.
      -   * Some services may not provide such metadata.  Any method that returns a
      -   * long-running operation should document the metadata type, if any.
      -   * 
      - */ - public boolean hasMetadata() { - return metadata_ != null; - } - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -   * Some service-specific metadata associated with the operation.  It typically
      -   * contains progress information and common metadata such as create time.
      -   * Some services may not provide such metadata.  Any method that returns a
      -   * long-running operation should document the metadata type, if any.
      -   * 
      - */ - public com.google.protobuf.Any getMetadata() { - return metadata_ == null ? com.google.protobuf.Any.getDefaultInstance() : metadata_; - } - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -   * Some service-specific metadata associated with the operation.  It typically
      -   * contains progress information and common metadata such as create time.
      -   * Some services may not provide such metadata.  Any method that returns a
      -   * long-running operation should document the metadata type, if any.
      -   * 
      - */ - public com.google.protobuf.AnyOrBuilder getMetadataOrBuilder() { - return getMetadata(); - } - - public static final int DONE_FIELD_NUMBER = 3; - private boolean done_; - /** - * optional bool done = 3; - * - *
      -   * If the value is false, it means the operation is still in progress.
      -   * If true, the operation is completed and the `result` is available.
      -   * 
      - */ - public boolean getDone() { - return done_; - } - - public static final int ERROR_FIELD_NUMBER = 4; - /** - * optional .google.rpc.Status error = 4; - * - *
      -   * The error result of the operation in case of failure.
      -   * 
      - */ - public com.google.rpc.Status getError() { - if (resultCase_ == 4) { - return (com.google.rpc.Status) result_; - } - return com.google.rpc.Status.getDefaultInstance(); - } - /** - * optional .google.rpc.Status error = 4; - * - *
      -   * The error result of the operation in case of failure.
      -   * 
      - */ - public com.google.rpc.StatusOrBuilder getErrorOrBuilder() { - if (resultCase_ == 4) { - return (com.google.rpc.Status) result_; - } - return com.google.rpc.Status.getDefaultInstance(); - } - - public static final int RESPONSE_FIELD_NUMBER = 5; - /** - * optional .google.protobuf.Any response = 5; - * - *
      -   * The normal response of the operation in case of success.  If the original
      -   * method returns no data on success, such as `Delete`, the response will be
      -   * `google.protobuf.Empty`.  If the original method is standard
      -   * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -   * methods, the response should have the type `XxxResponse`, where `Xxx`
      -   * is the original method name.  For example, if the original method name
      -   * is `TakeSnapshot()`, the inferred response type will be
      -   * `TakeSnapshotResponse`.
      -   * 
      - */ - public com.google.protobuf.Any getResponse() { - if (resultCase_ == 5) { - return (com.google.protobuf.Any) result_; - } - return com.google.protobuf.Any.getDefaultInstance(); - } - /** - * optional .google.protobuf.Any response = 5; - * - *
      -   * The normal response of the operation in case of success.  If the original
      -   * method returns no data on success, such as `Delete`, the response will be
      -   * `google.protobuf.Empty`.  If the original method is standard
      -   * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -   * methods, the response should have the type `XxxResponse`, where `Xxx`
      -   * is the original method name.  For example, if the original method name
      -   * is `TakeSnapshot()`, the inferred response type will be
      -   * `TakeSnapshotResponse`.
      -   * 
      - */ - public com.google.protobuf.AnyOrBuilder getResponseOrBuilder() { - if (resultCase_ == 5) { - return (com.google.protobuf.Any) result_; - } - return com.google.protobuf.Any.getDefaultInstance(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); - } - if (metadata_ != null) { - output.writeMessage(2, getMetadata()); - } - if (done_ != false) { - output.writeBool(3, done_); - } - if (resultCase_ == 4) { - output.writeMessage(4, (com.google.rpc.Status) result_); - } - if (resultCase_ == 5) { - output.writeMessage(5, (com.google.protobuf.Any) result_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); - } - if (metadata_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, getMetadata()); - } - if (done_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(3, done_); - } - if (resultCase_ == 4) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, (com.google.rpc.Status) result_); - } - if (resultCase_ == 5) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, (com.google.protobuf.Any) result_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.longrunning.Operation parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.Operation parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.Operation parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.longrunning.Operation parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.longrunning.Operation parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.Operation parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.longrunning.Operation parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.longrunning.Operation parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.longrunning.Operation parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.longrunning.Operation parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.longrunning.Operation prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.longrunning.Operation} - * - *
      -   * This resource represents a long-running operation that is the result of a
      -   * network API call.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.longrunning.Operation) - com.google.longrunning.OperationOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_Operation_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_Operation_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.longrunning.Operation.class, com.google.longrunning.Operation.Builder.class); - } - - // Construct using com.google.longrunning.Operation.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - name_ = ""; - - if (metadataBuilder_ == null) { - metadata_ = null; - } else { - metadata_ = null; - metadataBuilder_ = null; - } - done_ = false; - - resultCase_ = 0; - result_ = null; - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.longrunning.OperationsProto.internal_static_google_longrunning_Operation_descriptor; - } - - public com.google.longrunning.Operation getDefaultInstanceForType() { - return com.google.longrunning.Operation.getDefaultInstance(); - } - - public com.google.longrunning.Operation build() { - com.google.longrunning.Operation result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.longrunning.Operation buildPartial() { - com.google.longrunning.Operation result = new com.google.longrunning.Operation(this); - result.name_ = name_; - if (metadataBuilder_ == null) { - result.metadata_ = metadata_; - } else { - result.metadata_ = metadataBuilder_.build(); - } - result.done_ = done_; - if (resultCase_ == 4) { - if (errorBuilder_ == null) { - result.result_ = result_; - } else { - result.result_ = errorBuilder_.build(); - } - } - if (resultCase_ == 5) { - if (responseBuilder_ == null) { - result.result_ = result_; - } else { - result.result_ = responseBuilder_.build(); - } - } - result.resultCase_ = resultCase_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.longrunning.Operation) { - return mergeFrom((com.google.longrunning.Operation)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.longrunning.Operation other) { - if (other == com.google.longrunning.Operation.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (other.hasMetadata()) { - mergeMetadata(other.getMetadata()); - } - if (other.getDone() != false) { - setDone(other.getDone()); - } - switch (other.getResultCase()) { - case ERROR: { - mergeError(other.getError()); - break; - } - case RESPONSE: { - mergeResponse(other.getResponse()); - break; - } - case RESULT_NOT_SET: { - break; - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.longrunning.Operation parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.longrunning.Operation) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int resultCase_ = 0; - private java.lang.Object result_; - public ResultCase - getResultCase() { - return ResultCase.valueOf( - resultCase_); - } - - public Builder clearResult() { - resultCase_ = 0; - result_ = null; - onChanged(); - return this; - } - - - private java.lang.Object name_ = ""; - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource, which is only unique within the same
      -     * service that originally returns it.
      -     * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource, which is only unique within the same
      -     * service that originally returns it.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource, which is only unique within the same
      -     * service that originally returns it.
      -     * 
      - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource, which is only unique within the same
      -     * service that originally returns it.
      -     * 
      - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the operation resource, which is only unique within the same
      -     * service that originally returns it.
      -     * 
      - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.Any metadata_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> metadataBuilder_; - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -     * Some service-specific metadata associated with the operation.  It typically
      -     * contains progress information and common metadata such as create time.
      -     * Some services may not provide such metadata.  Any method that returns a
      -     * long-running operation should document the metadata type, if any.
      -     * 
      - */ - public boolean hasMetadata() { - return metadataBuilder_ != null || metadata_ != null; - } - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -     * Some service-specific metadata associated with the operation.  It typically
      -     * contains progress information and common metadata such as create time.
      -     * Some services may not provide such metadata.  Any method that returns a
      -     * long-running operation should document the metadata type, if any.
      -     * 
      - */ - public com.google.protobuf.Any getMetadata() { - if (metadataBuilder_ == null) { - return metadata_ == null ? com.google.protobuf.Any.getDefaultInstance() : metadata_; - } else { - return metadataBuilder_.getMessage(); - } - } - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -     * Some service-specific metadata associated with the operation.  It typically
      -     * contains progress information and common metadata such as create time.
      -     * Some services may not provide such metadata.  Any method that returns a
      -     * long-running operation should document the metadata type, if any.
      -     * 
      - */ - public Builder setMetadata(com.google.protobuf.Any value) { - if (metadataBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - metadata_ = value; - onChanged(); - } else { - metadataBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -     * Some service-specific metadata associated with the operation.  It typically
      -     * contains progress information and common metadata such as create time.
      -     * Some services may not provide such metadata.  Any method that returns a
      -     * long-running operation should document the metadata type, if any.
      -     * 
      - */ - public Builder setMetadata( - com.google.protobuf.Any.Builder builderForValue) { - if (metadataBuilder_ == null) { - metadata_ = builderForValue.build(); - onChanged(); - } else { - metadataBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -     * Some service-specific metadata associated with the operation.  It typically
      -     * contains progress information and common metadata such as create time.
      -     * Some services may not provide such metadata.  Any method that returns a
      -     * long-running operation should document the metadata type, if any.
      -     * 
      - */ - public Builder mergeMetadata(com.google.protobuf.Any value) { - if (metadataBuilder_ == null) { - if (metadata_ != null) { - metadata_ = - com.google.protobuf.Any.newBuilder(metadata_).mergeFrom(value).buildPartial(); - } else { - metadata_ = value; - } - onChanged(); - } else { - metadataBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -     * Some service-specific metadata associated with the operation.  It typically
      -     * contains progress information and common metadata such as create time.
      -     * Some services may not provide such metadata.  Any method that returns a
      -     * long-running operation should document the metadata type, if any.
      -     * 
      - */ - public Builder clearMetadata() { - if (metadataBuilder_ == null) { - metadata_ = null; - onChanged(); - } else { - metadata_ = null; - metadataBuilder_ = null; - } - - return this; - } - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -     * Some service-specific metadata associated with the operation.  It typically
      -     * contains progress information and common metadata such as create time.
      -     * Some services may not provide such metadata.  Any method that returns a
      -     * long-running operation should document the metadata type, if any.
      -     * 
      - */ - public com.google.protobuf.Any.Builder getMetadataBuilder() { - - onChanged(); - return getMetadataFieldBuilder().getBuilder(); - } - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -     * Some service-specific metadata associated with the operation.  It typically
      -     * contains progress information and common metadata such as create time.
      -     * Some services may not provide such metadata.  Any method that returns a
      -     * long-running operation should document the metadata type, if any.
      -     * 
      - */ - public com.google.protobuf.AnyOrBuilder getMetadataOrBuilder() { - if (metadataBuilder_ != null) { - return metadataBuilder_.getMessageOrBuilder(); - } else { - return metadata_ == null ? - com.google.protobuf.Any.getDefaultInstance() : metadata_; - } - } - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -     * Some service-specific metadata associated with the operation.  It typically
      -     * contains progress information and common metadata such as create time.
      -     * Some services may not provide such metadata.  Any method that returns a
      -     * long-running operation should document the metadata type, if any.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> - getMetadataFieldBuilder() { - if (metadataBuilder_ == null) { - metadataBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>( - getMetadata(), - getParentForChildren(), - isClean()); - metadata_ = null; - } - return metadataBuilder_; - } - - private boolean done_ ; - /** - * optional bool done = 3; - * - *
      -     * If the value is false, it means the operation is still in progress.
      -     * If true, the operation is completed and the `result` is available.
      -     * 
      - */ - public boolean getDone() { - return done_; - } - /** - * optional bool done = 3; - * - *
      -     * If the value is false, it means the operation is still in progress.
      -     * If true, the operation is completed and the `result` is available.
      -     * 
      - */ - public Builder setDone(boolean value) { - - done_ = value; - onChanged(); - return this; - } - /** - * optional bool done = 3; - * - *
      -     * If the value is false, it means the operation is still in progress.
      -     * If true, the operation is completed and the `result` is available.
      -     * 
      - */ - public Builder clearDone() { - - done_ = false; - onChanged(); - return this; - } - - private com.google.protobuf.SingleFieldBuilder< - com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> errorBuilder_; - /** - * optional .google.rpc.Status error = 4; - * - *
      -     * The error result of the operation in case of failure.
      -     * 
      - */ - public com.google.rpc.Status getError() { - if (errorBuilder_ == null) { - if (resultCase_ == 4) { - return (com.google.rpc.Status) result_; - } - return com.google.rpc.Status.getDefaultInstance(); - } else { - if (resultCase_ == 4) { - return errorBuilder_.getMessage(); - } - return com.google.rpc.Status.getDefaultInstance(); - } - } - /** - * optional .google.rpc.Status error = 4; - * - *
      -     * The error result of the operation in case of failure.
      -     * 
      - */ - public Builder setError(com.google.rpc.Status value) { - if (errorBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - result_ = value; - onChanged(); - } else { - errorBuilder_.setMessage(value); - } - resultCase_ = 4; - return this; - } - /** - * optional .google.rpc.Status error = 4; - * - *
      -     * The error result of the operation in case of failure.
      -     * 
      - */ - public Builder setError( - com.google.rpc.Status.Builder builderForValue) { - if (errorBuilder_ == null) { - result_ = builderForValue.build(); - onChanged(); - } else { - errorBuilder_.setMessage(builderForValue.build()); - } - resultCase_ = 4; - return this; - } - /** - * optional .google.rpc.Status error = 4; - * - *
      -     * The error result of the operation in case of failure.
      -     * 
      - */ - public Builder mergeError(com.google.rpc.Status value) { - if (errorBuilder_ == null) { - if (resultCase_ == 4 && - result_ != com.google.rpc.Status.getDefaultInstance()) { - result_ = com.google.rpc.Status.newBuilder((com.google.rpc.Status) result_) - .mergeFrom(value).buildPartial(); - } else { - result_ = value; - } - onChanged(); - } else { - if (resultCase_ == 4) { - errorBuilder_.mergeFrom(value); - } - errorBuilder_.setMessage(value); - } - resultCase_ = 4; - return this; - } - /** - * optional .google.rpc.Status error = 4; - * - *
      -     * The error result of the operation in case of failure.
      -     * 
      - */ - public Builder clearError() { - if (errorBuilder_ == null) { - if (resultCase_ == 4) { - resultCase_ = 0; - result_ = null; - onChanged(); - } - } else { - if (resultCase_ == 4) { - resultCase_ = 0; - result_ = null; - } - errorBuilder_.clear(); - } - return this; - } - /** - * optional .google.rpc.Status error = 4; - * - *
      -     * The error result of the operation in case of failure.
      -     * 
      - */ - public com.google.rpc.Status.Builder getErrorBuilder() { - return getErrorFieldBuilder().getBuilder(); - } - /** - * optional .google.rpc.Status error = 4; - * - *
      -     * The error result of the operation in case of failure.
      -     * 
      - */ - public com.google.rpc.StatusOrBuilder getErrorOrBuilder() { - if ((resultCase_ == 4) && (errorBuilder_ != null)) { - return errorBuilder_.getMessageOrBuilder(); - } else { - if (resultCase_ == 4) { - return (com.google.rpc.Status) result_; - } - return com.google.rpc.Status.getDefaultInstance(); - } - } - /** - * optional .google.rpc.Status error = 4; - * - *
      -     * The error result of the operation in case of failure.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> - getErrorFieldBuilder() { - if (errorBuilder_ == null) { - if (!(resultCase_ == 4)) { - result_ = com.google.rpc.Status.getDefaultInstance(); - } - errorBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder>( - (com.google.rpc.Status) result_, - getParentForChildren(), - isClean()); - result_ = null; - } - resultCase_ = 4; - onChanged();; - return errorBuilder_; - } - - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> responseBuilder_; - /** - * optional .google.protobuf.Any response = 5; - * - *
      -     * The normal response of the operation in case of success.  If the original
      -     * method returns no data on success, such as `Delete`, the response will be
      -     * `google.protobuf.Empty`.  If the original method is standard
      -     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -     * methods, the response should have the type `XxxResponse`, where `Xxx`
      -     * is the original method name.  For example, if the original method name
      -     * is `TakeSnapshot()`, the inferred response type will be
      -     * `TakeSnapshotResponse`.
      -     * 
      - */ - public com.google.protobuf.Any getResponse() { - if (responseBuilder_ == null) { - if (resultCase_ == 5) { - return (com.google.protobuf.Any) result_; - } - return com.google.protobuf.Any.getDefaultInstance(); - } else { - if (resultCase_ == 5) { - return responseBuilder_.getMessage(); - } - return com.google.protobuf.Any.getDefaultInstance(); - } - } - /** - * optional .google.protobuf.Any response = 5; - * - *
      -     * The normal response of the operation in case of success.  If the original
      -     * method returns no data on success, such as `Delete`, the response will be
      -     * `google.protobuf.Empty`.  If the original method is standard
      -     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -     * methods, the response should have the type `XxxResponse`, where `Xxx`
      -     * is the original method name.  For example, if the original method name
      -     * is `TakeSnapshot()`, the inferred response type will be
      -     * `TakeSnapshotResponse`.
      -     * 
      - */ - public Builder setResponse(com.google.protobuf.Any value) { - if (responseBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - result_ = value; - onChanged(); - } else { - responseBuilder_.setMessage(value); - } - resultCase_ = 5; - return this; - } - /** - * optional .google.protobuf.Any response = 5; - * - *
      -     * The normal response of the operation in case of success.  If the original
      -     * method returns no data on success, such as `Delete`, the response will be
      -     * `google.protobuf.Empty`.  If the original method is standard
      -     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -     * methods, the response should have the type `XxxResponse`, where `Xxx`
      -     * is the original method name.  For example, if the original method name
      -     * is `TakeSnapshot()`, the inferred response type will be
      -     * `TakeSnapshotResponse`.
      -     * 
      - */ - public Builder setResponse( - com.google.protobuf.Any.Builder builderForValue) { - if (responseBuilder_ == null) { - result_ = builderForValue.build(); - onChanged(); - } else { - responseBuilder_.setMessage(builderForValue.build()); - } - resultCase_ = 5; - return this; - } - /** - * optional .google.protobuf.Any response = 5; - * - *
      -     * The normal response of the operation in case of success.  If the original
      -     * method returns no data on success, such as `Delete`, the response will be
      -     * `google.protobuf.Empty`.  If the original method is standard
      -     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -     * methods, the response should have the type `XxxResponse`, where `Xxx`
      -     * is the original method name.  For example, if the original method name
      -     * is `TakeSnapshot()`, the inferred response type will be
      -     * `TakeSnapshotResponse`.
      -     * 
      - */ - public Builder mergeResponse(com.google.protobuf.Any value) { - if (responseBuilder_ == null) { - if (resultCase_ == 5 && - result_ != com.google.protobuf.Any.getDefaultInstance()) { - result_ = com.google.protobuf.Any.newBuilder((com.google.protobuf.Any) result_) - .mergeFrom(value).buildPartial(); - } else { - result_ = value; - } - onChanged(); - } else { - if (resultCase_ == 5) { - responseBuilder_.mergeFrom(value); - } - responseBuilder_.setMessage(value); - } - resultCase_ = 5; - return this; - } - /** - * optional .google.protobuf.Any response = 5; - * - *
      -     * The normal response of the operation in case of success.  If the original
      -     * method returns no data on success, such as `Delete`, the response will be
      -     * `google.protobuf.Empty`.  If the original method is standard
      -     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -     * methods, the response should have the type `XxxResponse`, where `Xxx`
      -     * is the original method name.  For example, if the original method name
      -     * is `TakeSnapshot()`, the inferred response type will be
      -     * `TakeSnapshotResponse`.
      -     * 
      - */ - public Builder clearResponse() { - if (responseBuilder_ == null) { - if (resultCase_ == 5) { - resultCase_ = 0; - result_ = null; - onChanged(); - } - } else { - if (resultCase_ == 5) { - resultCase_ = 0; - result_ = null; - } - responseBuilder_.clear(); - } - return this; - } - /** - * optional .google.protobuf.Any response = 5; - * - *
      -     * The normal response of the operation in case of success.  If the original
      -     * method returns no data on success, such as `Delete`, the response will be
      -     * `google.protobuf.Empty`.  If the original method is standard
      -     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -     * methods, the response should have the type `XxxResponse`, where `Xxx`
      -     * is the original method name.  For example, if the original method name
      -     * is `TakeSnapshot()`, the inferred response type will be
      -     * `TakeSnapshotResponse`.
      -     * 
      - */ - public com.google.protobuf.Any.Builder getResponseBuilder() { - return getResponseFieldBuilder().getBuilder(); - } - /** - * optional .google.protobuf.Any response = 5; - * - *
      -     * The normal response of the operation in case of success.  If the original
      -     * method returns no data on success, such as `Delete`, the response will be
      -     * `google.protobuf.Empty`.  If the original method is standard
      -     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -     * methods, the response should have the type `XxxResponse`, where `Xxx`
      -     * is the original method name.  For example, if the original method name
      -     * is `TakeSnapshot()`, the inferred response type will be
      -     * `TakeSnapshotResponse`.
      -     * 
      - */ - public com.google.protobuf.AnyOrBuilder getResponseOrBuilder() { - if ((resultCase_ == 5) && (responseBuilder_ != null)) { - return responseBuilder_.getMessageOrBuilder(); - } else { - if (resultCase_ == 5) { - return (com.google.protobuf.Any) result_; - } - return com.google.protobuf.Any.getDefaultInstance(); - } - } - /** - * optional .google.protobuf.Any response = 5; - * - *
      -     * The normal response of the operation in case of success.  If the original
      -     * method returns no data on success, such as `Delete`, the response will be
      -     * `google.protobuf.Empty`.  If the original method is standard
      -     * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -     * methods, the response should have the type `XxxResponse`, where `Xxx`
      -     * is the original method name.  For example, if the original method name
      -     * is `TakeSnapshot()`, the inferred response type will be
      -     * `TakeSnapshotResponse`.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> - getResponseFieldBuilder() { - if (responseBuilder_ == null) { - if (!(resultCase_ == 5)) { - result_ = com.google.protobuf.Any.getDefaultInstance(); - } - responseBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>( - (com.google.protobuf.Any) result_, - getParentForChildren(), - isClean()); - result_ = null; - } - resultCase_ = 5; - onChanged();; - return responseBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.longrunning.Operation) - } - - // @@protoc_insertion_point(class_scope:google.longrunning.Operation) - private static final com.google.longrunning.Operation DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.longrunning.Operation(); - } - - public static com.google.longrunning.Operation getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Operation parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Operation(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.longrunning.Operation getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationOrBuilder.java deleted file mode 100644 index 8366f5d21f3e..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationOrBuilder.java +++ /dev/null @@ -1,123 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -public interface OperationOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.longrunning.Operation) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource, which is only unique within the same
      -   * service that originally returns it.
      -   * 
      - */ - java.lang.String getName(); - /** - * optional string name = 1; - * - *
      -   * The name of the operation resource, which is only unique within the same
      -   * service that originally returns it.
      -   * 
      - */ - com.google.protobuf.ByteString - getNameBytes(); - - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -   * Some service-specific metadata associated with the operation.  It typically
      -   * contains progress information and common metadata such as create time.
      -   * Some services may not provide such metadata.  Any method that returns a
      -   * long-running operation should document the metadata type, if any.
      -   * 
      - */ - boolean hasMetadata(); - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -   * Some service-specific metadata associated with the operation.  It typically
      -   * contains progress information and common metadata such as create time.
      -   * Some services may not provide such metadata.  Any method that returns a
      -   * long-running operation should document the metadata type, if any.
      -   * 
      - */ - com.google.protobuf.Any getMetadata(); - /** - * optional .google.protobuf.Any metadata = 2; - * - *
      -   * Some service-specific metadata associated with the operation.  It typically
      -   * contains progress information and common metadata such as create time.
      -   * Some services may not provide such metadata.  Any method that returns a
      -   * long-running operation should document the metadata type, if any.
      -   * 
      - */ - com.google.protobuf.AnyOrBuilder getMetadataOrBuilder(); - - /** - * optional bool done = 3; - * - *
      -   * If the value is false, it means the operation is still in progress.
      -   * If true, the operation is completed and the `result` is available.
      -   * 
      - */ - boolean getDone(); - - /** - * optional .google.rpc.Status error = 4; - * - *
      -   * The error result of the operation in case of failure.
      -   * 
      - */ - com.google.rpc.Status getError(); - /** - * optional .google.rpc.Status error = 4; - * - *
      -   * The error result of the operation in case of failure.
      -   * 
      - */ - com.google.rpc.StatusOrBuilder getErrorOrBuilder(); - - /** - * optional .google.protobuf.Any response = 5; - * - *
      -   * The normal response of the operation in case of success.  If the original
      -   * method returns no data on success, such as `Delete`, the response will be
      -   * `google.protobuf.Empty`.  If the original method is standard
      -   * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -   * methods, the response should have the type `XxxResponse`, where `Xxx`
      -   * is the original method name.  For example, if the original method name
      -   * is `TakeSnapshot()`, the inferred response type will be
      -   * `TakeSnapshotResponse`.
      -   * 
      - */ - com.google.protobuf.Any getResponse(); - /** - * optional .google.protobuf.Any response = 5; - * - *
      -   * The normal response of the operation in case of success.  If the original
      -   * method returns no data on success, such as `Delete`, the response will be
      -   * `google.protobuf.Empty`.  If the original method is standard
      -   * `Get`/`Create`/`Update`, the response should be the resource.  For other
      -   * methods, the response should have the type `XxxResponse`, where `Xxx`
      -   * is the original method name.  For example, if the original method name
      -   * is `TakeSnapshot()`, the inferred response type will be
      -   * `TakeSnapshotResponse`.
      -   * 
      - */ - com.google.protobuf.AnyOrBuilder getResponseOrBuilder(); - - public com.google.longrunning.Operation.ResultCase getResultCase(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsGrpc.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsGrpc.java deleted file mode 100644 index 0c1c82a52874..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsGrpc.java +++ /dev/null @@ -1,306 +0,0 @@ -package com.google.longrunning; - -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; -import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; -import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ClientCalls.blockingUnaryCall; -import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; -import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; -import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; -import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; - -@javax.annotation.Generated("by gRPC proto compiler") -public class OperationsGrpc { - - private OperationsGrpc() {} - - public static final String SERVICE_NAME = "google.longrunning.Operations"; - - // Static method descriptors that strictly reflect the proto. - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_GET_OPERATION = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.longrunning.Operations", "GetOperation"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.GetOperationRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.Operation.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_LIST_OPERATIONS = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.longrunning.Operations", "ListOperations"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.ListOperationsRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.ListOperationsResponse.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_CANCEL_OPERATION = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.longrunning.Operations", "CancelOperation"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.CancelOperationRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_DELETE_OPERATION = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.longrunning.Operations", "DeleteOperation"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.longrunning.DeleteOperationRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); - - public static OperationsStub newStub(io.grpc.Channel channel) { - return new OperationsStub(channel); - } - - public static OperationsBlockingStub newBlockingStub( - io.grpc.Channel channel) { - return new OperationsBlockingStub(channel); - } - - public static OperationsFutureStub newFutureStub( - io.grpc.Channel channel) { - return new OperationsFutureStub(channel); - } - - public static interface Operations { - - public void getOperation(com.google.longrunning.GetOperationRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void listOperations(com.google.longrunning.ListOperationsRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void cancelOperation(com.google.longrunning.CancelOperationRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void deleteOperation(com.google.longrunning.DeleteOperationRequest request, - io.grpc.stub.StreamObserver responseObserver); - } - - public static interface OperationsBlockingClient { - - public com.google.longrunning.Operation getOperation(com.google.longrunning.GetOperationRequest request); - - public com.google.longrunning.ListOperationsResponse listOperations(com.google.longrunning.ListOperationsRequest request); - - public com.google.protobuf.Empty cancelOperation(com.google.longrunning.CancelOperationRequest request); - - public com.google.protobuf.Empty deleteOperation(com.google.longrunning.DeleteOperationRequest request); - } - - public static interface OperationsFutureClient { - - public com.google.common.util.concurrent.ListenableFuture getOperation( - com.google.longrunning.GetOperationRequest request); - - public com.google.common.util.concurrent.ListenableFuture listOperations( - com.google.longrunning.ListOperationsRequest request); - - public com.google.common.util.concurrent.ListenableFuture cancelOperation( - com.google.longrunning.CancelOperationRequest request); - - public com.google.common.util.concurrent.ListenableFuture deleteOperation( - com.google.longrunning.DeleteOperationRequest request); - } - - public static class OperationsStub extends io.grpc.stub.AbstractStub - implements Operations { - private OperationsStub(io.grpc.Channel channel) { - super(channel); - } - - private OperationsStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected OperationsStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new OperationsStub(channel, callOptions); - } - - @java.lang.Override - public void getOperation(com.google.longrunning.GetOperationRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_GET_OPERATION, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void listOperations(com.google.longrunning.ListOperationsRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_LIST_OPERATIONS, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void cancelOperation(com.google.longrunning.CancelOperationRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_CANCEL_OPERATION, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void deleteOperation(com.google.longrunning.DeleteOperationRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_DELETE_OPERATION, getCallOptions()), request, responseObserver); - } - } - - public static class OperationsBlockingStub extends io.grpc.stub.AbstractStub - implements OperationsBlockingClient { - private OperationsBlockingStub(io.grpc.Channel channel) { - super(channel); - } - - private OperationsBlockingStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected OperationsBlockingStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new OperationsBlockingStub(channel, callOptions); - } - - @java.lang.Override - public com.google.longrunning.Operation getOperation(com.google.longrunning.GetOperationRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_GET_OPERATION, getCallOptions()), request); - } - - @java.lang.Override - public com.google.longrunning.ListOperationsResponse listOperations(com.google.longrunning.ListOperationsRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_LIST_OPERATIONS, getCallOptions()), request); - } - - @java.lang.Override - public com.google.protobuf.Empty cancelOperation(com.google.longrunning.CancelOperationRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_CANCEL_OPERATION, getCallOptions()), request); - } - - @java.lang.Override - public com.google.protobuf.Empty deleteOperation(com.google.longrunning.DeleteOperationRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_DELETE_OPERATION, getCallOptions()), request); - } - } - - public static class OperationsFutureStub extends io.grpc.stub.AbstractStub - implements OperationsFutureClient { - private OperationsFutureStub(io.grpc.Channel channel) { - super(channel); - } - - private OperationsFutureStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected OperationsFutureStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new OperationsFutureStub(channel, callOptions); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture getOperation( - com.google.longrunning.GetOperationRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_GET_OPERATION, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture listOperations( - com.google.longrunning.ListOperationsRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_LIST_OPERATIONS, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture cancelOperation( - com.google.longrunning.CancelOperationRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_CANCEL_OPERATION, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture deleteOperation( - com.google.longrunning.DeleteOperationRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_DELETE_OPERATION, getCallOptions()), request); - } - } - - public static io.grpc.ServerServiceDefinition bindService( - final Operations serviceImpl) { - return io.grpc.ServerServiceDefinition.builder(SERVICE_NAME) - .addMethod( - METHOD_GET_OPERATION, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.longrunning.GetOperationRequest, - com.google.longrunning.Operation>() { - @java.lang.Override - public void invoke( - com.google.longrunning.GetOperationRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.getOperation(request, responseObserver); - } - })) - .addMethod( - METHOD_LIST_OPERATIONS, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.longrunning.ListOperationsRequest, - com.google.longrunning.ListOperationsResponse>() { - @java.lang.Override - public void invoke( - com.google.longrunning.ListOperationsRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.listOperations(request, responseObserver); - } - })) - .addMethod( - METHOD_CANCEL_OPERATION, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.longrunning.CancelOperationRequest, - com.google.protobuf.Empty>() { - @java.lang.Override - public void invoke( - com.google.longrunning.CancelOperationRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.cancelOperation(request, responseObserver); - } - })) - .addMethod( - METHOD_DELETE_OPERATION, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.longrunning.DeleteOperationRequest, - com.google.protobuf.Empty>() { - @java.lang.Override - public void invoke( - com.google.longrunning.DeleteOperationRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.deleteOperation(request, responseObserver); - } - })).build(); - } -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsProto.java b/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsProto.java deleted file mode 100644 index 462e611fba19..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/longrunning/OperationsProto.java +++ /dev/null @@ -1,146 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/longrunning/operations.proto - -package com.google.longrunning; - -public final class OperationsProto { - private OperationsProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_longrunning_Operation_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_longrunning_Operation_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_longrunning_GetOperationRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_longrunning_GetOperationRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_longrunning_ListOperationsRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_longrunning_ListOperationsRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_longrunning_ListOperationsResponse_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_longrunning_ListOperationsResponse_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_longrunning_CancelOperationRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_longrunning_CancelOperationRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_longrunning_DeleteOperationRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_longrunning_DeleteOperationRequest_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n#google/longrunning/operations.proto\022\022g" + - "oogle.longrunning\032\034google/api/annotation" + - "s.proto\032\031google/protobuf/any.proto\032\033goog" + - "le/protobuf/empty.proto\032\027google/rpc/stat" + - "us.proto\"\250\001\n\tOperation\022\014\n\004name\030\001 \001(\t\022&\n\010" + - "metadata\030\002 \001(\0132\024.google.protobuf.Any\022\014\n\004" + - "done\030\003 \001(\010\022#\n\005error\030\004 \001(\0132\022.google.rpc.S" + - "tatusH\000\022(\n\010response\030\005 \001(\0132\024.google.proto" + - "buf.AnyH\000B\010\n\006result\"#\n\023GetOperationReque" + - "st\022\014\n\004name\030\001 \001(\t\"\\\n\025ListOperationsReques", - "t\022\014\n\004name\030\004 \001(\t\022\016\n\006filter\030\001 \001(\t\022\021\n\tpage_" + - "size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\"d\n\026ListOp" + - "erationsResponse\0221\n\noperations\030\001 \003(\0132\035.g" + - "oogle.longrunning.Operation\022\027\n\017next_page" + - "_token\030\002 \001(\t\"&\n\026CancelOperationRequest\022\014" + - "\n\004name\030\001 \001(\t\"&\n\026DeleteOperationRequest\022\014" + - "\n\004name\030\001 \001(\t2\214\004\n\nOperations\022x\n\014GetOperat" + - "ion\022\'.google.longrunning.GetOperationReq" + - "uest\032\035.google.longrunning.Operation\" \202\323\344" + - "\223\002\032\022\030/v1/{name=operations/**}\022\206\001\n\016ListOp", - "erations\022).google.longrunning.ListOperat" + - "ionsRequest\032*.google.longrunning.ListOpe" + - "rationsResponse\"\035\202\323\344\223\002\027\022\025/v1/{name=opera" + - "tions}\022\201\001\n\017CancelOperation\022*.google.long" + - "running.CancelOperationRequest\032\026.google." + - "protobuf.Empty\"*\202\323\344\223\002$\"\037/v1/{name=operat" + - "ions/**}:cancel:\001*\022w\n\017DeleteOperation\022*." + - "google.longrunning.DeleteOperationReques" + - "t\032\026.google.protobuf.Empty\" \202\323\344\223\002\032*\030/v1/{" + - "name=operations/**}B+\n\026com.google.longru", - "nningB\017OperationsProtoP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.api.AnnotationsProto.getDescriptor(), - com.google.protobuf.AnyProto.getDescriptor(), - com.google.protobuf.EmptyProto.getDescriptor(), - com.google.rpc.StatusProto.getDescriptor(), - }, assigner); - internal_static_google_longrunning_Operation_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_longrunning_Operation_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_longrunning_Operation_descriptor, - new java.lang.String[] { "Name", "Metadata", "Done", "Error", "Response", "Result", }); - internal_static_google_longrunning_GetOperationRequest_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_google_longrunning_GetOperationRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_longrunning_GetOperationRequest_descriptor, - new java.lang.String[] { "Name", }); - internal_static_google_longrunning_ListOperationsRequest_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_google_longrunning_ListOperationsRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_longrunning_ListOperationsRequest_descriptor, - new java.lang.String[] { "Name", "Filter", "PageSize", "PageToken", }); - internal_static_google_longrunning_ListOperationsResponse_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_google_longrunning_ListOperationsResponse_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_longrunning_ListOperationsResponse_descriptor, - new java.lang.String[] { "Operations", "NextPageToken", }); - internal_static_google_longrunning_CancelOperationRequest_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_google_longrunning_CancelOperationRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_longrunning_CancelOperationRequest_descriptor, - new java.lang.String[] { "Name", }); - internal_static_google_longrunning_DeleteOperationRequest_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_google_longrunning_DeleteOperationRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_longrunning_DeleteOperationRequest_descriptor, - new java.lang.String[] { "Name", }); - com.google.protobuf.ExtensionRegistry registry = - com.google.protobuf.ExtensionRegistry.newInstance(); - registry.add(com.google.api.AnnotationsProto.http); - com.google.protobuf.Descriptors.FileDescriptor - .internalUpdateFileDescriptor(descriptor, registry); - com.google.api.AnnotationsProto.getDescriptor(); - com.google.protobuf.AnyProto.getDescriptor(); - com.google.protobuf.EmptyProto.getDescriptor(); - com.google.rpc.StatusProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequest.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequest.java deleted file mode 100644 index acb0dc65019d..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequest.java +++ /dev/null @@ -1,1437 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -/** - * Protobuf type {@code google.rpc.BadRequest} - * - *
      - * Describes violations in a client request. This error type focuses on the
      - * syntactic aspects of the request.
      - * 
      - */ -public final class BadRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.BadRequest) - BadRequestOrBuilder { - // Use BadRequest.newBuilder() to construct. - private BadRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private BadRequest() { - fieldViolations_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private BadRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - fieldViolations_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - fieldViolations_.add(input.readMessage(com.google.rpc.BadRequest.FieldViolation.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - fieldViolations_ = java.util.Collections.unmodifiableList(fieldViolations_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.BadRequest.class, com.google.rpc.BadRequest.Builder.class); - } - - public interface FieldViolationOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.BadRequest.FieldViolation) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string field = 1; - * - *
      -     * A path leading to a field in the request body. The value will be a
      -     * sequence of dot-separated identifiers that identify a protocol buffer
      -     * field. E.g., "violations.field" would identify this field.
      -     * 
      - */ - java.lang.String getField(); - /** - * optional string field = 1; - * - *
      -     * A path leading to a field in the request body. The value will be a
      -     * sequence of dot-separated identifiers that identify a protocol buffer
      -     * field. E.g., "violations.field" would identify this field.
      -     * 
      - */ - com.google.protobuf.ByteString - getFieldBytes(); - - /** - * optional string description = 2; - * - *
      -     * A description of why the request element is bad.
      -     * 
      - */ - java.lang.String getDescription(); - /** - * optional string description = 2; - * - *
      -     * A description of why the request element is bad.
      -     * 
      - */ - com.google.protobuf.ByteString - getDescriptionBytes(); - } - /** - * Protobuf type {@code google.rpc.BadRequest.FieldViolation} - * - *
      -   * A message type used to describe a single bad request field.
      -   * 
      - */ - public static final class FieldViolation extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.BadRequest.FieldViolation) - FieldViolationOrBuilder { - // Use FieldViolation.newBuilder() to construct. - private FieldViolation(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private FieldViolation() { - field_ = ""; - description_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private FieldViolation( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - field_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - description_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_FieldViolation_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_FieldViolation_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.BadRequest.FieldViolation.class, com.google.rpc.BadRequest.FieldViolation.Builder.class); - } - - public static final int FIELD_FIELD_NUMBER = 1; - private volatile java.lang.Object field_; - /** - * optional string field = 1; - * - *
      -     * A path leading to a field in the request body. The value will be a
      -     * sequence of dot-separated identifiers that identify a protocol buffer
      -     * field. E.g., "violations.field" would identify this field.
      -     * 
      - */ - public java.lang.String getField() { - java.lang.Object ref = field_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - field_ = s; - return s; - } - } - /** - * optional string field = 1; - * - *
      -     * A path leading to a field in the request body. The value will be a
      -     * sequence of dot-separated identifiers that identify a protocol buffer
      -     * field. E.g., "violations.field" would identify this field.
      -     * 
      - */ - public com.google.protobuf.ByteString - getFieldBytes() { - java.lang.Object ref = field_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - field_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DESCRIPTION_FIELD_NUMBER = 2; - private volatile java.lang.Object description_; - /** - * optional string description = 2; - * - *
      -     * A description of why the request element is bad.
      -     * 
      - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } - } - /** - * optional string description = 2; - * - *
      -     * A description of why the request element is bad.
      -     * 
      - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getFieldBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, field_); - } - if (!getDescriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, description_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getFieldBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, field_); - } - if (!getDescriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, description_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.BadRequest.FieldViolation parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.BadRequest.FieldViolation parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.BadRequest.FieldViolation parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.BadRequest.FieldViolation parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.BadRequest.FieldViolation parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.BadRequest.FieldViolation parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.BadRequest.FieldViolation parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.BadRequest.FieldViolation parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.BadRequest.FieldViolation parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.BadRequest.FieldViolation parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.BadRequest.FieldViolation prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.BadRequest.FieldViolation} - * - *
      -     * A message type used to describe a single bad request field.
      -     * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.BadRequest.FieldViolation) - com.google.rpc.BadRequest.FieldViolationOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_FieldViolation_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_FieldViolation_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.BadRequest.FieldViolation.class, com.google.rpc.BadRequest.FieldViolation.Builder.class); - } - - // Construct using com.google.rpc.BadRequest.FieldViolation.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - field_ = ""; - - description_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_FieldViolation_descriptor; - } - - public com.google.rpc.BadRequest.FieldViolation getDefaultInstanceForType() { - return com.google.rpc.BadRequest.FieldViolation.getDefaultInstance(); - } - - public com.google.rpc.BadRequest.FieldViolation build() { - com.google.rpc.BadRequest.FieldViolation result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.BadRequest.FieldViolation buildPartial() { - com.google.rpc.BadRequest.FieldViolation result = new com.google.rpc.BadRequest.FieldViolation(this); - result.field_ = field_; - result.description_ = description_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.BadRequest.FieldViolation) { - return mergeFrom((com.google.rpc.BadRequest.FieldViolation)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.BadRequest.FieldViolation other) { - if (other == com.google.rpc.BadRequest.FieldViolation.getDefaultInstance()) return this; - if (!other.getField().isEmpty()) { - field_ = other.field_; - onChanged(); - } - if (!other.getDescription().isEmpty()) { - description_ = other.description_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.BadRequest.FieldViolation parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.BadRequest.FieldViolation) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object field_ = ""; - /** - * optional string field = 1; - * - *
      -       * A path leading to a field in the request body. The value will be a
      -       * sequence of dot-separated identifiers that identify a protocol buffer
      -       * field. E.g., "violations.field" would identify this field.
      -       * 
      - */ - public java.lang.String getField() { - java.lang.Object ref = field_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - field_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string field = 1; - * - *
      -       * A path leading to a field in the request body. The value will be a
      -       * sequence of dot-separated identifiers that identify a protocol buffer
      -       * field. E.g., "violations.field" would identify this field.
      -       * 
      - */ - public com.google.protobuf.ByteString - getFieldBytes() { - java.lang.Object ref = field_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - field_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string field = 1; - * - *
      -       * A path leading to a field in the request body. The value will be a
      -       * sequence of dot-separated identifiers that identify a protocol buffer
      -       * field. E.g., "violations.field" would identify this field.
      -       * 
      - */ - public Builder setField( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - field_ = value; - onChanged(); - return this; - } - /** - * optional string field = 1; - * - *
      -       * A path leading to a field in the request body. The value will be a
      -       * sequence of dot-separated identifiers that identify a protocol buffer
      -       * field. E.g., "violations.field" would identify this field.
      -       * 
      - */ - public Builder clearField() { - - field_ = getDefaultInstance().getField(); - onChanged(); - return this; - } - /** - * optional string field = 1; - * - *
      -       * A path leading to a field in the request body. The value will be a
      -       * sequence of dot-separated identifiers that identify a protocol buffer
      -       * field. E.g., "violations.field" would identify this field.
      -       * 
      - */ - public Builder setFieldBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - field_ = value; - onChanged(); - return this; - } - - private java.lang.Object description_ = ""; - /** - * optional string description = 2; - * - *
      -       * A description of why the request element is bad.
      -       * 
      - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string description = 2; - * - *
      -       * A description of why the request element is bad.
      -       * 
      - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string description = 2; - * - *
      -       * A description of why the request element is bad.
      -       * 
      - */ - public Builder setDescription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - description_ = value; - onChanged(); - return this; - } - /** - * optional string description = 2; - * - *
      -       * A description of why the request element is bad.
      -       * 
      - */ - public Builder clearDescription() { - - description_ = getDefaultInstance().getDescription(); - onChanged(); - return this; - } - /** - * optional string description = 2; - * - *
      -       * A description of why the request element is bad.
      -       * 
      - */ - public Builder setDescriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - description_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.BadRequest.FieldViolation) - } - - // @@protoc_insertion_point(class_scope:google.rpc.BadRequest.FieldViolation) - private static final com.google.rpc.BadRequest.FieldViolation DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.BadRequest.FieldViolation(); - } - - public static com.google.rpc.BadRequest.FieldViolation getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public FieldViolation parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new FieldViolation(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.BadRequest.FieldViolation getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public static final int FIELD_VIOLATIONS_FIELD_NUMBER = 1; - private java.util.List fieldViolations_; - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -   * Describes all violations in a client request.
      -   * 
      - */ - public java.util.List getFieldViolationsList() { - return fieldViolations_; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -   * Describes all violations in a client request.
      -   * 
      - */ - public java.util.List - getFieldViolationsOrBuilderList() { - return fieldViolations_; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -   * Describes all violations in a client request.
      -   * 
      - */ - public int getFieldViolationsCount() { - return fieldViolations_.size(); - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -   * Describes all violations in a client request.
      -   * 
      - */ - public com.google.rpc.BadRequest.FieldViolation getFieldViolations(int index) { - return fieldViolations_.get(index); - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -   * Describes all violations in a client request.
      -   * 
      - */ - public com.google.rpc.BadRequest.FieldViolationOrBuilder getFieldViolationsOrBuilder( - int index) { - return fieldViolations_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < fieldViolations_.size(); i++) { - output.writeMessage(1, fieldViolations_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < fieldViolations_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, fieldViolations_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.BadRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.BadRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.BadRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.BadRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.BadRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.BadRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.BadRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.BadRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.BadRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.BadRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.BadRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.BadRequest} - * - *
      -   * Describes violations in a client request. This error type focuses on the
      -   * syntactic aspects of the request.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.BadRequest) - com.google.rpc.BadRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.BadRequest.class, com.google.rpc.BadRequest.Builder.class); - } - - // Construct using com.google.rpc.BadRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getFieldViolationsFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (fieldViolationsBuilder_ == null) { - fieldViolations_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - fieldViolationsBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_BadRequest_descriptor; - } - - public com.google.rpc.BadRequest getDefaultInstanceForType() { - return com.google.rpc.BadRequest.getDefaultInstance(); - } - - public com.google.rpc.BadRequest build() { - com.google.rpc.BadRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.BadRequest buildPartial() { - com.google.rpc.BadRequest result = new com.google.rpc.BadRequest(this); - int from_bitField0_ = bitField0_; - if (fieldViolationsBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - fieldViolations_ = java.util.Collections.unmodifiableList(fieldViolations_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.fieldViolations_ = fieldViolations_; - } else { - result.fieldViolations_ = fieldViolationsBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.BadRequest) { - return mergeFrom((com.google.rpc.BadRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.BadRequest other) { - if (other == com.google.rpc.BadRequest.getDefaultInstance()) return this; - if (fieldViolationsBuilder_ == null) { - if (!other.fieldViolations_.isEmpty()) { - if (fieldViolations_.isEmpty()) { - fieldViolations_ = other.fieldViolations_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureFieldViolationsIsMutable(); - fieldViolations_.addAll(other.fieldViolations_); - } - onChanged(); - } - } else { - if (!other.fieldViolations_.isEmpty()) { - if (fieldViolationsBuilder_.isEmpty()) { - fieldViolationsBuilder_.dispose(); - fieldViolationsBuilder_ = null; - fieldViolations_ = other.fieldViolations_; - bitField0_ = (bitField0_ & ~0x00000001); - fieldViolationsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getFieldViolationsFieldBuilder() : null; - } else { - fieldViolationsBuilder_.addAllMessages(other.fieldViolations_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.BadRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.BadRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List fieldViolations_ = - java.util.Collections.emptyList(); - private void ensureFieldViolationsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - fieldViolations_ = new java.util.ArrayList(fieldViolations_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.rpc.BadRequest.FieldViolation, com.google.rpc.BadRequest.FieldViolation.Builder, com.google.rpc.BadRequest.FieldViolationOrBuilder> fieldViolationsBuilder_; - - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public java.util.List getFieldViolationsList() { - if (fieldViolationsBuilder_ == null) { - return java.util.Collections.unmodifiableList(fieldViolations_); - } else { - return fieldViolationsBuilder_.getMessageList(); - } - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public int getFieldViolationsCount() { - if (fieldViolationsBuilder_ == null) { - return fieldViolations_.size(); - } else { - return fieldViolationsBuilder_.getCount(); - } - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public com.google.rpc.BadRequest.FieldViolation getFieldViolations(int index) { - if (fieldViolationsBuilder_ == null) { - return fieldViolations_.get(index); - } else { - return fieldViolationsBuilder_.getMessage(index); - } - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public Builder setFieldViolations( - int index, com.google.rpc.BadRequest.FieldViolation value) { - if (fieldViolationsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureFieldViolationsIsMutable(); - fieldViolations_.set(index, value); - onChanged(); - } else { - fieldViolationsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public Builder setFieldViolations( - int index, com.google.rpc.BadRequest.FieldViolation.Builder builderForValue) { - if (fieldViolationsBuilder_ == null) { - ensureFieldViolationsIsMutable(); - fieldViolations_.set(index, builderForValue.build()); - onChanged(); - } else { - fieldViolationsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public Builder addFieldViolations(com.google.rpc.BadRequest.FieldViolation value) { - if (fieldViolationsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureFieldViolationsIsMutable(); - fieldViolations_.add(value); - onChanged(); - } else { - fieldViolationsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public Builder addFieldViolations( - int index, com.google.rpc.BadRequest.FieldViolation value) { - if (fieldViolationsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureFieldViolationsIsMutable(); - fieldViolations_.add(index, value); - onChanged(); - } else { - fieldViolationsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public Builder addFieldViolations( - com.google.rpc.BadRequest.FieldViolation.Builder builderForValue) { - if (fieldViolationsBuilder_ == null) { - ensureFieldViolationsIsMutable(); - fieldViolations_.add(builderForValue.build()); - onChanged(); - } else { - fieldViolationsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public Builder addFieldViolations( - int index, com.google.rpc.BadRequest.FieldViolation.Builder builderForValue) { - if (fieldViolationsBuilder_ == null) { - ensureFieldViolationsIsMutable(); - fieldViolations_.add(index, builderForValue.build()); - onChanged(); - } else { - fieldViolationsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public Builder addAllFieldViolations( - java.lang.Iterable values) { - if (fieldViolationsBuilder_ == null) { - ensureFieldViolationsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, fieldViolations_); - onChanged(); - } else { - fieldViolationsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public Builder clearFieldViolations() { - if (fieldViolationsBuilder_ == null) { - fieldViolations_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - fieldViolationsBuilder_.clear(); - } - return this; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public Builder removeFieldViolations(int index) { - if (fieldViolationsBuilder_ == null) { - ensureFieldViolationsIsMutable(); - fieldViolations_.remove(index); - onChanged(); - } else { - fieldViolationsBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public com.google.rpc.BadRequest.FieldViolation.Builder getFieldViolationsBuilder( - int index) { - return getFieldViolationsFieldBuilder().getBuilder(index); - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public com.google.rpc.BadRequest.FieldViolationOrBuilder getFieldViolationsOrBuilder( - int index) { - if (fieldViolationsBuilder_ == null) { - return fieldViolations_.get(index); } else { - return fieldViolationsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public java.util.List - getFieldViolationsOrBuilderList() { - if (fieldViolationsBuilder_ != null) { - return fieldViolationsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(fieldViolations_); - } - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public com.google.rpc.BadRequest.FieldViolation.Builder addFieldViolationsBuilder() { - return getFieldViolationsFieldBuilder().addBuilder( - com.google.rpc.BadRequest.FieldViolation.getDefaultInstance()); - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public com.google.rpc.BadRequest.FieldViolation.Builder addFieldViolationsBuilder( - int index) { - return getFieldViolationsFieldBuilder().addBuilder( - index, com.google.rpc.BadRequest.FieldViolation.getDefaultInstance()); - } - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -     * Describes all violations in a client request.
      -     * 
      - */ - public java.util.List - getFieldViolationsBuilderList() { - return getFieldViolationsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.rpc.BadRequest.FieldViolation, com.google.rpc.BadRequest.FieldViolation.Builder, com.google.rpc.BadRequest.FieldViolationOrBuilder> - getFieldViolationsFieldBuilder() { - if (fieldViolationsBuilder_ == null) { - fieldViolationsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.rpc.BadRequest.FieldViolation, com.google.rpc.BadRequest.FieldViolation.Builder, com.google.rpc.BadRequest.FieldViolationOrBuilder>( - fieldViolations_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - fieldViolations_ = null; - } - return fieldViolationsBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.BadRequest) - } - - // @@protoc_insertion_point(class_scope:google.rpc.BadRequest) - private static final com.google.rpc.BadRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.BadRequest(); - } - - public static com.google.rpc.BadRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public BadRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new BadRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.BadRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequestOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequestOrBuilder.java deleted file mode 100644 index 6363fe8b9a0e..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/BadRequestOrBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -public interface BadRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.BadRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -   * Describes all violations in a client request.
      -   * 
      - */ - java.util.List - getFieldViolationsList(); - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -   * Describes all violations in a client request.
      -   * 
      - */ - com.google.rpc.BadRequest.FieldViolation getFieldViolations(int index); - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -   * Describes all violations in a client request.
      -   * 
      - */ - int getFieldViolationsCount(); - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -   * Describes all violations in a client request.
      -   * 
      - */ - java.util.List - getFieldViolationsOrBuilderList(); - /** - * repeated .google.rpc.BadRequest.FieldViolation field_violations = 1; - * - *
      -   * Describes all violations in a client request.
      -   * 
      - */ - com.google.rpc.BadRequest.FieldViolationOrBuilder getFieldViolationsOrBuilder( - int index); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/Code.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/Code.java deleted file mode 100644 index 3fcbad557708..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/Code.java +++ /dev/null @@ -1,543 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/code.proto - -package com.google.rpc; - -/** - * Protobuf enum {@code google.rpc.Code} - * - *
      - * The canonical error codes for Google APIs.
      - * Warnings:
      - * -   Do not change any numeric assignments.
      - * -   Changes to this list should be made only if there is a compelling
      - *     need that can't be satisfied in another way.
      - * Sometimes multiple error codes may apply.  Services should return
      - * the most specific error code that applies.  For example, prefer
      - * `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply.
      - * Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`.
      - * 
      - */ -public enum Code - implements com.google.protobuf.ProtocolMessageEnum { - /** - * OK = 0; - * - *
      -   * Not an error; returned on success
      -   * HTTP Mapping: 200 OK
      -   * 
      - */ - OK(0, 0), - /** - * CANCELLED = 1; - * - *
      -   * The operation was cancelled, typically by the caller.
      -   * HTTP Mapping: 499 Client Closed Request
      -   * 
      - */ - CANCELLED(1, 1), - /** - * UNKNOWN = 2; - * - *
      -   * Unknown error.  For example, this error may be returned when
      -   * a `Status` value received from another address space belongs to
      -   * an error space that is not known in this address space.  Also
      -   * errors raised by APIs that do not return enough error information
      -   * may be converted to this error.
      -   * HTTP Mapping: 500 Internal Server Error
      -   * 
      - */ - UNKNOWN(2, 2), - /** - * INVALID_ARGUMENT = 3; - * - *
      -   * The client specified an invalid argument.  Note that this differs
      -   * from `FAILED_PRECONDITION`.  `INVALID_ARGUMENT` indicates arguments
      -   * that are problematic regardless of the state of the system
      -   * (e.g., a malformed file name).
      -   * HTTP Mapping: 400 Bad Request
      -   * 
      - */ - INVALID_ARGUMENT(3, 3), - /** - * DEADLINE_EXCEEDED = 4; - * - *
      -   * The deadline expired before the operation could complete. For operations
      -   * that change the state of the system, this error may be returned
      -   * even if the operation has completed successfully.  For example, a
      -   * successful response from a server could have been delayed long
      -   * enough for the deadline to expire.
      -   * HTTP Mapping: 504 Gateway Timeout
      -   * 
      - */ - DEADLINE_EXCEEDED(4, 4), - /** - * NOT_FOUND = 5; - * - *
      -   * Some requested entity (e.g., file or directory) was not found.
      -   * For privacy reasons, this code *might* be returned when the client
      -   * does not have the access rights to the entity.
      -   * HTTP Mapping: 404 Not Found
      -   * 
      - */ - NOT_FOUND(5, 5), - /** - * ALREADY_EXISTS = 6; - * - *
      -   * The entity that a client attempted to create (e.g., file or directory)
      -   * already exists.
      -   * HTTP Mapping: 409 Conflict
      -   * 
      - */ - ALREADY_EXISTS(6, 6), - /** - * PERMISSION_DENIED = 7; - * - *
      -   * The caller does not have permission to execute the specified
      -   * operation. `PERMISSION_DENIED` must not be used for rejections
      -   * caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
      -   * instead for those errors). `PERMISSION_DENIED` must not be
      -   * used if the caller can not be identified (use `UNAUTHENTICATED`
      -   * instead for those errors).
      -   * HTTP Mapping: 403 Forbidden
      -   * 
      - */ - PERMISSION_DENIED(7, 7), - /** - * UNAUTHENTICATED = 16; - * - *
      -   * The request does not have valid authentication credentials for the
      -   * operation.
      -   * HTTP Mapping: 401 Unauthorized
      -   * 
      - */ - UNAUTHENTICATED(8, 16), - /** - * RESOURCE_EXHAUSTED = 8; - * - *
      -   * Some resource has been exhausted, perhaps a per-user quota, or
      -   * perhaps the entire file system is out of space.
      -   * HTTP Mapping: 429 Too Many Requests
      -   * 
      - */ - RESOURCE_EXHAUSTED(9, 8), - /** - * FAILED_PRECONDITION = 9; - * - *
      -   * The operation was rejected because the system is not in a state
      -   * required for the operation's execution.  For example, the directory
      -   * to be deleted is non-empty, an rmdir operation is applied to
      -   * a non-directory, etc.
      -   * Service implementors can use the following guidelines to decide
      -   * between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
      -   *  (a) Use `UNAVAILABLE` if the client can retry just the failing call.
      -   *  (b) Use `ABORTED` if the client should retry at a higher level
      -   *      (e.g., restarting a read-modify-write sequence).
      -   *  (c) Use `FAILED_PRECONDITION` if the client should not retry until
      -   *      the system state has been explicitly fixed.  E.g., if an "rmdir"
      -   *      fails because the directory is non-empty, `FAILED_PRECONDITION`
      -   *      should be returned since the client should not retry unless
      -   *      the files are deleted from the directory.
      -   *  (d) Use `FAILED_PRECONDITION` if the client performs conditional
      -   *      REST Get/Update/Delete on a resource and the resource on the
      -   *      server does not match the condition. E.g., conflicting
      -   *      read-modify-write on the same resource.
      -   * HTTP Mapping: 400 Bad Request
      -   * NOTE: HTTP spec says `412 Precondition Failed` should be used only if
      -   * the request contains Etag-related headers. So if the server does see
      -   * Etag-related headers in the request, it may choose to return 412
      -   * instead of 400 for this error code.
      -   * 
      - */ - FAILED_PRECONDITION(10, 9), - /** - * ABORTED = 10; - * - *
      -   * The operation was aborted, typically due to a concurrency issue such as
      -   * a sequencer check failure or transaction abort.
      -   * See the guidelines above for deciding between `FAILED_PRECONDITION`,
      -   * `ABORTED`, and `UNAVAILABLE`.
      -   * HTTP Mapping: 409 Conflict
      -   * 
      - */ - ABORTED(11, 10), - /** - * OUT_OF_RANGE = 11; - * - *
      -   * The operation was attempted past the valid range.  E.g., seeking or
      -   * reading past end-of-file.
      -   * Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
      -   * be fixed if the system state changes. For example, a 32-bit file
      -   * system will generate `INVALID_ARGUMENT` if asked to read at an
      -   * offset that is not in the range [0,2^32-1], but it will generate
      -   * `OUT_OF_RANGE` if asked to read from an offset past the current
      -   * file size.
      -   * There is a fair bit of overlap between `FAILED_PRECONDITION` and
      -   * `OUT_OF_RANGE`.  We recommend using `OUT_OF_RANGE` (the more specific
      -   * error) when it applies so that callers who are iterating through
      -   * a space can easily look for an `OUT_OF_RANGE` error to detect when
      -   * they are done.
      -   * HTTP Mapping: 400 Bad Request
      -   * 
      - */ - OUT_OF_RANGE(12, 11), - /** - * UNIMPLEMENTED = 12; - * - *
      -   * The operation is not implemented or is not supported/enabled in this
      -   * service.
      -   * HTTP Mapping: 501 Not Implemented
      -   * 
      - */ - UNIMPLEMENTED(13, 12), - /** - * INTERNAL = 13; - * - *
      -   * Internal errors.  This means that some invariants expected by the
      -   * underlying system have been broken.  This error code is reserved
      -   * for serious errors.
      -   * HTTP Mapping: 500 Internal Server Error
      -   * 
      - */ - INTERNAL(14, 13), - /** - * UNAVAILABLE = 14; - * - *
      -   * The service is currently unavailable.  This is most likely a
      -   * transient condition, which can be corrected by retrying with
      -   * a backoff.
      -   * See the guidelines above for deciding between `FAILED_PRECONDITION`,
      -   * `ABORTED`, and `UNAVAILABLE`.
      -   * HTTP Mapping: 503 Service Unavailable
      -   * 
      - */ - UNAVAILABLE(15, 14), - /** - * DATA_LOSS = 15; - * - *
      -   * Unrecoverable data loss or corruption.
      -   * HTTP Mapping: 500 Internal Server Error
      -   * 
      - */ - DATA_LOSS(16, 15), - UNRECOGNIZED(-1, -1), - ; - - /** - * OK = 0; - * - *
      -   * Not an error; returned on success
      -   * HTTP Mapping: 200 OK
      -   * 
      - */ - public static final int OK_VALUE = 0; - /** - * CANCELLED = 1; - * - *
      -   * The operation was cancelled, typically by the caller.
      -   * HTTP Mapping: 499 Client Closed Request
      -   * 
      - */ - public static final int CANCELLED_VALUE = 1; - /** - * UNKNOWN = 2; - * - *
      -   * Unknown error.  For example, this error may be returned when
      -   * a `Status` value received from another address space belongs to
      -   * an error space that is not known in this address space.  Also
      -   * errors raised by APIs that do not return enough error information
      -   * may be converted to this error.
      -   * HTTP Mapping: 500 Internal Server Error
      -   * 
      - */ - public static final int UNKNOWN_VALUE = 2; - /** - * INVALID_ARGUMENT = 3; - * - *
      -   * The client specified an invalid argument.  Note that this differs
      -   * from `FAILED_PRECONDITION`.  `INVALID_ARGUMENT` indicates arguments
      -   * that are problematic regardless of the state of the system
      -   * (e.g., a malformed file name).
      -   * HTTP Mapping: 400 Bad Request
      -   * 
      - */ - public static final int INVALID_ARGUMENT_VALUE = 3; - /** - * DEADLINE_EXCEEDED = 4; - * - *
      -   * The deadline expired before the operation could complete. For operations
      -   * that change the state of the system, this error may be returned
      -   * even if the operation has completed successfully.  For example, a
      -   * successful response from a server could have been delayed long
      -   * enough for the deadline to expire.
      -   * HTTP Mapping: 504 Gateway Timeout
      -   * 
      - */ - public static final int DEADLINE_EXCEEDED_VALUE = 4; - /** - * NOT_FOUND = 5; - * - *
      -   * Some requested entity (e.g., file or directory) was not found.
      -   * For privacy reasons, this code *might* be returned when the client
      -   * does not have the access rights to the entity.
      -   * HTTP Mapping: 404 Not Found
      -   * 
      - */ - public static final int NOT_FOUND_VALUE = 5; - /** - * ALREADY_EXISTS = 6; - * - *
      -   * The entity that a client attempted to create (e.g., file or directory)
      -   * already exists.
      -   * HTTP Mapping: 409 Conflict
      -   * 
      - */ - public static final int ALREADY_EXISTS_VALUE = 6; - /** - * PERMISSION_DENIED = 7; - * - *
      -   * The caller does not have permission to execute the specified
      -   * operation. `PERMISSION_DENIED` must not be used for rejections
      -   * caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
      -   * instead for those errors). `PERMISSION_DENIED` must not be
      -   * used if the caller can not be identified (use `UNAUTHENTICATED`
      -   * instead for those errors).
      -   * HTTP Mapping: 403 Forbidden
      -   * 
      - */ - public static final int PERMISSION_DENIED_VALUE = 7; - /** - * UNAUTHENTICATED = 16; - * - *
      -   * The request does not have valid authentication credentials for the
      -   * operation.
      -   * HTTP Mapping: 401 Unauthorized
      -   * 
      - */ - public static final int UNAUTHENTICATED_VALUE = 16; - /** - * RESOURCE_EXHAUSTED = 8; - * - *
      -   * Some resource has been exhausted, perhaps a per-user quota, or
      -   * perhaps the entire file system is out of space.
      -   * HTTP Mapping: 429 Too Many Requests
      -   * 
      - */ - public static final int RESOURCE_EXHAUSTED_VALUE = 8; - /** - * FAILED_PRECONDITION = 9; - * - *
      -   * The operation was rejected because the system is not in a state
      -   * required for the operation's execution.  For example, the directory
      -   * to be deleted is non-empty, an rmdir operation is applied to
      -   * a non-directory, etc.
      -   * Service implementors can use the following guidelines to decide
      -   * between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
      -   *  (a) Use `UNAVAILABLE` if the client can retry just the failing call.
      -   *  (b) Use `ABORTED` if the client should retry at a higher level
      -   *      (e.g., restarting a read-modify-write sequence).
      -   *  (c) Use `FAILED_PRECONDITION` if the client should not retry until
      -   *      the system state has been explicitly fixed.  E.g., if an "rmdir"
      -   *      fails because the directory is non-empty, `FAILED_PRECONDITION`
      -   *      should be returned since the client should not retry unless
      -   *      the files are deleted from the directory.
      -   *  (d) Use `FAILED_PRECONDITION` if the client performs conditional
      -   *      REST Get/Update/Delete on a resource and the resource on the
      -   *      server does not match the condition. E.g., conflicting
      -   *      read-modify-write on the same resource.
      -   * HTTP Mapping: 400 Bad Request
      -   * NOTE: HTTP spec says `412 Precondition Failed` should be used only if
      -   * the request contains Etag-related headers. So if the server does see
      -   * Etag-related headers in the request, it may choose to return 412
      -   * instead of 400 for this error code.
      -   * 
      - */ - public static final int FAILED_PRECONDITION_VALUE = 9; - /** - * ABORTED = 10; - * - *
      -   * The operation was aborted, typically due to a concurrency issue such as
      -   * a sequencer check failure or transaction abort.
      -   * See the guidelines above for deciding between `FAILED_PRECONDITION`,
      -   * `ABORTED`, and `UNAVAILABLE`.
      -   * HTTP Mapping: 409 Conflict
      -   * 
      - */ - public static final int ABORTED_VALUE = 10; - /** - * OUT_OF_RANGE = 11; - * - *
      -   * The operation was attempted past the valid range.  E.g., seeking or
      -   * reading past end-of-file.
      -   * Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
      -   * be fixed if the system state changes. For example, a 32-bit file
      -   * system will generate `INVALID_ARGUMENT` if asked to read at an
      -   * offset that is not in the range [0,2^32-1], but it will generate
      -   * `OUT_OF_RANGE` if asked to read from an offset past the current
      -   * file size.
      -   * There is a fair bit of overlap between `FAILED_PRECONDITION` and
      -   * `OUT_OF_RANGE`.  We recommend using `OUT_OF_RANGE` (the more specific
      -   * error) when it applies so that callers who are iterating through
      -   * a space can easily look for an `OUT_OF_RANGE` error to detect when
      -   * they are done.
      -   * HTTP Mapping: 400 Bad Request
      -   * 
      - */ - public static final int OUT_OF_RANGE_VALUE = 11; - /** - * UNIMPLEMENTED = 12; - * - *
      -   * The operation is not implemented or is not supported/enabled in this
      -   * service.
      -   * HTTP Mapping: 501 Not Implemented
      -   * 
      - */ - public static final int UNIMPLEMENTED_VALUE = 12; - /** - * INTERNAL = 13; - * - *
      -   * Internal errors.  This means that some invariants expected by the
      -   * underlying system have been broken.  This error code is reserved
      -   * for serious errors.
      -   * HTTP Mapping: 500 Internal Server Error
      -   * 
      - */ - public static final int INTERNAL_VALUE = 13; - /** - * UNAVAILABLE = 14; - * - *
      -   * The service is currently unavailable.  This is most likely a
      -   * transient condition, which can be corrected by retrying with
      -   * a backoff.
      -   * See the guidelines above for deciding between `FAILED_PRECONDITION`,
      -   * `ABORTED`, and `UNAVAILABLE`.
      -   * HTTP Mapping: 503 Service Unavailable
      -   * 
      - */ - public static final int UNAVAILABLE_VALUE = 14; - /** - * DATA_LOSS = 15; - * - *
      -   * Unrecoverable data loss or corruption.
      -   * HTTP Mapping: 500 Internal Server Error
      -   * 
      - */ - public static final int DATA_LOSS_VALUE = 15; - - - public final int getNumber() { - if (index == -1) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - public static Code valueOf(int value) { - switch (value) { - case 0: return OK; - case 1: return CANCELLED; - case 2: return UNKNOWN; - case 3: return INVALID_ARGUMENT; - case 4: return DEADLINE_EXCEEDED; - case 5: return NOT_FOUND; - case 6: return ALREADY_EXISTS; - case 7: return PERMISSION_DENIED; - case 16: return UNAUTHENTICATED; - case 8: return RESOURCE_EXHAUSTED; - case 9: return FAILED_PRECONDITION; - case 10: return ABORTED; - case 11: return OUT_OF_RANGE; - case 12: return UNIMPLEMENTED; - case 13: return INTERNAL; - case 14: return UNAVAILABLE; - case 15: return DATA_LOSS; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static final com.google.protobuf.Internal.EnumLiteMap< - Code> internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public Code findValueByNumber(int number) { - return Code.valueOf(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(index); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return com.google.rpc.CodeProto.getDescriptor() - .getEnumTypes().get(0); - } - - private static final Code[] VALUES = values(); - - public static Code valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int index; - private final int value; - - private Code(int index, int value) { - this.index = index; - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.rpc.Code) -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/CodeProto.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/CodeProto.java deleted file mode 100644 index 95dc036ed327..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/CodeProto.java +++ /dev/null @@ -1,46 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/code.proto - -package com.google.rpc; - -public final class CodeProto { - private CodeProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\025google/rpc/code.proto\022\ngoogle.rpc*\267\002\n\004" + - "Code\022\006\n\002OK\020\000\022\r\n\tCANCELLED\020\001\022\013\n\007UNKNOWN\020\002" + - "\022\024\n\020INVALID_ARGUMENT\020\003\022\025\n\021DEADLINE_EXCEE" + - "DED\020\004\022\r\n\tNOT_FOUND\020\005\022\022\n\016ALREADY_EXISTS\020\006" + - "\022\025\n\021PERMISSION_DENIED\020\007\022\023\n\017UNAUTHENTICAT" + - "ED\020\020\022\026\n\022RESOURCE_EXHAUSTED\020\010\022\027\n\023FAILED_P" + - "RECONDITION\020\t\022\013\n\007ABORTED\020\n\022\020\n\014OUT_OF_RAN" + - "GE\020\013\022\021\n\rUNIMPLEMENTED\020\014\022\014\n\010INTERNAL\020\r\022\017\n" + - "\013UNAVAILABLE\020\016\022\r\n\tDATA_LOSS\020\017B\035\n\016com.goo" + - "gle.rpcB\tCodeProtoP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfo.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfo.java deleted file mode 100644 index 74550a10502d..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfo.java +++ /dev/null @@ -1,697 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -/** - * Protobuf type {@code google.rpc.DebugInfo} - * - *
      - * Describes additional debugging info.
      - * 
      - */ -public final class DebugInfo extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.DebugInfo) - DebugInfoOrBuilder { - // Use DebugInfo.newBuilder() to construct. - private DebugInfo(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private DebugInfo() { - stackEntries_ = com.google.protobuf.LazyStringArrayList.EMPTY; - detail_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private DebugInfo( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - stackEntries_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; - } - stackEntries_.add(s); - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - detail_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - stackEntries_ = stackEntries_.getUnmodifiableView(); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_DebugInfo_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_DebugInfo_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.DebugInfo.class, com.google.rpc.DebugInfo.Builder.class); - } - - private int bitField0_; - public static final int STACK_ENTRIES_FIELD_NUMBER = 1; - private com.google.protobuf.LazyStringList stackEntries_; - /** - * repeated string stack_entries = 1; - * - *
      -   * The stack trace entries indicating where the error occurred.
      -   * 
      - */ - public com.google.protobuf.ProtocolStringList - getStackEntriesList() { - return stackEntries_; - } - /** - * repeated string stack_entries = 1; - * - *
      -   * The stack trace entries indicating where the error occurred.
      -   * 
      - */ - public int getStackEntriesCount() { - return stackEntries_.size(); - } - /** - * repeated string stack_entries = 1; - * - *
      -   * The stack trace entries indicating where the error occurred.
      -   * 
      - */ - public java.lang.String getStackEntries(int index) { - return stackEntries_.get(index); - } - /** - * repeated string stack_entries = 1; - * - *
      -   * The stack trace entries indicating where the error occurred.
      -   * 
      - */ - public com.google.protobuf.ByteString - getStackEntriesBytes(int index) { - return stackEntries_.getByteString(index); - } - - public static final int DETAIL_FIELD_NUMBER = 2; - private volatile java.lang.Object detail_; - /** - * optional string detail = 2; - * - *
      -   * Additional debugging information provided by the server.
      -   * 
      - */ - public java.lang.String getDetail() { - java.lang.Object ref = detail_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - detail_ = s; - return s; - } - } - /** - * optional string detail = 2; - * - *
      -   * Additional debugging information provided by the server.
      -   * 
      - */ - public com.google.protobuf.ByteString - getDetailBytes() { - java.lang.Object ref = detail_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - detail_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < stackEntries_.size(); i++) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, stackEntries_.getRaw(i)); - } - if (!getDetailBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, detail_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - for (int i = 0; i < stackEntries_.size(); i++) { - dataSize += computeStringSizeNoTag(stackEntries_.getRaw(i)); - } - size += dataSize; - size += 1 * getStackEntriesList().size(); - } - if (!getDetailBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, detail_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.DebugInfo parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.DebugInfo parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.DebugInfo parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.DebugInfo parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.DebugInfo parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.DebugInfo parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.DebugInfo parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.DebugInfo parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.DebugInfo parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.DebugInfo parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.DebugInfo prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.DebugInfo} - * - *
      -   * Describes additional debugging info.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.DebugInfo) - com.google.rpc.DebugInfoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_DebugInfo_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_DebugInfo_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.DebugInfo.class, com.google.rpc.DebugInfo.Builder.class); - } - - // Construct using com.google.rpc.DebugInfo.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - stackEntries_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - detail_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_DebugInfo_descriptor; - } - - public com.google.rpc.DebugInfo getDefaultInstanceForType() { - return com.google.rpc.DebugInfo.getDefaultInstance(); - } - - public com.google.rpc.DebugInfo build() { - com.google.rpc.DebugInfo result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.DebugInfo buildPartial() { - com.google.rpc.DebugInfo result = new com.google.rpc.DebugInfo(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - stackEntries_ = stackEntries_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.stackEntries_ = stackEntries_; - result.detail_ = detail_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.DebugInfo) { - return mergeFrom((com.google.rpc.DebugInfo)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.DebugInfo other) { - if (other == com.google.rpc.DebugInfo.getDefaultInstance()) return this; - if (!other.stackEntries_.isEmpty()) { - if (stackEntries_.isEmpty()) { - stackEntries_ = other.stackEntries_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureStackEntriesIsMutable(); - stackEntries_.addAll(other.stackEntries_); - } - onChanged(); - } - if (!other.getDetail().isEmpty()) { - detail_ = other.detail_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.DebugInfo parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.DebugInfo) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private com.google.protobuf.LazyStringList stackEntries_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureStackEntriesIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - stackEntries_ = new com.google.protobuf.LazyStringArrayList(stackEntries_); - bitField0_ |= 0x00000001; - } - } - /** - * repeated string stack_entries = 1; - * - *
      -     * The stack trace entries indicating where the error occurred.
      -     * 
      - */ - public com.google.protobuf.ProtocolStringList - getStackEntriesList() { - return stackEntries_.getUnmodifiableView(); - } - /** - * repeated string stack_entries = 1; - * - *
      -     * The stack trace entries indicating where the error occurred.
      -     * 
      - */ - public int getStackEntriesCount() { - return stackEntries_.size(); - } - /** - * repeated string stack_entries = 1; - * - *
      -     * The stack trace entries indicating where the error occurred.
      -     * 
      - */ - public java.lang.String getStackEntries(int index) { - return stackEntries_.get(index); - } - /** - * repeated string stack_entries = 1; - * - *
      -     * The stack trace entries indicating where the error occurred.
      -     * 
      - */ - public com.google.protobuf.ByteString - getStackEntriesBytes(int index) { - return stackEntries_.getByteString(index); - } - /** - * repeated string stack_entries = 1; - * - *
      -     * The stack trace entries indicating where the error occurred.
      -     * 
      - */ - public Builder setStackEntries( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureStackEntriesIsMutable(); - stackEntries_.set(index, value); - onChanged(); - return this; - } - /** - * repeated string stack_entries = 1; - * - *
      -     * The stack trace entries indicating where the error occurred.
      -     * 
      - */ - public Builder addStackEntries( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureStackEntriesIsMutable(); - stackEntries_.add(value); - onChanged(); - return this; - } - /** - * repeated string stack_entries = 1; - * - *
      -     * The stack trace entries indicating where the error occurred.
      -     * 
      - */ - public Builder addAllStackEntries( - java.lang.Iterable values) { - ensureStackEntriesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, stackEntries_); - onChanged(); - return this; - } - /** - * repeated string stack_entries = 1; - * - *
      -     * The stack trace entries indicating where the error occurred.
      -     * 
      - */ - public Builder clearStackEntries() { - stackEntries_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - * repeated string stack_entries = 1; - * - *
      -     * The stack trace entries indicating where the error occurred.
      -     * 
      - */ - public Builder addStackEntriesBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureStackEntriesIsMutable(); - stackEntries_.add(value); - onChanged(); - return this; - } - - private java.lang.Object detail_ = ""; - /** - * optional string detail = 2; - * - *
      -     * Additional debugging information provided by the server.
      -     * 
      - */ - public java.lang.String getDetail() { - java.lang.Object ref = detail_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - detail_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string detail = 2; - * - *
      -     * Additional debugging information provided by the server.
      -     * 
      - */ - public com.google.protobuf.ByteString - getDetailBytes() { - java.lang.Object ref = detail_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - detail_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string detail = 2; - * - *
      -     * Additional debugging information provided by the server.
      -     * 
      - */ - public Builder setDetail( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - detail_ = value; - onChanged(); - return this; - } - /** - * optional string detail = 2; - * - *
      -     * Additional debugging information provided by the server.
      -     * 
      - */ - public Builder clearDetail() { - - detail_ = getDefaultInstance().getDetail(); - onChanged(); - return this; - } - /** - * optional string detail = 2; - * - *
      -     * Additional debugging information provided by the server.
      -     * 
      - */ - public Builder setDetailBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - detail_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.DebugInfo) - } - - // @@protoc_insertion_point(class_scope:google.rpc.DebugInfo) - private static final com.google.rpc.DebugInfo DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.DebugInfo(); - } - - public static com.google.rpc.DebugInfo getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public DebugInfo parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new DebugInfo(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.DebugInfo getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfoOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfoOrBuilder.java deleted file mode 100644 index 25d0e498747a..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/DebugInfoOrBuilder.java +++ /dev/null @@ -1,62 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -public interface DebugInfoOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.DebugInfo) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated string stack_entries = 1; - * - *
      -   * The stack trace entries indicating where the error occurred.
      -   * 
      - */ - com.google.protobuf.ProtocolStringList - getStackEntriesList(); - /** - * repeated string stack_entries = 1; - * - *
      -   * The stack trace entries indicating where the error occurred.
      -   * 
      - */ - int getStackEntriesCount(); - /** - * repeated string stack_entries = 1; - * - *
      -   * The stack trace entries indicating where the error occurred.
      -   * 
      - */ - java.lang.String getStackEntries(int index); - /** - * repeated string stack_entries = 1; - * - *
      -   * The stack trace entries indicating where the error occurred.
      -   * 
      - */ - com.google.protobuf.ByteString - getStackEntriesBytes(int index); - - /** - * optional string detail = 2; - * - *
      -   * Additional debugging information provided by the server.
      -   * 
      - */ - java.lang.String getDetail(); - /** - * optional string detail = 2; - * - *
      -   * Additional debugging information provided by the server.
      -   * 
      - */ - com.google.protobuf.ByteString - getDetailBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/ErrorDetailsProto.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/ErrorDetailsProto.java deleted file mode 100644 index 1760e0a1d4bf..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/ErrorDetailsProto.java +++ /dev/null @@ -1,167 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -public final class ErrorDetailsProto { - private ErrorDetailsProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_RetryInfo_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_RetryInfo_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_DebugInfo_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_DebugInfo_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_QuotaFailure_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_QuotaFailure_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_QuotaFailure_Violation_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_QuotaFailure_Violation_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_BadRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_BadRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_BadRequest_FieldViolation_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_BadRequest_FieldViolation_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_RequestInfo_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_RequestInfo_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_ResourceInfo_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_ResourceInfo_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_Help_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_Help_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_Help_Link_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_Help_Link_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\036google/rpc/error_details.proto\022\ngoogle" + - ".rpc\032\036google/protobuf/duration.proto\";\n\t" + - "RetryInfo\022.\n\013retry_delay\030\001 \001(\0132\031.google." + - "protobuf.Duration\"2\n\tDebugInfo\022\025\n\rstack_" + - "entries\030\001 \003(\t\022\016\n\006detail\030\002 \001(\t\"y\n\014QuotaFa" + - "ilure\0226\n\nviolations\030\001 \003(\0132\".google.rpc.Q" + - "uotaFailure.Violation\0321\n\tViolation\022\017\n\007su" + - "bject\030\001 \001(\t\022\023\n\013description\030\002 \001(\t\"\203\001\n\nBad" + - "Request\022?\n\020field_violations\030\001 \003(\0132%.goog" + - "le.rpc.BadRequest.FieldViolation\0324\n\016Fiel", - "dViolation\022\r\n\005field\030\001 \001(\t\022\023\n\013description" + - "\030\002 \001(\t\"7\n\013RequestInfo\022\022\n\nrequest_id\030\001 \001(" + - "\t\022\024\n\014serving_data\030\002 \001(\t\"`\n\014ResourceInfo\022" + - "\025\n\rresource_type\030\001 \001(\t\022\025\n\rresource_name\030" + - "\002 \001(\t\022\r\n\005owner\030\003 \001(\t\022\023\n\013description\030\004 \001(" + - "\t\"V\n\004Help\022$\n\005links\030\001 \003(\0132\025.google.rpc.He" + - "lp.Link\032(\n\004Link\022\023\n\013description\030\001 \001(\t\022\013\n\003" + - "url\030\002 \001(\tB%\n\016com.google.rpcB\021ErrorDetail" + - "sProtoP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.DurationProto.getDescriptor(), - }, assigner); - internal_static_google_rpc_RetryInfo_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_rpc_RetryInfo_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_RetryInfo_descriptor, - new java.lang.String[] { "RetryDelay", }); - internal_static_google_rpc_DebugInfo_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_google_rpc_DebugInfo_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_DebugInfo_descriptor, - new java.lang.String[] { "StackEntries", "Detail", }); - internal_static_google_rpc_QuotaFailure_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_google_rpc_QuotaFailure_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_QuotaFailure_descriptor, - new java.lang.String[] { "Violations", }); - internal_static_google_rpc_QuotaFailure_Violation_descriptor = - internal_static_google_rpc_QuotaFailure_descriptor.getNestedTypes().get(0); - internal_static_google_rpc_QuotaFailure_Violation_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_QuotaFailure_Violation_descriptor, - new java.lang.String[] { "Subject", "Description", }); - internal_static_google_rpc_BadRequest_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_google_rpc_BadRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_BadRequest_descriptor, - new java.lang.String[] { "FieldViolations", }); - internal_static_google_rpc_BadRequest_FieldViolation_descriptor = - internal_static_google_rpc_BadRequest_descriptor.getNestedTypes().get(0); - internal_static_google_rpc_BadRequest_FieldViolation_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_BadRequest_FieldViolation_descriptor, - new java.lang.String[] { "Field", "Description", }); - internal_static_google_rpc_RequestInfo_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_google_rpc_RequestInfo_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_RequestInfo_descriptor, - new java.lang.String[] { "RequestId", "ServingData", }); - internal_static_google_rpc_ResourceInfo_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_google_rpc_ResourceInfo_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_ResourceInfo_descriptor, - new java.lang.String[] { "ResourceType", "ResourceName", "Owner", "Description", }); - internal_static_google_rpc_Help_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_google_rpc_Help_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_Help_descriptor, - new java.lang.String[] { "Links", }); - internal_static_google_rpc_Help_Link_descriptor = - internal_static_google_rpc_Help_descriptor.getNestedTypes().get(0); - internal_static_google_rpc_Help_Link_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_Help_Link_descriptor, - new java.lang.String[] { "Description", "Url", }); - com.google.protobuf.DurationProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/Help.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/Help.java deleted file mode 100644 index 92fe066f6f78..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/Help.java +++ /dev/null @@ -1,1423 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -/** - * Protobuf type {@code google.rpc.Help} - * - *
      - * Provides links to documentation or for performing an out of band action.
      - * For example, if a quota check failed with an error indicating the calling
      - * project hasn't enabled the accessed service, this can contain a URL pointing
      - * directly to the right place in the developer console to flip the bit.
      - * 
      - */ -public final class Help extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.Help) - HelpOrBuilder { - // Use Help.newBuilder() to construct. - private Help(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Help() { - links_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Help( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - links_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - links_.add(input.readMessage(com.google.rpc.Help.Link.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - links_ = java.util.Collections.unmodifiableList(links_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.Help.class, com.google.rpc.Help.Builder.class); - } - - public interface LinkOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.Help.Link) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string description = 1; - * - *
      -     * Describes what the link offers.
      -     * 
      - */ - java.lang.String getDescription(); - /** - * optional string description = 1; - * - *
      -     * Describes what the link offers.
      -     * 
      - */ - com.google.protobuf.ByteString - getDescriptionBytes(); - - /** - * optional string url = 2; - * - *
      -     * The URL of the link.
      -     * 
      - */ - java.lang.String getUrl(); - /** - * optional string url = 2; - * - *
      -     * The URL of the link.
      -     * 
      - */ - com.google.protobuf.ByteString - getUrlBytes(); - } - /** - * Protobuf type {@code google.rpc.Help.Link} - * - *
      -   * Describes a URL link.
      -   * 
      - */ - public static final class Link extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.Help.Link) - LinkOrBuilder { - // Use Link.newBuilder() to construct. - private Link(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Link() { - description_ = ""; - url_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Link( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - description_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - url_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_Link_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_Link_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.Help.Link.class, com.google.rpc.Help.Link.Builder.class); - } - - public static final int DESCRIPTION_FIELD_NUMBER = 1; - private volatile java.lang.Object description_; - /** - * optional string description = 1; - * - *
      -     * Describes what the link offers.
      -     * 
      - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } - } - /** - * optional string description = 1; - * - *
      -     * Describes what the link offers.
      -     * 
      - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int URL_FIELD_NUMBER = 2; - private volatile java.lang.Object url_; - /** - * optional string url = 2; - * - *
      -     * The URL of the link.
      -     * 
      - */ - public java.lang.String getUrl() { - java.lang.Object ref = url_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - url_ = s; - return s; - } - } - /** - * optional string url = 2; - * - *
      -     * The URL of the link.
      -     * 
      - */ - public com.google.protobuf.ByteString - getUrlBytes() { - java.lang.Object ref = url_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getDescriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, description_); - } - if (!getUrlBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, url_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getDescriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, description_); - } - if (!getUrlBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, url_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.Help.Link parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.Help.Link parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.Help.Link parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.Help.Link parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.Help.Link parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.Help.Link parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.Help.Link parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.Help.Link parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.Help.Link parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.Help.Link parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.Help.Link prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.Help.Link} - * - *
      -     * Describes a URL link.
      -     * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.Help.Link) - com.google.rpc.Help.LinkOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_Link_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_Link_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.Help.Link.class, com.google.rpc.Help.Link.Builder.class); - } - - // Construct using com.google.rpc.Help.Link.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - description_ = ""; - - url_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_Link_descriptor; - } - - public com.google.rpc.Help.Link getDefaultInstanceForType() { - return com.google.rpc.Help.Link.getDefaultInstance(); - } - - public com.google.rpc.Help.Link build() { - com.google.rpc.Help.Link result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.Help.Link buildPartial() { - com.google.rpc.Help.Link result = new com.google.rpc.Help.Link(this); - result.description_ = description_; - result.url_ = url_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.Help.Link) { - return mergeFrom((com.google.rpc.Help.Link)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.Help.Link other) { - if (other == com.google.rpc.Help.Link.getDefaultInstance()) return this; - if (!other.getDescription().isEmpty()) { - description_ = other.description_; - onChanged(); - } - if (!other.getUrl().isEmpty()) { - url_ = other.url_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.Help.Link parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.Help.Link) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object description_ = ""; - /** - * optional string description = 1; - * - *
      -       * Describes what the link offers.
      -       * 
      - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string description = 1; - * - *
      -       * Describes what the link offers.
      -       * 
      - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string description = 1; - * - *
      -       * Describes what the link offers.
      -       * 
      - */ - public Builder setDescription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - description_ = value; - onChanged(); - return this; - } - /** - * optional string description = 1; - * - *
      -       * Describes what the link offers.
      -       * 
      - */ - public Builder clearDescription() { - - description_ = getDefaultInstance().getDescription(); - onChanged(); - return this; - } - /** - * optional string description = 1; - * - *
      -       * Describes what the link offers.
      -       * 
      - */ - public Builder setDescriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - description_ = value; - onChanged(); - return this; - } - - private java.lang.Object url_ = ""; - /** - * optional string url = 2; - * - *
      -       * The URL of the link.
      -       * 
      - */ - public java.lang.String getUrl() { - java.lang.Object ref = url_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - url_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string url = 2; - * - *
      -       * The URL of the link.
      -       * 
      - */ - public com.google.protobuf.ByteString - getUrlBytes() { - java.lang.Object ref = url_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - url_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string url = 2; - * - *
      -       * The URL of the link.
      -       * 
      - */ - public Builder setUrl( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - url_ = value; - onChanged(); - return this; - } - /** - * optional string url = 2; - * - *
      -       * The URL of the link.
      -       * 
      - */ - public Builder clearUrl() { - - url_ = getDefaultInstance().getUrl(); - onChanged(); - return this; - } - /** - * optional string url = 2; - * - *
      -       * The URL of the link.
      -       * 
      - */ - public Builder setUrlBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - url_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.Help.Link) - } - - // @@protoc_insertion_point(class_scope:google.rpc.Help.Link) - private static final com.google.rpc.Help.Link DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.Help.Link(); - } - - public static com.google.rpc.Help.Link getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Link parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Link(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.Help.Link getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public static final int LINKS_FIELD_NUMBER = 1; - private java.util.List links_; - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -   * URL(s) pointing to additional information on handling the current error.
      -   * 
      - */ - public java.util.List getLinksList() { - return links_; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -   * URL(s) pointing to additional information on handling the current error.
      -   * 
      - */ - public java.util.List - getLinksOrBuilderList() { - return links_; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -   * URL(s) pointing to additional information on handling the current error.
      -   * 
      - */ - public int getLinksCount() { - return links_.size(); - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -   * URL(s) pointing to additional information on handling the current error.
      -   * 
      - */ - public com.google.rpc.Help.Link getLinks(int index) { - return links_.get(index); - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -   * URL(s) pointing to additional information on handling the current error.
      -   * 
      - */ - public com.google.rpc.Help.LinkOrBuilder getLinksOrBuilder( - int index) { - return links_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < links_.size(); i++) { - output.writeMessage(1, links_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < links_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, links_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.Help parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.Help parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.Help parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.Help parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.Help parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.Help parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.Help parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.Help parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.Help parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.Help parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.Help prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.Help} - * - *
      -   * Provides links to documentation or for performing an out of band action.
      -   * For example, if a quota check failed with an error indicating the calling
      -   * project hasn't enabled the accessed service, this can contain a URL pointing
      -   * directly to the right place in the developer console to flip the bit.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.Help) - com.google.rpc.HelpOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.Help.class, com.google.rpc.Help.Builder.class); - } - - // Construct using com.google.rpc.Help.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getLinksFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (linksBuilder_ == null) { - links_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - linksBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_Help_descriptor; - } - - public com.google.rpc.Help getDefaultInstanceForType() { - return com.google.rpc.Help.getDefaultInstance(); - } - - public com.google.rpc.Help build() { - com.google.rpc.Help result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.Help buildPartial() { - com.google.rpc.Help result = new com.google.rpc.Help(this); - int from_bitField0_ = bitField0_; - if (linksBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - links_ = java.util.Collections.unmodifiableList(links_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.links_ = links_; - } else { - result.links_ = linksBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.Help) { - return mergeFrom((com.google.rpc.Help)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.Help other) { - if (other == com.google.rpc.Help.getDefaultInstance()) return this; - if (linksBuilder_ == null) { - if (!other.links_.isEmpty()) { - if (links_.isEmpty()) { - links_ = other.links_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureLinksIsMutable(); - links_.addAll(other.links_); - } - onChanged(); - } - } else { - if (!other.links_.isEmpty()) { - if (linksBuilder_.isEmpty()) { - linksBuilder_.dispose(); - linksBuilder_ = null; - links_ = other.links_; - bitField0_ = (bitField0_ & ~0x00000001); - linksBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getLinksFieldBuilder() : null; - } else { - linksBuilder_.addAllMessages(other.links_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.Help parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.Help) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List links_ = - java.util.Collections.emptyList(); - private void ensureLinksIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - links_ = new java.util.ArrayList(links_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.rpc.Help.Link, com.google.rpc.Help.Link.Builder, com.google.rpc.Help.LinkOrBuilder> linksBuilder_; - - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public java.util.List getLinksList() { - if (linksBuilder_ == null) { - return java.util.Collections.unmodifiableList(links_); - } else { - return linksBuilder_.getMessageList(); - } - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public int getLinksCount() { - if (linksBuilder_ == null) { - return links_.size(); - } else { - return linksBuilder_.getCount(); - } - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public com.google.rpc.Help.Link getLinks(int index) { - if (linksBuilder_ == null) { - return links_.get(index); - } else { - return linksBuilder_.getMessage(index); - } - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public Builder setLinks( - int index, com.google.rpc.Help.Link value) { - if (linksBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureLinksIsMutable(); - links_.set(index, value); - onChanged(); - } else { - linksBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public Builder setLinks( - int index, com.google.rpc.Help.Link.Builder builderForValue) { - if (linksBuilder_ == null) { - ensureLinksIsMutable(); - links_.set(index, builderForValue.build()); - onChanged(); - } else { - linksBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public Builder addLinks(com.google.rpc.Help.Link value) { - if (linksBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureLinksIsMutable(); - links_.add(value); - onChanged(); - } else { - linksBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public Builder addLinks( - int index, com.google.rpc.Help.Link value) { - if (linksBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureLinksIsMutable(); - links_.add(index, value); - onChanged(); - } else { - linksBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public Builder addLinks( - com.google.rpc.Help.Link.Builder builderForValue) { - if (linksBuilder_ == null) { - ensureLinksIsMutable(); - links_.add(builderForValue.build()); - onChanged(); - } else { - linksBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public Builder addLinks( - int index, com.google.rpc.Help.Link.Builder builderForValue) { - if (linksBuilder_ == null) { - ensureLinksIsMutable(); - links_.add(index, builderForValue.build()); - onChanged(); - } else { - linksBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public Builder addAllLinks( - java.lang.Iterable values) { - if (linksBuilder_ == null) { - ensureLinksIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, links_); - onChanged(); - } else { - linksBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public Builder clearLinks() { - if (linksBuilder_ == null) { - links_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - linksBuilder_.clear(); - } - return this; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public Builder removeLinks(int index) { - if (linksBuilder_ == null) { - ensureLinksIsMutable(); - links_.remove(index); - onChanged(); - } else { - linksBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public com.google.rpc.Help.Link.Builder getLinksBuilder( - int index) { - return getLinksFieldBuilder().getBuilder(index); - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public com.google.rpc.Help.LinkOrBuilder getLinksOrBuilder( - int index) { - if (linksBuilder_ == null) { - return links_.get(index); } else { - return linksBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public java.util.List - getLinksOrBuilderList() { - if (linksBuilder_ != null) { - return linksBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(links_); - } - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public com.google.rpc.Help.Link.Builder addLinksBuilder() { - return getLinksFieldBuilder().addBuilder( - com.google.rpc.Help.Link.getDefaultInstance()); - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public com.google.rpc.Help.Link.Builder addLinksBuilder( - int index) { - return getLinksFieldBuilder().addBuilder( - index, com.google.rpc.Help.Link.getDefaultInstance()); - } - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -     * URL(s) pointing to additional information on handling the current error.
      -     * 
      - */ - public java.util.List - getLinksBuilderList() { - return getLinksFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.rpc.Help.Link, com.google.rpc.Help.Link.Builder, com.google.rpc.Help.LinkOrBuilder> - getLinksFieldBuilder() { - if (linksBuilder_ == null) { - linksBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.rpc.Help.Link, com.google.rpc.Help.Link.Builder, com.google.rpc.Help.LinkOrBuilder>( - links_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - links_ = null; - } - return linksBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.Help) - } - - // @@protoc_insertion_point(class_scope:google.rpc.Help) - private static final com.google.rpc.Help DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.Help(); - } - - public static com.google.rpc.Help getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Help parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Help(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.Help getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/HelpOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/HelpOrBuilder.java deleted file mode 100644 index ffaca8109020..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/HelpOrBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -public interface HelpOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.Help) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -   * URL(s) pointing to additional information on handling the current error.
      -   * 
      - */ - java.util.List - getLinksList(); - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -   * URL(s) pointing to additional information on handling the current error.
      -   * 
      - */ - com.google.rpc.Help.Link getLinks(int index); - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -   * URL(s) pointing to additional information on handling the current error.
      -   * 
      - */ - int getLinksCount(); - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -   * URL(s) pointing to additional information on handling the current error.
      -   * 
      - */ - java.util.List - getLinksOrBuilderList(); - /** - * repeated .google.rpc.Help.Link links = 1; - * - *
      -   * URL(s) pointing to additional information on handling the current error.
      -   * 
      - */ - com.google.rpc.Help.LinkOrBuilder getLinksOrBuilder( - int index); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailure.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailure.java deleted file mode 100644 index 3051a2773fbb..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailure.java +++ /dev/null @@ -1,1498 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -/** - * Protobuf type {@code google.rpc.QuotaFailure} - * - *
      - * Describes how a quota check failed.
      - * For example if a daily limit was exceeded for the calling project,
      - * a service could respond with a QuotaFailure detail containing the project
      - * id and the description of the quota limit that was exceeded.  If the
      - * calling project hasn't enabled the service in the developer console, then
      - * a service could respond with the project id and set `service_disabled`
      - * to true.
      - * Also see RetryDetail and Help types for other details about handling a
      - * quota failure.
      - * 
      - */ -public final class QuotaFailure extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.QuotaFailure) - QuotaFailureOrBuilder { - // Use QuotaFailure.newBuilder() to construct. - private QuotaFailure(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private QuotaFailure() { - violations_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private QuotaFailure( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - violations_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - violations_.add(input.readMessage(com.google.rpc.QuotaFailure.Violation.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - violations_ = java.util.Collections.unmodifiableList(violations_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.QuotaFailure.class, com.google.rpc.QuotaFailure.Builder.class); - } - - public interface ViolationOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.QuotaFailure.Violation) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string subject = 1; - * - *
      -     * The subject on which the quota check failed.
      -     * For example, "clientip:<ip address of client>" or "project:<Google
      -     * developer project id>".
      -     * 
      - */ - java.lang.String getSubject(); - /** - * optional string subject = 1; - * - *
      -     * The subject on which the quota check failed.
      -     * For example, "clientip:<ip address of client>" or "project:<Google
      -     * developer project id>".
      -     * 
      - */ - com.google.protobuf.ByteString - getSubjectBytes(); - - /** - * optional string description = 2; - * - *
      -     * A description of how the quota check failed. Clients can use this
      -     * description to find more about the quota configuration in the service's
      -     * public documentation, or find the relevant quota limit to adjust through
      -     * developer console.
      -     * For example: "Service disabled" or "Daily Limit for read operations
      -     * exceeded".
      -     * 
      - */ - java.lang.String getDescription(); - /** - * optional string description = 2; - * - *
      -     * A description of how the quota check failed. Clients can use this
      -     * description to find more about the quota configuration in the service's
      -     * public documentation, or find the relevant quota limit to adjust through
      -     * developer console.
      -     * For example: "Service disabled" or "Daily Limit for read operations
      -     * exceeded".
      -     * 
      - */ - com.google.protobuf.ByteString - getDescriptionBytes(); - } - /** - * Protobuf type {@code google.rpc.QuotaFailure.Violation} - * - *
      -   * A message type used to describe a single quota violation.  For example, a
      -   * daily quota or a custom quota that was exceeded.
      -   * 
      - */ - public static final class Violation extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.QuotaFailure.Violation) - ViolationOrBuilder { - // Use Violation.newBuilder() to construct. - private Violation(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Violation() { - subject_ = ""; - description_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Violation( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - subject_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - description_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_Violation_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_Violation_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.QuotaFailure.Violation.class, com.google.rpc.QuotaFailure.Violation.Builder.class); - } - - public static final int SUBJECT_FIELD_NUMBER = 1; - private volatile java.lang.Object subject_; - /** - * optional string subject = 1; - * - *
      -     * The subject on which the quota check failed.
      -     * For example, "clientip:<ip address of client>" or "project:<Google
      -     * developer project id>".
      -     * 
      - */ - public java.lang.String getSubject() { - java.lang.Object ref = subject_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subject_ = s; - return s; - } - } - /** - * optional string subject = 1; - * - *
      -     * The subject on which the quota check failed.
      -     * For example, "clientip:<ip address of client>" or "project:<Google
      -     * developer project id>".
      -     * 
      - */ - public com.google.protobuf.ByteString - getSubjectBytes() { - java.lang.Object ref = subject_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subject_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DESCRIPTION_FIELD_NUMBER = 2; - private volatile java.lang.Object description_; - /** - * optional string description = 2; - * - *
      -     * A description of how the quota check failed. Clients can use this
      -     * description to find more about the quota configuration in the service's
      -     * public documentation, or find the relevant quota limit to adjust through
      -     * developer console.
      -     * For example: "Service disabled" or "Daily Limit for read operations
      -     * exceeded".
      -     * 
      - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } - } - /** - * optional string description = 2; - * - *
      -     * A description of how the quota check failed. Clients can use this
      -     * description to find more about the quota configuration in the service's
      -     * public documentation, or find the relevant quota limit to adjust through
      -     * developer console.
      -     * For example: "Service disabled" or "Daily Limit for read operations
      -     * exceeded".
      -     * 
      - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSubjectBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, subject_); - } - if (!getDescriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, description_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSubjectBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subject_); - } - if (!getDescriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, description_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.QuotaFailure.Violation parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.QuotaFailure.Violation parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.QuotaFailure.Violation parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.QuotaFailure.Violation parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.QuotaFailure.Violation parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.QuotaFailure.Violation parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.QuotaFailure.Violation parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.QuotaFailure.Violation parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.QuotaFailure.Violation parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.QuotaFailure.Violation parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.QuotaFailure.Violation prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.QuotaFailure.Violation} - * - *
      -     * A message type used to describe a single quota violation.  For example, a
      -     * daily quota or a custom quota that was exceeded.
      -     * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.QuotaFailure.Violation) - com.google.rpc.QuotaFailure.ViolationOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_Violation_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_Violation_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.QuotaFailure.Violation.class, com.google.rpc.QuotaFailure.Violation.Builder.class); - } - - // Construct using com.google.rpc.QuotaFailure.Violation.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - subject_ = ""; - - description_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_Violation_descriptor; - } - - public com.google.rpc.QuotaFailure.Violation getDefaultInstanceForType() { - return com.google.rpc.QuotaFailure.Violation.getDefaultInstance(); - } - - public com.google.rpc.QuotaFailure.Violation build() { - com.google.rpc.QuotaFailure.Violation result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.QuotaFailure.Violation buildPartial() { - com.google.rpc.QuotaFailure.Violation result = new com.google.rpc.QuotaFailure.Violation(this); - result.subject_ = subject_; - result.description_ = description_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.QuotaFailure.Violation) { - return mergeFrom((com.google.rpc.QuotaFailure.Violation)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.QuotaFailure.Violation other) { - if (other == com.google.rpc.QuotaFailure.Violation.getDefaultInstance()) return this; - if (!other.getSubject().isEmpty()) { - subject_ = other.subject_; - onChanged(); - } - if (!other.getDescription().isEmpty()) { - description_ = other.description_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.QuotaFailure.Violation parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.QuotaFailure.Violation) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object subject_ = ""; - /** - * optional string subject = 1; - * - *
      -       * The subject on which the quota check failed.
      -       * For example, "clientip:<ip address of client>" or "project:<Google
      -       * developer project id>".
      -       * 
      - */ - public java.lang.String getSubject() { - java.lang.Object ref = subject_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subject_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string subject = 1; - * - *
      -       * The subject on which the quota check failed.
      -       * For example, "clientip:<ip address of client>" or "project:<Google
      -       * developer project id>".
      -       * 
      - */ - public com.google.protobuf.ByteString - getSubjectBytes() { - java.lang.Object ref = subject_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subject_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string subject = 1; - * - *
      -       * The subject on which the quota check failed.
      -       * For example, "clientip:<ip address of client>" or "project:<Google
      -       * developer project id>".
      -       * 
      - */ - public Builder setSubject( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subject_ = value; - onChanged(); - return this; - } - /** - * optional string subject = 1; - * - *
      -       * The subject on which the quota check failed.
      -       * For example, "clientip:<ip address of client>" or "project:<Google
      -       * developer project id>".
      -       * 
      - */ - public Builder clearSubject() { - - subject_ = getDefaultInstance().getSubject(); - onChanged(); - return this; - } - /** - * optional string subject = 1; - * - *
      -       * The subject on which the quota check failed.
      -       * For example, "clientip:<ip address of client>" or "project:<Google
      -       * developer project id>".
      -       * 
      - */ - public Builder setSubjectBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subject_ = value; - onChanged(); - return this; - } - - private java.lang.Object description_ = ""; - /** - * optional string description = 2; - * - *
      -       * A description of how the quota check failed. Clients can use this
      -       * description to find more about the quota configuration in the service's
      -       * public documentation, or find the relevant quota limit to adjust through
      -       * developer console.
      -       * For example: "Service disabled" or "Daily Limit for read operations
      -       * exceeded".
      -       * 
      - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string description = 2; - * - *
      -       * A description of how the quota check failed. Clients can use this
      -       * description to find more about the quota configuration in the service's
      -       * public documentation, or find the relevant quota limit to adjust through
      -       * developer console.
      -       * For example: "Service disabled" or "Daily Limit for read operations
      -       * exceeded".
      -       * 
      - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string description = 2; - * - *
      -       * A description of how the quota check failed. Clients can use this
      -       * description to find more about the quota configuration in the service's
      -       * public documentation, or find the relevant quota limit to adjust through
      -       * developer console.
      -       * For example: "Service disabled" or "Daily Limit for read operations
      -       * exceeded".
      -       * 
      - */ - public Builder setDescription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - description_ = value; - onChanged(); - return this; - } - /** - * optional string description = 2; - * - *
      -       * A description of how the quota check failed. Clients can use this
      -       * description to find more about the quota configuration in the service's
      -       * public documentation, or find the relevant quota limit to adjust through
      -       * developer console.
      -       * For example: "Service disabled" or "Daily Limit for read operations
      -       * exceeded".
      -       * 
      - */ - public Builder clearDescription() { - - description_ = getDefaultInstance().getDescription(); - onChanged(); - return this; - } - /** - * optional string description = 2; - * - *
      -       * A description of how the quota check failed. Clients can use this
      -       * description to find more about the quota configuration in the service's
      -       * public documentation, or find the relevant quota limit to adjust through
      -       * developer console.
      -       * For example: "Service disabled" or "Daily Limit for read operations
      -       * exceeded".
      -       * 
      - */ - public Builder setDescriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - description_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.QuotaFailure.Violation) - } - - // @@protoc_insertion_point(class_scope:google.rpc.QuotaFailure.Violation) - private static final com.google.rpc.QuotaFailure.Violation DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.QuotaFailure.Violation(); - } - - public static com.google.rpc.QuotaFailure.Violation getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Violation parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Violation(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.QuotaFailure.Violation getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public static final int VIOLATIONS_FIELD_NUMBER = 1; - private java.util.List violations_; - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -   * Describes all quota violations.
      -   * 
      - */ - public java.util.List getViolationsList() { - return violations_; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -   * Describes all quota violations.
      -   * 
      - */ - public java.util.List - getViolationsOrBuilderList() { - return violations_; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -   * Describes all quota violations.
      -   * 
      - */ - public int getViolationsCount() { - return violations_.size(); - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -   * Describes all quota violations.
      -   * 
      - */ - public com.google.rpc.QuotaFailure.Violation getViolations(int index) { - return violations_.get(index); - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -   * Describes all quota violations.
      -   * 
      - */ - public com.google.rpc.QuotaFailure.ViolationOrBuilder getViolationsOrBuilder( - int index) { - return violations_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < violations_.size(); i++) { - output.writeMessage(1, violations_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < violations_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, violations_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.QuotaFailure parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.QuotaFailure parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.QuotaFailure parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.QuotaFailure parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.QuotaFailure parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.QuotaFailure parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.QuotaFailure parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.QuotaFailure parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.QuotaFailure parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.QuotaFailure parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.QuotaFailure prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.QuotaFailure} - * - *
      -   * Describes how a quota check failed.
      -   * For example if a daily limit was exceeded for the calling project,
      -   * a service could respond with a QuotaFailure detail containing the project
      -   * id and the description of the quota limit that was exceeded.  If the
      -   * calling project hasn't enabled the service in the developer console, then
      -   * a service could respond with the project id and set `service_disabled`
      -   * to true.
      -   * Also see RetryDetail and Help types for other details about handling a
      -   * quota failure.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.QuotaFailure) - com.google.rpc.QuotaFailureOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.QuotaFailure.class, com.google.rpc.QuotaFailure.Builder.class); - } - - // Construct using com.google.rpc.QuotaFailure.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getViolationsFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (violationsBuilder_ == null) { - violations_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - violationsBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_QuotaFailure_descriptor; - } - - public com.google.rpc.QuotaFailure getDefaultInstanceForType() { - return com.google.rpc.QuotaFailure.getDefaultInstance(); - } - - public com.google.rpc.QuotaFailure build() { - com.google.rpc.QuotaFailure result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.QuotaFailure buildPartial() { - com.google.rpc.QuotaFailure result = new com.google.rpc.QuotaFailure(this); - int from_bitField0_ = bitField0_; - if (violationsBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - violations_ = java.util.Collections.unmodifiableList(violations_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.violations_ = violations_; - } else { - result.violations_ = violationsBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.QuotaFailure) { - return mergeFrom((com.google.rpc.QuotaFailure)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.QuotaFailure other) { - if (other == com.google.rpc.QuotaFailure.getDefaultInstance()) return this; - if (violationsBuilder_ == null) { - if (!other.violations_.isEmpty()) { - if (violations_.isEmpty()) { - violations_ = other.violations_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureViolationsIsMutable(); - violations_.addAll(other.violations_); - } - onChanged(); - } - } else { - if (!other.violations_.isEmpty()) { - if (violationsBuilder_.isEmpty()) { - violationsBuilder_.dispose(); - violationsBuilder_ = null; - violations_ = other.violations_; - bitField0_ = (bitField0_ & ~0x00000001); - violationsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getViolationsFieldBuilder() : null; - } else { - violationsBuilder_.addAllMessages(other.violations_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.QuotaFailure parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.QuotaFailure) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List violations_ = - java.util.Collections.emptyList(); - private void ensureViolationsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - violations_ = new java.util.ArrayList(violations_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.rpc.QuotaFailure.Violation, com.google.rpc.QuotaFailure.Violation.Builder, com.google.rpc.QuotaFailure.ViolationOrBuilder> violationsBuilder_; - - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public java.util.List getViolationsList() { - if (violationsBuilder_ == null) { - return java.util.Collections.unmodifiableList(violations_); - } else { - return violationsBuilder_.getMessageList(); - } - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public int getViolationsCount() { - if (violationsBuilder_ == null) { - return violations_.size(); - } else { - return violationsBuilder_.getCount(); - } - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public com.google.rpc.QuotaFailure.Violation getViolations(int index) { - if (violationsBuilder_ == null) { - return violations_.get(index); - } else { - return violationsBuilder_.getMessage(index); - } - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public Builder setViolations( - int index, com.google.rpc.QuotaFailure.Violation value) { - if (violationsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureViolationsIsMutable(); - violations_.set(index, value); - onChanged(); - } else { - violationsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public Builder setViolations( - int index, com.google.rpc.QuotaFailure.Violation.Builder builderForValue) { - if (violationsBuilder_ == null) { - ensureViolationsIsMutable(); - violations_.set(index, builderForValue.build()); - onChanged(); - } else { - violationsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public Builder addViolations(com.google.rpc.QuotaFailure.Violation value) { - if (violationsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureViolationsIsMutable(); - violations_.add(value); - onChanged(); - } else { - violationsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public Builder addViolations( - int index, com.google.rpc.QuotaFailure.Violation value) { - if (violationsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureViolationsIsMutable(); - violations_.add(index, value); - onChanged(); - } else { - violationsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public Builder addViolations( - com.google.rpc.QuotaFailure.Violation.Builder builderForValue) { - if (violationsBuilder_ == null) { - ensureViolationsIsMutable(); - violations_.add(builderForValue.build()); - onChanged(); - } else { - violationsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public Builder addViolations( - int index, com.google.rpc.QuotaFailure.Violation.Builder builderForValue) { - if (violationsBuilder_ == null) { - ensureViolationsIsMutable(); - violations_.add(index, builderForValue.build()); - onChanged(); - } else { - violationsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public Builder addAllViolations( - java.lang.Iterable values) { - if (violationsBuilder_ == null) { - ensureViolationsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, violations_); - onChanged(); - } else { - violationsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public Builder clearViolations() { - if (violationsBuilder_ == null) { - violations_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - violationsBuilder_.clear(); - } - return this; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public Builder removeViolations(int index) { - if (violationsBuilder_ == null) { - ensureViolationsIsMutable(); - violations_.remove(index); - onChanged(); - } else { - violationsBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public com.google.rpc.QuotaFailure.Violation.Builder getViolationsBuilder( - int index) { - return getViolationsFieldBuilder().getBuilder(index); - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public com.google.rpc.QuotaFailure.ViolationOrBuilder getViolationsOrBuilder( - int index) { - if (violationsBuilder_ == null) { - return violations_.get(index); } else { - return violationsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public java.util.List - getViolationsOrBuilderList() { - if (violationsBuilder_ != null) { - return violationsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(violations_); - } - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public com.google.rpc.QuotaFailure.Violation.Builder addViolationsBuilder() { - return getViolationsFieldBuilder().addBuilder( - com.google.rpc.QuotaFailure.Violation.getDefaultInstance()); - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public com.google.rpc.QuotaFailure.Violation.Builder addViolationsBuilder( - int index) { - return getViolationsFieldBuilder().addBuilder( - index, com.google.rpc.QuotaFailure.Violation.getDefaultInstance()); - } - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -     * Describes all quota violations.
      -     * 
      - */ - public java.util.List - getViolationsBuilderList() { - return getViolationsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.rpc.QuotaFailure.Violation, com.google.rpc.QuotaFailure.Violation.Builder, com.google.rpc.QuotaFailure.ViolationOrBuilder> - getViolationsFieldBuilder() { - if (violationsBuilder_ == null) { - violationsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.rpc.QuotaFailure.Violation, com.google.rpc.QuotaFailure.Violation.Builder, com.google.rpc.QuotaFailure.ViolationOrBuilder>( - violations_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - violations_ = null; - } - return violationsBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.QuotaFailure) - } - - // @@protoc_insertion_point(class_scope:google.rpc.QuotaFailure) - private static final com.google.rpc.QuotaFailure DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.QuotaFailure(); - } - - public static com.google.rpc.QuotaFailure getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public QuotaFailure parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new QuotaFailure(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.QuotaFailure getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailureOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailureOrBuilder.java deleted file mode 100644 index e586659760de..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/QuotaFailureOrBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -public interface QuotaFailureOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.QuotaFailure) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -   * Describes all quota violations.
      -   * 
      - */ - java.util.List - getViolationsList(); - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -   * Describes all quota violations.
      -   * 
      - */ - com.google.rpc.QuotaFailure.Violation getViolations(int index); - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -   * Describes all quota violations.
      -   * 
      - */ - int getViolationsCount(); - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -   * Describes all quota violations.
      -   * 
      - */ - java.util.List - getViolationsOrBuilderList(); - /** - * repeated .google.rpc.QuotaFailure.Violation violations = 1; - * - *
      -   * Describes all quota violations.
      -   * 
      - */ - com.google.rpc.QuotaFailure.ViolationOrBuilder getViolationsOrBuilder( - int index); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfo.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfo.java deleted file mode 100644 index 1654fd4aaab8..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfo.java +++ /dev/null @@ -1,643 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -/** - * Protobuf type {@code google.rpc.RequestInfo} - * - *
      - * Contains metadata about the request that clients can attach when filing a bug
      - * or providing other forms of feedback.
      - * 
      - */ -public final class RequestInfo extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.RequestInfo) - RequestInfoOrBuilder { - // Use RequestInfo.newBuilder() to construct. - private RequestInfo(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private RequestInfo() { - requestId_ = ""; - servingData_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private RequestInfo( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - requestId_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - servingData_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RequestInfo_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RequestInfo_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.RequestInfo.class, com.google.rpc.RequestInfo.Builder.class); - } - - public static final int REQUEST_ID_FIELD_NUMBER = 1; - private volatile java.lang.Object requestId_; - /** - * optional string request_id = 1; - * - *
      -   * An opaque string that should only be interpreted by the service generating
      -   * it. For example, it can be used to identify requests in the service's logs.
      -   * 
      - */ - public java.lang.String getRequestId() { - java.lang.Object ref = requestId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - requestId_ = s; - return s; - } - } - /** - * optional string request_id = 1; - * - *
      -   * An opaque string that should only be interpreted by the service generating
      -   * it. For example, it can be used to identify requests in the service's logs.
      -   * 
      - */ - public com.google.protobuf.ByteString - getRequestIdBytes() { - java.lang.Object ref = requestId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - requestId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SERVING_DATA_FIELD_NUMBER = 2; - private volatile java.lang.Object servingData_; - /** - * optional string serving_data = 2; - * - *
      -   * Any data that was used to serve this request. For example, an encrypted
      -   * stack trace that can be sent back to the service provider for debugging.
      -   * 
      - */ - public java.lang.String getServingData() { - java.lang.Object ref = servingData_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - servingData_ = s; - return s; - } - } - /** - * optional string serving_data = 2; - * - *
      -   * Any data that was used to serve this request. For example, an encrypted
      -   * stack trace that can be sent back to the service provider for debugging.
      -   * 
      - */ - public com.google.protobuf.ByteString - getServingDataBytes() { - java.lang.Object ref = servingData_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - servingData_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getRequestIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, requestId_); - } - if (!getServingDataBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, servingData_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getRequestIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, requestId_); - } - if (!getServingDataBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, servingData_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.RequestInfo parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.RequestInfo parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.RequestInfo parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.RequestInfo parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.RequestInfo parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.RequestInfo parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.RequestInfo parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.RequestInfo parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.RequestInfo parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.RequestInfo parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.RequestInfo prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.RequestInfo} - * - *
      -   * Contains metadata about the request that clients can attach when filing a bug
      -   * or providing other forms of feedback.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.RequestInfo) - com.google.rpc.RequestInfoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RequestInfo_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RequestInfo_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.RequestInfo.class, com.google.rpc.RequestInfo.Builder.class); - } - - // Construct using com.google.rpc.RequestInfo.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - requestId_ = ""; - - servingData_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RequestInfo_descriptor; - } - - public com.google.rpc.RequestInfo getDefaultInstanceForType() { - return com.google.rpc.RequestInfo.getDefaultInstance(); - } - - public com.google.rpc.RequestInfo build() { - com.google.rpc.RequestInfo result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.RequestInfo buildPartial() { - com.google.rpc.RequestInfo result = new com.google.rpc.RequestInfo(this); - result.requestId_ = requestId_; - result.servingData_ = servingData_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.RequestInfo) { - return mergeFrom((com.google.rpc.RequestInfo)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.RequestInfo other) { - if (other == com.google.rpc.RequestInfo.getDefaultInstance()) return this; - if (!other.getRequestId().isEmpty()) { - requestId_ = other.requestId_; - onChanged(); - } - if (!other.getServingData().isEmpty()) { - servingData_ = other.servingData_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.RequestInfo parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.RequestInfo) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object requestId_ = ""; - /** - * optional string request_id = 1; - * - *
      -     * An opaque string that should only be interpreted by the service generating
      -     * it. For example, it can be used to identify requests in the service's logs.
      -     * 
      - */ - public java.lang.String getRequestId() { - java.lang.Object ref = requestId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - requestId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string request_id = 1; - * - *
      -     * An opaque string that should only be interpreted by the service generating
      -     * it. For example, it can be used to identify requests in the service's logs.
      -     * 
      - */ - public com.google.protobuf.ByteString - getRequestIdBytes() { - java.lang.Object ref = requestId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - requestId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string request_id = 1; - * - *
      -     * An opaque string that should only be interpreted by the service generating
      -     * it. For example, it can be used to identify requests in the service's logs.
      -     * 
      - */ - public Builder setRequestId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - requestId_ = value; - onChanged(); - return this; - } - /** - * optional string request_id = 1; - * - *
      -     * An opaque string that should only be interpreted by the service generating
      -     * it. For example, it can be used to identify requests in the service's logs.
      -     * 
      - */ - public Builder clearRequestId() { - - requestId_ = getDefaultInstance().getRequestId(); - onChanged(); - return this; - } - /** - * optional string request_id = 1; - * - *
      -     * An opaque string that should only be interpreted by the service generating
      -     * it. For example, it can be used to identify requests in the service's logs.
      -     * 
      - */ - public Builder setRequestIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - requestId_ = value; - onChanged(); - return this; - } - - private java.lang.Object servingData_ = ""; - /** - * optional string serving_data = 2; - * - *
      -     * Any data that was used to serve this request. For example, an encrypted
      -     * stack trace that can be sent back to the service provider for debugging.
      -     * 
      - */ - public java.lang.String getServingData() { - java.lang.Object ref = servingData_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - servingData_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string serving_data = 2; - * - *
      -     * Any data that was used to serve this request. For example, an encrypted
      -     * stack trace that can be sent back to the service provider for debugging.
      -     * 
      - */ - public com.google.protobuf.ByteString - getServingDataBytes() { - java.lang.Object ref = servingData_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - servingData_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string serving_data = 2; - * - *
      -     * Any data that was used to serve this request. For example, an encrypted
      -     * stack trace that can be sent back to the service provider for debugging.
      -     * 
      - */ - public Builder setServingData( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - servingData_ = value; - onChanged(); - return this; - } - /** - * optional string serving_data = 2; - * - *
      -     * Any data that was used to serve this request. For example, an encrypted
      -     * stack trace that can be sent back to the service provider for debugging.
      -     * 
      - */ - public Builder clearServingData() { - - servingData_ = getDefaultInstance().getServingData(); - onChanged(); - return this; - } - /** - * optional string serving_data = 2; - * - *
      -     * Any data that was used to serve this request. For example, an encrypted
      -     * stack trace that can be sent back to the service provider for debugging.
      -     * 
      - */ - public Builder setServingDataBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - servingData_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.RequestInfo) - } - - // @@protoc_insertion_point(class_scope:google.rpc.RequestInfo) - private static final com.google.rpc.RequestInfo DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.RequestInfo(); - } - - public static com.google.rpc.RequestInfo getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public RequestInfo parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new RequestInfo(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.RequestInfo getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfoOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfoOrBuilder.java deleted file mode 100644 index 94ad03b0f1c9..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RequestInfoOrBuilder.java +++ /dev/null @@ -1,49 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -public interface RequestInfoOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.RequestInfo) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string request_id = 1; - * - *
      -   * An opaque string that should only be interpreted by the service generating
      -   * it. For example, it can be used to identify requests in the service's logs.
      -   * 
      - */ - java.lang.String getRequestId(); - /** - * optional string request_id = 1; - * - *
      -   * An opaque string that should only be interpreted by the service generating
      -   * it. For example, it can be used to identify requests in the service's logs.
      -   * 
      - */ - com.google.protobuf.ByteString - getRequestIdBytes(); - - /** - * optional string serving_data = 2; - * - *
      -   * Any data that was used to serve this request. For example, an encrypted
      -   * stack trace that can be sent back to the service provider for debugging.
      -   * 
      - */ - java.lang.String getServingData(); - /** - * optional string serving_data = 2; - * - *
      -   * Any data that was used to serve this request. For example, an encrypted
      -   * stack trace that can be sent back to the service provider for debugging.
      -   * 
      - */ - com.google.protobuf.ByteString - getServingDataBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfo.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfo.java deleted file mode 100644 index 9e69a569483e..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfo.java +++ /dev/null @@ -1,985 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -/** - * Protobuf type {@code google.rpc.ResourceInfo} - * - *
      - * Describes the resource that is being accessed.
      - * 
      - */ -public final class ResourceInfo extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.ResourceInfo) - ResourceInfoOrBuilder { - // Use ResourceInfo.newBuilder() to construct. - private ResourceInfo(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ResourceInfo() { - resourceType_ = ""; - resourceName_ = ""; - owner_ = ""; - description_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ResourceInfo( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - resourceType_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - resourceName_ = s; - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - owner_ = s; - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - - description_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_ResourceInfo_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_ResourceInfo_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.ResourceInfo.class, com.google.rpc.ResourceInfo.Builder.class); - } - - public static final int RESOURCE_TYPE_FIELD_NUMBER = 1; - private volatile java.lang.Object resourceType_; - /** - * optional string resource_type = 1; - * - *
      -   * A name for the type of resource being accessed, e.g. "sql table",
      -   * "cloud storage bucket", "file", "Google calendar"; or the type URL
      -   * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      -   * 
      - */ - public java.lang.String getResourceType() { - java.lang.Object ref = resourceType_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - resourceType_ = s; - return s; - } - } - /** - * optional string resource_type = 1; - * - *
      -   * A name for the type of resource being accessed, e.g. "sql table",
      -   * "cloud storage bucket", "file", "Google calendar"; or the type URL
      -   * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      -   * 
      - */ - public com.google.protobuf.ByteString - getResourceTypeBytes() { - java.lang.Object ref = resourceType_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - resourceType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RESOURCE_NAME_FIELD_NUMBER = 2; - private volatile java.lang.Object resourceName_; - /** - * optional string resource_name = 2; - * - *
      -   * The name of the resource being accessed.  For example, a shared calendar
      -   * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      -   * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      -   * 
      - */ - public java.lang.String getResourceName() { - java.lang.Object ref = resourceName_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - resourceName_ = s; - return s; - } - } - /** - * optional string resource_name = 2; - * - *
      -   * The name of the resource being accessed.  For example, a shared calendar
      -   * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      -   * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      -   * 
      - */ - public com.google.protobuf.ByteString - getResourceNameBytes() { - java.lang.Object ref = resourceName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - resourceName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int OWNER_FIELD_NUMBER = 3; - private volatile java.lang.Object owner_; - /** - * optional string owner = 3; - * - *
      -   * The owner of the resource (optional).
      -   * For example, "user:<owner email>" or "project:<Google developer project
      -   * id>".
      -   * 
      - */ - public java.lang.String getOwner() { - java.lang.Object ref = owner_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - owner_ = s; - return s; - } - } - /** - * optional string owner = 3; - * - *
      -   * The owner of the resource (optional).
      -   * For example, "user:<owner email>" or "project:<Google developer project
      -   * id>".
      -   * 
      - */ - public com.google.protobuf.ByteString - getOwnerBytes() { - java.lang.Object ref = owner_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - owner_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DESCRIPTION_FIELD_NUMBER = 4; - private volatile java.lang.Object description_; - /** - * optional string description = 4; - * - *
      -   * Describes what error is encountered when accessing this resource.
      -   * For example, updating a cloud project may require the `writer` permission
      -   * on the developer console project.
      -   * 
      - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } - } - /** - * optional string description = 4; - * - *
      -   * Describes what error is encountered when accessing this resource.
      -   * For example, updating a cloud project may require the `writer` permission
      -   * on the developer console project.
      -   * 
      - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getResourceTypeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, resourceType_); - } - if (!getResourceNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, resourceName_); - } - if (!getOwnerBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 3, owner_); - } - if (!getDescriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 4, description_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getResourceTypeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, resourceType_); - } - if (!getResourceNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, resourceName_); - } - if (!getOwnerBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(3, owner_); - } - if (!getDescriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(4, description_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.ResourceInfo parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.ResourceInfo parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.ResourceInfo parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.ResourceInfo parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.ResourceInfo parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.ResourceInfo parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.ResourceInfo parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.ResourceInfo parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.ResourceInfo parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.ResourceInfo parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.ResourceInfo prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.ResourceInfo} - * - *
      -   * Describes the resource that is being accessed.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.ResourceInfo) - com.google.rpc.ResourceInfoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_ResourceInfo_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_ResourceInfo_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.ResourceInfo.class, com.google.rpc.ResourceInfo.Builder.class); - } - - // Construct using com.google.rpc.ResourceInfo.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - resourceType_ = ""; - - resourceName_ = ""; - - owner_ = ""; - - description_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_ResourceInfo_descriptor; - } - - public com.google.rpc.ResourceInfo getDefaultInstanceForType() { - return com.google.rpc.ResourceInfo.getDefaultInstance(); - } - - public com.google.rpc.ResourceInfo build() { - com.google.rpc.ResourceInfo result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.ResourceInfo buildPartial() { - com.google.rpc.ResourceInfo result = new com.google.rpc.ResourceInfo(this); - result.resourceType_ = resourceType_; - result.resourceName_ = resourceName_; - result.owner_ = owner_; - result.description_ = description_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.ResourceInfo) { - return mergeFrom((com.google.rpc.ResourceInfo)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.ResourceInfo other) { - if (other == com.google.rpc.ResourceInfo.getDefaultInstance()) return this; - if (!other.getResourceType().isEmpty()) { - resourceType_ = other.resourceType_; - onChanged(); - } - if (!other.getResourceName().isEmpty()) { - resourceName_ = other.resourceName_; - onChanged(); - } - if (!other.getOwner().isEmpty()) { - owner_ = other.owner_; - onChanged(); - } - if (!other.getDescription().isEmpty()) { - description_ = other.description_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.ResourceInfo parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.ResourceInfo) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object resourceType_ = ""; - /** - * optional string resource_type = 1; - * - *
      -     * A name for the type of resource being accessed, e.g. "sql table",
      -     * "cloud storage bucket", "file", "Google calendar"; or the type URL
      -     * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      -     * 
      - */ - public java.lang.String getResourceType() { - java.lang.Object ref = resourceType_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - resourceType_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string resource_type = 1; - * - *
      -     * A name for the type of resource being accessed, e.g. "sql table",
      -     * "cloud storage bucket", "file", "Google calendar"; or the type URL
      -     * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      -     * 
      - */ - public com.google.protobuf.ByteString - getResourceTypeBytes() { - java.lang.Object ref = resourceType_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - resourceType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string resource_type = 1; - * - *
      -     * A name for the type of resource being accessed, e.g. "sql table",
      -     * "cloud storage bucket", "file", "Google calendar"; or the type URL
      -     * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      -     * 
      - */ - public Builder setResourceType( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - resourceType_ = value; - onChanged(); - return this; - } - /** - * optional string resource_type = 1; - * - *
      -     * A name for the type of resource being accessed, e.g. "sql table",
      -     * "cloud storage bucket", "file", "Google calendar"; or the type URL
      -     * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      -     * 
      - */ - public Builder clearResourceType() { - - resourceType_ = getDefaultInstance().getResourceType(); - onChanged(); - return this; - } - /** - * optional string resource_type = 1; - * - *
      -     * A name for the type of resource being accessed, e.g. "sql table",
      -     * "cloud storage bucket", "file", "Google calendar"; or the type URL
      -     * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      -     * 
      - */ - public Builder setResourceTypeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - resourceType_ = value; - onChanged(); - return this; - } - - private java.lang.Object resourceName_ = ""; - /** - * optional string resource_name = 2; - * - *
      -     * The name of the resource being accessed.  For example, a shared calendar
      -     * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      -     * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      -     * 
      - */ - public java.lang.String getResourceName() { - java.lang.Object ref = resourceName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - resourceName_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string resource_name = 2; - * - *
      -     * The name of the resource being accessed.  For example, a shared calendar
      -     * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      -     * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      -     * 
      - */ - public com.google.protobuf.ByteString - getResourceNameBytes() { - java.lang.Object ref = resourceName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - resourceName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string resource_name = 2; - * - *
      -     * The name of the resource being accessed.  For example, a shared calendar
      -     * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      -     * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      -     * 
      - */ - public Builder setResourceName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - resourceName_ = value; - onChanged(); - return this; - } - /** - * optional string resource_name = 2; - * - *
      -     * The name of the resource being accessed.  For example, a shared calendar
      -     * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      -     * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      -     * 
      - */ - public Builder clearResourceName() { - - resourceName_ = getDefaultInstance().getResourceName(); - onChanged(); - return this; - } - /** - * optional string resource_name = 2; - * - *
      -     * The name of the resource being accessed.  For example, a shared calendar
      -     * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      -     * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      -     * 
      - */ - public Builder setResourceNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - resourceName_ = value; - onChanged(); - return this; - } - - private java.lang.Object owner_ = ""; - /** - * optional string owner = 3; - * - *
      -     * The owner of the resource (optional).
      -     * For example, "user:<owner email>" or "project:<Google developer project
      -     * id>".
      -     * 
      - */ - public java.lang.String getOwner() { - java.lang.Object ref = owner_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - owner_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string owner = 3; - * - *
      -     * The owner of the resource (optional).
      -     * For example, "user:<owner email>" or "project:<Google developer project
      -     * id>".
      -     * 
      - */ - public com.google.protobuf.ByteString - getOwnerBytes() { - java.lang.Object ref = owner_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - owner_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string owner = 3; - * - *
      -     * The owner of the resource (optional).
      -     * For example, "user:<owner email>" or "project:<Google developer project
      -     * id>".
      -     * 
      - */ - public Builder setOwner( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - owner_ = value; - onChanged(); - return this; - } - /** - * optional string owner = 3; - * - *
      -     * The owner of the resource (optional).
      -     * For example, "user:<owner email>" or "project:<Google developer project
      -     * id>".
      -     * 
      - */ - public Builder clearOwner() { - - owner_ = getDefaultInstance().getOwner(); - onChanged(); - return this; - } - /** - * optional string owner = 3; - * - *
      -     * The owner of the resource (optional).
      -     * For example, "user:<owner email>" or "project:<Google developer project
      -     * id>".
      -     * 
      - */ - public Builder setOwnerBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - owner_ = value; - onChanged(); - return this; - } - - private java.lang.Object description_ = ""; - /** - * optional string description = 4; - * - *
      -     * Describes what error is encountered when accessing this resource.
      -     * For example, updating a cloud project may require the `writer` permission
      -     * on the developer console project.
      -     * 
      - */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string description = 4; - * - *
      -     * Describes what error is encountered when accessing this resource.
      -     * For example, updating a cloud project may require the `writer` permission
      -     * on the developer console project.
      -     * 
      - */ - public com.google.protobuf.ByteString - getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - description_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string description = 4; - * - *
      -     * Describes what error is encountered when accessing this resource.
      -     * For example, updating a cloud project may require the `writer` permission
      -     * on the developer console project.
      -     * 
      - */ - public Builder setDescription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - description_ = value; - onChanged(); - return this; - } - /** - * optional string description = 4; - * - *
      -     * Describes what error is encountered when accessing this resource.
      -     * For example, updating a cloud project may require the `writer` permission
      -     * on the developer console project.
      -     * 
      - */ - public Builder clearDescription() { - - description_ = getDefaultInstance().getDescription(); - onChanged(); - return this; - } - /** - * optional string description = 4; - * - *
      -     * Describes what error is encountered when accessing this resource.
      -     * For example, updating a cloud project may require the `writer` permission
      -     * on the developer console project.
      -     * 
      - */ - public Builder setDescriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - description_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.ResourceInfo) - } - - // @@protoc_insertion_point(class_scope:google.rpc.ResourceInfo) - private static final com.google.rpc.ResourceInfo DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.ResourceInfo(); - } - - public static com.google.rpc.ResourceInfo getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ResourceInfo parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ResourceInfo(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.ResourceInfo getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfoOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfoOrBuilder.java deleted file mode 100644 index 5c48486c13a8..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/ResourceInfoOrBuilder.java +++ /dev/null @@ -1,97 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -public interface ResourceInfoOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.ResourceInfo) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string resource_type = 1; - * - *
      -   * A name for the type of resource being accessed, e.g. "sql table",
      -   * "cloud storage bucket", "file", "Google calendar"; or the type URL
      -   * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      -   * 
      - */ - java.lang.String getResourceType(); - /** - * optional string resource_type = 1; - * - *
      -   * A name for the type of resource being accessed, e.g. "sql table",
      -   * "cloud storage bucket", "file", "Google calendar"; or the type URL
      -   * of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
      -   * 
      - */ - com.google.protobuf.ByteString - getResourceTypeBytes(); - - /** - * optional string resource_name = 2; - * - *
      -   * The name of the resource being accessed.  For example, a shared calendar
      -   * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      -   * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      -   * 
      - */ - java.lang.String getResourceName(); - /** - * optional string resource_name = 2; - * - *
      -   * The name of the resource being accessed.  For example, a shared calendar
      -   * name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
      -   * error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
      -   * 
      - */ - com.google.protobuf.ByteString - getResourceNameBytes(); - - /** - * optional string owner = 3; - * - *
      -   * The owner of the resource (optional).
      -   * For example, "user:<owner email>" or "project:<Google developer project
      -   * id>".
      -   * 
      - */ - java.lang.String getOwner(); - /** - * optional string owner = 3; - * - *
      -   * The owner of the resource (optional).
      -   * For example, "user:<owner email>" or "project:<Google developer project
      -   * id>".
      -   * 
      - */ - com.google.protobuf.ByteString - getOwnerBytes(); - - /** - * optional string description = 4; - * - *
      -   * Describes what error is encountered when accessing this resource.
      -   * For example, updating a cloud project may require the `writer` permission
      -   * on the developer console project.
      -   * 
      - */ - java.lang.String getDescription(); - /** - * optional string description = 4; - * - *
      -   * Describes what error is encountered when accessing this resource.
      -   * For example, updating a cloud project may require the `writer` permission
      -   * on the developer console project.
      -   * 
      - */ - com.google.protobuf.ByteString - getDescriptionBytes(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfo.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfo.java deleted file mode 100644 index 8da5185492bd..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfo.java +++ /dev/null @@ -1,565 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -/** - * Protobuf type {@code google.rpc.RetryInfo} - * - *
      - * Describes when the clients can retry a failed request. Clients could ignore
      - * the recommendation here or retry when this information is missing from error
      - * responses.
      - * It's always recommended that clients should use exponential backoff when
      - * retrying.
      - * Clients should wait until `retry_delay` amount of time has passed since
      - * receiving the error response before retrying.  If retrying requests also
      - * fail, clients should use an exponential backoff scheme to gradually increase
      - * the delay between retries based on `retry_delay`, until either a maximum
      - * number of retires have been reached or a maximum retry delay cap has been
      - * reached.
      - * 
      - */ -public final class RetryInfo extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.RetryInfo) - RetryInfoOrBuilder { - // Use RetryInfo.newBuilder() to construct. - private RetryInfo(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private RetryInfo() { - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private RetryInfo( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - com.google.protobuf.Duration.Builder subBuilder = null; - if (retryDelay_ != null) { - subBuilder = retryDelay_.toBuilder(); - } - retryDelay_ = input.readMessage(com.google.protobuf.Duration.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(retryDelay_); - retryDelay_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RetryInfo_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RetryInfo_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.RetryInfo.class, com.google.rpc.RetryInfo.Builder.class); - } - - public static final int RETRY_DELAY_FIELD_NUMBER = 1; - private com.google.protobuf.Duration retryDelay_; - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -   * Clients should wait at least this long between retrying the same request.
      -   * 
      - */ - public boolean hasRetryDelay() { - return retryDelay_ != null; - } - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -   * Clients should wait at least this long between retrying the same request.
      -   * 
      - */ - public com.google.protobuf.Duration getRetryDelay() { - return retryDelay_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retryDelay_; - } - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -   * Clients should wait at least this long between retrying the same request.
      -   * 
      - */ - public com.google.protobuf.DurationOrBuilder getRetryDelayOrBuilder() { - return getRetryDelay(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (retryDelay_ != null) { - output.writeMessage(1, getRetryDelay()); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (retryDelay_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getRetryDelay()); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.RetryInfo parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.RetryInfo parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.RetryInfo parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.RetryInfo parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.RetryInfo parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.RetryInfo parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.RetryInfo parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.RetryInfo parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.RetryInfo parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.RetryInfo parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.RetryInfo prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.RetryInfo} - * - *
      -   * Describes when the clients can retry a failed request. Clients could ignore
      -   * the recommendation here or retry when this information is missing from error
      -   * responses.
      -   * It's always recommended that clients should use exponential backoff when
      -   * retrying.
      -   * Clients should wait until `retry_delay` amount of time has passed since
      -   * receiving the error response before retrying.  If retrying requests also
      -   * fail, clients should use an exponential backoff scheme to gradually increase
      -   * the delay between retries based on `retry_delay`, until either a maximum
      -   * number of retires have been reached or a maximum retry delay cap has been
      -   * reached.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.RetryInfo) - com.google.rpc.RetryInfoOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RetryInfo_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RetryInfo_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.RetryInfo.class, com.google.rpc.RetryInfo.Builder.class); - } - - // Construct using com.google.rpc.RetryInfo.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - if (retryDelayBuilder_ == null) { - retryDelay_ = null; - } else { - retryDelay_ = null; - retryDelayBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.ErrorDetailsProto.internal_static_google_rpc_RetryInfo_descriptor; - } - - public com.google.rpc.RetryInfo getDefaultInstanceForType() { - return com.google.rpc.RetryInfo.getDefaultInstance(); - } - - public com.google.rpc.RetryInfo build() { - com.google.rpc.RetryInfo result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.RetryInfo buildPartial() { - com.google.rpc.RetryInfo result = new com.google.rpc.RetryInfo(this); - if (retryDelayBuilder_ == null) { - result.retryDelay_ = retryDelay_; - } else { - result.retryDelay_ = retryDelayBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.RetryInfo) { - return mergeFrom((com.google.rpc.RetryInfo)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.RetryInfo other) { - if (other == com.google.rpc.RetryInfo.getDefaultInstance()) return this; - if (other.hasRetryDelay()) { - mergeRetryDelay(other.getRetryDelay()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.RetryInfo parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.RetryInfo) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private com.google.protobuf.Duration retryDelay_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Duration, com.google.protobuf.Duration.Builder, com.google.protobuf.DurationOrBuilder> retryDelayBuilder_; - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -     * Clients should wait at least this long between retrying the same request.
      -     * 
      - */ - public boolean hasRetryDelay() { - return retryDelayBuilder_ != null || retryDelay_ != null; - } - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -     * Clients should wait at least this long between retrying the same request.
      -     * 
      - */ - public com.google.protobuf.Duration getRetryDelay() { - if (retryDelayBuilder_ == null) { - return retryDelay_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retryDelay_; - } else { - return retryDelayBuilder_.getMessage(); - } - } - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -     * Clients should wait at least this long between retrying the same request.
      -     * 
      - */ - public Builder setRetryDelay(com.google.protobuf.Duration value) { - if (retryDelayBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - retryDelay_ = value; - onChanged(); - } else { - retryDelayBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -     * Clients should wait at least this long between retrying the same request.
      -     * 
      - */ - public Builder setRetryDelay( - com.google.protobuf.Duration.Builder builderForValue) { - if (retryDelayBuilder_ == null) { - retryDelay_ = builderForValue.build(); - onChanged(); - } else { - retryDelayBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -     * Clients should wait at least this long between retrying the same request.
      -     * 
      - */ - public Builder mergeRetryDelay(com.google.protobuf.Duration value) { - if (retryDelayBuilder_ == null) { - if (retryDelay_ != null) { - retryDelay_ = - com.google.protobuf.Duration.newBuilder(retryDelay_).mergeFrom(value).buildPartial(); - } else { - retryDelay_ = value; - } - onChanged(); - } else { - retryDelayBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -     * Clients should wait at least this long between retrying the same request.
      -     * 
      - */ - public Builder clearRetryDelay() { - if (retryDelayBuilder_ == null) { - retryDelay_ = null; - onChanged(); - } else { - retryDelay_ = null; - retryDelayBuilder_ = null; - } - - return this; - } - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -     * Clients should wait at least this long between retrying the same request.
      -     * 
      - */ - public com.google.protobuf.Duration.Builder getRetryDelayBuilder() { - - onChanged(); - return getRetryDelayFieldBuilder().getBuilder(); - } - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -     * Clients should wait at least this long between retrying the same request.
      -     * 
      - */ - public com.google.protobuf.DurationOrBuilder getRetryDelayOrBuilder() { - if (retryDelayBuilder_ != null) { - return retryDelayBuilder_.getMessageOrBuilder(); - } else { - return retryDelay_ == null ? - com.google.protobuf.Duration.getDefaultInstance() : retryDelay_; - } - } - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -     * Clients should wait at least this long between retrying the same request.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Duration, com.google.protobuf.Duration.Builder, com.google.protobuf.DurationOrBuilder> - getRetryDelayFieldBuilder() { - if (retryDelayBuilder_ == null) { - retryDelayBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.Duration, com.google.protobuf.Duration.Builder, com.google.protobuf.DurationOrBuilder>( - getRetryDelay(), - getParentForChildren(), - isClean()); - retryDelay_ = null; - } - return retryDelayBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.RetryInfo) - } - - // @@protoc_insertion_point(class_scope:google.rpc.RetryInfo) - private static final com.google.rpc.RetryInfo DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.RetryInfo(); - } - - public static com.google.rpc.RetryInfo getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public RetryInfo parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new RetryInfo(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.RetryInfo getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfoOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfoOrBuilder.java deleted file mode 100644 index f4b347a1d04e..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/RetryInfoOrBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/error_details.proto - -package com.google.rpc; - -public interface RetryInfoOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.RetryInfo) - com.google.protobuf.MessageOrBuilder { - - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -   * Clients should wait at least this long between retrying the same request.
      -   * 
      - */ - boolean hasRetryDelay(); - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -   * Clients should wait at least this long between retrying the same request.
      -   * 
      - */ - com.google.protobuf.Duration getRetryDelay(); - /** - * optional .google.protobuf.Duration retry_delay = 1; - * - *
      -   * Clients should wait at least this long between retrying the same request.
      -   * 
      - */ - com.google.protobuf.DurationOrBuilder getRetryDelayOrBuilder(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/Status.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/Status.java deleted file mode 100644 index be0c3a54ec64..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/Status.java +++ /dev/null @@ -1,1092 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/status.proto - -package com.google.rpc; - -/** - * Protobuf type {@code google.rpc.Status} - * - *
      - * The `Status` type defines a logical error model that is suitable for different
      - * programming environments, including REST APIs and RPC APIs. It is used by
      - * [gRPC](https://github.com/grpc). The error model is designed to be:
      - * - Simple to use and understand for most users
      - * - Flexible enough to meet unexpected needs
      - * # Overview
      - * The `Status` message contains three pieces of data: error code, error message,
      - * and error details. The error code should be an enum value of
      - * [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed.  The
      - * error message should be a developer-facing English message that helps
      - * developers *understand* and *resolve* the error. If a localized user-facing
      - * error message is needed, put the localized message in the error details or
      - * localize it in the client. The optional error details may contain arbitrary
      - * information about the error. There is a predefined set of error detail types
      - * in the package `google.rpc` which can be used for common error conditions.
      - * # Language mapping
      - * The `Status` message is the logical representation of the error model, but it
      - * is not necessarily the actual wire format. When the `Status` message is
      - * exposed in different client libraries and different wire protocols, it can be
      - * mapped differently. For example, it will likely be mapped to some exceptions
      - * in Java, but more likely mapped to some error codes in C.
      - * # Other uses
      - * The error model and the `Status` message can be used in a variety of
      - * environments, either with or without APIs, to provide a
      - * consistent developer experience across different environments.
      - * Example uses of this error model include:
      - * - Partial errors. If a service needs to return partial errors to the client,
      - *     it may embed the `Status` in the normal response to indicate the partial
      - *     errors.
      - * - Workflow errors. A typical workflow has multiple steps. Each step may
      - *     have a `Status` message for error reporting purpose.
      - * - Batch operations. If a client uses batch request and batch response, the
      - *     `Status` message should be used directly inside batch response, one for
      - *     each error sub-response.
      - * - Asynchronous operations. If an API call embeds asynchronous operation
      - *     results in its response, the status of those operations should be
      - *     represented directly using the `Status` message.
      - * - Logging. If some API errors are stored in logs, the message `Status` could
      - *     be used directly after any stripping needed for security/privacy reasons.
      - * 
      - */ -public final class Status extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.rpc.Status) - StatusOrBuilder { - // Use Status.newBuilder() to construct. - private Status(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Status() { - code_ = 0; - message_ = ""; - details_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Status( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 8: { - - code_ = input.readInt32(); - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - message_ = s; - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - details_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - details_.add(input.readMessage(com.google.protobuf.Any.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - details_ = java.util.Collections.unmodifiableList(details_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.StatusProto.internal_static_google_rpc_Status_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.StatusProto.internal_static_google_rpc_Status_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.Status.class, com.google.rpc.Status.Builder.class); - } - - private int bitField0_; - public static final int CODE_FIELD_NUMBER = 1; - private int code_; - /** - * optional int32 code = 1; - * - *
      -   * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
      -   * 
      - */ - public int getCode() { - return code_; - } - - public static final int MESSAGE_FIELD_NUMBER = 2; - private volatile java.lang.Object message_; - /** - * optional string message = 2; - * - *
      -   * A developer-facing error message, which should be in English. Any
      -   * user-facing error message should be localized and sent in the
      -   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      -   * 
      - */ - public java.lang.String getMessage() { - java.lang.Object ref = message_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - message_ = s; - return s; - } - } - /** - * optional string message = 2; - * - *
      -   * A developer-facing error message, which should be in English. Any
      -   * user-facing error message should be localized and sent in the
      -   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      -   * 
      - */ - public com.google.protobuf.ByteString - getMessageBytes() { - java.lang.Object ref = message_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - message_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DETAILS_FIELD_NUMBER = 3; - private java.util.List details_; - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -   * A list of messages that carry the error details.  There will be a
      -   * common set of message types for APIs to use.
      -   * 
      - */ - public java.util.List getDetailsList() { - return details_; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -   * A list of messages that carry the error details.  There will be a
      -   * common set of message types for APIs to use.
      -   * 
      - */ - public java.util.List - getDetailsOrBuilderList() { - return details_; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -   * A list of messages that carry the error details.  There will be a
      -   * common set of message types for APIs to use.
      -   * 
      - */ - public int getDetailsCount() { - return details_.size(); - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -   * A list of messages that carry the error details.  There will be a
      -   * common set of message types for APIs to use.
      -   * 
      - */ - public com.google.protobuf.Any getDetails(int index) { - return details_.get(index); - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -   * A list of messages that carry the error details.  There will be a
      -   * common set of message types for APIs to use.
      -   * 
      - */ - public com.google.protobuf.AnyOrBuilder getDetailsOrBuilder( - int index) { - return details_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (code_ != 0) { - output.writeInt32(1, code_); - } - if (!getMessageBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, message_); - } - for (int i = 0; i < details_.size(); i++) { - output.writeMessage(3, details_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (code_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(1, code_); - } - if (!getMessageBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, message_); - } - for (int i = 0; i < details_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, details_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.rpc.Status parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.Status parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.Status parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.rpc.Status parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.rpc.Status parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.Status parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.rpc.Status parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.rpc.Status parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.rpc.Status parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.rpc.Status parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.rpc.Status prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.rpc.Status} - * - *
      -   * The `Status` type defines a logical error model that is suitable for different
      -   * programming environments, including REST APIs and RPC APIs. It is used by
      -   * [gRPC](https://github.com/grpc). The error model is designed to be:
      -   * - Simple to use and understand for most users
      -   * - Flexible enough to meet unexpected needs
      -   * # Overview
      -   * The `Status` message contains three pieces of data: error code, error message,
      -   * and error details. The error code should be an enum value of
      -   * [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed.  The
      -   * error message should be a developer-facing English message that helps
      -   * developers *understand* and *resolve* the error. If a localized user-facing
      -   * error message is needed, put the localized message in the error details or
      -   * localize it in the client. The optional error details may contain arbitrary
      -   * information about the error. There is a predefined set of error detail types
      -   * in the package `google.rpc` which can be used for common error conditions.
      -   * # Language mapping
      -   * The `Status` message is the logical representation of the error model, but it
      -   * is not necessarily the actual wire format. When the `Status` message is
      -   * exposed in different client libraries and different wire protocols, it can be
      -   * mapped differently. For example, it will likely be mapped to some exceptions
      -   * in Java, but more likely mapped to some error codes in C.
      -   * # Other uses
      -   * The error model and the `Status` message can be used in a variety of
      -   * environments, either with or without APIs, to provide a
      -   * consistent developer experience across different environments.
      -   * Example uses of this error model include:
      -   * - Partial errors. If a service needs to return partial errors to the client,
      -   *     it may embed the `Status` in the normal response to indicate the partial
      -   *     errors.
      -   * - Workflow errors. A typical workflow has multiple steps. Each step may
      -   *     have a `Status` message for error reporting purpose.
      -   * - Batch operations. If a client uses batch request and batch response, the
      -   *     `Status` message should be used directly inside batch response, one for
      -   *     each error sub-response.
      -   * - Asynchronous operations. If an API call embeds asynchronous operation
      -   *     results in its response, the status of those operations should be
      -   *     represented directly using the `Status` message.
      -   * - Logging. If some API errors are stored in logs, the message `Status` could
      -   *     be used directly after any stripping needed for security/privacy reasons.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.rpc.Status) - com.google.rpc.StatusOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.rpc.StatusProto.internal_static_google_rpc_Status_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.rpc.StatusProto.internal_static_google_rpc_Status_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.rpc.Status.class, com.google.rpc.Status.Builder.class); - } - - // Construct using com.google.rpc.Status.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getDetailsFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - code_ = 0; - - message_ = ""; - - if (detailsBuilder_ == null) { - details_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - } else { - detailsBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.rpc.StatusProto.internal_static_google_rpc_Status_descriptor; - } - - public com.google.rpc.Status getDefaultInstanceForType() { - return com.google.rpc.Status.getDefaultInstance(); - } - - public com.google.rpc.Status build() { - com.google.rpc.Status result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.rpc.Status buildPartial() { - com.google.rpc.Status result = new com.google.rpc.Status(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.code_ = code_; - result.message_ = message_; - if (detailsBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004)) { - details_ = java.util.Collections.unmodifiableList(details_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.details_ = details_; - } else { - result.details_ = detailsBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.rpc.Status) { - return mergeFrom((com.google.rpc.Status)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.rpc.Status other) { - if (other == com.google.rpc.Status.getDefaultInstance()) return this; - if (other.getCode() != 0) { - setCode(other.getCode()); - } - if (!other.getMessage().isEmpty()) { - message_ = other.message_; - onChanged(); - } - if (detailsBuilder_ == null) { - if (!other.details_.isEmpty()) { - if (details_.isEmpty()) { - details_ = other.details_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureDetailsIsMutable(); - details_.addAll(other.details_); - } - onChanged(); - } - } else { - if (!other.details_.isEmpty()) { - if (detailsBuilder_.isEmpty()) { - detailsBuilder_.dispose(); - detailsBuilder_ = null; - details_ = other.details_; - bitField0_ = (bitField0_ & ~0x00000004); - detailsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getDetailsFieldBuilder() : null; - } else { - detailsBuilder_.addAllMessages(other.details_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.rpc.Status parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.rpc.Status) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private int code_ ; - /** - * optional int32 code = 1; - * - *
      -     * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
      -     * 
      - */ - public int getCode() { - return code_; - } - /** - * optional int32 code = 1; - * - *
      -     * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
      -     * 
      - */ - public Builder setCode(int value) { - - code_ = value; - onChanged(); - return this; - } - /** - * optional int32 code = 1; - * - *
      -     * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
      -     * 
      - */ - public Builder clearCode() { - - code_ = 0; - onChanged(); - return this; - } - - private java.lang.Object message_ = ""; - /** - * optional string message = 2; - * - *
      -     * A developer-facing error message, which should be in English. Any
      -     * user-facing error message should be localized and sent in the
      -     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      -     * 
      - */ - public java.lang.String getMessage() { - java.lang.Object ref = message_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - message_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string message = 2; - * - *
      -     * A developer-facing error message, which should be in English. Any
      -     * user-facing error message should be localized and sent in the
      -     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      -     * 
      - */ - public com.google.protobuf.ByteString - getMessageBytes() { - java.lang.Object ref = message_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - message_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string message = 2; - * - *
      -     * A developer-facing error message, which should be in English. Any
      -     * user-facing error message should be localized and sent in the
      -     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      -     * 
      - */ - public Builder setMessage( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - message_ = value; - onChanged(); - return this; - } - /** - * optional string message = 2; - * - *
      -     * A developer-facing error message, which should be in English. Any
      -     * user-facing error message should be localized and sent in the
      -     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      -     * 
      - */ - public Builder clearMessage() { - - message_ = getDefaultInstance().getMessage(); - onChanged(); - return this; - } - /** - * optional string message = 2; - * - *
      -     * A developer-facing error message, which should be in English. Any
      -     * user-facing error message should be localized and sent in the
      -     * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      -     * 
      - */ - public Builder setMessageBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - message_ = value; - onChanged(); - return this; - } - - private java.util.List details_ = - java.util.Collections.emptyList(); - private void ensureDetailsIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - details_ = new java.util.ArrayList(details_); - bitField0_ |= 0x00000004; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> detailsBuilder_; - - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public java.util.List getDetailsList() { - if (detailsBuilder_ == null) { - return java.util.Collections.unmodifiableList(details_); - } else { - return detailsBuilder_.getMessageList(); - } - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public int getDetailsCount() { - if (detailsBuilder_ == null) { - return details_.size(); - } else { - return detailsBuilder_.getCount(); - } - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public com.google.protobuf.Any getDetails(int index) { - if (detailsBuilder_ == null) { - return details_.get(index); - } else { - return detailsBuilder_.getMessage(index); - } - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public Builder setDetails( - int index, com.google.protobuf.Any value) { - if (detailsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDetailsIsMutable(); - details_.set(index, value); - onChanged(); - } else { - detailsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public Builder setDetails( - int index, com.google.protobuf.Any.Builder builderForValue) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.set(index, builderForValue.build()); - onChanged(); - } else { - detailsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public Builder addDetails(com.google.protobuf.Any value) { - if (detailsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDetailsIsMutable(); - details_.add(value); - onChanged(); - } else { - detailsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public Builder addDetails( - int index, com.google.protobuf.Any value) { - if (detailsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDetailsIsMutable(); - details_.add(index, value); - onChanged(); - } else { - detailsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public Builder addDetails( - com.google.protobuf.Any.Builder builderForValue) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.add(builderForValue.build()); - onChanged(); - } else { - detailsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public Builder addDetails( - int index, com.google.protobuf.Any.Builder builderForValue) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.add(index, builderForValue.build()); - onChanged(); - } else { - detailsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public Builder addAllDetails( - java.lang.Iterable values) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, details_); - onChanged(); - } else { - detailsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public Builder clearDetails() { - if (detailsBuilder_ == null) { - details_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - } else { - detailsBuilder_.clear(); - } - return this; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public Builder removeDetails(int index) { - if (detailsBuilder_ == null) { - ensureDetailsIsMutable(); - details_.remove(index); - onChanged(); - } else { - detailsBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public com.google.protobuf.Any.Builder getDetailsBuilder( - int index) { - return getDetailsFieldBuilder().getBuilder(index); - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public com.google.protobuf.AnyOrBuilder getDetailsOrBuilder( - int index) { - if (detailsBuilder_ == null) { - return details_.get(index); } else { - return detailsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public java.util.List - getDetailsOrBuilderList() { - if (detailsBuilder_ != null) { - return detailsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(details_); - } - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public com.google.protobuf.Any.Builder addDetailsBuilder() { - return getDetailsFieldBuilder().addBuilder( - com.google.protobuf.Any.getDefaultInstance()); - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public com.google.protobuf.Any.Builder addDetailsBuilder( - int index) { - return getDetailsFieldBuilder().addBuilder( - index, com.google.protobuf.Any.getDefaultInstance()); - } - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -     * A list of messages that carry the error details.  There will be a
      -     * common set of message types for APIs to use.
      -     * 
      - */ - public java.util.List - getDetailsBuilderList() { - return getDetailsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> - getDetailsFieldBuilder() { - if (detailsBuilder_ == null) { - detailsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>( - details_, - ((bitField0_ & 0x00000004) == 0x00000004), - getParentForChildren(), - isClean()); - details_ = null; - } - return detailsBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.rpc.Status) - } - - // @@protoc_insertion_point(class_scope:google.rpc.Status) - private static final com.google.rpc.Status DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.rpc.Status(); - } - - public static com.google.rpc.Status getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Status parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Status(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.rpc.Status getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusOrBuilder.java deleted file mode 100644 index d34e7133da6a..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusOrBuilder.java +++ /dev/null @@ -1,89 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/status.proto - -package com.google.rpc; - -public interface StatusOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.rpc.Status) - com.google.protobuf.MessageOrBuilder { - - /** - * optional int32 code = 1; - * - *
      -   * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
      -   * 
      - */ - int getCode(); - - /** - * optional string message = 2; - * - *
      -   * A developer-facing error message, which should be in English. Any
      -   * user-facing error message should be localized and sent in the
      -   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      -   * 
      - */ - java.lang.String getMessage(); - /** - * optional string message = 2; - * - *
      -   * A developer-facing error message, which should be in English. Any
      -   * user-facing error message should be localized and sent in the
      -   * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
      -   * 
      - */ - com.google.protobuf.ByteString - getMessageBytes(); - - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -   * A list of messages that carry the error details.  There will be a
      -   * common set of message types for APIs to use.
      -   * 
      - */ - java.util.List - getDetailsList(); - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -   * A list of messages that carry the error details.  There will be a
      -   * common set of message types for APIs to use.
      -   * 
      - */ - com.google.protobuf.Any getDetails(int index); - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -   * A list of messages that carry the error details.  There will be a
      -   * common set of message types for APIs to use.
      -   * 
      - */ - int getDetailsCount(); - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -   * A list of messages that carry the error details.  There will be a
      -   * common set of message types for APIs to use.
      -   * 
      - */ - java.util.List - getDetailsOrBuilderList(); - /** - * repeated .google.protobuf.Any details = 3; - * - *
      -   * A list of messages that carry the error details.  There will be a
      -   * common set of message types for APIs to use.
      -   * 
      - */ - com.google.protobuf.AnyOrBuilder getDetailsOrBuilder( - int index); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusProto.java b/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusProto.java deleted file mode 100644 index 46c87a712b3f..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/rpc/StatusProto.java +++ /dev/null @@ -1,54 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/rpc/status.proto - -package com.google.rpc; - -public final class StatusProto { - private StatusProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_rpc_Status_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_rpc_Status_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\027google/rpc/status.proto\022\ngoogle.rpc\032\031g" + - "oogle/protobuf/any.proto\"N\n\006Status\022\014\n\004co" + - "de\030\001 \001(\005\022\017\n\007message\030\002 \001(\t\022%\n\007details\030\003 \003" + - "(\0132\024.google.protobuf.AnyB\037\n\016com.google.r" + - "pcB\013StatusProtoP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.AnyProto.getDescriptor(), - }, assigner); - internal_static_google_rpc_Status_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_rpc_Status_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_rpc_Status_descriptor, - new java.lang.String[] { "Code", "Message", "Details", }); - com.google.protobuf.AnyProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/Color.java b/gcloud-java-gax/generated/src/main/java/com/google/type/Color.java deleted file mode 100644 index a4d6c9f79529..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/Color.java +++ /dev/null @@ -1,1047 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/color.proto - -package com.google.type; - -/** - * Protobuf type {@code google.type.Color} - * - *
      - * Represents a color in the RGBA color space. This representation is designed
      - * for simplicity of conversion to/from color representations in various
      - * languages over compactness; for example, the fields of this representation
      - * can be trivially provided to the constructor of "java.awt.Color" in Java; it
      - * can also be trivially provided to UIColor's "+colorWithRed:green:blue:alpha"
      - * method in iOS; and, with just a little work, it can be easily formatted into
      - * a CSS "rgba()" string in JavaScript, as well. Here are some examples:
      - * Example (Java):
      - *      import com.google.type.Color;
      - *      // ...
      - *      public static java.awt.Color fromProto(Color protocolor) {
      - *        float alpha = protocolor.hasAlpha()
      - *            ? protocolor.getAlpha().getValue()
      - *            : 1.0;
      - *        return new java.awt.Color(
      - *            protocolor.getRed(),
      - *            protocolor.getGreen(),
      - *            protocolor.getBlue(),
      - *            alpha);
      - *      }
      - *      public static Color toProto(java.awt.Color color) {
      - *        float red = (float) color.getRed();
      - *        float green = (float) color.getGreen();
      - *        float blue = (float) color.getBlue();
      - *        float denominator = 255.0;
      - *        Color.Builder resultBuilder =
      - *            Color
      - *                .newBuilder()
      - *                .setRed(red / denominator)
      - *                .setGreen(green / denominator)
      - *                .setBlue(blue / denominator);
      - *        int alpha = color.getAlpha();
      - *        if (alpha != 255) {
      - *          result.setAlpha(
      - *              FloatValue
      - *                  .newBuilder()
      - *                  .setValue(((float) alpha) / denominator)
      - *                  .build());
      - *        }
      - *        return resultBuilder.build();
      - *      }
      - *      // ...
      - * Example (iOS / Obj-C):
      - *      // ...
      - *      static UIColor* fromProto(Color* protocolor) {
      - *         float red = [protocolor red];
      - *         float green = [protocolor green];
      - *         float blue = [protocolor blue];
      - *         FloatValue* alpha_wrapper = [protocolor alpha];
      - *         float alpha = 1.0;
      - *         if (alpha_wrapper != nil) {
      - *           alpha = [alpha_wrapper value];
      - *         }
      - *         return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
      - *      }
      - *      static Color* toProto(UIColor* color) {
      - *          CGFloat red, green, blue, alpha;
      - *          if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
      - *            return nil;
      - *          }
      - *          Color* result = [Color alloc] init];
      - *          [result setRed:red];
      - *          [result setGreen:green];
      - *          [result setBlue:blue];
      - *          if (alpha <= 0.9999) {
      - *            [result setAlpha:floatWrapperWithValue(alpha)];
      - *          }
      - *          [result autorelease];
      - *          return result;
      - *     }
      - *     // ...
      - *  Example (JavaScript):
      - *     // ...
      - *     var protoToCssColor = function(rgb_color) {
      - *        var redFrac = rgb_color.red || 0.0;
      - *        var greenFrac = rgb_color.green || 0.0;
      - *        var blueFrac = rgb_color.blue || 0.0;
      - *        var red = Math.floor(redFrac * 255);
      - *        var green = Math.floor(greenFrac * 255);
      - *        var blue = Math.floor(blueFrac * 255);
      - *        if (!('alpha' in rgb_color)) {
      - *           return rgbToCssColor_(red, green, blue);
      - *        }
      - *        var alphaFrac = rgb_color.alpha.value || 0.0;
      - *        var rgbParams = [red, green, blue].join(',');
      - *        return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
      - *     };
      - *     var rgbToCssColor_ = function(red, green, blue) {
      - *       var rgbNumber = new Number((red << 16) | (green << 8) | blue);
      - *       var hexString = rgbNumber.toString(16);
      - *       var missingZeros = 6 - hexString.length;
      - *       var resultBuilder = ['#'];
      - *       for (var i = 0; i < missingZeros; i++) {
      - *          resultBuilder.push('0');
      - *       }
      - *       resultBuilder.push(hexString);
      - *       return resultBuilder.join('');
      - *     };
      - *     // ...
      - * 
      - */ -public final class Color extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.type.Color) - ColorOrBuilder { - // Use Color.newBuilder() to construct. - private Color(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Color() { - red_ = 0F; - green_ = 0F; - blue_ = 0F; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Color( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 13: { - - red_ = input.readFloat(); - break; - } - case 21: { - - green_ = input.readFloat(); - break; - } - case 29: { - - blue_ = input.readFloat(); - break; - } - case 34: { - com.google.protobuf.FloatValue.Builder subBuilder = null; - if (alpha_ != null) { - subBuilder = alpha_.toBuilder(); - } - alpha_ = input.readMessage(com.google.protobuf.FloatValue.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(alpha_); - alpha_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.type.ColorProto.internal_static_google_type_Color_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.type.ColorProto.internal_static_google_type_Color_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.type.Color.class, com.google.type.Color.Builder.class); - } - - public static final int RED_FIELD_NUMBER = 1; - private float red_; - /** - * optional float red = 1; - * - *
      -   * The amount of red in the color as a value in the interval [0, 1].
      -   * 
      - */ - public float getRed() { - return red_; - } - - public static final int GREEN_FIELD_NUMBER = 2; - private float green_; - /** - * optional float green = 2; - * - *
      -   * The amount of green in the color as a value in the interval [0, 1].
      -   * 
      - */ - public float getGreen() { - return green_; - } - - public static final int BLUE_FIELD_NUMBER = 3; - private float blue_; - /** - * optional float blue = 3; - * - *
      -   * The amount of blue in the color as a value in the interval [0, 1].
      -   * 
      - */ - public float getBlue() { - return blue_; - } - - public static final int ALPHA_FIELD_NUMBER = 4; - private com.google.protobuf.FloatValue alpha_; - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -   * The fraction of this color that should be applied to the pixel. That is,
      -   * the final pixel color is defined by the equation:
      -   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -   * This means that a value of 1.0 corresponds to a solid color, whereas
      -   * a value of 0.0 corresponds to a completely transparent color. This
      -   * uses a wrapper message rather than a simple float scalar so that it is
      -   * possible to distinguish between a default value and the value being unset.
      -   * If omitted, this color object is to be rendered as a solid color
      -   * (as if the alpha value had been explicitly given with a value of 1.0).
      -   * 
      - */ - public boolean hasAlpha() { - return alpha_ != null; - } - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -   * The fraction of this color that should be applied to the pixel. That is,
      -   * the final pixel color is defined by the equation:
      -   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -   * This means that a value of 1.0 corresponds to a solid color, whereas
      -   * a value of 0.0 corresponds to a completely transparent color. This
      -   * uses a wrapper message rather than a simple float scalar so that it is
      -   * possible to distinguish between a default value and the value being unset.
      -   * If omitted, this color object is to be rendered as a solid color
      -   * (as if the alpha value had been explicitly given with a value of 1.0).
      -   * 
      - */ - public com.google.protobuf.FloatValue getAlpha() { - return alpha_ == null ? com.google.protobuf.FloatValue.getDefaultInstance() : alpha_; - } - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -   * The fraction of this color that should be applied to the pixel. That is,
      -   * the final pixel color is defined by the equation:
      -   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -   * This means that a value of 1.0 corresponds to a solid color, whereas
      -   * a value of 0.0 corresponds to a completely transparent color. This
      -   * uses a wrapper message rather than a simple float scalar so that it is
      -   * possible to distinguish between a default value and the value being unset.
      -   * If omitted, this color object is to be rendered as a solid color
      -   * (as if the alpha value had been explicitly given with a value of 1.0).
      -   * 
      - */ - public com.google.protobuf.FloatValueOrBuilder getAlphaOrBuilder() { - return getAlpha(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (red_ != 0F) { - output.writeFloat(1, red_); - } - if (green_ != 0F) { - output.writeFloat(2, green_); - } - if (blue_ != 0F) { - output.writeFloat(3, blue_); - } - if (alpha_ != null) { - output.writeMessage(4, getAlpha()); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (red_ != 0F) { - size += com.google.protobuf.CodedOutputStream - .computeFloatSize(1, red_); - } - if (green_ != 0F) { - size += com.google.protobuf.CodedOutputStream - .computeFloatSize(2, green_); - } - if (blue_ != 0F) { - size += com.google.protobuf.CodedOutputStream - .computeFloatSize(3, blue_); - } - if (alpha_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, getAlpha()); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.type.Color parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.type.Color parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.type.Color parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.type.Color parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.type.Color parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.type.Color parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.type.Color parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.type.Color parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.type.Color parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.type.Color parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.type.Color prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.type.Color} - * - *
      -   * Represents a color in the RGBA color space. This representation is designed
      -   * for simplicity of conversion to/from color representations in various
      -   * languages over compactness; for example, the fields of this representation
      -   * can be trivially provided to the constructor of "java.awt.Color" in Java; it
      -   * can also be trivially provided to UIColor's "+colorWithRed:green:blue:alpha"
      -   * method in iOS; and, with just a little work, it can be easily formatted into
      -   * a CSS "rgba()" string in JavaScript, as well. Here are some examples:
      -   * Example (Java):
      -   *      import com.google.type.Color;
      -   *      // ...
      -   *      public static java.awt.Color fromProto(Color protocolor) {
      -   *        float alpha = protocolor.hasAlpha()
      -   *            ? protocolor.getAlpha().getValue()
      -   *            : 1.0;
      -   *        return new java.awt.Color(
      -   *            protocolor.getRed(),
      -   *            protocolor.getGreen(),
      -   *            protocolor.getBlue(),
      -   *            alpha);
      -   *      }
      -   *      public static Color toProto(java.awt.Color color) {
      -   *        float red = (float) color.getRed();
      -   *        float green = (float) color.getGreen();
      -   *        float blue = (float) color.getBlue();
      -   *        float denominator = 255.0;
      -   *        Color.Builder resultBuilder =
      -   *            Color
      -   *                .newBuilder()
      -   *                .setRed(red / denominator)
      -   *                .setGreen(green / denominator)
      -   *                .setBlue(blue / denominator);
      -   *        int alpha = color.getAlpha();
      -   *        if (alpha != 255) {
      -   *          result.setAlpha(
      -   *              FloatValue
      -   *                  .newBuilder()
      -   *                  .setValue(((float) alpha) / denominator)
      -   *                  .build());
      -   *        }
      -   *        return resultBuilder.build();
      -   *      }
      -   *      // ...
      -   * Example (iOS / Obj-C):
      -   *      // ...
      -   *      static UIColor* fromProto(Color* protocolor) {
      -   *         float red = [protocolor red];
      -   *         float green = [protocolor green];
      -   *         float blue = [protocolor blue];
      -   *         FloatValue* alpha_wrapper = [protocolor alpha];
      -   *         float alpha = 1.0;
      -   *         if (alpha_wrapper != nil) {
      -   *           alpha = [alpha_wrapper value];
      -   *         }
      -   *         return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
      -   *      }
      -   *      static Color* toProto(UIColor* color) {
      -   *          CGFloat red, green, blue, alpha;
      -   *          if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
      -   *            return nil;
      -   *          }
      -   *          Color* result = [Color alloc] init];
      -   *          [result setRed:red];
      -   *          [result setGreen:green];
      -   *          [result setBlue:blue];
      -   *          if (alpha <= 0.9999) {
      -   *            [result setAlpha:floatWrapperWithValue(alpha)];
      -   *          }
      -   *          [result autorelease];
      -   *          return result;
      -   *     }
      -   *     // ...
      -   *  Example (JavaScript):
      -   *     // ...
      -   *     var protoToCssColor = function(rgb_color) {
      -   *        var redFrac = rgb_color.red || 0.0;
      -   *        var greenFrac = rgb_color.green || 0.0;
      -   *        var blueFrac = rgb_color.blue || 0.0;
      -   *        var red = Math.floor(redFrac * 255);
      -   *        var green = Math.floor(greenFrac * 255);
      -   *        var blue = Math.floor(blueFrac * 255);
      -   *        if (!('alpha' in rgb_color)) {
      -   *           return rgbToCssColor_(red, green, blue);
      -   *        }
      -   *        var alphaFrac = rgb_color.alpha.value || 0.0;
      -   *        var rgbParams = [red, green, blue].join(',');
      -   *        return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
      -   *     };
      -   *     var rgbToCssColor_ = function(red, green, blue) {
      -   *       var rgbNumber = new Number((red << 16) | (green << 8) | blue);
      -   *       var hexString = rgbNumber.toString(16);
      -   *       var missingZeros = 6 - hexString.length;
      -   *       var resultBuilder = ['#'];
      -   *       for (var i = 0; i < missingZeros; i++) {
      -   *          resultBuilder.push('0');
      -   *       }
      -   *       resultBuilder.push(hexString);
      -   *       return resultBuilder.join('');
      -   *     };
      -   *     // ...
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.type.Color) - com.google.type.ColorOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.type.ColorProto.internal_static_google_type_Color_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.type.ColorProto.internal_static_google_type_Color_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.type.Color.class, com.google.type.Color.Builder.class); - } - - // Construct using com.google.type.Color.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - red_ = 0F; - - green_ = 0F; - - blue_ = 0F; - - if (alphaBuilder_ == null) { - alpha_ = null; - } else { - alpha_ = null; - alphaBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.type.ColorProto.internal_static_google_type_Color_descriptor; - } - - public com.google.type.Color getDefaultInstanceForType() { - return com.google.type.Color.getDefaultInstance(); - } - - public com.google.type.Color build() { - com.google.type.Color result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.type.Color buildPartial() { - com.google.type.Color result = new com.google.type.Color(this); - result.red_ = red_; - result.green_ = green_; - result.blue_ = blue_; - if (alphaBuilder_ == null) { - result.alpha_ = alpha_; - } else { - result.alpha_ = alphaBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.type.Color) { - return mergeFrom((com.google.type.Color)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.type.Color other) { - if (other == com.google.type.Color.getDefaultInstance()) return this; - if (other.getRed() != 0F) { - setRed(other.getRed()); - } - if (other.getGreen() != 0F) { - setGreen(other.getGreen()); - } - if (other.getBlue() != 0F) { - setBlue(other.getBlue()); - } - if (other.hasAlpha()) { - mergeAlpha(other.getAlpha()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.type.Color parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.type.Color) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private float red_ ; - /** - * optional float red = 1; - * - *
      -     * The amount of red in the color as a value in the interval [0, 1].
      -     * 
      - */ - public float getRed() { - return red_; - } - /** - * optional float red = 1; - * - *
      -     * The amount of red in the color as a value in the interval [0, 1].
      -     * 
      - */ - public Builder setRed(float value) { - - red_ = value; - onChanged(); - return this; - } - /** - * optional float red = 1; - * - *
      -     * The amount of red in the color as a value in the interval [0, 1].
      -     * 
      - */ - public Builder clearRed() { - - red_ = 0F; - onChanged(); - return this; - } - - private float green_ ; - /** - * optional float green = 2; - * - *
      -     * The amount of green in the color as a value in the interval [0, 1].
      -     * 
      - */ - public float getGreen() { - return green_; - } - /** - * optional float green = 2; - * - *
      -     * The amount of green in the color as a value in the interval [0, 1].
      -     * 
      - */ - public Builder setGreen(float value) { - - green_ = value; - onChanged(); - return this; - } - /** - * optional float green = 2; - * - *
      -     * The amount of green in the color as a value in the interval [0, 1].
      -     * 
      - */ - public Builder clearGreen() { - - green_ = 0F; - onChanged(); - return this; - } - - private float blue_ ; - /** - * optional float blue = 3; - * - *
      -     * The amount of blue in the color as a value in the interval [0, 1].
      -     * 
      - */ - public float getBlue() { - return blue_; - } - /** - * optional float blue = 3; - * - *
      -     * The amount of blue in the color as a value in the interval [0, 1].
      -     * 
      - */ - public Builder setBlue(float value) { - - blue_ = value; - onChanged(); - return this; - } - /** - * optional float blue = 3; - * - *
      -     * The amount of blue in the color as a value in the interval [0, 1].
      -     * 
      - */ - public Builder clearBlue() { - - blue_ = 0F; - onChanged(); - return this; - } - - private com.google.protobuf.FloatValue alpha_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.FloatValue, com.google.protobuf.FloatValue.Builder, com.google.protobuf.FloatValueOrBuilder> alphaBuilder_; - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -     * The fraction of this color that should be applied to the pixel. That is,
      -     * the final pixel color is defined by the equation:
      -     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -     * This means that a value of 1.0 corresponds to a solid color, whereas
      -     * a value of 0.0 corresponds to a completely transparent color. This
      -     * uses a wrapper message rather than a simple float scalar so that it is
      -     * possible to distinguish between a default value and the value being unset.
      -     * If omitted, this color object is to be rendered as a solid color
      -     * (as if the alpha value had been explicitly given with a value of 1.0).
      -     * 
      - */ - public boolean hasAlpha() { - return alphaBuilder_ != null || alpha_ != null; - } - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -     * The fraction of this color that should be applied to the pixel. That is,
      -     * the final pixel color is defined by the equation:
      -     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -     * This means that a value of 1.0 corresponds to a solid color, whereas
      -     * a value of 0.0 corresponds to a completely transparent color. This
      -     * uses a wrapper message rather than a simple float scalar so that it is
      -     * possible to distinguish between a default value and the value being unset.
      -     * If omitted, this color object is to be rendered as a solid color
      -     * (as if the alpha value had been explicitly given with a value of 1.0).
      -     * 
      - */ - public com.google.protobuf.FloatValue getAlpha() { - if (alphaBuilder_ == null) { - return alpha_ == null ? com.google.protobuf.FloatValue.getDefaultInstance() : alpha_; - } else { - return alphaBuilder_.getMessage(); - } - } - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -     * The fraction of this color that should be applied to the pixel. That is,
      -     * the final pixel color is defined by the equation:
      -     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -     * This means that a value of 1.0 corresponds to a solid color, whereas
      -     * a value of 0.0 corresponds to a completely transparent color. This
      -     * uses a wrapper message rather than a simple float scalar so that it is
      -     * possible to distinguish between a default value and the value being unset.
      -     * If omitted, this color object is to be rendered as a solid color
      -     * (as if the alpha value had been explicitly given with a value of 1.0).
      -     * 
      - */ - public Builder setAlpha(com.google.protobuf.FloatValue value) { - if (alphaBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - alpha_ = value; - onChanged(); - } else { - alphaBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -     * The fraction of this color that should be applied to the pixel. That is,
      -     * the final pixel color is defined by the equation:
      -     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -     * This means that a value of 1.0 corresponds to a solid color, whereas
      -     * a value of 0.0 corresponds to a completely transparent color. This
      -     * uses a wrapper message rather than a simple float scalar so that it is
      -     * possible to distinguish between a default value and the value being unset.
      -     * If omitted, this color object is to be rendered as a solid color
      -     * (as if the alpha value had been explicitly given with a value of 1.0).
      -     * 
      - */ - public Builder setAlpha( - com.google.protobuf.FloatValue.Builder builderForValue) { - if (alphaBuilder_ == null) { - alpha_ = builderForValue.build(); - onChanged(); - } else { - alphaBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -     * The fraction of this color that should be applied to the pixel. That is,
      -     * the final pixel color is defined by the equation:
      -     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -     * This means that a value of 1.0 corresponds to a solid color, whereas
      -     * a value of 0.0 corresponds to a completely transparent color. This
      -     * uses a wrapper message rather than a simple float scalar so that it is
      -     * possible to distinguish between a default value and the value being unset.
      -     * If omitted, this color object is to be rendered as a solid color
      -     * (as if the alpha value had been explicitly given with a value of 1.0).
      -     * 
      - */ - public Builder mergeAlpha(com.google.protobuf.FloatValue value) { - if (alphaBuilder_ == null) { - if (alpha_ != null) { - alpha_ = - com.google.protobuf.FloatValue.newBuilder(alpha_).mergeFrom(value).buildPartial(); - } else { - alpha_ = value; - } - onChanged(); - } else { - alphaBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -     * The fraction of this color that should be applied to the pixel. That is,
      -     * the final pixel color is defined by the equation:
      -     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -     * This means that a value of 1.0 corresponds to a solid color, whereas
      -     * a value of 0.0 corresponds to a completely transparent color. This
      -     * uses a wrapper message rather than a simple float scalar so that it is
      -     * possible to distinguish between a default value and the value being unset.
      -     * If omitted, this color object is to be rendered as a solid color
      -     * (as if the alpha value had been explicitly given with a value of 1.0).
      -     * 
      - */ - public Builder clearAlpha() { - if (alphaBuilder_ == null) { - alpha_ = null; - onChanged(); - } else { - alpha_ = null; - alphaBuilder_ = null; - } - - return this; - } - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -     * The fraction of this color that should be applied to the pixel. That is,
      -     * the final pixel color is defined by the equation:
      -     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -     * This means that a value of 1.0 corresponds to a solid color, whereas
      -     * a value of 0.0 corresponds to a completely transparent color. This
      -     * uses a wrapper message rather than a simple float scalar so that it is
      -     * possible to distinguish between a default value and the value being unset.
      -     * If omitted, this color object is to be rendered as a solid color
      -     * (as if the alpha value had been explicitly given with a value of 1.0).
      -     * 
      - */ - public com.google.protobuf.FloatValue.Builder getAlphaBuilder() { - - onChanged(); - return getAlphaFieldBuilder().getBuilder(); - } - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -     * The fraction of this color that should be applied to the pixel. That is,
      -     * the final pixel color is defined by the equation:
      -     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -     * This means that a value of 1.0 corresponds to a solid color, whereas
      -     * a value of 0.0 corresponds to a completely transparent color. This
      -     * uses a wrapper message rather than a simple float scalar so that it is
      -     * possible to distinguish between a default value and the value being unset.
      -     * If omitted, this color object is to be rendered as a solid color
      -     * (as if the alpha value had been explicitly given with a value of 1.0).
      -     * 
      - */ - public com.google.protobuf.FloatValueOrBuilder getAlphaOrBuilder() { - if (alphaBuilder_ != null) { - return alphaBuilder_.getMessageOrBuilder(); - } else { - return alpha_ == null ? - com.google.protobuf.FloatValue.getDefaultInstance() : alpha_; - } - } - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -     * The fraction of this color that should be applied to the pixel. That is,
      -     * the final pixel color is defined by the equation:
      -     *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -     * This means that a value of 1.0 corresponds to a solid color, whereas
      -     * a value of 0.0 corresponds to a completely transparent color. This
      -     * uses a wrapper message rather than a simple float scalar so that it is
      -     * possible to distinguish between a default value and the value being unset.
      -     * If omitted, this color object is to be rendered as a solid color
      -     * (as if the alpha value had been explicitly given with a value of 1.0).
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.FloatValue, com.google.protobuf.FloatValue.Builder, com.google.protobuf.FloatValueOrBuilder> - getAlphaFieldBuilder() { - if (alphaBuilder_ == null) { - alphaBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.protobuf.FloatValue, com.google.protobuf.FloatValue.Builder, com.google.protobuf.FloatValueOrBuilder>( - getAlpha(), - getParentForChildren(), - isClean()); - alpha_ = null; - } - return alphaBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.type.Color) - } - - // @@protoc_insertion_point(class_scope:google.type.Color) - private static final com.google.type.Color DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.type.Color(); - } - - public static com.google.type.Color getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Color parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Color(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.type.Color getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/ColorOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/type/ColorOrBuilder.java deleted file mode 100644 index d6c1ea1ed3fd..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/ColorOrBuilder.java +++ /dev/null @@ -1,85 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/color.proto - -package com.google.type; - -public interface ColorOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.type.Color) - com.google.protobuf.MessageOrBuilder { - - /** - * optional float red = 1; - * - *
      -   * The amount of red in the color as a value in the interval [0, 1].
      -   * 
      - */ - float getRed(); - - /** - * optional float green = 2; - * - *
      -   * The amount of green in the color as a value in the interval [0, 1].
      -   * 
      - */ - float getGreen(); - - /** - * optional float blue = 3; - * - *
      -   * The amount of blue in the color as a value in the interval [0, 1].
      -   * 
      - */ - float getBlue(); - - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -   * The fraction of this color that should be applied to the pixel. That is,
      -   * the final pixel color is defined by the equation:
      -   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -   * This means that a value of 1.0 corresponds to a solid color, whereas
      -   * a value of 0.0 corresponds to a completely transparent color. This
      -   * uses a wrapper message rather than a simple float scalar so that it is
      -   * possible to distinguish between a default value and the value being unset.
      -   * If omitted, this color object is to be rendered as a solid color
      -   * (as if the alpha value had been explicitly given with a value of 1.0).
      -   * 
      - */ - boolean hasAlpha(); - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -   * The fraction of this color that should be applied to the pixel. That is,
      -   * the final pixel color is defined by the equation:
      -   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -   * This means that a value of 1.0 corresponds to a solid color, whereas
      -   * a value of 0.0 corresponds to a completely transparent color. This
      -   * uses a wrapper message rather than a simple float scalar so that it is
      -   * possible to distinguish between a default value and the value being unset.
      -   * If omitted, this color object is to be rendered as a solid color
      -   * (as if the alpha value had been explicitly given with a value of 1.0).
      -   * 
      - */ - com.google.protobuf.FloatValue getAlpha(); - /** - * optional .google.protobuf.FloatValue alpha = 4; - * - *
      -   * The fraction of this color that should be applied to the pixel. That is,
      -   * the final pixel color is defined by the equation:
      -   *   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
      -   * This means that a value of 1.0 corresponds to a solid color, whereas
      -   * a value of 0.0 corresponds to a completely transparent color. This
      -   * uses a wrapper message rather than a simple float scalar so that it is
      -   * possible to distinguish between a default value and the value being unset.
      -   * If omitted, this color object is to be rendered as a solid color
      -   * (as if the alpha value had been explicitly given with a value of 1.0).
      -   * 
      - */ - com.google.protobuf.FloatValueOrBuilder getAlphaOrBuilder(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/ColorProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/ColorProto.java deleted file mode 100644 index 7706183802ed..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/ColorProto.java +++ /dev/null @@ -1,55 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/color.proto - -package com.google.type; - -public final class ColorProto { - private ColorProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_type_Color_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_type_Color_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\027google/type/color.proto\022\013google.type\032\036" + - "google/protobuf/wrappers.proto\"]\n\005Color\022" + - "\013\n\003red\030\001 \001(\002\022\r\n\005green\030\002 \001(\002\022\014\n\004blue\030\003 \001(" + - "\002\022*\n\005alpha\030\004 \001(\0132\033.google.protobuf.Float" + - "ValueB\037\n\017com.google.typeB\nColorProtoP\001b\006" + - "proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.WrappersProto.getDescriptor(), - }, assigner); - internal_static_google_type_Color_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_type_Color_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_type_Color_descriptor, - new java.lang.String[] { "Red", "Green", "Blue", "Alpha", }); - com.google.protobuf.WrappersProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/Date.java b/gcloud-java-gax/generated/src/main/java/com/google/type/Date.java deleted file mode 100644 index b4a06c47f778..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/Date.java +++ /dev/null @@ -1,593 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/date.proto - -package com.google.type; - -/** - * Protobuf type {@code google.type.Date} - * - *
      - * Represents a whole calendar date, e.g. date of birth. The time of day and
      - * time zone are either specified elsewhere or are not significant. The date
      - * is relative to the Proleptic Gregorian Calendar. The day may be 0 to
      - * represent a year and month where the day is not significant, e.g. credit card
      - * expiration date. The year may be 0 to represent a month and day independent
      - * of year, e.g. anniversary date. Related types are [google.type.TimeOfDay][google.type.TimeOfDay]
      - * and [google.protobuf.Timestamp][google.protobuf.Timestamp].
      - * 
      - */ -public final class Date extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.type.Date) - DateOrBuilder { - // Use Date.newBuilder() to construct. - private Date(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Date() { - year_ = 0; - month_ = 0; - day_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Date( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 8: { - - year_ = input.readInt32(); - break; - } - case 16: { - - month_ = input.readInt32(); - break; - } - case 24: { - - day_ = input.readInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.type.DateProto.internal_static_google_type_Date_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.type.DateProto.internal_static_google_type_Date_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.type.Date.class, com.google.type.Date.Builder.class); - } - - public static final int YEAR_FIELD_NUMBER = 1; - private int year_; - /** - * optional int32 year = 1; - * - *
      -   * Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
      -   * a year.
      -   * 
      - */ - public int getYear() { - return year_; - } - - public static final int MONTH_FIELD_NUMBER = 2; - private int month_; - /** - * optional int32 month = 2; - * - *
      -   * Month of year of date. Must be from 1 to 12.
      -   * 
      - */ - public int getMonth() { - return month_; - } - - public static final int DAY_FIELD_NUMBER = 3; - private int day_; - /** - * optional int32 day = 3; - * - *
      -   * Day of month. Must be from 1 to 31 and valid for the year and month, or 0
      -   * if specifying a year/month where the day is not sigificant.
      -   * 
      - */ - public int getDay() { - return day_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (year_ != 0) { - output.writeInt32(1, year_); - } - if (month_ != 0) { - output.writeInt32(2, month_); - } - if (day_ != 0) { - output.writeInt32(3, day_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (year_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(1, year_); - } - if (month_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, month_); - } - if (day_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, day_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.type.Date)) { - return super.equals(obj); - } - com.google.type.Date other = (com.google.type.Date) obj; - - boolean result = true; - result = result && (getYear() - == other.getYear()); - result = result && (getMonth() - == other.getMonth()); - result = result && (getDay() - == other.getDay()); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptorForType().hashCode(); - hash = (37 * hash) + YEAR_FIELD_NUMBER; - hash = (53 * hash) + getYear(); - hash = (37 * hash) + MONTH_FIELD_NUMBER; - hash = (53 * hash) + getMonth(); - hash = (37 * hash) + DAY_FIELD_NUMBER; - hash = (53 * hash) + getDay(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.type.Date parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.type.Date parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.type.Date parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.type.Date parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.type.Date parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.type.Date parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.type.Date parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.type.Date parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.type.Date parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.type.Date parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.type.Date prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.type.Date} - * - *
      -   * Represents a whole calendar date, e.g. date of birth. The time of day and
      -   * time zone are either specified elsewhere or are not significant. The date
      -   * is relative to the Proleptic Gregorian Calendar. The day may be 0 to
      -   * represent a year and month where the day is not significant, e.g. credit card
      -   * expiration date. The year may be 0 to represent a month and day independent
      -   * of year, e.g. anniversary date. Related types are [google.type.TimeOfDay][google.type.TimeOfDay]
      -   * and [google.protobuf.Timestamp][google.protobuf.Timestamp].
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.type.Date) - com.google.type.DateOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.type.DateProto.internal_static_google_type_Date_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.type.DateProto.internal_static_google_type_Date_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.type.Date.class, com.google.type.Date.Builder.class); - } - - // Construct using com.google.type.Date.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - year_ = 0; - - month_ = 0; - - day_ = 0; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.type.DateProto.internal_static_google_type_Date_descriptor; - } - - public com.google.type.Date getDefaultInstanceForType() { - return com.google.type.Date.getDefaultInstance(); - } - - public com.google.type.Date build() { - com.google.type.Date result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.type.Date buildPartial() { - com.google.type.Date result = new com.google.type.Date(this); - result.year_ = year_; - result.month_ = month_; - result.day_ = day_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.type.Date) { - return mergeFrom((com.google.type.Date)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.type.Date other) { - if (other == com.google.type.Date.getDefaultInstance()) return this; - if (other.getYear() != 0) { - setYear(other.getYear()); - } - if (other.getMonth() != 0) { - setMonth(other.getMonth()); - } - if (other.getDay() != 0) { - setDay(other.getDay()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.type.Date parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.type.Date) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int year_ ; - /** - * optional int32 year = 1; - * - *
      -     * Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
      -     * a year.
      -     * 
      - */ - public int getYear() { - return year_; - } - /** - * optional int32 year = 1; - * - *
      -     * Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
      -     * a year.
      -     * 
      - */ - public Builder setYear(int value) { - - year_ = value; - onChanged(); - return this; - } - /** - * optional int32 year = 1; - * - *
      -     * Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
      -     * a year.
      -     * 
      - */ - public Builder clearYear() { - - year_ = 0; - onChanged(); - return this; - } - - private int month_ ; - /** - * optional int32 month = 2; - * - *
      -     * Month of year of date. Must be from 1 to 12.
      -     * 
      - */ - public int getMonth() { - return month_; - } - /** - * optional int32 month = 2; - * - *
      -     * Month of year of date. Must be from 1 to 12.
      -     * 
      - */ - public Builder setMonth(int value) { - - month_ = value; - onChanged(); - return this; - } - /** - * optional int32 month = 2; - * - *
      -     * Month of year of date. Must be from 1 to 12.
      -     * 
      - */ - public Builder clearMonth() { - - month_ = 0; - onChanged(); - return this; - } - - private int day_ ; - /** - * optional int32 day = 3; - * - *
      -     * Day of month. Must be from 1 to 31 and valid for the year and month, or 0
      -     * if specifying a year/month where the day is not sigificant.
      -     * 
      - */ - public int getDay() { - return day_; - } - /** - * optional int32 day = 3; - * - *
      -     * Day of month. Must be from 1 to 31 and valid for the year and month, or 0
      -     * if specifying a year/month where the day is not sigificant.
      -     * 
      - */ - public Builder setDay(int value) { - - day_ = value; - onChanged(); - return this; - } - /** - * optional int32 day = 3; - * - *
      -     * Day of month. Must be from 1 to 31 and valid for the year and month, or 0
      -     * if specifying a year/month where the day is not sigificant.
      -     * 
      - */ - public Builder clearDay() { - - day_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.type.Date) - } - - // @@protoc_insertion_point(class_scope:google.type.Date) - private static final com.google.type.Date DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.type.Date(); - } - - public static com.google.type.Date getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Date parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Date(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.type.Date getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/DateOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/type/DateOrBuilder.java deleted file mode 100644 index adf3a03af627..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/DateOrBuilder.java +++ /dev/null @@ -1,38 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/date.proto - -package com.google.type; - -public interface DateOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.type.Date) - com.google.protobuf.MessageOrBuilder { - - /** - * optional int32 year = 1; - * - *
      -   * Year of date. Must be from 1 to 9,999, or 0 if specifying a date without
      -   * a year.
      -   * 
      - */ - int getYear(); - - /** - * optional int32 month = 2; - * - *
      -   * Month of year of date. Must be from 1 to 12.
      -   * 
      - */ - int getMonth(); - - /** - * optional int32 day = 3; - * - *
      -   * Day of month. Must be from 1 to 31 and valid for the year and month, or 0
      -   * if specifying a year/month where the day is not sigificant.
      -   * 
      - */ - int getDay(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/DateProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/DateProto.java deleted file mode 100644 index 2ddd35383cd5..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/DateProto.java +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/date.proto - -package com.google.type; - -public final class DateProto { - private DateProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_type_Date_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_type_Date_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\026google/type/date.proto\022\013google.type\"0\n" + - "\004Date\022\014\n\004year\030\001 \001(\005\022\r\n\005month\030\002 \001(\005\022\013\n\003da" + - "y\030\003 \001(\005B!\n\017com.google.typeB\tDateProtoP\001\240" + - "\001\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_google_type_Date_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_type_Date_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_type_Date_descriptor, - new java.lang.String[] { "Year", "Month", "Day", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeek.java b/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeek.java deleted file mode 100644 index 06df59326e8c..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeek.java +++ /dev/null @@ -1,220 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/dayofweek.proto - -package com.google.type; - -/** - * Protobuf enum {@code google.type.DayOfWeek} - * - *
      - * Represents a day of week.
      - * 
      - */ -public enum DayOfWeek - implements com.google.protobuf.ProtocolMessageEnum { - /** - * DAY_OF_WEEK_UNSPECIFIED = 0; - * - *
      -   * The unspecified day-of-week.
      -   * 
      - */ - DAY_OF_WEEK_UNSPECIFIED(0, 0), - /** - * MONDAY = 1; - * - *
      -   * The day-of-week of Monday.
      -   * 
      - */ - MONDAY(1, 1), - /** - * TUESDAY = 2; - * - *
      -   * The day-of-week of Tuesday.
      -   * 
      - */ - TUESDAY(2, 2), - /** - * WEDNESDAY = 3; - * - *
      -   * The day-of-week of Wednesday.
      -   * 
      - */ - WEDNESDAY(3, 3), - /** - * THURSDAY = 4; - * - *
      -   * The day-of-week of Thursday.
      -   * 
      - */ - THURSDAY(4, 4), - /** - * FRIDAY = 5; - * - *
      -   * The day-of-week of Friday.
      -   * 
      - */ - FRIDAY(5, 5), - /** - * SATURDAY = 6; - * - *
      -   * The day-of-week of Saturday.
      -   * 
      - */ - SATURDAY(6, 6), - /** - * SUNDAY = 7; - * - *
      -   * The day-of-week of Sunday.
      -   * 
      - */ - SUNDAY(7, 7), - UNRECOGNIZED(-1, -1), - ; - - /** - * DAY_OF_WEEK_UNSPECIFIED = 0; - * - *
      -   * The unspecified day-of-week.
      -   * 
      - */ - public static final int DAY_OF_WEEK_UNSPECIFIED_VALUE = 0; - /** - * MONDAY = 1; - * - *
      -   * The day-of-week of Monday.
      -   * 
      - */ - public static final int MONDAY_VALUE = 1; - /** - * TUESDAY = 2; - * - *
      -   * The day-of-week of Tuesday.
      -   * 
      - */ - public static final int TUESDAY_VALUE = 2; - /** - * WEDNESDAY = 3; - * - *
      -   * The day-of-week of Wednesday.
      -   * 
      - */ - public static final int WEDNESDAY_VALUE = 3; - /** - * THURSDAY = 4; - * - *
      -   * The day-of-week of Thursday.
      -   * 
      - */ - public static final int THURSDAY_VALUE = 4; - /** - * FRIDAY = 5; - * - *
      -   * The day-of-week of Friday.
      -   * 
      - */ - public static final int FRIDAY_VALUE = 5; - /** - * SATURDAY = 6; - * - *
      -   * The day-of-week of Saturday.
      -   * 
      - */ - public static final int SATURDAY_VALUE = 6; - /** - * SUNDAY = 7; - * - *
      -   * The day-of-week of Sunday.
      -   * 
      - */ - public static final int SUNDAY_VALUE = 7; - - - public final int getNumber() { - if (index == -1) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - public static DayOfWeek valueOf(int value) { - switch (value) { - case 0: return DAY_OF_WEEK_UNSPECIFIED; - case 1: return MONDAY; - case 2: return TUESDAY; - case 3: return WEDNESDAY; - case 4: return THURSDAY; - case 5: return FRIDAY; - case 6: return SATURDAY; - case 7: return SUNDAY; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static final com.google.protobuf.Internal.EnumLiteMap< - DayOfWeek> internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public DayOfWeek findValueByNumber(int number) { - return DayOfWeek.valueOf(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(index); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return com.google.type.DayOfWeekProto.getDescriptor() - .getEnumTypes().get(0); - } - - private static final DayOfWeek[] VALUES = values(); - - public static DayOfWeek valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int index; - private final int value; - - private DayOfWeek(int index, int value) { - this.index = index; - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.type.DayOfWeek) -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeekProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeekProto.java deleted file mode 100644 index 8fc4a373d4c7..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/DayOfWeekProto.java +++ /dev/null @@ -1,42 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/dayofweek.proto - -package com.google.type; - -public final class DayOfWeekProto { - private DayOfWeekProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\033google/type/dayofweek.proto\022\013google.ty" + - "pe*\204\001\n\tDayOfWeek\022\033\n\027DAY_OF_WEEK_UNSPECIF" + - "IED\020\000\022\n\n\006MONDAY\020\001\022\013\n\007TUESDAY\020\002\022\r\n\tWEDNES" + - "DAY\020\003\022\014\n\010THURSDAY\020\004\022\n\n\006FRIDAY\020\005\022\014\n\010SATUR" + - "DAY\020\006\022\n\n\006SUNDAY\020\007B&\n\017com.google.typeB\016Da" + - "yOfWeekProtoP\001\240\001\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/LatLng.java b/gcloud-java-gax/generated/src/main/java/com/google/type/LatLng.java deleted file mode 100644 index a01d4f50b3db..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/LatLng.java +++ /dev/null @@ -1,513 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/latlng.proto - -package com.google.type; - -/** - * Protobuf type {@code google.type.LatLng} - * - *
      - * An object representing a latitude/longitude pair. This is expressed as a pair
      - * of doubles representing degrees latitude and degrees longitude. Unless
      - * specified otherwise, this must conform to the
      - * <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
      - * standard</a>. Values must be within normalized ranges.
      - * 
      - */ -public final class LatLng extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.type.LatLng) - LatLngOrBuilder { - // Use LatLng.newBuilder() to construct. - private LatLng(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private LatLng() { - latitude_ = 0D; - longitude_ = 0D; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private LatLng( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 9: { - - latitude_ = input.readDouble(); - break; - } - case 17: { - - longitude_ = input.readDouble(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.type.LatLngProto.internal_static_google_type_LatLng_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.type.LatLngProto.internal_static_google_type_LatLng_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.type.LatLng.class, com.google.type.LatLng.Builder.class); - } - - public static final int LATITUDE_FIELD_NUMBER = 1; - private double latitude_; - /** - * optional double latitude = 1; - * - *
      -   * The latitude in degrees. It must be in the range [-90.0, +90.0].
      -   * 
      - */ - public double getLatitude() { - return latitude_; - } - - public static final int LONGITUDE_FIELD_NUMBER = 2; - private double longitude_; - /** - * optional double longitude = 2; - * - *
      -   * The longitude in degrees. It must be in the range [-180.0, +180.0].
      -   * 
      - */ - public double getLongitude() { - return longitude_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (latitude_ != 0D) { - output.writeDouble(1, latitude_); - } - if (longitude_ != 0D) { - output.writeDouble(2, longitude_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (latitude_ != 0D) { - size += com.google.protobuf.CodedOutputStream - .computeDoubleSize(1, latitude_); - } - if (longitude_ != 0D) { - size += com.google.protobuf.CodedOutputStream - .computeDoubleSize(2, longitude_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.type.LatLng)) { - return super.equals(obj); - } - com.google.type.LatLng other = (com.google.type.LatLng) obj; - - boolean result = true; - result = result && ( - java.lang.Double.doubleToLongBits(getLatitude()) - == java.lang.Double.doubleToLongBits( - other.getLatitude())); - result = result && ( - java.lang.Double.doubleToLongBits(getLongitude()) - == java.lang.Double.doubleToLongBits( - other.getLongitude())); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptorForType().hashCode(); - hash = (37 * hash) + LATITUDE_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - java.lang.Double.doubleToLongBits(getLatitude())); - hash = (37 * hash) + LONGITUDE_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - java.lang.Double.doubleToLongBits(getLongitude())); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.type.LatLng parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.type.LatLng parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.type.LatLng parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.type.LatLng parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.type.LatLng parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.type.LatLng parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.type.LatLng parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.type.LatLng parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.type.LatLng parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.type.LatLng parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.type.LatLng prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.type.LatLng} - * - *
      -   * An object representing a latitude/longitude pair. This is expressed as a pair
      -   * of doubles representing degrees latitude and degrees longitude. Unless
      -   * specified otherwise, this must conform to the
      -   * <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
      -   * standard</a>. Values must be within normalized ranges.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.type.LatLng) - com.google.type.LatLngOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.type.LatLngProto.internal_static_google_type_LatLng_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.type.LatLngProto.internal_static_google_type_LatLng_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.type.LatLng.class, com.google.type.LatLng.Builder.class); - } - - // Construct using com.google.type.LatLng.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - latitude_ = 0D; - - longitude_ = 0D; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.type.LatLngProto.internal_static_google_type_LatLng_descriptor; - } - - public com.google.type.LatLng getDefaultInstanceForType() { - return com.google.type.LatLng.getDefaultInstance(); - } - - public com.google.type.LatLng build() { - com.google.type.LatLng result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.type.LatLng buildPartial() { - com.google.type.LatLng result = new com.google.type.LatLng(this); - result.latitude_ = latitude_; - result.longitude_ = longitude_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.type.LatLng) { - return mergeFrom((com.google.type.LatLng)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.type.LatLng other) { - if (other == com.google.type.LatLng.getDefaultInstance()) return this; - if (other.getLatitude() != 0D) { - setLatitude(other.getLatitude()); - } - if (other.getLongitude() != 0D) { - setLongitude(other.getLongitude()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.type.LatLng parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.type.LatLng) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private double latitude_ ; - /** - * optional double latitude = 1; - * - *
      -     * The latitude in degrees. It must be in the range [-90.0, +90.0].
      -     * 
      - */ - public double getLatitude() { - return latitude_; - } - /** - * optional double latitude = 1; - * - *
      -     * The latitude in degrees. It must be in the range [-90.0, +90.0].
      -     * 
      - */ - public Builder setLatitude(double value) { - - latitude_ = value; - onChanged(); - return this; - } - /** - * optional double latitude = 1; - * - *
      -     * The latitude in degrees. It must be in the range [-90.0, +90.0].
      -     * 
      - */ - public Builder clearLatitude() { - - latitude_ = 0D; - onChanged(); - return this; - } - - private double longitude_ ; - /** - * optional double longitude = 2; - * - *
      -     * The longitude in degrees. It must be in the range [-180.0, +180.0].
      -     * 
      - */ - public double getLongitude() { - return longitude_; - } - /** - * optional double longitude = 2; - * - *
      -     * The longitude in degrees. It must be in the range [-180.0, +180.0].
      -     * 
      - */ - public Builder setLongitude(double value) { - - longitude_ = value; - onChanged(); - return this; - } - /** - * optional double longitude = 2; - * - *
      -     * The longitude in degrees. It must be in the range [-180.0, +180.0].
      -     * 
      - */ - public Builder clearLongitude() { - - longitude_ = 0D; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.type.LatLng) - } - - // @@protoc_insertion_point(class_scope:google.type.LatLng) - private static final com.google.type.LatLng DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.type.LatLng(); - } - - public static com.google.type.LatLng getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public LatLng parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new LatLng(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.type.LatLng getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngOrBuilder.java deleted file mode 100644 index a068aedf045d..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngOrBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/latlng.proto - -package com.google.type; - -public interface LatLngOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.type.LatLng) - com.google.protobuf.MessageOrBuilder { - - /** - * optional double latitude = 1; - * - *
      -   * The latitude in degrees. It must be in the range [-90.0, +90.0].
      -   * 
      - */ - double getLatitude(); - - /** - * optional double longitude = 2; - * - *
      -   * The longitude in degrees. It must be in the range [-180.0, +180.0].
      -   * 
      - */ - double getLongitude(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngProto.java deleted file mode 100644 index 35b63fce9cda..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/LatLngProto.java +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/latlng.proto - -package com.google.type; - -public final class LatLngProto { - private LatLngProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_type_LatLng_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_type_LatLng_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\030google/type/latlng.proto\022\013google.type\"" + - "-\n\006LatLng\022\020\n\010latitude\030\001 \001(\001\022\021\n\tlongitude" + - "\030\002 \001(\001B#\n\017com.google.typeB\013LatLngProtoP\001" + - "\240\001\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_google_type_LatLng_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_type_LatLng_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_type_LatLng_descriptor, - new java.lang.String[] { "Latitude", "Longitude", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/Money.java b/gcloud-java-gax/generated/src/main/java/com/google/type/Money.java deleted file mode 100644 index 18025d34fe87..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/Money.java +++ /dev/null @@ -1,640 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/money.proto - -package com.google.type; - -/** - * Protobuf type {@code google.type.Money} - * - *
      - * Represents an amount of money with its currency type.
      - * 
      - */ -public final class Money extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.type.Money) - MoneyOrBuilder { - // Use Money.newBuilder() to construct. - private Money(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Money() { - currencyCode_ = ""; - units_ = 0L; - nanos_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Money( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - currencyCode_ = s; - break; - } - case 16: { - - units_ = input.readInt64(); - break; - } - case 24: { - - nanos_ = input.readInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.type.MoneyProto.internal_static_google_type_Money_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.type.MoneyProto.internal_static_google_type_Money_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.type.Money.class, com.google.type.Money.Builder.class); - } - - public static final int CURRENCY_CODE_FIELD_NUMBER = 1; - private volatile java.lang.Object currencyCode_; - /** - * optional string currency_code = 1; - * - *
      -   * The 3-letter currency code defined in ISO 4217.
      -   * 
      - */ - public java.lang.String getCurrencyCode() { - java.lang.Object ref = currencyCode_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - currencyCode_ = s; - return s; - } - } - /** - * optional string currency_code = 1; - * - *
      -   * The 3-letter currency code defined in ISO 4217.
      -   * 
      - */ - public com.google.protobuf.ByteString - getCurrencyCodeBytes() { - java.lang.Object ref = currencyCode_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - currencyCode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int UNITS_FIELD_NUMBER = 2; - private long units_; - /** - * optional int64 units = 2; - * - *
      -   * The whole units of the amount.
      -   * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
      -   * 
      - */ - public long getUnits() { - return units_; - } - - public static final int NANOS_FIELD_NUMBER = 3; - private int nanos_; - /** - * optional int32 nanos = 3; - * - *
      -   * Number of nano (10^-9) units of the amount.
      -   * The value must be between -999,999,999 and +999,999,999 inclusive.
      -   * If `units` is positive, `nanos` must be positive or zero.
      -   * If `units` is zero, `nanos` can be positive, zero, or negative.
      -   * If `units` is negative, `nanos` must be negative or zero.
      -   * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
      -   * 
      - */ - public int getNanos() { - return nanos_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getCurrencyCodeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, currencyCode_); - } - if (units_ != 0L) { - output.writeInt64(2, units_); - } - if (nanos_ != 0) { - output.writeInt32(3, nanos_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getCurrencyCodeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, currencyCode_); - } - if (units_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, units_); - } - if (nanos_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, nanos_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.type.Money parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.type.Money parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.type.Money parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.type.Money parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.type.Money parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.type.Money parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.type.Money parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.type.Money parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.type.Money parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.type.Money parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.type.Money prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.type.Money} - * - *
      -   * Represents an amount of money with its currency type.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.type.Money) - com.google.type.MoneyOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.type.MoneyProto.internal_static_google_type_Money_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.type.MoneyProto.internal_static_google_type_Money_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.type.Money.class, com.google.type.Money.Builder.class); - } - - // Construct using com.google.type.Money.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - currencyCode_ = ""; - - units_ = 0L; - - nanos_ = 0; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.type.MoneyProto.internal_static_google_type_Money_descriptor; - } - - public com.google.type.Money getDefaultInstanceForType() { - return com.google.type.Money.getDefaultInstance(); - } - - public com.google.type.Money build() { - com.google.type.Money result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.type.Money buildPartial() { - com.google.type.Money result = new com.google.type.Money(this); - result.currencyCode_ = currencyCode_; - result.units_ = units_; - result.nanos_ = nanos_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.type.Money) { - return mergeFrom((com.google.type.Money)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.type.Money other) { - if (other == com.google.type.Money.getDefaultInstance()) return this; - if (!other.getCurrencyCode().isEmpty()) { - currencyCode_ = other.currencyCode_; - onChanged(); - } - if (other.getUnits() != 0L) { - setUnits(other.getUnits()); - } - if (other.getNanos() != 0) { - setNanos(other.getNanos()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.type.Money parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.type.Money) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object currencyCode_ = ""; - /** - * optional string currency_code = 1; - * - *
      -     * The 3-letter currency code defined in ISO 4217.
      -     * 
      - */ - public java.lang.String getCurrencyCode() { - java.lang.Object ref = currencyCode_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - currencyCode_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string currency_code = 1; - * - *
      -     * The 3-letter currency code defined in ISO 4217.
      -     * 
      - */ - public com.google.protobuf.ByteString - getCurrencyCodeBytes() { - java.lang.Object ref = currencyCode_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - currencyCode_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string currency_code = 1; - * - *
      -     * The 3-letter currency code defined in ISO 4217.
      -     * 
      - */ - public Builder setCurrencyCode( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - currencyCode_ = value; - onChanged(); - return this; - } - /** - * optional string currency_code = 1; - * - *
      -     * The 3-letter currency code defined in ISO 4217.
      -     * 
      - */ - public Builder clearCurrencyCode() { - - currencyCode_ = getDefaultInstance().getCurrencyCode(); - onChanged(); - return this; - } - /** - * optional string currency_code = 1; - * - *
      -     * The 3-letter currency code defined in ISO 4217.
      -     * 
      - */ - public Builder setCurrencyCodeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - currencyCode_ = value; - onChanged(); - return this; - } - - private long units_ ; - /** - * optional int64 units = 2; - * - *
      -     * The whole units of the amount.
      -     * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
      -     * 
      - */ - public long getUnits() { - return units_; - } - /** - * optional int64 units = 2; - * - *
      -     * The whole units of the amount.
      -     * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
      -     * 
      - */ - public Builder setUnits(long value) { - - units_ = value; - onChanged(); - return this; - } - /** - * optional int64 units = 2; - * - *
      -     * The whole units of the amount.
      -     * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
      -     * 
      - */ - public Builder clearUnits() { - - units_ = 0L; - onChanged(); - return this; - } - - private int nanos_ ; - /** - * optional int32 nanos = 3; - * - *
      -     * Number of nano (10^-9) units of the amount.
      -     * The value must be between -999,999,999 and +999,999,999 inclusive.
      -     * If `units` is positive, `nanos` must be positive or zero.
      -     * If `units` is zero, `nanos` can be positive, zero, or negative.
      -     * If `units` is negative, `nanos` must be negative or zero.
      -     * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
      -     * 
      - */ - public int getNanos() { - return nanos_; - } - /** - * optional int32 nanos = 3; - * - *
      -     * Number of nano (10^-9) units of the amount.
      -     * The value must be between -999,999,999 and +999,999,999 inclusive.
      -     * If `units` is positive, `nanos` must be positive or zero.
      -     * If `units` is zero, `nanos` can be positive, zero, or negative.
      -     * If `units` is negative, `nanos` must be negative or zero.
      -     * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
      -     * 
      - */ - public Builder setNanos(int value) { - - nanos_ = value; - onChanged(); - return this; - } - /** - * optional int32 nanos = 3; - * - *
      -     * Number of nano (10^-9) units of the amount.
      -     * The value must be between -999,999,999 and +999,999,999 inclusive.
      -     * If `units` is positive, `nanos` must be positive or zero.
      -     * If `units` is zero, `nanos` can be positive, zero, or negative.
      -     * If `units` is negative, `nanos` must be negative or zero.
      -     * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
      -     * 
      - */ - public Builder clearNanos() { - - nanos_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.type.Money) - } - - // @@protoc_insertion_point(class_scope:google.type.Money) - private static final com.google.type.Money DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.type.Money(); - } - - public static com.google.type.Money getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Money parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Money(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.type.Money getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyOrBuilder.java deleted file mode 100644 index 88567eecfba8..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyOrBuilder.java +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/money.proto - -package com.google.type; - -public interface MoneyOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.type.Money) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string currency_code = 1; - * - *
      -   * The 3-letter currency code defined in ISO 4217.
      -   * 
      - */ - java.lang.String getCurrencyCode(); - /** - * optional string currency_code = 1; - * - *
      -   * The 3-letter currency code defined in ISO 4217.
      -   * 
      - */ - com.google.protobuf.ByteString - getCurrencyCodeBytes(); - - /** - * optional int64 units = 2; - * - *
      -   * The whole units of the amount.
      -   * For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
      -   * 
      - */ - long getUnits(); - - /** - * optional int32 nanos = 3; - * - *
      -   * Number of nano (10^-9) units of the amount.
      -   * The value must be between -999,999,999 and +999,999,999 inclusive.
      -   * If `units` is positive, `nanos` must be positive or zero.
      -   * If `units` is zero, `nanos` can be positive, zero, or negative.
      -   * If `units` is negative, `nanos` must be negative or zero.
      -   * For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
      -   * 
      - */ - int getNanos(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyProto.java deleted file mode 100644 index 4c5f0abec619..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/MoneyProto.java +++ /dev/null @@ -1,51 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/money.proto - -package com.google.type; - -public final class MoneyProto { - private MoneyProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_type_Money_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_type_Money_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\027google/type/money.proto\022\013google.type\"<" + - "\n\005Money\022\025\n\rcurrency_code\030\001 \001(\t\022\r\n\005units\030" + - "\002 \001(\003\022\r\n\005nanos\030\003 \001(\005B\037\n\017com.google.typeB" + - "\nMoneyProtoP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_google_type_Money_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_type_Money_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_type_Money_descriptor, - new java.lang.String[] { "CurrencyCode", "Units", "Nanos", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDay.java b/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDay.java deleted file mode 100644 index 494356df0c58..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDay.java +++ /dev/null @@ -1,659 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/timeofday.proto - -package com.google.type; - -/** - * Protobuf type {@code google.type.TimeOfDay} - * - *
      - * Represents a time of day. The date and time zone are either not significant
      - * or are specified elsewhere. An API may chose to allow leap seconds. Related
      - * types are [google.type.Date][google.type.Date] and [google.protobuf.Timestamp][google.protobuf.Timestamp].
      - * 
      - */ -public final class TimeOfDay extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.type.TimeOfDay) - TimeOfDayOrBuilder { - // Use TimeOfDay.newBuilder() to construct. - private TimeOfDay(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private TimeOfDay() { - hours_ = 0; - minutes_ = 0; - seconds_ = 0; - nanos_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private TimeOfDay( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 8: { - - hours_ = input.readInt32(); - break; - } - case 16: { - - minutes_ = input.readInt32(); - break; - } - case 24: { - - seconds_ = input.readInt32(); - break; - } - case 32: { - - nanos_ = input.readInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.type.TimeOfDayProto.internal_static_google_type_TimeOfDay_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.type.TimeOfDayProto.internal_static_google_type_TimeOfDay_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.type.TimeOfDay.class, com.google.type.TimeOfDay.Builder.class); - } - - public static final int HOURS_FIELD_NUMBER = 1; - private int hours_; - /** - * optional int32 hours = 1; - * - *
      -   * Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
      -   * to allow the value "24:00:00" for scenarios like business closing time.
      -   * 
      - */ - public int getHours() { - return hours_; - } - - public static final int MINUTES_FIELD_NUMBER = 2; - private int minutes_; - /** - * optional int32 minutes = 2; - * - *
      -   * Minutes of hour of day. Must be from 0 to 59.
      -   * 
      - */ - public int getMinutes() { - return minutes_; - } - - public static final int SECONDS_FIELD_NUMBER = 3; - private int seconds_; - /** - * optional int32 seconds = 3; - * - *
      -   * Seconds of minutes of the time. Must normally be from 0 to 59. An API may
      -   * allow the value 60 if it allows leap-seconds.
      -   * 
      - */ - public int getSeconds() { - return seconds_; - } - - public static final int NANOS_FIELD_NUMBER = 4; - private int nanos_; - /** - * optional int32 nanos = 4; - * - *
      -   * Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
      -   * 
      - */ - public int getNanos() { - return nanos_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (hours_ != 0) { - output.writeInt32(1, hours_); - } - if (minutes_ != 0) { - output.writeInt32(2, minutes_); - } - if (seconds_ != 0) { - output.writeInt32(3, seconds_); - } - if (nanos_ != 0) { - output.writeInt32(4, nanos_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (hours_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(1, hours_); - } - if (minutes_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, minutes_); - } - if (seconds_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, seconds_); - } - if (nanos_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(4, nanos_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.type.TimeOfDay)) { - return super.equals(obj); - } - com.google.type.TimeOfDay other = (com.google.type.TimeOfDay) obj; - - boolean result = true; - result = result && (getHours() - == other.getHours()); - result = result && (getMinutes() - == other.getMinutes()); - result = result && (getSeconds() - == other.getSeconds()); - result = result && (getNanos() - == other.getNanos()); - return result; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptorForType().hashCode(); - hash = (37 * hash) + HOURS_FIELD_NUMBER; - hash = (53 * hash) + getHours(); - hash = (37 * hash) + MINUTES_FIELD_NUMBER; - hash = (53 * hash) + getMinutes(); - hash = (37 * hash) + SECONDS_FIELD_NUMBER; - hash = (53 * hash) + getSeconds(); - hash = (37 * hash) + NANOS_FIELD_NUMBER; - hash = (53 * hash) + getNanos(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.type.TimeOfDay parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.type.TimeOfDay parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.type.TimeOfDay parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.type.TimeOfDay parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.type.TimeOfDay parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.type.TimeOfDay parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.type.TimeOfDay parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.type.TimeOfDay parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.type.TimeOfDay parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.type.TimeOfDay parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.type.TimeOfDay prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.type.TimeOfDay} - * - *
      -   * Represents a time of day. The date and time zone are either not significant
      -   * or are specified elsewhere. An API may chose to allow leap seconds. Related
      -   * types are [google.type.Date][google.type.Date] and [google.protobuf.Timestamp][google.protobuf.Timestamp].
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.type.TimeOfDay) - com.google.type.TimeOfDayOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.type.TimeOfDayProto.internal_static_google_type_TimeOfDay_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.type.TimeOfDayProto.internal_static_google_type_TimeOfDay_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.type.TimeOfDay.class, com.google.type.TimeOfDay.Builder.class); - } - - // Construct using com.google.type.TimeOfDay.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - hours_ = 0; - - minutes_ = 0; - - seconds_ = 0; - - nanos_ = 0; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.type.TimeOfDayProto.internal_static_google_type_TimeOfDay_descriptor; - } - - public com.google.type.TimeOfDay getDefaultInstanceForType() { - return com.google.type.TimeOfDay.getDefaultInstance(); - } - - public com.google.type.TimeOfDay build() { - com.google.type.TimeOfDay result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.type.TimeOfDay buildPartial() { - com.google.type.TimeOfDay result = new com.google.type.TimeOfDay(this); - result.hours_ = hours_; - result.minutes_ = minutes_; - result.seconds_ = seconds_; - result.nanos_ = nanos_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.type.TimeOfDay) { - return mergeFrom((com.google.type.TimeOfDay)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.type.TimeOfDay other) { - if (other == com.google.type.TimeOfDay.getDefaultInstance()) return this; - if (other.getHours() != 0) { - setHours(other.getHours()); - } - if (other.getMinutes() != 0) { - setMinutes(other.getMinutes()); - } - if (other.getSeconds() != 0) { - setSeconds(other.getSeconds()); - } - if (other.getNanos() != 0) { - setNanos(other.getNanos()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.type.TimeOfDay parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.type.TimeOfDay) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private int hours_ ; - /** - * optional int32 hours = 1; - * - *
      -     * Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
      -     * to allow the value "24:00:00" for scenarios like business closing time.
      -     * 
      - */ - public int getHours() { - return hours_; - } - /** - * optional int32 hours = 1; - * - *
      -     * Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
      -     * to allow the value "24:00:00" for scenarios like business closing time.
      -     * 
      - */ - public Builder setHours(int value) { - - hours_ = value; - onChanged(); - return this; - } - /** - * optional int32 hours = 1; - * - *
      -     * Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
      -     * to allow the value "24:00:00" for scenarios like business closing time.
      -     * 
      - */ - public Builder clearHours() { - - hours_ = 0; - onChanged(); - return this; - } - - private int minutes_ ; - /** - * optional int32 minutes = 2; - * - *
      -     * Minutes of hour of day. Must be from 0 to 59.
      -     * 
      - */ - public int getMinutes() { - return minutes_; - } - /** - * optional int32 minutes = 2; - * - *
      -     * Minutes of hour of day. Must be from 0 to 59.
      -     * 
      - */ - public Builder setMinutes(int value) { - - minutes_ = value; - onChanged(); - return this; - } - /** - * optional int32 minutes = 2; - * - *
      -     * Minutes of hour of day. Must be from 0 to 59.
      -     * 
      - */ - public Builder clearMinutes() { - - minutes_ = 0; - onChanged(); - return this; - } - - private int seconds_ ; - /** - * optional int32 seconds = 3; - * - *
      -     * Seconds of minutes of the time. Must normally be from 0 to 59. An API may
      -     * allow the value 60 if it allows leap-seconds.
      -     * 
      - */ - public int getSeconds() { - return seconds_; - } - /** - * optional int32 seconds = 3; - * - *
      -     * Seconds of minutes of the time. Must normally be from 0 to 59. An API may
      -     * allow the value 60 if it allows leap-seconds.
      -     * 
      - */ - public Builder setSeconds(int value) { - - seconds_ = value; - onChanged(); - return this; - } - /** - * optional int32 seconds = 3; - * - *
      -     * Seconds of minutes of the time. Must normally be from 0 to 59. An API may
      -     * allow the value 60 if it allows leap-seconds.
      -     * 
      - */ - public Builder clearSeconds() { - - seconds_ = 0; - onChanged(); - return this; - } - - private int nanos_ ; - /** - * optional int32 nanos = 4; - * - *
      -     * Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
      -     * 
      - */ - public int getNanos() { - return nanos_; - } - /** - * optional int32 nanos = 4; - * - *
      -     * Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
      -     * 
      - */ - public Builder setNanos(int value) { - - nanos_ = value; - onChanged(); - return this; - } - /** - * optional int32 nanos = 4; - * - *
      -     * Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
      -     * 
      - */ - public Builder clearNanos() { - - nanos_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.type.TimeOfDay) - } - - // @@protoc_insertion_point(class_scope:google.type.TimeOfDay) - private static final com.google.type.TimeOfDay DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.type.TimeOfDay(); - } - - public static com.google.type.TimeOfDay getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public TimeOfDay parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new TimeOfDay(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.type.TimeOfDay getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayOrBuilder.java b/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayOrBuilder.java deleted file mode 100644 index d1eda79b5fb0..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayOrBuilder.java +++ /dev/null @@ -1,47 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/timeofday.proto - -package com.google.type; - -public interface TimeOfDayOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.type.TimeOfDay) - com.google.protobuf.MessageOrBuilder { - - /** - * optional int32 hours = 1; - * - *
      -   * Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
      -   * to allow the value "24:00:00" for scenarios like business closing time.
      -   * 
      - */ - int getHours(); - - /** - * optional int32 minutes = 2; - * - *
      -   * Minutes of hour of day. Must be from 0 to 59.
      -   * 
      - */ - int getMinutes(); - - /** - * optional int32 seconds = 3; - * - *
      -   * Seconds of minutes of the time. Must normally be from 0 to 59. An API may
      -   * allow the value 60 if it allows leap-seconds.
      -   * 
      - */ - int getSeconds(); - - /** - * optional int32 nanos = 4; - * - *
      -   * Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
      -   * 
      - */ - int getNanos(); -} diff --git a/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayProto.java b/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayProto.java deleted file mode 100644 index e995fee5b778..000000000000 --- a/gcloud-java-gax/generated/src/main/java/com/google/type/TimeOfDayProto.java +++ /dev/null @@ -1,52 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/type/timeofday.proto - -package com.google.type; - -public final class TimeOfDayProto { - private TimeOfDayProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_type_TimeOfDay_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_type_TimeOfDay_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\033google/type/timeofday.proto\022\013google.ty" + - "pe\"K\n\tTimeOfDay\022\r\n\005hours\030\001 \001(\005\022\017\n\007minute" + - "s\030\002 \001(\005\022\017\n\007seconds\030\003 \001(\005\022\r\n\005nanos\030\004 \001(\005B" + - "&\n\017com.google.typeB\016TimeOfDayProtoP\001\240\001\001b" + - "\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_google_type_TimeOfDay_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_type_TimeOfDay_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_type_TimeOfDay_descriptor, - new java.lang.String[] { "Hours", "Minutes", "Seconds", "Nanos", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java deleted file mode 100644 index 2e563a4413d0..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ApiCallable.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.grpc; - -import com.google.common.util.concurrent.ListenableFuture; - -import io.grpc.CallOptions; -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.ExperimentalApi; -import io.grpc.MethodDescriptor; -import io.grpc.MethodDescriptor.MethodType; -import io.grpc.StatusException; -import io.grpc.stub.ClientCalls; -import io.grpc.stub.StreamObserver; - -import java.util.Iterator; -import java.util.concurrent.Executor; - -import javax.annotation.Nullable; - -/** - * A callable is an object which represents one or more rpc calls. Various operators on callables - * produce new callables, representing common API programming patterns. Callables can be used to - * directly operate against an api, or to efficiently implement wrappers for apis which add - * additional functionality and processing. - * - *

      Technically, callables are a factory for grpc {@link ClientCall} objects, and can be executed - * by methods of the {@link ClientCalls} class. They also provide shortcuts for direct execution of - * the callable instance. - */ -@ExperimentalApi -public abstract class ApiCallable { - - // TODO(wrwg): Support interceptors and method/call option configurations. - - // Subclass Contract - // ================= - - /** - * Creates a new GRPC call from this callable. A channel may or may not be provided. - * If a channel is not provided, the callable must be bound to a channel. - */ - public abstract ClientCall newCall(@Nullable Channel channel); - - /** - * Return a descriptor for this callable, or null if none available. - */ - @Nullable public CallableDescriptor getDescriptor() { - return null; - } - - /** - * Gets the channel bound to this callable, or null, if none is bound to it. - */ - @Nullable public Channel getBoundChannel() { - return null; - } - - // Binding Callables - // ================= - - /** - * Returns a callable which is bound to the given channel. Operations on the result can - * omit the channel. If a channel is provided anyway, it overrides the bound channel. - */ - public ApiCallable bind(final Channel boundChannel) { - return new ApiCallable() { - @Override - public ClientCall newCall(@Nullable Channel channel) { - if (channel == null) { - // If the caller does not provide a channel, we use the bound one. - channel = boundChannel; - } - return ApiCallable.this.newCall(channel); - } - - @Override - @Nullable - public CallableDescriptor getDescriptor() { - return ApiCallable.this.getDescriptor(); - } - - @Override - @Nullable - public Channel getBoundChannel() { - return boundChannel; - } - }; - } - - // Running Callables - // ================= - - private void requireMethodType(MethodType type) { - MethodType actualType = getDescriptor() != null - ? getDescriptor().getMethodDescriptor().getType() : null; - if (actualType == null || actualType == MethodType.UNKNOWN || actualType.equals(type)) { - return; - } - throw new IllegalArgumentException(String.format( - "Requested method type '%s' differs from actual type '%s'", type, actualType)); - } - - /** - * Convenience method to run a unary callable synchronously. If no channel is provided, - * the callable must be bound to one. - */ - public ResponseT call(@Nullable Channel channel, RequestT request) { - requireMethodType(MethodType.UNARY); - return ClientCalls.blockingUnaryCall(newCall(channel), request); - } - - /** - * Convenience method to run a unary callable synchronously, without channel. Requires a callable - * which is bound to a channel. - */ - public ResponseT call(RequestT request) { - return call(null, request); - } - - /** - * Convenience method to run a unary callable asynchronously. If no channel is provided, - * the callable must be bound to one. - */ - public void asyncCall(@Nullable Channel channel, RequestT request, - StreamObserver responseObserver) { - requireMethodType(MethodType.UNARY); - ClientCalls.asyncUnaryCall(newCall(channel), request, responseObserver); - } - - /** - * Convenience method to run a unary callable asynchronously, without channel. Requires a callable - * which is bound to a channel. - */ - public void asyncCall(RequestT request, StreamObserver responseObserver) { - asyncCall(null, request, responseObserver); - } - - /** - * Convenience method to run a unary callable returning a future. If no channel is provided, - * the callable must be bound to one. - */ - public ListenableFuture futureCall(@Nullable Channel channel, RequestT request) { - requireMethodType(MethodType.UNARY); - return ClientCalls.futureUnaryCall(newCall(channel), request); - } - - /** - * Convenience method to run a unary callable returning a future, without a channel. Requires a - * callable which is bound to a channel. - */ - public ListenableFuture futureCall(RequestT request) { - return futureCall(null, request); - } - - /** - * Convenience method for a blocking server streaming call. If no channel is provided, - * the callable must be bound to one. - * - *

      Returns an iterable for the responses. Note the returned iterable can be used only once. - * Returning an Iterator would be more precise, but iterators cannot be used in Java for loops. - */ - public Iterable iterableResponseStreamCall(@Nullable Channel channel, - RequestT request) { - requireMethodType(MethodType.SERVER_STREAMING); - final Iterator result = - ClientCalls.blockingServerStreamingCall(newCall(channel), request); - return new Iterable() { - @Override - public Iterator iterator() { - return result; - } - }; - } - - /** - * Convenience method for a blocking server streaming call, without a channel. Requires a - * callable which is bound to a channel. - * - *

      Returns an iterable for the responses. Note the returned iterable can be used only once. - * Returning an Iterator would be more precise, but iterators cannot be used in Java for loops. - */ - public Iterable iterableResponseStreamCall(RequestT request) { - return iterableResponseStreamCall(null, request); - } - - // Creation - // ======== - - /** - * Returns a callable which executes the described method. - * - *

      -   *  Response response = Callable.create(SerivceGrpc.CONFIG.myMethod).call(channel, request);
      -   * 
      - */ - public static ApiCallable - create(MethodDescriptor descriptor) { - return create(CallableDescriptor.create(descriptor)); - } - - /** - * Returns a callable which executes the method described by a {@link CallableDescriptor}. - */ - public static ApiCallable - create(final CallableDescriptor descriptor) { - return new ApiCallable() { - @Override public ClientCall newCall(Channel channel) { - if (channel == null) { - throw new IllegalStateException(String.format( - "unbound callable for method '%s' requires a channel for execution", - descriptor.getMethodDescriptor().getFullMethodName())); - } - return channel.newCall(descriptor.getMethodDescriptor(), CallOptions.DEFAULT); - } - - @Override public CallableDescriptor getDescriptor() { - return descriptor; - } - - @Override public String toString() { - return descriptor.getMethodDescriptor().getFullMethodName(); - } - }; - } - - /** - * Returns a callable which executes the given function asynchronously on each provided - * input. The supplied executor is used for creating tasks for each input. Example: - * - *
      -   *  Callable.Transformer<RequestT, ResponseT> transformer = ...;
      -   *  Response response = Callable.create(transformer, executor).call(channel, request);
      -   * 
      - */ - public static ApiCallable - create(Transformer transformer, Executor executor) { - return new TransformingCallable(transformer, executor); - } - - - /** - * Returns a callable which executes the given function immediately on each provided input. - * Similar as {@link #create(Transformer, Executor)} but does not operate asynchronously and does - * not require an executor. - * - *

      Note that the callable returned by this method does not respect flow control. Some - * operations applied to it may deadlock because of this. However, it is safe to use this - * callable in the context of a {@link #followedBy(ApiCallable)} operation, which is the major - * use cases for transformers. But if you use a transformer to simulate a real rpc - * you should use {@link #create(Transformer, Executor)} instead. - */ - public static ApiCallable - create(Transformer transformer) { - return new TransformingCallable(transformer, null); - } - - /** - * Interface for a transformer. It can throw a {@link StatusException} to indicate an error. - */ - public interface Transformer { - ResponseT apply(RequestT request) throws StatusException; - } - - /** - * Returns a callable which echos its input. - */ - public static ApiCallable - identity() { - return new TransformingCallable(new Transformer() { - @Override public RequestT apply(RequestT request) throws StatusException { - return request; - } - }, null); - } - - /** - * Returns a callable which always returns the given constant. - */ - public static ApiCallable - constant(final ResponseT result) { - return new TransformingCallable(new Transformer() { - @Override public ResponseT apply(RequestT request) throws StatusException { - return result; - } - }, null); - } - - // Followed-By - // =========== - - /** - * Returns a callable which forwards the responses from this callable as requests into the other - * callable. Works both for unary and streaming operands. Example: - * - *

      -   * String bookName = ...;
      -   * Callable.Transformer<Book, GetAuthorRequest> bookToGetAuthorRequest = ...;
      -   * Author response =
      -   *     Callable.create(LibraryGrpc.CONFIG.getBook)
      -   *             .followedBy(Callable.create(bookToGetAuthorRequest))
      -   *             .followedBy(Callable.create(LibraryGrpc.CONFIG.getAuthor))
      -   *             .call(channel, new GetBookRequest().setName(bookName).build());
      -   * 
      - * - *

      For streaming calls, each output of the first callable will be forwarded to the second - * one as it arrives, allowing for streaming pipelines. - */ - public ApiCallable - followedBy(ApiCallable callable) { - return new FollowedByCallable(this, callable); - } - - // Retrying - // ======== - - /** - * Returns a callable which retries using exponential back-off on transient errors. Example: - * - *

      -   * Response response = Callable.create(METHOD).retrying().call(channel, request);
      -   * 
      - * - *

      The call will be retried if and only if the returned status code is {@code UNAVAILABLE}. - * - *

      No output will be produced until the underlying callable has succeeded. Applied to compound - * callables, this can be used to implement simple transactions supposed the underlying callables - * are either side-effect free or idempotent. - * - *

      Note that the retry callable requires to buffer all inputs and outputs of the underlying - * callable, and should be used with care when applied to streaming calls. - */ - public ApiCallable retrying() { - return new RetryingCallable(this); - } - - // Page Streaming - // ============== - - /** - * Returns a callable which streams the resources obtained from a series of calls to a method - * implementing the pagination pattern. Example: - * - *

      -   *  for (Resource resource :
      -   *       Callable.create(listBooksDescriptor)
      -   *               .pageStreaming(pageDescriptor)
      -   *               .iterableResponseStreamCall(channel, request)) {
      -   *    doSomething(resource);
      -   *  }
      -   *
      - * - *

      The returned stream does not buffer results; if it is traversed again, the API will be - * called again. - */ - public ApiCallable - pageStreaming(PageDescriptor pageDescriptor) { - return new PageStreamingCallable(this, pageDescriptor); - } - -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CallableDescriptor.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CallableDescriptor.java deleted file mode 100644 index b2c3a6952e32..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CallableDescriptor.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.grpc; - -import com.google.common.base.Preconditions; - -import io.grpc.ExperimentalApi; -import io.grpc.MethodDescriptor; - -import javax.annotation.Nullable; - -/** - * Describes meta data for a {@link ApiCallable}. - */ -@ExperimentalApi -class CallableDescriptor { - - /** - * Constructs a descriptor from grpc descriptor. - */ - public static CallableDescriptor - create(MethodDescriptor grpcDescriptor) { - return new CallableDescriptor(grpcDescriptor); - } - - private final MethodDescriptor descriptor; - - private CallableDescriptor(MethodDescriptor descriptor) { - this.descriptor = Preconditions.checkNotNull(descriptor); - } - - /** - * Returns the grpc method descriptor. - */ - public MethodDescriptor getMethodDescriptor() { - return descriptor; - } - - /** - * Returns a page descriptor if one is derivable from the callable descriptor, null if not. - * By default, this returns null, but sub-classes may override this. - */ - @Nullable public PageDescriptor - getPageDescriptor(@SuppressWarnings("unused") Class resourceType) { - return null; - } -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CompoundClientCall.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CompoundClientCall.java deleted file mode 100644 index 99b8aaa35fbd..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/CompoundClientCall.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.grpc; - -import io.grpc.ClientCall; -import io.grpc.Metadata; -import io.grpc.Status; - -/** - * A helper to implement compound calls which is used for the implementation of other callables in - * this package. This allows to have the listener and call types being implemented from one class, - * which is not possible out-of-the-box because {@link ClientCall} is a class, not an interface. - * (Note that in Java8 ClientCall could be an interface, because it does not has instance data.) - */ -abstract class CompoundClientCall - extends ClientCall { - - private final InnerListener listener = new InnerListener(); - - void onHeaders(@SuppressWarnings("unused") Metadata headers) { - // We typically ignore response headers in compound calls. - } - - abstract void onMessage(InnerResT message); - - abstract void onClose(Status status, Metadata trailers); - - final ClientCall.Listener listener() { - return listener; - } - - class InnerListener extends ClientCall.Listener { - - @Override - public void onHeaders(Metadata headers) { - CompoundClientCall.this.onHeaders(headers); - } - - @Override - public void onMessage(InnerResT message) { - CompoundClientCall.this.onMessage(message); - } - - @Override - public void onClose(Status status, Metadata trailers) { - CompoundClientCall.this.onClose(status, trailers); - } - } -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/FollowedByCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/FollowedByCallable.java deleted file mode 100644 index 3fe019153c15..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/FollowedByCallable.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.grpc; - -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.Metadata; -import io.grpc.Status; - -import javax.annotation.Nullable; - -/** - * Helper type for the implementation of {@link ApiCallable} methods. Please see there first for the - * specification of what this is doing. This class is concerned with the how. - * - *

      Implements the followedBy callable, which executes two callables in parallel, piping output - * from the first to the second. - */ -class FollowedByCallable extends ApiCallable { - - private final ApiCallable first; - private final ApiCallable second; - - FollowedByCallable(ApiCallable first, ApiCallable second) { - this.first = first; - this.second = second; - } - - @Override - public String toString() { - return String.format("followedBy(%s, %s)", first, second); - } - - @Override - @Nullable - public Channel getBoundChannel() { - // Inherit a bound channel from operands. - Channel channel = first.getBoundChannel(); - if (channel != null) { - return channel; - } - return second.getBoundChannel(); - } - - @Override - public ClientCall newCall(Channel channel) { - return new FollowedByCall(channel); - } - - /** - * Both calls are started in parallel, and the output from the first is immediately piped as input - * into the second. As we don't know the required input for the second call, we request all output - * from the first as soon as some output for the composite is requested. - */ - private class FollowedByCall extends CompoundClientCall { - - private Channel channel; - private ClientCall firstCall; - private ClientCall secondCall; - private ClientCall.Listener listener; - - private FollowedByCall(Channel channel) { - this.channel = channel; - } - - @Override - public void start(ClientCall.Listener listener, Metadata headers) { - this.listener = listener; - this.firstCall = first.newCall(channel); - this.secondCall = second.newCall(channel); - - // This instance's listener will receive output from the first call. - this.firstCall.start(this.listener(), headers); - - // The ForwardingCallable listener will receive output from the second call. - this.secondCall.start(listener, headers); - } - - @Override - public void request(int numMessages) { - // We don't know how much inputs the second call needs, so we request all what is available. - firstCall.request(Integer.MAX_VALUE); - secondCall.request(numMessages); - } - - @Override - public void cancel() { - firstCall.cancel(); - secondCall.cancel(); - } - - @Override - public void sendMessage(RequestT message) { - firstCall.sendMessage(message); - } - - @Override - public void halfClose() { - firstCall.halfClose(); - } - - @Override - public void onMessage(InterT message) { - secondCall.sendMessage(message); - } - - @Override - public void onClose(Status status, Metadata trailers) { - if (status.isOk()) { - secondCall.halfClose(); - return; - } - secondCall.cancel(); - listener.onClose(status, trailers); - } - } -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageDescriptor.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageDescriptor.java deleted file mode 100644 index b8f47957e9db..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageDescriptor.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.grpc; - -import io.grpc.ExperimentalApi; - -/** - * An interface which describes the paging pattern. - */ -@ExperimentalApi -public interface PageDescriptor { - - /** - * Delivers the empty page token. - */ - Object emptyToken(); - - /** - * Injects a page token into the request. - */ - RequestT injectToken(RequestT payload, Object token); - - /** - * Extracts the next token from the response. Returns the empty token if there are - * no more pages. - */ - Object extractNextToken(ResponseT payload); - - /** - * Extracts an iterable of resources from the response. - */ - Iterable extractResources(ResponseT payload); -} \ No newline at end of file diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageStreamingCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageStreamingCallable.java deleted file mode 100644 index d864ec4fc562..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/PageStreamingCallable.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.grpc; - -import com.google.common.base.Preconditions; - -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.Metadata; -import io.grpc.Status; - -import java.util.concurrent.Semaphore; - -import javax.annotation.Nullable; - -/** - * Helper type for the implementation of {@link ApiCallable} methods. Please see there first for the - * specification of what this is doing. This class is concerned with the how. - * - *

      Implementation of the pageStreaming callable. - */ -class PageStreamingCallable extends ApiCallable { - - private final ApiCallable callable; - private final PageDescriptor pageDescriptor; - - - PageStreamingCallable(ApiCallable callable, - PageDescriptor pageDescriptor) { - this.callable = Preconditions.checkNotNull(callable); - this.pageDescriptor = Preconditions.checkNotNull(pageDescriptor); - } - - @Override public String toString() { - return String.format("pageStreaming(%s)", callable.toString()); - } - - @Override - @Nullable - public Channel getBoundChannel() { - return callable.getBoundChannel(); - } - - @Override - public ClientCall newCall(Channel channel) { - return new PageStreamingCall(channel); - } - - /** - * Class which handles both the call logic for the callable and listens to page call responses. - * - *

      The implementation uses a semaphore to handle flow control, since the callable level flow - * control via request() doesn't map 1:1 to the page call flow control. The semaphore holds at any - * time the number of requested messages on callable level. Blocking on the semaphore happens - * exclusively in onMessage() calls for pages. Apart of the first page call which is scheduled at - * the time the caller half-closes, all future page calls will be triggered from onMessage() as - * well. This avoids thread safety issues, assuming the ClientCall concurrency contract. - */ - private class PageStreamingCall extends CompoundClientCall { - - private final Channel channel; - private ClientCall.Listener outerListener; - private Metadata headers; - private RequestT request; - private Semaphore requestedSemaphore = new Semaphore(0); - private ClientCall currentCall; - private Object nextPageToken = pageDescriptor.emptyToken(); - private boolean sentClose; - - private PageStreamingCall(Channel channel) { - this.channel = channel; - } - - @Override - public void start(ClientCall.Listener responseListener, Metadata headers) { - this.outerListener = responseListener; - this.headers = headers; - currentCall = callable.newCall(channel); - currentCall.start(listener(), headers); - } - - @Override - public void request(int numMessages) { - requestedSemaphore.release(numMessages); - } - - @Override - public void sendMessage(RequestT request) { - Preconditions.checkState(this.request == null); - this.request = request; - } - - @Override - public void halfClose() { - // Trigger the call for the first page. - requestNextPage(); - } - - @Override - public void cancel() { - currentCall.cancel(); - if (!sentClose) { - outerListener.onClose(Status.CANCELLED, new Metadata()); - } - } - - @SuppressWarnings("unchecked") - private void requestNextPage() { - currentCall.request(1); - currentCall.sendMessage(pageDescriptor.injectToken(request, nextPageToken)); - currentCall.halfClose(); - } - - @Override - public void onMessage(ResponseT response) { - // Extract the token for the next page. If empty, there are no more pages, - // and we set the token to null. - Object token = pageDescriptor.extractNextToken(response); - nextPageToken = token.equals(pageDescriptor.emptyToken()) ? null : token; - - // Deliver as much resources as have been requested. This may block via - // our semaphore, and while we are delivering, more requests may come in. - for (ResourceT resource : pageDescriptor.extractResources(response)) { - try { - requestedSemaphore.acquire(); - } catch (InterruptedException e) { - outerListener.onClose(Status.fromThrowable(e), new Metadata()); - sentClose = true; - currentCall.cancel(); - return; - } - outerListener.onMessage(resource); - } - - // If there is a next page, create a new call and request it. - if (nextPageToken != null) { - currentCall = callable.newCall(channel); - currentCall.start(listener(), headers); - requestNextPage(); - } else { - outerListener.onClose(Status.OK, new Metadata()); - sentClose = true; - } - } - - @Override - public void onClose(Status status, Metadata trailers) { - if (!status.isOk()) { - // If there is an error, propagate it. Otherwise let onMessage determine how to continue. - outerListener.onClose(status, trailers); - sentClose = true; - } - } - } -} - diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/RetryingCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/RetryingCallable.java deleted file mode 100644 index d476890c85e9..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/RetryingCallable.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.grpc; - -import com.google.common.base.Throwables; -import com.google.common.collect.Lists; - -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.Metadata; -import io.grpc.Status; - -import java.util.List; -import java.util.Random; - -import javax.annotation.Nullable; - -/** - * Helper type for the implementation of {@link ApiCallable} methods. Please see there first for the - * specification of what this is doing. This class is concerned with the how. - * - *

      Implementation of the retrying callable. - */ -class RetryingCallable extends ApiCallable { - - // TODO(wgg): make the parameters below configurable. They are currently taken from - // http://en.wikipedia.org/wiki/Exponential_backoff. - - private static final int SLOT_TIME_MILLIS = 2; - private static final int TRUNCATE_AFTER = 10; - private static final int MAX_ATTEMPTS = 16; - private static final Random randomGenerator = new Random(0); - - private final ApiCallable callable; - - RetryingCallable(ApiCallable callable) { - this.callable = callable; - } - - @Override public String toString() { - return String.format("retrying(%s)", callable.toString()); - } - - @Override - @Nullable - public CallableDescriptor getDescriptor() { - return callable.getDescriptor(); - } - - @Override - @Nullable - public Channel getBoundChannel() { - return callable.getBoundChannel(); - } - - @Override public ClientCall newCall(Channel channel) { - return new RetryingCall(channel); - } - - private static boolean canRetry(Status status) { - return status.getCode() == Status.Code.UNAVAILABLE; - } - - /** - * Class implementing the call for retry. - * - *

      This remembers all actions from the caller in order to replay the call if needed. No output - * will be produced until the call has successfully ended. Thus this call requires full buffering - * of inputs and outputs, - */ - private class RetryingCall extends CompoundClientCall { - - private final Channel channel; - private ClientCall.Listener listener; - private int requested; - private Metadata requestHeaders; - private final List requestPayloads = Lists.newArrayList(); - private final List responsePayloads = Lists.newArrayList(); - private Metadata responseHeaders; - private int attempt; - private ClientCall currentCall; - - private RetryingCall(Channel channel) { - this.channel = channel; - } - - @Override - public void start(ClientCall.Listener listener, Metadata headers) { - this.listener = listener; - requestHeaders = headers; - currentCall = callable.newCall(channel); - currentCall.start(listener(), headers); - } - - @Override - public void request(int numMessages) { - requested += numMessages; - currentCall.request(numMessages); - } - - @Override - public void cancel() { - currentCall.cancel(); - } - - @Override - public void halfClose() { - currentCall.halfClose(); - } - - @Override - public void sendMessage(RequestT message) { - requestPayloads.add(message); - currentCall.sendMessage(message); - } - - @Override - public void onHeaders(Metadata headers) { - responseHeaders = headers; - } - - @Override - void onMessage(ResponseT message) { - responsePayloads.add(message); - } - - @Override - public void onClose(Status status, Metadata trailers) { - if (status.isOk() || !canRetry(status) || attempt >= MAX_ATTEMPTS) { - // Call succeeded or failed non-transiently or failed too often; feed underlying listener - // with the result. - if (status.isOk()) { - if (responseHeaders != null) { - listener.onHeaders(responseHeaders); - } - for (ResponseT response : responsePayloads) { - listener.onMessage(response); - } - } - listener.onClose(status, trailers); - return; - } - - // Sleep using duration calculated by exponential backoff algorithm. - attempt++; - int slots = 1 << (attempt - 1 > TRUNCATE_AFTER ? TRUNCATE_AFTER : attempt - 1); - int slot = randomGenerator.nextInt(slots); - if (slot > 0) { - try { - Thread.sleep(SLOT_TIME_MILLIS * slot); - } catch (InterruptedException e) { - throw Throwables.propagate(e); - } - } - - // Start call again. - responseHeaders = null; - responsePayloads.clear(); - currentCall = callable.newCall(channel); - currentCall.start(listener(), requestHeaders); - currentCall.request(requested); - for (RequestT request : requestPayloads) { - currentCall.sendMessage(request); - } - currentCall.halfClose(); - } - } -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java deleted file mode 100644 index eb3ca2b7a9d9..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/ServiceApiSettings.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.grpc; - -import com.google.auth.Credentials; - -import io.grpc.ManagedChannel; - -/** - * A settings class to configure a service api class. - */ -public class ServiceApiSettings { - private boolean isIdempotentRetrying; - - private Credentials credentials; - - private String serviceAddress; - private int port; - - private ManagedChannel channel; - - public ServiceApiSettings() { - isIdempotentRetrying = true; - credentials = null; - serviceAddress = null; - port = 0; - } - - /** - * Set to true in order to have the service retry all idempotent methods, - * set to false otherwise. The default is true. This setting generally translates to - * doing retries for calls which perform gets, deletes, and updates, but not calls which - * perform creates. - */ - public ServiceApiSettings setIsIdempotentRetrying(boolean isIdempotentRetrying) { - this.isIdempotentRetrying = isIdempotentRetrying; - return this; - } - - public boolean getIsIdempotentRetrying() { - return isIdempotentRetrying; - } - - /** - * Sets the credentials to use in order to call the service. The default is to acquire - * the credentials using GoogleCredentials.getApplicationDefault(). These credentials - * will not be used if the channel is set. - */ - public ServiceApiSettings setCredentials(Credentials credentials) { - this.credentials = credentials; - return this; - } - - public Credentials getCredentials() { - return credentials; - } - - /** - * The path used to reach the service. This value will not be used if the channel is set. - */ - public ServiceApiSettings setServiceAddress(String serviceAddress) { - this.serviceAddress = serviceAddress; - return this; - } - - public String getServiceAddress() { - return serviceAddress; - } - - /** - * The port used to reach the service. This value will not be used if the channel is set. - */ - public ServiceApiSettings setPort(int port) { - this.port = port; - return this; - } - - public int getPort() { - return port; - } - - /** - * The channel used to send requests to the service. Whichever service api class that - * this instance of ServiceApiSettings is passed to will call shutdown() on this - * channel. This injection mechanism is intended for use by unit tests to override - * the channel that would be created by default for real calls to the service. - */ - public ServiceApiSettings setChannel(ManagedChannel channel) { - this.channel = channel; - return this; - } - - public ManagedChannel getChannel() { - return channel; - } -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/TransformingCallable.java b/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/TransformingCallable.java deleted file mode 100644 index 507194a50688..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/grpc/TransformingCallable.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.grpc; - -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; - -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.Metadata; -import io.grpc.Status; -import io.grpc.StatusException; -import io.grpc.internal.SerializingExecutor; - -import java.util.concurrent.Executor; -import java.util.concurrent.Semaphore; - -import javax.annotation.Nullable; - -/** - * Helper type for the implementation of {@link ApiCallable} methods. Please see there first for the - * specification of what this is doing. This class is concerned with the how. - * - *

      Implements the transform callable, which executes a function to produce a stream of responses - * from a stream of requests. - */ -class TransformingCallable extends ApiCallable { - - private final Transformer transformer; - @Nullable private final Executor executor; - - TransformingCallable(Transformer transformer, - Executor executor) { - this.transformer = Preconditions.checkNotNull(transformer); - this.executor = executor; - } - - @Override - public String toString() { - return "transforming(...)"; - } - - @Override - public ClientCall newCall(Channel channel) { - return new TransformCall(); - } - - /** - * Implements the transforming call. If an executor is provided, delivery of results will - * happen asynchronously and flow control is respected. If not, results will be delivered - * to the listener immediately on sendMessage(). This violates the ClientCall contract as - * methods on Call are supposed to be non-blocking, whereas methods on Listener can block. - * In most practical cases, this should not matter (see also high-level documentation in - * Callable). - * - *

      Note that this class does not need to be thread-safe since (a) the contract for - * ClientCall does not require thread-safeness (b) we use a SerializingExecutor for - * asynchronous callbacks which is guaranteed to run not more than one thread. - */ - private class TransformCall extends ClientCall { - - private final SerializingExecutor callExecutor = - executor == null ? null : new SerializingExecutor(executor); - private final Semaphore semaphore = new Semaphore(0); - private ClientCall.Listener listener; - private boolean sentClose; - - @Override - public void start(ClientCall.Listener listener, Metadata headers) { - this.listener = listener; - } - - @Override - public void request(int numMessages) { - if (callExecutor != null) { - semaphore.release(numMessages); - } - } - - @Override - public void cancel() { - if (!sentClose) { - listener.onClose(Status.CANCELLED, new Metadata()); - sentClose = true; - } - } - - @Override - public void sendMessage(final RequestT message) { - if (callExecutor == null) { - doSend(message); - return; - } - callExecutor.execute(new Runnable() { - @Override public void run() { - try { - semaphore.acquire(); - doSend(message); - } catch (Throwable t) { - cancel(); - throw Throwables.propagate(t); - } - } - }); - } - - @SuppressWarnings("deprecation") // e.getStatus() - private void doSend(RequestT message) { - try { - listener.onMessage(transformer.apply(message)); - } catch (StatusException e) { - sentClose = true; - listener.onClose(e.getStatus(), new Metadata()); - } catch (Throwable t) { - // TODO(wgg): should we throw anything else here, or catch like below? Catching might - // be an issue for debugging. - sentClose = true; - listener.onClose(Status.fromThrowable(t), new Metadata()); - } - } - - @Override - public void halfClose() { - if (callExecutor == null) { - doClose(); - return; - } - callExecutor.execute(new Runnable() { - @Override public void run() { - doClose(); - } - }); - } - - private void doClose() { - if (!sentClose) { - sentClose = true; - listener.onClose(Status.OK, new Metadata()); - } - } - } -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java b/gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java deleted file mode 100644 index 3327db0c0211..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/internal/ApiUtils.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.internal; - -import com.google.auth.Credentials; -import com.google.auth.oauth2.GoogleCredentials; -import com.google.common.collect.Lists; - -import io.gapi.gax.grpc.ApiCallable; -import io.gapi.gax.grpc.ServiceApiSettings; -import io.grpc.ClientInterceptor; -import io.grpc.ManagedChannel; -import io.grpc.auth.ClientAuthInterceptor; -import io.grpc.netty.NegotiationType; -import io.grpc.netty.NettyChannelBuilder; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.Executors; - -public class ApiUtils { - - // TODO(wgg): make this configurable - private static final int AUTH_THREADS = 4; - - public static ApiCallable prepareIdempotentCallable( - ApiCallable callable, ServiceApiSettings settings) { - ApiCallable theCallable = callable; - if (settings.getIsIdempotentRetrying()) { - theCallable = theCallable.retrying(); - } - return theCallable; - } - - /** - * Acquires application-default credentials, applying the given scopes if the - * credentials require scopes. - */ - public static Credentials credentialsWithScopes(String scopes[]) throws IOException { - List scopeList = Arrays.asList(scopes); - GoogleCredentials credentials = GoogleCredentials.getApplicationDefault(); - if (credentials.createScopedRequired()) { - credentials = credentials.createScoped(scopeList); - } - return credentials; - } - - /** - * Creates a channel for the given address, port, and credentials. - */ - public static ManagedChannel createChannel(String address, int port, Credentials credentials) - throws IOException { - List interceptors = Lists.newArrayList(); - //TODO: MIGRATION interceptors.add(ChannelFactory.authorityInterceptor(address)); - - interceptors.add(new ClientAuthInterceptor(credentials, - Executors.newFixedThreadPool(AUTH_THREADS))); - - return NettyChannelBuilder - .forAddress(address, port) - .negotiationType(NegotiationType.TLS) - .intercept(interceptors) - .build(); - } - - /** - * Creates a new instance of ServiceApiSettings with all fields populated, using - * the given defaults if the corresponding values are not set on ServiceApiSettings. - */ - public static ServiceApiSettings populateSettings(ServiceApiSettings settings, - String defaultServiceAddress, int defaultServicePort, String scopes[]) throws IOException { - ManagedChannel channel = settings.getChannel(); - - if (channel == null) { - String servicePath = settings.getServiceAddress(); - if (servicePath == null) { - servicePath = defaultServiceAddress; - } - - int port = settings.getPort(); - if (port == 0) { - port = defaultServicePort; - } - - Credentials credentials = settings.getCredentials(); - if (credentials == null) { - credentials = credentialsWithScopes(scopes); - } - - channel = ApiUtils.createChannel(servicePath, port, credentials); - } - - return new ServiceApiSettings() - .setChannel(channel) - .setIsIdempotentRetrying(settings.getIsIdempotentRetrying()); - } -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java deleted file mode 100644 index a20c2b6a1f10..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/PathTemplate.java +++ /dev/null @@ -1,881 +0,0 @@ -package io.gapi.gax.protobuf; - -import com.google.auto.value.AutoValue; -import com.google.common.annotations.Beta; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.annotation.Nullable; - -/** - * Represents a path template. - * - *

      Templates use the syntax of the API platform; see the protobuf of {@link HttpRule} for - * details. A template consists of a sequence of literals, wildcards, and variable bindings, - * where each binding can have a sub-path. A string representation can be parsed into an - * instance of {@link PathTemplate}, which can then be used to perform matching and instantiation. - * - *

      Matching and instantiation deals with unescaping and escaping using URL encoding rules. For - * example, if a template variable for a single segment is instantiated with a string like - * {@code "a/b"}, the slash will be escaped to {@code "%2f"}. (Note that slash will not be escaped - * for a multiple-segment variable, but other characters will). The literals in the template - * itself are not escaped automatically, and must be already URL encoded. - * - *

      Here is an example for a template using simple variables: - *

      - *   PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}");
      - *   assert template.match("v2/shelves"} == false
      - *   Map<String, String> values = template.match("v1/shelves/s1/books/b1");
      - *   assert values.equals(ImmutableMap.of("shelf", s1", "book", "b1");
      - *   assert template.instantiate(values).equals("v1/shelves/s1/books/b1");
      - * 
      - * - * Templates can use variables which match sub-paths. Example: - *
      - *   PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}"};
      - *   assert template.match("v1/shelves/books/b1") == null;
      - *   assert template.match("v1/shelves/s1/books/b1")
      - *                  .equals(ImmutableMap.of("name", "shelves/s1/books/b1"));
      - * 
      - * - * Path templates can also be used with only wildcards. Each wildcard is associated - * with an implicit variable {@code $n}, where n is the zero-based position of the - * wildcard. Example: - *
      - *   PathTemplate template = PathTemplate.create("shelves/*/books/*"};
      - *   assert template.match("shelves/books/b1") == null;
      - *   Map<String, String> values = template.match("v1/shelves/s1/books/b1");
      - *   assert values.equals(ImmutableMap.of("$0", s1", "$1", "b1");
      - * 
      - * - * Paths input to matching can use URL relative syntax to indicate a host name by prefixing the - * host name, as in {@code //somewhere.io/some/path}. The host name is matched into the special - * variable {@link #HOSTNAME_VAR}. Patterns are agnostic about host names, and the same pattern - * can be used for URL relative syntax and simple path syntax: - *
      - *   PathTemplate template = PathTemplate.create("shelves/*"};
      - *   assert template.match("//somewhere.io/shelves/s1")
      - *                  .equals(ImmutableMap.of(PathTemplate.HOSTNAME_VAR, "//somewhere.io",
      - *                                          "$0", "s1"));
      - *   assert template.match("shelves/s1")
      - *                  .equals(ImmutableMap.of("$0", "s1"));
      - * 
      - * - * For the representation of a resource name see {@link ResourceName}, which is based - * on path templates. - */ -@Beta -public class PathTemplate { - - /** - * A constant identifying the special variable used for endpoint bindings in - * the result of {@link #matchFromFullName(String)}. - */ - public static final String HOSTNAME_VAR = "$hostname"; - - // A regexp to match a custom verb at the end of a path. - private static final Pattern CUSTOM_VERB_PATTERN = Pattern.compile(":([^/*}{=]+)$"); - - // A splitter on slash. - private static final Splitter SLASH_SPLITTER = Splitter.on('/').trimResults(); - - // Helper Types - // ============ - - /** - * Specifies a path segment kind. - */ - enum SegmentKind { - /** A literal path segment. */ - LITERAL, - - /** A custom verb. Can only appear at the end of path. */ - CUSTOM_VERB, - - /** A simple wildcard ('*'). */ - WILDCARD, - - /** A path wildcard ('**'). */ - PATH_WILDCARD, - - /** A field binding start. */ - BINDING, - - /** A field binding end. */ - END_BINDING, - } - - /** - * Specifies a path segment. - */ - @AutoValue - abstract static class Segment { - - /** - * A constant for the WILDCARD segment. - */ - private static final Segment WILDCARD = create(SegmentKind.WILDCARD, "*"); - - /** - * A constant for the PATH_WILDCARD segment. - */ - private static final Segment PATH_WILDCARD = create(SegmentKind.PATH_WILDCARD, "**"); - - /** - * A constant for the END_BINDING segment. - */ - private static final Segment END_BINDING = create(SegmentKind.END_BINDING, ""); - - /** - * Creates a segment of given kind and value. - */ - private static Segment create(SegmentKind kind, String value) { - return new AutoValue_PathTemplate_Segment(kind, value); - } - - /** - * The path segment kind. - */ - abstract SegmentKind kind(); - - /** - * The value for the segment. For literals, custom verbs, and wildcards, this reflects the value - * as it appears in the template. For bindings, this represents the variable of the binding. - */ - abstract String value(); - - /** - * Returns true of this segment is one of the wildcards, - */ - boolean isAnyWildcard() { - return kind() == SegmentKind.WILDCARD || kind() == SegmentKind.PATH_WILDCARD; - } - - String separator() { - switch (kind()) { - case CUSTOM_VERB: - return ":"; - case END_BINDING: - return ""; - default: - return "/"; - } - } - } - - /** - * Creates a path template from a string. The string must satisfy the syntax - * of path templates of the API platform; see {@link HttpRule}'s proto source. - * - * @throws ValidationException if there are errors while parsing the template. - */ - public static PathTemplate create(String template) { - return new PathTemplate(parseTemplate(template)); - } - - // Instance State and Methods - // ========================== - - // List of segments of this template. - private final ImmutableList segments; - - // Map from variable names to bindings in the template. - private final ImmutableMap bindings; - - private PathTemplate(Iterable segments) { - this.segments = ImmutableList.copyOf(segments); - if (this.segments.isEmpty()) { - throw new ValidationException("template cannot be empty."); - } - Map bindings = Maps.newLinkedHashMap(); - for (Segment seg : this.segments) { - if (seg.kind() == SegmentKind.BINDING) { - if (bindings.containsKey(seg.value())) { - throw new ValidationException("Duplicate binding '%s'", seg.value()); - } - bindings.put(seg.value(), seg); - } - } - this.bindings = ImmutableMap.copyOf(bindings); - } - - /** - * Returns the set of variable names used in the template. - */ - public Set vars() { - return bindings.keySet(); - } - - /** - * Returns a template for the parent of this template. - * - * @throws ValidationException if the template has no parent. - */ - public PathTemplate parentTemplate() { - int i = segments.size(); - Segment seg = segments.get(--i); - if (seg.kind() == SegmentKind.END_BINDING) { - while (i > 0 && segments.get(--i).kind() != SegmentKind.BINDING) {} - } - if (i == 0) { - throw new ValidationException("template does not have a parent"); - } - return new PathTemplate(segments.subList(0, i)); - } - - /** - * Returns a template where all variable bindings have been replaced by wildcards, but - * which is equivalent regards matching to this one. - */ - public PathTemplate withoutVars() { - StringBuilder result = new StringBuilder(); - ListIterator iterator = segments.listIterator(); - boolean start = true; - while (iterator.hasNext()) { - Segment seg = iterator.next(); - switch (seg.kind()) { - case BINDING: - case END_BINDING: - break; - default: - if (!start) { - result.append(seg.separator()); - } else { - start = false; - } - result.append(seg.value()); - } - } - return create(result.toString()); - } - - /** - * Returns a path template for the sub-path of the given variable. Example: - * - *
      -   *   PathTemplate template = PathTemplate.create("v1/{name=shelves/*/books/*}");
      -   *   assert template.subTemplate("name").toString().equals("shelves/*/books/*");
      -   * 
      - * - * The returned template will never have named variables, but only wildcards, which are - * dealt with in matching and instantiation using '$n'-variables. See the documentation of - * {@link #match(String)} and {@link #instantiate(Map)}, respectively. - * - *

      For a variable which has no sub-path, this returns a path template with a single wildcard - * ('*'). - * - * @throws ValidationException if the variable does not exist in the template. - */ - public PathTemplate subTemplate(String varName) { - List sub = Lists.newArrayList(); - boolean inBinding = false; - for (Segment seg : segments) { - if (seg.kind() == SegmentKind.BINDING && seg.value().equals(varName)) { - inBinding = true; - } else if (inBinding) { - if (seg.kind() == SegmentKind.END_BINDING) { - return PathTemplate.create(toSyntax(sub, true)); - } else { - sub.add(seg); - } - } - } - throw new ValidationException("Variable '%s' is undefined in template '%s'", - varName, this.toRawString()); - } - - /** - * Returns true of this template ends with a literal. - */ - public boolean endsWithLiteral() { - return segments.get(segments.size() - 1).kind() == SegmentKind.LITERAL; - } - - /** - * Returns true of this template ends with a custom verb. - */ - public boolean endsWithCustomVerb() { - return segments.get(segments.size() - 1).kind() == SegmentKind.CUSTOM_VERB; - } - - /** - * Creates a resource name from this template and a path. - * - * @throws ValidationException if the path does not match the template. - */ - public ResourceName parse(String path) { - return ResourceName.create(this, path); - } - - /** - * Returns the name of a singleton variable used by this template. If the template does not - * contain a single variable, returns null. - */ - @Nullable - public String singleVar() { - if (bindings.size() == 1) { - return bindings.entrySet().iterator().next().getKey(); - } - return null; - } - - // Template Matching - // ================= - - /** - * Returns true if the template matches the path. - */ - public boolean matches(String path) { - return match(path) != null; - } - - /** - * Matches the path, returning a map from variable names to matched values. All matched values - * will be properly unescaped using URL encoding rules. If the path does not match the template, - * null is returned. - * - * If the path starts with '//', the first segment will be interpreted as a host name and stored - * in the variable {@link #HOSTNAME_VAR}. - * - *

      See the {@link PathTemplate} class documentation for examples. - * - *

      For free wildcards in the template, the matching process creates variables named '$n', - * where 'n' is the wildcard's position in the template (starting at n=0). For example: - * - *

      -   *   PathTemplate template = PathTemplate.create("shelves/*/books/*");
      -   *   assert template.match("shelves/s1/books/b2")
      -   *              .equals(ImmutableMap.of("$0", "s1", "$1", "b1"));
      -   *   assert template.match("//somewhere.io/shelves/s1/books/b2")
      -   *              .equals(ImmutableMap.of(HOSTNAME_VAR, "//somewhere.io", "$0", "s1", "$1", "b1"));
      -   * 
      - * - * All matched values will be properly unescaped using URL encoding rules. - */ - @Nullable - public ImmutableMap match(String path) { - return match(path, false); - } - - /** - * Matches the path, where the first segment is interpreted as the host name regardless of - * whether it starts with '//' or not. Example: - * - *
      -   *   assert template("{name=shelves/*}").matchFromFullName("somewhere.io/shelves/s1")
      -   *            .equals(ImmutableMap.of(HOSTNAME_VAR, "somewhere.io", "name", "shelves/s1"));
      -   * 
      - */ - @Nullable - public ImmutableMap matchFromFullName(String path) { - return match(path, true); - } - - // Matches a path. - private ImmutableMap match(String path, boolean forceHostName) { - // Quick check for trailing custom verb. - Segment last = segments.get(segments.size() - 1); - if (last.kind() == SegmentKind.CUSTOM_VERB) { - Matcher matcher = CUSTOM_VERB_PATTERN.matcher(path); - if (!matcher.find() || !decodeUrl(matcher.group(1)).equals(last.value())) { - return null; - } - path = path.substring(0, matcher.start(0)); - } - - // Do full match. - boolean withHostName = path.startsWith("//"); - if (withHostName) { - path = path.substring(2); - } - List input = SLASH_SPLITTER.splitToList(path); - int inPos = 0; - Map values = Maps.newLinkedHashMap(); - if (withHostName || forceHostName) { - if (input.isEmpty()) { - return null; - } - String hostName = input.get(inPos++); - if (withHostName) { - // Put the // back, so we can distinguish this case from forceHostName. - hostName = "//" + hostName; - } - values.put(HOSTNAME_VAR, hostName); - } - if (!match(input, inPos, segments, 0, values)) { - return null; - } - return ImmutableMap.copyOf(values); - } - - // Tries to match the input based on the segments at given positions. Returns a boolean - // indicating whether the match was successful. - private static boolean match(List input, int inPos, List segments, int segPos, - Map values) { - String currentVar = null; - while (segPos < segments.size()) { - Segment seg = segments.get(segPos++); - switch (seg.kind()) { - case END_BINDING: - // End current variable binding scope. - currentVar = null; - continue; - case BINDING: - // Start variable binding scope. - currentVar = seg.value(); - continue; - default: - if (inPos >= input.size()) { - // End of input - return false; - } - // Check literal match. - String next = decodeUrl(input.get(inPos++)); - if (seg.kind() == SegmentKind.LITERAL) { - if (!seg.value().equals(next)) { - // Literal does not match. - return false; - } - } - if (currentVar != null) { - // Create or extend current match - String current = values.get(currentVar); - if (current == null) { - values.put(currentVar, next); - } else { - values.put(currentVar, current + "/" + next); - } - } - if (seg.kind() == SegmentKind.PATH_WILDCARD) { - // Compute the number of additional input the ** can consume. This - // is possible because we restrict patterns to have only one **. - int segsToMatch = 0; - for (int i = segPos; i < segments.size(); i++) { - switch (segments.get(i).kind()) { - case BINDING: - case END_BINDING: - // skip - continue; - default: - segsToMatch++; - } - } - int available = (input.size() - inPos) - segsToMatch; - while (available-- > 0) { - values.put(currentVar, values.get(currentVar) + "/" + decodeUrl(input.get(inPos++))); - } - } - } - } - return inPos == input.size(); - } - - // Template Instantiation - // ====================== - - /** - * Instantiate the template based on the given variable assignment. Performs proper - * URL escaping of variable assignments. - * - *

      Note that free wildcards in the template must have bindings of '$n' variables, where - * 'n' is the position of the wildcard (starting at 0). See the documentation of - * {@link #match(String)} for details. - * - * @throws ValidationException if a variable occurs in the template without a binding. - */ - public String instantiate(Map values) { - return instantiate(values, false); - } - - /** - * Shortcut for {@link #instantiate(Map)} with a vararg parameter for keys and values. - */ - public String instantiate(String... keysAndValues) { - ImmutableMap.Builder builder = ImmutableMap.builder(); - for (int i = 0; i < keysAndValues.length; i += 2) { - builder.put(keysAndValues[i], keysAndValues[i + 1]); - } - return instantiate(builder.build()); - } - - /** - * Same like {@link #instantiate(Map)} but allows for unbound variables, which are - * substituted using their original syntax. Example: - * - *

      -   *   PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}");
      -   *   assert template.instantiatePartial(ImmutableMap.of("shelf", "s1"))
      -   *             .equals("v1/shelves/s1/books/{book}");
      -   * 
      - * - * The result of this call can be used to create a new template. - */ - public String instantiatePartial(Map values) { - return instantiate(values, true); - } - - private String instantiate(Map values, boolean allowPartial) { - StringBuilder result = new StringBuilder(); - if (values.containsKey(HOSTNAME_VAR)) { - result.append(values.get(HOSTNAME_VAR)); - result.append('/'); - } - boolean continueLast = true; // Whether to not append separator - boolean skip = false; // Whether we are substituting a binding and segments shall be skipped. - ListIterator iterator = segments.listIterator(); - while (iterator.hasNext()) { - Segment seg = iterator.next(); - if (!skip && !continueLast) { - result.append(seg.separator()); - } - continueLast = false; - switch (seg.kind()) { - case BINDING: - String var = seg.value(); - String value = values.get(seg.value()); - if (value == null) { - if (!allowPartial) { - throw new ValidationException("Unbound variable '%s'. Bindings: %s", - var, values); - } - // Append pattern to output - if (var.startsWith("$")) { - // Eliminate positional variable. - result.append(iterator.next().value()); - iterator.next(); - continue; - } - result.append('{'); - result.append(seg.value()); - result.append('='); - continueLast = true; - continue; - } - Segment next = iterator.next(); - Segment nextNext = iterator.next(); - boolean pathEscape = next.kind() == SegmentKind.PATH_WILDCARD - || nextNext.kind() != SegmentKind.END_BINDING; - restore(iterator, iterator.nextIndex() - 2); - if (!pathEscape) { - result.append(encodeUrl(value)); - } else { - // For a path wildcard or path of length greater 1, split the value and escape - // every sub-segment. - boolean first = true; - for (String subSeg : SLASH_SPLITTER.split(value)) { - if (!first) { - result.append('/'); - } - first = false; - result.append(encodeUrl(subSeg)); - } - } - skip = true; - continue; - case END_BINDING: - if (!skip) { - result.append('}'); - } - skip = false; - continue; - default: - if (!skip) { - result.append(seg.value()); - } - } - } - return result.toString(); - } - - // Positional Matching and Instantiation - // ===================================== - - /** - * Instantiates the template from the given positional parameters. The template must not be build - * from named bindings, but only contain wildcards. Each parameter position corresponds to a - * wildcard of the according position in the template. - */ - public String encode(String... values) { - ImmutableMap.Builder builder = ImmutableMap.builder(); - int i = 0; - for (String value : values) { - builder.put("$" + i++, value); - } - // We will get an error if there are named bindings which are not reached by values. - return instantiate(builder.build()); - } - - /** - * Matches the template into a list of positional values. The template must not be build from - * named bindings, but only contain wildcards. For each wildcard in the template, a value - * is returned at corresponding position in the list. - */ - public List decode(String path) { - Map match = match(path); - if (match == null) { - throw new IllegalArgumentException(String.format("template '%s' does not match '%s'", - this, path)); - } - List result = Lists.newArrayList(); - for (Map.Entry entry : match.entrySet()) { - String key = entry.getKey(); - if (!key.startsWith("$")) { - throw new IllegalArgumentException("template must not contain named bindings"); - } - int i = Integer.parseInt(key.substring(1)); - while (result.size() <= i) { - result.add(""); - } - result.set(i, entry.getValue()); - } - return ImmutableList.copyOf(result); - } - - // Template Parsing - // ================ - - private static ImmutableList parseTemplate(String template) { - // Skip useless leading slash. - if (template.startsWith("/")) { - template = template.substring(1); - } - - // Extract trailing custom verb. - Matcher matcher = CUSTOM_VERB_PATTERN.matcher(template); - String customVerb = null; - if (matcher.find()) { - customVerb = matcher.group(1); - template = template.substring(0, matcher.start(0)); - } - - ImmutableList.Builder builder = ImmutableList.builder(); - String varName = null; - int freeWildcardCounter = 0; - int pathWildCardBound = 0; - - for (String seg : Splitter.on('/').trimResults().split(template)) { - // If segment starts with '{', a binding group starts. - boolean bindingStarts = seg.startsWith("{"); - boolean implicitWildcard = false; - if (bindingStarts) { - if (varName != null) { - throw new ValidationException("parse error: nested binding in '%s'", template); - } - seg = seg.substring(1); - - int i = seg.indexOf('='); - if (i <= 0) { - // Possibly looking at something like "{name}" with implicit wildcard. - if (seg.endsWith("}")) { - // Remember to add an implicit wildcard later. - implicitWildcard = true; - varName = seg.substring(0, seg.length() - 1).trim(); - seg = seg.substring(seg.length() - 1).trim(); - } else { - throw new ValidationException("parse error: invalid binding syntax in '%s'", template); - } - } else { - // Looking at something like "{name=wildcard}". - varName = seg.substring(0, i).trim(); - seg = seg.substring(i + 1).trim(); - } - builder.add(Segment.create(SegmentKind.BINDING, varName)); - } - - // If segment ends with '}', a binding group ends. Remove the brace and remember. - boolean bindingEnds = seg.endsWith("}"); - if (bindingEnds) { - seg = seg.substring(0, seg.length() - 1).trim(); - } - - // Process the segment, after stripping off "{name=.." and "..}". - switch (seg) { - case "**": - case "*": - if ("**".equals(seg)) { - pathWildCardBound++; - } - Segment wildcard = seg.length() == 2 ? Segment.PATH_WILDCARD : Segment.WILDCARD; - if (varName == null) { - // Not in a binding, turn wildcard into implicit binding. - // "*" => "{$n=*}" - builder.add(Segment.create(SegmentKind.BINDING, "$" + freeWildcardCounter)); - freeWildcardCounter++; - builder.add(wildcard); - builder.add(Segment.END_BINDING); - } else { - builder.add(wildcard); - } - break; - case "": - if (!bindingEnds) { - throw new ValidationException("parse error: empty segment not allowed in '%s'", - template); - } - // If the wildcard is implicit, seg will be empty. Just continue. - break; - default: - builder.add(Segment.create(SegmentKind.LITERAL, seg)); - } - - // End a binding. - if (bindingEnds) { - // Reset varName to null for next binding. - varName = null; - - if (implicitWildcard) { - // Looking at something like "{var}". Insert an implicit wildcard, as it is the same - // as "{var=*}". - builder.add(Segment.WILDCARD); - } - builder.add(Segment.END_BINDING); - } - - if (pathWildCardBound > 1) { - // Report restriction on number of '**' in the pattern. There can be only one, which - // enables non-backtracking based matching. - throw new ValidationException( - "parse error: pattern must not contain more than one path wildcard ('**') in '%s'", - template); - } - - } - - if (customVerb != null) { - builder.add(Segment.create(SegmentKind.CUSTOM_VERB, customVerb)); - } - return builder.build(); - } - - // Helpers - // ======= - - private static String encodeUrl(String text) { - try { - return URLEncoder.encode(text, StandardCharsets.UTF_8.name()); - } catch (UnsupportedEncodingException e) { - throw new ValidationException("UTF-8 encoding is not supported on this platform"); - } - } - - private static String decodeUrl(String url) { - try { - return URLDecoder.decode(url, StandardCharsets.UTF_8.name()); - } catch (UnsupportedEncodingException e) { - throw new ValidationException("UTF-8 encoding is not supported on this platform"); - } - } - - // Checks for the given segments kind. On success, consumes them. Otherwise leaves - // the list iterator in its state. - private static boolean peek(ListIterator segments, SegmentKind... kinds) { - int start = segments.nextIndex(); - boolean success = false; - for (SegmentKind kind : kinds) { - if (!segments.hasNext() || segments.next().kind() != kind) { - success = false; - break; - } - } - if (success) { - return true; - } - restore(segments, start); - return false; - } - - // Restores a list iterator back to a given index. - private static void restore(ListIterator segments, int index) { - while (segments.nextIndex() > index) { - segments.previous(); - } - } - - // Equality and String Conversion - // ============================== - - /** - * Returns a pretty version of the template as a string. - */ - @Override - public String toString() { - return toSyntax(segments, true); - } - - /** - * Returns a raw version of the template as a string. This renders the template in its - * internal, normalized form. - */ - public String toRawString() { - return toSyntax(segments, false); - } - - private static String toSyntax(List segments, boolean pretty) { - StringBuilder result = new StringBuilder(); - boolean continueLast = true; // if true, no slash is appended. - ListIterator iterator = segments.listIterator(); - while (iterator.hasNext()) { - Segment seg = iterator.next(); - if (!continueLast) { - result.append(seg.separator()); - } - continueLast = false; - switch (seg.kind()) { - case BINDING: - if (pretty && seg.value().startsWith("$")) { - // Remove the internal binding. - seg = iterator.next(); // Consume wildcard - result.append(seg.value()); - iterator.next(); // Consume END_BINDING - continue; - } - result.append('{'); - result.append(seg.value()); - if (pretty && peek(iterator, SegmentKind.WILDCARD, SegmentKind.END_BINDING)) { - // Reduce {name=*} to {name}. - result.append('}'); - continue; - } - result.append('='); - continueLast = true; - continue; - case END_BINDING: - result.append('}'); - continue; - default: - result.append(seg.value()); - continue; - } - } - return result.toString(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof PathTemplate)) { - return false; - } - PathTemplate other = (PathTemplate) obj; - return Objects.equals(segments, other.segments); - } - - @Override - public int hashCode() { - return segments.hashCode(); - } -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ResourceName.java b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ResourceName.java deleted file mode 100644 index 5eea8509ff44..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ResourceName.java +++ /dev/null @@ -1,275 +0,0 @@ -package io.gapi.gax.protobuf; - -import com.google.common.annotations.Beta; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Sets; - -import java.util.Collection; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import javax.annotation.Nullable; - -/** - * Class for representing and working with resource names. - * - *

      A resource name is represented by {@link PathTemplate}, an assignment to variables in - * the template, and an optional endpoint. The {@code ResourceName} class implements - * the map interface (unmodifiable) to work with the variable assignments, and has methods - * to reproduce the string representation of the name, to construct new names, and to dereference - * names into resources. - * - *

      As a resource name essentially represents a match of a path template against a string, it - * can be also used for other purposes than naming resources. However, not all provided methods - * may make sense in all applications. - * - *

      Usage examples: - * - *

      - *   PathTemplate template = PathTemplate.create("shelves/*/books/*");
      - *   ResourceName resourceName = ResourceName.create(template, "shelves/s1/books/b1");
      - *   assert resourceName.get("$1").equals("b1");
      - *   assert resourceName.parentName().toString().equals("shelves/s1/books");
      - * 
      - */ -@Beta -public class ResourceName implements Map { - - // ResourceName Resolver - // ===================== - - /** - * Represents a resource name resolver which can be registered with this class. - */ - public interface Resolver { - /** - * Resolves the resource name into a resource by calling the underlying API. - */ - T resolve(Class resourceType, ResourceName name, @Nullable String version); - } - - // The registered resource name resolver. - // TODO(wgg): its a bit spooky to have this static global. Think of ways to - // configure this from the outside instead if programmatically (e.g. java properties). - private static volatile Resolver resourceNameResolver = new Resolver() { - @Override - public T resolve(Class resourceType, ResourceName name, String version) { - throw new IllegalStateException( - "No resource name resolver is registered in ResourceName class."); - } - }; - - /** - * Sets the resource name resolver which is used by the {@link #resolve(Class, String)} method. - * By default, no resolver is registered. - */ - public static void registerResourceNameResolver(Resolver resolver) { - resourceNameResolver = resolver; - } - - // ResourceName - // ============ - - /** - * Creates a new resource name based on given template and path. The path must match - * the template, otherwise null is returned. - * - * @throws ValidationException if the path does not match the template. - */ - public static ResourceName create(PathTemplate template, String path) { - ImmutableMap values = template.match(path); - if (values == null) { - throw new ValidationException("path '%s' does not match template '%s'", path, template); - } - return new ResourceName(template, values, null); - } - - /** - * Creates a new resource name from a template and a value assignment for variables. - * - * @throws ValidationException if not all variables in the template are bound. - */ - public static ResourceName create(PathTemplate template, Map values) { - if (!values.keySet().containsAll(template.vars())) { - Set unbound = Sets.newLinkedHashSet(template.vars()); - unbound.removeAll(values.keySet()); - throw new ValidationException("unbound variables: %s", unbound); - } - return new ResourceName(template, values, null); - } - - /** - * Creates a new resource name based on given template and path, where the path contains an - * endpoint. If the path does not match, null is returned. - */ - @Nullable - public static ResourceName createFromFullName(PathTemplate template, String path) { - ImmutableMap values = template.matchFromFullName(path); - if (values == null) { - return null; - } - return new ResourceName(template, values, null); - } - - private final PathTemplate template; - private final ImmutableMap values; - private final String endpoint; - - private volatile String stringRepr; - - private ResourceName(PathTemplate template, Map values, String endpoint) { - this.template = template; - this.values = ImmutableMap.copyOf(values); - this.endpoint = endpoint; - } - - @Override - public String toString() { - if (stringRepr == null) { - stringRepr = template.instantiate(values); - } - return stringRepr; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof ResourceName)) { - return false; - } - ResourceName other = (ResourceName) obj; - return Objects.equals(template, other.template) - && Objects.equals(endpoint, other.endpoint) - && Objects.equals(values, other.values); - } - - @Override - public int hashCode() { - return Objects.hash(template, endpoint, values); - } - - /** - * Gets the template associated with this resource name. - */ - public PathTemplate template() { - return template; - } - - /** - * Checks whether the resource name has an endpoint. - */ - public boolean hasEndpoint() { - return endpoint != null; - } - - /** - * Returns the endpoint of this resource name, or null if none is defined. - */ - @Nullable - public String endpoint() { - return endpoint; - } - - /** - * Returns a resource name with specified endpoint. - */ - public ResourceName withEndpoint(String endpoint) { - return new ResourceName(template, values, Preconditions.checkNotNull(endpoint)); - } - - /** - * Returns the parent resource name. For example, if the name is {@code shelves/s1/books/b1}, the - * parent is {@code shelves/s1/books}. - */ - public ResourceName parentName() { - PathTemplate parentTemplate = template.parentTemplate(); - return new ResourceName(parentTemplate, values, endpoint); - } - - /** - * Returns true of the resource name starts with the parent resource name, i.e. is a child - * of the parent. - */ - public boolean startsWith(ResourceName parentName) { - // TODO(wgg): more efficient implementation. - return toString().startsWith(parentName.toString()); - } - - /** - * Attempts to resolve a resource name into a resource, by calling the associated API. - * The resource name must have an endpoint. An optional version can be specified to - * determine in which version of the API to call. - */ - public T resolve(Class resourceType, @Nullable String version) { - Preconditions.checkArgument(hasEndpoint(), "Resource name must have an endpoint."); - return resourceNameResolver.resolve(resourceType, this, version); - } - - // Map Interface - // ============= - - @Override - public int size() { - return values.size(); - } - - @Override - public boolean isEmpty() { - return values.isEmpty(); - } - - @Override - public boolean containsKey(Object key) { - return values.containsKey(key); - } - - @Override - public boolean containsValue(Object value) { - return values.containsValue(value); - } - - @Override - public String get(Object key) { - return values.get(key); - } - - @Override - @Deprecated - public String put(String key, String value) { - return values.put(key, value); - } - - @Override - @Deprecated - public String remove(Object key) { - return values.remove(key); - } - - @Override - @Deprecated - public void putAll(Map m) { - values.putAll(m); - } - - @Override - @Deprecated - public void clear() { - values.clear(); - } - - @Override - public Set keySet() { - return values.keySet(); - } - - @Override - public Collection values() { - return values.values(); - } - - @Override - public Set> entrySet() { - return values.entrySet(); - } -} diff --git a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ValidationException.java b/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ValidationException.java deleted file mode 100644 index 3e2d90e6d118..000000000000 --- a/gcloud-java-gax/src/main/java/io/gapi/gax/protobuf/ValidationException.java +++ /dev/null @@ -1,63 +0,0 @@ -package io.gapi.gax.protobuf; - -import com.google.common.annotations.Beta; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; - -import java.util.Stack; - -/** - * Exception thrown if there is a validation problem with a path template, http config, or related - * framework methods. Comes as an illegal argument exception subclass. Allows to globally - * set a thread-local validation context description which each exception inherits. - */ -@Beta -public class ValidationException extends IllegalArgumentException { - - private static ThreadLocal>> contextLocal = - new ThreadLocal>>(); - - /** - * Sets the validation context description. Each thread has its own description, so - * this is thread safe. - */ - public static void pushCurrentThreadValidationContext(Supplier supplier) { - Stack> stack = contextLocal.get(); - if (stack == null) { - stack = new Stack<>(); - contextLocal.set(stack); - } - stack.push(supplier); - } - - public static void pushCurrentThreadValidationContext(String context) { - pushCurrentThreadValidationContext(Suppliers.ofInstance(context)); - } - /** - * Clears the validation context. - */ - public static void popCurrentThreadValidationContext() { - Stack stack = contextLocal.get(); - if (stack != null) { - stack.pop(); - } - } - - /** - * Construct validation exception with implicit context. - */ - public ValidationException(String format, Object... args) { - super(message(contextLocal.get(), format, args)); - } - - private static String message(Stack> context, String format, Object... args) { - if (context == null || context.isEmpty()) { - return String.format(format, args); - } - StringBuilder result = new StringBuilder(); - for (Supplier supplier : context) { - result.append(supplier.get() + ": "); - } - return result.toString() + String.format(format, args); - } -} diff --git a/gcloud-java-gax/src/test/java/io/gapi/gax/grpc/ApiCallableTest.java b/gcloud-java-gax/src/test/java/io/gapi/gax/grpc/ApiCallableTest.java deleted file mode 100644 index 359f9da3693d..000000000000 --- a/gcloud-java-gax/src/test/java/io/gapi/gax/grpc/ApiCallableTest.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright 2015, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.gapi.gax.grpc; - -import com.google.common.base.Strings; -import com.google.common.collect.Lists; -import com.google.common.truth.Truth; - -import io.gapi.gax.grpc.ApiCallable; -import io.gapi.gax.grpc.PageDescriptor; -import io.gapi.gax.grpc.ApiCallable.Transformer; -import io.grpc.Channel; -import io.grpc.MethodDescriptor; -import io.grpc.Status; -import io.grpc.StatusException; -import io.grpc.stub.ClientCalls; -import io.grpc.stub.StreamObserver; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.concurrent.Executors; - -/** - * Tests for {@link ApiCallable}. - */ -@RunWith(JUnit4.class) -public class ApiCallableTest { - - private static final Transformer PLUS_ONE = - new Transformer() { - @Override public Integer apply(Integer request) throws StatusException { - return request + 1; - } - }; - - private static final Transformer TO_STRING = - new Transformer() { - @Override public String apply(Object request) throws StatusException { - return request.toString(); - } - }; - - private static final Transformer TO_INT = - new Transformer() { - @Override public Integer apply(String request) throws StatusException { - return Integer.parseInt(request); - } - }; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before public void setUp() { - MockitoAnnotations.initMocks(this); - } - - @Mock Channel channel; - - // Creation and Chaining - // ===================== - - @Mock StreamObserver output; - @Mock Transformer transformIntToInt; - - @Test public void transformAndFollowedBy() { - ApiCallable callable = - ApiCallable.create(TO_STRING) - .followedBy(ApiCallable.create(TO_INT)) - .followedBy(ApiCallable.create(PLUS_ONE)); - - // Unary call - Truth.assertThat(callable.call(channel, 1)).isEqualTo(2); - - // Streaming call - StreamObserver input = - ClientCalls.asyncBidiStreamingCall(callable.newCall(channel), output); - input.onNext(1); - input.onNext(2); - input.onNext(3); - input.onCompleted(); - - InOrder inOrder = Mockito.inOrder(output); - inOrder.verify(output).onNext(2); - inOrder.verify(output).onNext(3); - inOrder.verify(output).onNext(4); - } - - // Retry - // ===== - - @Test public void retry() throws StatusException { - Mockito.when(transformIntToInt.apply(Mockito.anyInt())) - .thenThrow(new StatusException(Status.UNAVAILABLE)) - .thenThrow(new StatusException(Status.UNAVAILABLE)) - .thenThrow(new StatusException(Status.UNAVAILABLE)) - .thenReturn(2); - ApiCallable callable = ApiCallable.create(transformIntToInt).retrying(); - Truth.assertThat(callable.call(channel, 1)).isEqualTo(2); - } - - - // Page Streaming - // ============== - - /** - * Request message. - */ - private static class Request { - String pageToken; - } - - /** - * Response message. - */ - private static class Response { - String nextPageToken; - List books; - } - - /** - * A page producer fake which uses a seeded random generator to produce different page - * sizes. - */ - private static class PageProducer implements Transformer { - List collection; - Random random = new Random(0); - - PageProducer() { - collection = new ArrayList(); - for (int i = 1; i < 20; i++) { - collection.add("book #" + i); - } - } - - @Override - public Response apply(Request request) { - int start = 0; - if (!Strings.isNullOrEmpty(request.pageToken)) { - start = Integer.parseInt(request.pageToken); - } - int end = start + random.nextInt(3); - String nextToken; - if (end >= collection.size()) { - end = collection.size(); - nextToken = ""; - } else { - nextToken = end + ""; - } - Response response = new Response(); - response.nextPageToken = nextToken; - response.books = collection.subList(start, end); - return response; - } - } - - private static class BooksPageDescriptor implements PageDescriptor { - - @Override - public Object emptyToken() { - return ""; - } - - @Override - public Request injectToken(Request payload, Object token) { - payload.pageToken = (String) token; - return payload; - } - - @Override - public Object extractNextToken(Response payload) { - return payload.nextPageToken; - } - - @Override - public Iterable extractResources(Response payload) { - return payload.books; - } - } - - @Test public void pageStreaming() { - - // Create a callable. - PageProducer producer = new PageProducer(); - ApiCallable callable = - ApiCallable.create(producer, Executors.newCachedThreadPool()) - .pageStreaming(new BooksPageDescriptor()); - - // Emit the call and check the result. - Truth.assertThat(Lists.newArrayList( - callable.iterableResponseStreamCall(channel, new Request()))) - .isEqualTo(producer.collection); - } - - // Binding - // ======= - - @Mock - MethodDescriptor method; - - @Test public void testUnboundFailure() { - Mockito.stub(method.getFullMethodName()).toReturn("mocked method"); - thrown.expectMessage( - "unbound callable for method 'mocked method' requires " - + "a channel for execution"); - - ApiCallable callable = ApiCallable.create(method); - callable.call(new Request()); - } -} diff --git a/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/PathTemplateTest.java b/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/PathTemplateTest.java deleted file mode 100644 index ecb16fc382aa..000000000000 --- a/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/PathTemplateTest.java +++ /dev/null @@ -1,168 +0,0 @@ -package io.gapi.gax.protobuf; - -import com.google.common.collect.ImmutableMap; -import com.google.common.truth.Truth; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import java.util.Map; - -/** - * Tests for {@link PathTemplate}. - */ -@RunWith(JUnit4.class) -public class PathTemplateTest { - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - // Match - // ===== - - @Test - public void matchAtomicResourceName() { - PathTemplate template = PathTemplate.create("buckets/*/*/objects/*"); - assertPositionalMatch(template.match("buckets/f/o/objects/bar"), "f", "o", "bar"); - } - - @Test - public void matchTemplateWithUnboundedWildcard() { - PathTemplate template = PathTemplate.create("buckets/*/objects/**"); - assertPositionalMatch(template.match("buckets/foo/objects/bar/baz"), "foo", "bar/baz"); - } - - @Test - public void matchWithForcedHostName() { - PathTemplate template = PathTemplate.create("buckets/*/objects/*"); - Map match = template.matchFromFullName("somewhere.io/buckets/b/objects/o"); - Truth.assertThat(match).isNotNull(); - Truth.assertThat(match.get(PathTemplate.HOSTNAME_VAR)).isEqualTo("somewhere.io"); - Truth.assertThat(match.get("$0")).isEqualTo("b"); - Truth.assertThat(match.get("$1")).isEqualTo("o"); - } - - @Test - public void matchWithHostName() { - PathTemplate template = PathTemplate.create("buckets/*/objects/*"); - Map match = template.match("//somewhere.io/buckets/b/objects/o"); - Truth.assertThat(match).isNotNull(); - Truth.assertThat(match.get(PathTemplate.HOSTNAME_VAR)).isEqualTo("//somewhere.io"); - Truth.assertThat(match.get("$0")).isEqualTo("b"); - Truth.assertThat(match.get("$1")).isEqualTo("o"); - } - - @Test - public void matchFailWhenPathMismatch() { - PathTemplate template = PathTemplate.create("buckets/*/*/objects/*"); - Truth.assertThat(template.match("buckets/f/o/o/objects/bar")).isNull(); - } - - @Test - public void matchFailWhenPathTooShort() { - PathTemplate template = PathTemplate.create("buckets/*/*/objects/*"); - Truth.assertThat(template.match("buckets/f/o/objects")).isNull(); - } - - @Test - public void matchFailWhenPathTooLong() { - PathTemplate template = PathTemplate.create("buckets/*/*/objects/*"); - Truth.assertThat(template.match("buckets/f/o/objects/too/long")).isNull(); - } - - @Test - public void matchWithUnboundInMiddle() { - PathTemplate template = PathTemplate.create("bar/**/foo/*"); - assertPositionalMatch(template.match("bar/foo/foo/foo/bar"), "foo/foo", "bar"); - } - - // Instantiate - // =========== - - @Test - public void instantiateAtomicResource() { - PathTemplate template = PathTemplate.create("buckets/*/*/*/objects/*"); - String url = template.instantiate("$0", "f", "$1", "o", "$2", "o", "$3", "bar"); - Truth.assertThat(url).isEqualTo("buckets/f/o/o/objects/bar"); - } - - @Test - public void instantiateEscapeUnsafeChar() { - PathTemplate template = PathTemplate.create("buckets/*/objects/*"); - Truth.assertThat(template.instantiate("$0", "f/o/o", "$1", "b/a/r")) - .isEqualTo("buckets/f%2Fo%2Fo/objects/b%2Fa%2Fr"); - } - - @Test - public void instantiateNotEscapeForUnboundedWildcard() { - PathTemplate template = PathTemplate.create("buckets/*/objects/**"); - Truth.assertThat(template.instantiate("$0", "f/o/o", "$1", "b/a/r")) - .isEqualTo("buckets/f%2Fo%2Fo/objects/b/a/r"); - } - - @Test - public void instantiateFailWhenTooFewVariables() { - thrown.expect(ValidationException.class); - PathTemplate template = PathTemplate.create("buckets/*/*/*/objects/*"); - template.instantiate("$0", "f", "1", "o"); - } - - @Test - public void instantiateWithUnboundInMiddle() { - PathTemplate template = PathTemplate.create("bar/**/foo/*"); - Truth.assertThat(template.instantiate("$0", "1/2", "$1", "3")) - .isEqualTo("bar/1/2/foo/3"); - } - - @Test - public void instantiatePartial() { - PathTemplate template = PathTemplate.create("bar/*/foo/*"); - String instance = template.instantiatePartial(ImmutableMap.of("$0", "_1")); - Truth.assertThat(instance).isEqualTo("bar/_1/foo/*"); - } - - @Test - public void instantiateWithHostName() { - PathTemplate template = PathTemplate.create("bar/*"); - String instance = template.instantiate(ImmutableMap.of( - PathTemplate.HOSTNAME_VAR, "//somewhere.io", - "$0", "foo")); - Truth.assertThat(instance).isEqualTo("//somewhere.io/bar/foo"); - } - - // Other - // ===== - - @Test - public void testMultiplePathWildcardFailure() { - thrown.expect(IllegalArgumentException.class); - PathTemplate.create("bar/**/{name=foo/**}:verb"); - } - - @Test - public void testTemplateWithSimpleBinding() { - PathTemplate template = PathTemplate.create("/v1/messages/{message_id}"); - String url = template.instantiate("message_id", "mymessage"); - Truth.assertThat(url).isEqualTo("v1/messages/mymessage"); - } - - @Test - public void testTemplateWithMultipleSimpleBindings() { - PathTemplate template = PathTemplate.create("v1/shelves/{shelf}/books/{book}"); - String url = template.instantiate("shelf", "s1", "book", "b1"); - Truth.assertThat(url).isEqualTo("v1/shelves/s1/books/b1"); - } - - - private static void assertPositionalMatch(Map match, String... expected) { - Truth.assertThat(match).isNotNull(); - int i = 0; - for (; i < expected.length; ++i) { - Truth.assertThat(expected[i]).isEqualTo(match.get("$" + i)); - } - Truth.assertThat(i).isEqualTo(match.size()); - } -} diff --git a/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/ResourceNameTest.java b/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/ResourceNameTest.java deleted file mode 100644 index dbef60bb64c5..000000000000 --- a/gcloud-java-gax/src/test/java/io/gapi/gax/protobuf/ResourceNameTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.gapi.gax.protobuf; - -import com.google.common.truth.Truth; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * Tests for {@link ResourceName}. As resource names are mostly a wrapper around path - * templates, not much needs to be done here. - */ -@RunWith(JUnit4.class) -public class ResourceNameTest { - - @Test - public void resourceNameMethods() { - PathTemplate template = PathTemplate.create("buckets/*/objects/**"); - ResourceName name = ResourceName.create(template, "buckets/b/objects/1/2"); - Truth.assertThat(name.toString()).isEqualTo("buckets/b/objects/1/2"); - Truth.assertThat(name.get("$1")).isEqualTo("1/2"); - Truth.assertThat(name.get("$0")).isEqualTo("b"); - Truth.assertThat(name.parentName().toString()).isEqualTo("buckets/b/objects"); - } -} From 23d10c0da7175348990a7ac4e7f3b4d8a98e872b Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Thu, 18 Feb 2016 13:36:40 -0800 Subject: [PATCH 187/203] Removing generated files from gcloud-java-pubsub --- .../google/pubsub/v1/AcknowledgeRequest.java | 710 ----------- .../v1/AcknowledgeRequestOrBuilder.java | 66 -- .../pubsub/v1/DeleteSubscriptionRequest.java | 476 -------- .../DeleteSubscriptionRequestOrBuilder.java | 27 - .../google/pubsub/v1/DeleteTopicRequest.java | 476 -------- .../v1/DeleteTopicRequestOrBuilder.java | 27 - .../pubsub/v1/GetSubscriptionRequest.java | 476 -------- .../v1/GetSubscriptionRequestOrBuilder.java | 27 - .../com/google/pubsub/v1/GetTopicRequest.java | 476 -------- .../pubsub/v1/GetTopicRequestOrBuilder.java | 27 - .../pubsub/v1/ListSubscriptionsRequest.java | 711 ----------- .../v1/ListSubscriptionsRequestOrBuilder.java | 58 - .../pubsub/v1/ListSubscriptionsResponse.java | 923 --------------- .../ListSubscriptionsResponseOrBuilder.java | 75 -- .../v1/ListTopicSubscriptionsRequest.java | 711 ----------- ...istTopicSubscriptionsRequestOrBuilder.java | 58 - .../v1/ListTopicSubscriptionsResponse.java | 711 ----------- ...stTopicSubscriptionsResponseOrBuilder.java | 66 -- .../google/pubsub/v1/ListTopicsRequest.java | 711 ----------- .../pubsub/v1/ListTopicsRequestOrBuilder.java | 58 - .../google/pubsub/v1/ListTopicsResponse.java | 916 --------------- .../v1/ListTopicsResponseOrBuilder.java | 73 -- .../pubsub/v1/ModifyAckDeadlineRequest.java | 783 ------------- .../v1/ModifyAckDeadlineRequestOrBuilder.java | 75 -- .../pubsub/v1/ModifyPushConfigRequest.java | 744 ------------ .../v1/ModifyPushConfigRequestOrBuilder.java | 64 - .../com/google/pubsub/v1/PublishRequest.java | 909 --------------- .../pubsub/v1/PublishRequestOrBuilder.java | 71 -- .../com/google/pubsub/v1/PublishResponse.java | 569 --------- .../pubsub/v1/PublishResponseOrBuilder.java | 52 - .../com/google/pubsub/v1/PublisherGrpc.java | 406 ------- .../com/google/pubsub/v1/PubsubMessage.java | 740 ------------ .../pubsub/v1/PubsubMessageOrBuilder.java | 53 - .../com/google/pubsub/v1/PubsubProto.java | 409 ------- .../com/google/pubsub/v1/PullRequest.java | 636 ---------- .../pubsub/v1/PullRequestOrBuilder.java | 50 - .../com/google/pubsub/v1/PullResponse.java | 824 ------------- .../pubsub/v1/PullResponseOrBuilder.java | 68 -- .../java/com/google/pubsub/v1/PushConfig.java | 711 ----------- .../google/pubsub/v1/PushConfigOrBuilder.java | 55 - .../com/google/pubsub/v1/ReceivedMessage.java | 696 ----------- .../pubsub/v1/ReceivedMessageOrBuilder.java | 52 - .../com/google/pubsub/v1/SubscriberGrpc.java | 506 -------- .../com/google/pubsub/v1/Subscription.java | 1038 ----------------- .../pubsub/v1/SubscriptionOrBuilder.java | 111 -- .../main/java/com/google/pubsub/v1/Topic.java | 511 -------- .../com/google/pubsub/v1/TopicOrBuilder.java | 37 - 47 files changed, 18029 deletions(-) delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponse.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponseOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponse.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponseOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponse.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponseOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponse.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponseOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublisherGrpc.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessage.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessageOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubProto.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequest.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequestOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponse.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponseOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfig.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfigOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessage.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessageOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriberGrpc.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Subscription.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriptionOrBuilder.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Topic.java delete mode 100644 gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/TopicOrBuilder.java diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequest.java deleted file mode 100644 index 1c5af6fed5d6..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequest.java +++ /dev/null @@ -1,710 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.AcknowledgeRequest} - * - *
      - * Request for the Acknowledge method.
      - * 
      - */ -public final class AcknowledgeRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.AcknowledgeRequest) - AcknowledgeRequestOrBuilder { - // Use AcknowledgeRequest.newBuilder() to construct. - private AcknowledgeRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private AcknowledgeRequest() { - subscription_ = ""; - ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private AcknowledgeRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - subscription_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - ackIds_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000002; - } - ackIds_.add(s); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - ackIds_ = ackIds_.getUnmodifiableView(); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_AcknowledgeRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.AcknowledgeRequest.class, com.google.pubsub.v1.AcknowledgeRequest.Builder.class); - } - - private int bitField0_; - public static final int SUBSCRIPTION_FIELD_NUMBER = 1; - private volatile java.lang.Object subscription_; - /** - * optional string subscription = 1; - * - *
      -   * The subscription whose message is being acknowledged.
      -   * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } - } - /** - * optional string subscription = 1; - * - *
      -   * The subscription whose message is being acknowledged.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int ACK_IDS_FIELD_NUMBER = 2; - private com.google.protobuf.LazyStringList ackIds_; - /** - * repeated string ack_ids = 2; - * - *
      -   * The acknowledgment ID for the messages being acknowledged that was returned
      -   * by the Pub/Sub system in the Pull response. Must not be empty.
      -   * 
      - */ - public com.google.protobuf.ProtocolStringList - getAckIdsList() { - return ackIds_; - } - /** - * repeated string ack_ids = 2; - * - *
      -   * The acknowledgment ID for the messages being acknowledged that was returned
      -   * by the Pub/Sub system in the Pull response. Must not be empty.
      -   * 
      - */ - public int getAckIdsCount() { - return ackIds_.size(); - } - /** - * repeated string ack_ids = 2; - * - *
      -   * The acknowledgment ID for the messages being acknowledged that was returned
      -   * by the Pub/Sub system in the Pull response. Must not be empty.
      -   * 
      - */ - public java.lang.String getAckIds(int index) { - return ackIds_.get(index); - } - /** - * repeated string ack_ids = 2; - * - *
      -   * The acknowledgment ID for the messages being acknowledged that was returned
      -   * by the Pub/Sub system in the Pull response. Must not be empty.
      -   * 
      - */ - public com.google.protobuf.ByteString - getAckIdsBytes(int index) { - return ackIds_.getByteString(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSubscriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); - } - for (int i = 0; i < ackIds_.size(); i++) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, ackIds_.getRaw(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSubscriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); - } - { - int dataSize = 0; - for (int i = 0; i < ackIds_.size(); i++) { - dataSize += computeStringSizeNoTag(ackIds_.getRaw(i)); - } - size += dataSize; - size += 1 * getAckIdsList().size(); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.AcknowledgeRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.AcknowledgeRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.AcknowledgeRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.AcknowledgeRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.AcknowledgeRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.AcknowledgeRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.AcknowledgeRequest} - * - *
      -   * Request for the Acknowledge method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.AcknowledgeRequest) - com.google.pubsub.v1.AcknowledgeRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_AcknowledgeRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.AcknowledgeRequest.class, com.google.pubsub.v1.AcknowledgeRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.AcknowledgeRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - subscription_ = ""; - - ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor; - } - - public com.google.pubsub.v1.AcknowledgeRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.AcknowledgeRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.AcknowledgeRequest build() { - com.google.pubsub.v1.AcknowledgeRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.AcknowledgeRequest buildPartial() { - com.google.pubsub.v1.AcknowledgeRequest result = new com.google.pubsub.v1.AcknowledgeRequest(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.subscription_ = subscription_; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - ackIds_ = ackIds_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.ackIds_ = ackIds_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.AcknowledgeRequest) { - return mergeFrom((com.google.pubsub.v1.AcknowledgeRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.AcknowledgeRequest other) { - if (other == com.google.pubsub.v1.AcknowledgeRequest.getDefaultInstance()) return this; - if (!other.getSubscription().isEmpty()) { - subscription_ = other.subscription_; - onChanged(); - } - if (!other.ackIds_.isEmpty()) { - if (ackIds_.isEmpty()) { - ackIds_ = other.ackIds_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureAckIdsIsMutable(); - ackIds_.addAll(other.ackIds_); - } - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.AcknowledgeRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.AcknowledgeRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object subscription_ = ""; - /** - * optional string subscription = 1; - * - *
      -     * The subscription whose message is being acknowledged.
      -     * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription whose message is being acknowledged.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription whose message is being acknowledged.
      -     * 
      - */ - public Builder setSubscription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subscription_ = value; - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription whose message is being acknowledged.
      -     * 
      - */ - public Builder clearSubscription() { - - subscription_ = getDefaultInstance().getSubscription(); - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription whose message is being acknowledged.
      -     * 
      - */ - public Builder setSubscriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subscription_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.LazyStringList ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureAckIdsIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - ackIds_ = new com.google.protobuf.LazyStringArrayList(ackIds_); - bitField0_ |= 0x00000002; - } - } - /** - * repeated string ack_ids = 2; - * - *
      -     * The acknowledgment ID for the messages being acknowledged that was returned
      -     * by the Pub/Sub system in the Pull response. Must not be empty.
      -     * 
      - */ - public com.google.protobuf.ProtocolStringList - getAckIdsList() { - return ackIds_.getUnmodifiableView(); - } - /** - * repeated string ack_ids = 2; - * - *
      -     * The acknowledgment ID for the messages being acknowledged that was returned
      -     * by the Pub/Sub system in the Pull response. Must not be empty.
      -     * 
      - */ - public int getAckIdsCount() { - return ackIds_.size(); - } - /** - * repeated string ack_ids = 2; - * - *
      -     * The acknowledgment ID for the messages being acknowledged that was returned
      -     * by the Pub/Sub system in the Pull response. Must not be empty.
      -     * 
      - */ - public java.lang.String getAckIds(int index) { - return ackIds_.get(index); - } - /** - * repeated string ack_ids = 2; - * - *
      -     * The acknowledgment ID for the messages being acknowledged that was returned
      -     * by the Pub/Sub system in the Pull response. Must not be empty.
      -     * 
      - */ - public com.google.protobuf.ByteString - getAckIdsBytes(int index) { - return ackIds_.getByteString(index); - } - /** - * repeated string ack_ids = 2; - * - *
      -     * The acknowledgment ID for the messages being acknowledged that was returned
      -     * by the Pub/Sub system in the Pull response. Must not be empty.
      -     * 
      - */ - public Builder setAckIds( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureAckIdsIsMutable(); - ackIds_.set(index, value); - onChanged(); - return this; - } - /** - * repeated string ack_ids = 2; - * - *
      -     * The acknowledgment ID for the messages being acknowledged that was returned
      -     * by the Pub/Sub system in the Pull response. Must not be empty.
      -     * 
      - */ - public Builder addAckIds( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureAckIdsIsMutable(); - ackIds_.add(value); - onChanged(); - return this; - } - /** - * repeated string ack_ids = 2; - * - *
      -     * The acknowledgment ID for the messages being acknowledged that was returned
      -     * by the Pub/Sub system in the Pull response. Must not be empty.
      -     * 
      - */ - public Builder addAllAckIds( - java.lang.Iterable values) { - ensureAckIdsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, ackIds_); - onChanged(); - return this; - } - /** - * repeated string ack_ids = 2; - * - *
      -     * The acknowledgment ID for the messages being acknowledged that was returned
      -     * by the Pub/Sub system in the Pull response. Must not be empty.
      -     * 
      - */ - public Builder clearAckIds() { - ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - * repeated string ack_ids = 2; - * - *
      -     * The acknowledgment ID for the messages being acknowledged that was returned
      -     * by the Pub/Sub system in the Pull response. Must not be empty.
      -     * 
      - */ - public Builder addAckIdsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureAckIdsIsMutable(); - ackIds_.add(value); - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.AcknowledgeRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.AcknowledgeRequest) - private static final com.google.pubsub.v1.AcknowledgeRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.AcknowledgeRequest(); - } - - public static com.google.pubsub.v1.AcknowledgeRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public AcknowledgeRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new AcknowledgeRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.AcknowledgeRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequestOrBuilder.java deleted file mode 100644 index 7a89660bbcfb..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/AcknowledgeRequestOrBuilder.java +++ /dev/null @@ -1,66 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface AcknowledgeRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.AcknowledgeRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string subscription = 1; - * - *
      -   * The subscription whose message is being acknowledged.
      -   * 
      - */ - java.lang.String getSubscription(); - /** - * optional string subscription = 1; - * - *
      -   * The subscription whose message is being acknowledged.
      -   * 
      - */ - com.google.protobuf.ByteString - getSubscriptionBytes(); - - /** - * repeated string ack_ids = 2; - * - *
      -   * The acknowledgment ID for the messages being acknowledged that was returned
      -   * by the Pub/Sub system in the Pull response. Must not be empty.
      -   * 
      - */ - com.google.protobuf.ProtocolStringList - getAckIdsList(); - /** - * repeated string ack_ids = 2; - * - *
      -   * The acknowledgment ID for the messages being acknowledged that was returned
      -   * by the Pub/Sub system in the Pull response. Must not be empty.
      -   * 
      - */ - int getAckIdsCount(); - /** - * repeated string ack_ids = 2; - * - *
      -   * The acknowledgment ID for the messages being acknowledged that was returned
      -   * by the Pub/Sub system in the Pull response. Must not be empty.
      -   * 
      - */ - java.lang.String getAckIds(int index); - /** - * repeated string ack_ids = 2; - * - *
      -   * The acknowledgment ID for the messages being acknowledged that was returned
      -   * by the Pub/Sub system in the Pull response. Must not be empty.
      -   * 
      - */ - com.google.protobuf.ByteString - getAckIdsBytes(int index); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequest.java deleted file mode 100644 index acdfd0d71c83..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequest.java +++ /dev/null @@ -1,476 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.DeleteSubscriptionRequest} - * - *
      - * Request for the DeleteSubscription method.
      - * 
      - */ -public final class DeleteSubscriptionRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.DeleteSubscriptionRequest) - DeleteSubscriptionRequestOrBuilder { - // Use DeleteSubscriptionRequest.newBuilder() to construct. - private DeleteSubscriptionRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private DeleteSubscriptionRequest() { - subscription_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private DeleteSubscriptionRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - subscription_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteSubscriptionRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.DeleteSubscriptionRequest.class, com.google.pubsub.v1.DeleteSubscriptionRequest.Builder.class); - } - - public static final int SUBSCRIPTION_FIELD_NUMBER = 1; - private volatile java.lang.Object subscription_; - /** - * optional string subscription = 1; - * - *
      -   * The subscription to delete.
      -   * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } - } - /** - * optional string subscription = 1; - * - *
      -   * The subscription to delete.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSubscriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSubscriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.DeleteSubscriptionRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.DeleteSubscriptionRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.DeleteSubscriptionRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.DeleteSubscriptionRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.DeleteSubscriptionRequest} - * - *
      -   * Request for the DeleteSubscription method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.DeleteSubscriptionRequest) - com.google.pubsub.v1.DeleteSubscriptionRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteSubscriptionRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.DeleteSubscriptionRequest.class, com.google.pubsub.v1.DeleteSubscriptionRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.DeleteSubscriptionRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - subscription_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor; - } - - public com.google.pubsub.v1.DeleteSubscriptionRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.DeleteSubscriptionRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.DeleteSubscriptionRequest build() { - com.google.pubsub.v1.DeleteSubscriptionRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.DeleteSubscriptionRequest buildPartial() { - com.google.pubsub.v1.DeleteSubscriptionRequest result = new com.google.pubsub.v1.DeleteSubscriptionRequest(this); - result.subscription_ = subscription_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.DeleteSubscriptionRequest) { - return mergeFrom((com.google.pubsub.v1.DeleteSubscriptionRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.DeleteSubscriptionRequest other) { - if (other == com.google.pubsub.v1.DeleteSubscriptionRequest.getDefaultInstance()) return this; - if (!other.getSubscription().isEmpty()) { - subscription_ = other.subscription_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.DeleteSubscriptionRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.DeleteSubscriptionRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object subscription_ = ""; - /** - * optional string subscription = 1; - * - *
      -     * The subscription to delete.
      -     * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription to delete.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription to delete.
      -     * 
      - */ - public Builder setSubscription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subscription_ = value; - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription to delete.
      -     * 
      - */ - public Builder clearSubscription() { - - subscription_ = getDefaultInstance().getSubscription(); - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription to delete.
      -     * 
      - */ - public Builder setSubscriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subscription_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.DeleteSubscriptionRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.DeleteSubscriptionRequest) - private static final com.google.pubsub.v1.DeleteSubscriptionRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.DeleteSubscriptionRequest(); - } - - public static com.google.pubsub.v1.DeleteSubscriptionRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public DeleteSubscriptionRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new DeleteSubscriptionRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.DeleteSubscriptionRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequestOrBuilder.java deleted file mode 100644 index d43222fb965c..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteSubscriptionRequestOrBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface DeleteSubscriptionRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.DeleteSubscriptionRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string subscription = 1; - * - *
      -   * The subscription to delete.
      -   * 
      - */ - java.lang.String getSubscription(); - /** - * optional string subscription = 1; - * - *
      -   * The subscription to delete.
      -   * 
      - */ - com.google.protobuf.ByteString - getSubscriptionBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequest.java deleted file mode 100644 index cb7dd1257eea..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequest.java +++ /dev/null @@ -1,476 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.DeleteTopicRequest} - * - *
      - * Request for the DeleteTopic method.
      - * 
      - */ -public final class DeleteTopicRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.DeleteTopicRequest) - DeleteTopicRequestOrBuilder { - // Use DeleteTopicRequest.newBuilder() to construct. - private DeleteTopicRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private DeleteTopicRequest() { - topic_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private DeleteTopicRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteTopicRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.DeleteTopicRequest.class, com.google.pubsub.v1.DeleteTopicRequest.Builder.class); - } - - public static final int TOPIC_FIELD_NUMBER = 1; - private volatile java.lang.Object topic_; - /** - * optional string topic = 1; - * - *
      -   * Name of the topic to delete.
      -   * 
      - */ - public java.lang.String getTopic() { - java.lang.Object ref = topic_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - /** - * optional string topic = 1; - * - *
      -   * Name of the topic to delete.
      -   * 
      - */ - public com.google.protobuf.ByteString - getTopicBytes() { - java.lang.Object ref = topic_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, topic_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, topic_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.DeleteTopicRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.DeleteTopicRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.DeleteTopicRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.DeleteTopicRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.DeleteTopicRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.DeleteTopicRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.DeleteTopicRequest} - * - *
      -   * Request for the DeleteTopic method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.DeleteTopicRequest) - com.google.pubsub.v1.DeleteTopicRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteTopicRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.DeleteTopicRequest.class, com.google.pubsub.v1.DeleteTopicRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.DeleteTopicRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - topic_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor; - } - - public com.google.pubsub.v1.DeleteTopicRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.DeleteTopicRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.DeleteTopicRequest build() { - com.google.pubsub.v1.DeleteTopicRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.DeleteTopicRequest buildPartial() { - com.google.pubsub.v1.DeleteTopicRequest result = new com.google.pubsub.v1.DeleteTopicRequest(this); - result.topic_ = topic_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.DeleteTopicRequest) { - return mergeFrom((com.google.pubsub.v1.DeleteTopicRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.DeleteTopicRequest other) { - if (other == com.google.pubsub.v1.DeleteTopicRequest.getDefaultInstance()) return this; - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.DeleteTopicRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.DeleteTopicRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object topic_ = ""; - /** - * optional string topic = 1; - * - *
      -     * Name of the topic to delete.
      -     * 
      - */ - public java.lang.String getTopic() { - java.lang.Object ref = topic_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string topic = 1; - * - *
      -     * Name of the topic to delete.
      -     * 
      - */ - public com.google.protobuf.ByteString - getTopicBytes() { - java.lang.Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string topic = 1; - * - *
      -     * Name of the topic to delete.
      -     * 
      - */ - public Builder setTopic( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - /** - * optional string topic = 1; - * - *
      -     * Name of the topic to delete.
      -     * 
      - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - /** - * optional string topic = 1; - * - *
      -     * Name of the topic to delete.
      -     * 
      - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.DeleteTopicRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.DeleteTopicRequest) - private static final com.google.pubsub.v1.DeleteTopicRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.DeleteTopicRequest(); - } - - public static com.google.pubsub.v1.DeleteTopicRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public DeleteTopicRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new DeleteTopicRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.DeleteTopicRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequestOrBuilder.java deleted file mode 100644 index c08d12083d31..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/DeleteTopicRequestOrBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface DeleteTopicRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.DeleteTopicRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string topic = 1; - * - *
      -   * Name of the topic to delete.
      -   * 
      - */ - java.lang.String getTopic(); - /** - * optional string topic = 1; - * - *
      -   * Name of the topic to delete.
      -   * 
      - */ - com.google.protobuf.ByteString - getTopicBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequest.java deleted file mode 100644 index b8bd3e5f0249..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequest.java +++ /dev/null @@ -1,476 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.GetSubscriptionRequest} - * - *
      - * Request for the GetSubscription method.
      - * 
      - */ -public final class GetSubscriptionRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.GetSubscriptionRequest) - GetSubscriptionRequestOrBuilder { - // Use GetSubscriptionRequest.newBuilder() to construct. - private GetSubscriptionRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private GetSubscriptionRequest() { - subscription_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private GetSubscriptionRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - subscription_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetSubscriptionRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.GetSubscriptionRequest.class, com.google.pubsub.v1.GetSubscriptionRequest.Builder.class); - } - - public static final int SUBSCRIPTION_FIELD_NUMBER = 1; - private volatile java.lang.Object subscription_; - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription to get.
      -   * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } - } - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription to get.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSubscriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSubscriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.GetSubscriptionRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.GetSubscriptionRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.GetSubscriptionRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.GetSubscriptionRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.GetSubscriptionRequest} - * - *
      -   * Request for the GetSubscription method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.GetSubscriptionRequest) - com.google.pubsub.v1.GetSubscriptionRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetSubscriptionRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.GetSubscriptionRequest.class, com.google.pubsub.v1.GetSubscriptionRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.GetSubscriptionRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - subscription_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor; - } - - public com.google.pubsub.v1.GetSubscriptionRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.GetSubscriptionRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.GetSubscriptionRequest build() { - com.google.pubsub.v1.GetSubscriptionRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.GetSubscriptionRequest buildPartial() { - com.google.pubsub.v1.GetSubscriptionRequest result = new com.google.pubsub.v1.GetSubscriptionRequest(this); - result.subscription_ = subscription_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.GetSubscriptionRequest) { - return mergeFrom((com.google.pubsub.v1.GetSubscriptionRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.GetSubscriptionRequest other) { - if (other == com.google.pubsub.v1.GetSubscriptionRequest.getDefaultInstance()) return this; - if (!other.getSubscription().isEmpty()) { - subscription_ = other.subscription_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.GetSubscriptionRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.GetSubscriptionRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object subscription_ = ""; - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription to get.
      -     * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription to get.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription to get.
      -     * 
      - */ - public Builder setSubscription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subscription_ = value; - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription to get.
      -     * 
      - */ - public Builder clearSubscription() { - - subscription_ = getDefaultInstance().getSubscription(); - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription to get.
      -     * 
      - */ - public Builder setSubscriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subscription_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.GetSubscriptionRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.GetSubscriptionRequest) - private static final com.google.pubsub.v1.GetSubscriptionRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.GetSubscriptionRequest(); - } - - public static com.google.pubsub.v1.GetSubscriptionRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public GetSubscriptionRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new GetSubscriptionRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.GetSubscriptionRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequestOrBuilder.java deleted file mode 100644 index 248eb0561e6f..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetSubscriptionRequestOrBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface GetSubscriptionRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.GetSubscriptionRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription to get.
      -   * 
      - */ - java.lang.String getSubscription(); - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription to get.
      -   * 
      - */ - com.google.protobuf.ByteString - getSubscriptionBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequest.java deleted file mode 100644 index 17961ce28ab0..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequest.java +++ /dev/null @@ -1,476 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.GetTopicRequest} - * - *
      - * Request for the GetTopic method.
      - * 
      - */ -public final class GetTopicRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.GetTopicRequest) - GetTopicRequestOrBuilder { - // Use GetTopicRequest.newBuilder() to construct. - private GetTopicRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private GetTopicRequest() { - topic_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private GetTopicRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetTopicRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetTopicRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.GetTopicRequest.class, com.google.pubsub.v1.GetTopicRequest.Builder.class); - } - - public static final int TOPIC_FIELD_NUMBER = 1; - private volatile java.lang.Object topic_; - /** - * optional string topic = 1; - * - *
      -   * The name of the topic to get.
      -   * 
      - */ - public java.lang.String getTopic() { - java.lang.Object ref = topic_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - /** - * optional string topic = 1; - * - *
      -   * The name of the topic to get.
      -   * 
      - */ - public com.google.protobuf.ByteString - getTopicBytes() { - java.lang.Object ref = topic_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, topic_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, topic_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.GetTopicRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.GetTopicRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.GetTopicRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.GetTopicRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.GetTopicRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.GetTopicRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.GetTopicRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.GetTopicRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.GetTopicRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.GetTopicRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.GetTopicRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.GetTopicRequest} - * - *
      -   * Request for the GetTopic method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.GetTopicRequest) - com.google.pubsub.v1.GetTopicRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetTopicRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetTopicRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.GetTopicRequest.class, com.google.pubsub.v1.GetTopicRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.GetTopicRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - topic_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_GetTopicRequest_descriptor; - } - - public com.google.pubsub.v1.GetTopicRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.GetTopicRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.GetTopicRequest build() { - com.google.pubsub.v1.GetTopicRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.GetTopicRequest buildPartial() { - com.google.pubsub.v1.GetTopicRequest result = new com.google.pubsub.v1.GetTopicRequest(this); - result.topic_ = topic_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.GetTopicRequest) { - return mergeFrom((com.google.pubsub.v1.GetTopicRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.GetTopicRequest other) { - if (other == com.google.pubsub.v1.GetTopicRequest.getDefaultInstance()) return this; - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.GetTopicRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.GetTopicRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object topic_ = ""; - /** - * optional string topic = 1; - * - *
      -     * The name of the topic to get.
      -     * 
      - */ - public java.lang.String getTopic() { - java.lang.Object ref = topic_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string topic = 1; - * - *
      -     * The name of the topic to get.
      -     * 
      - */ - public com.google.protobuf.ByteString - getTopicBytes() { - java.lang.Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string topic = 1; - * - *
      -     * The name of the topic to get.
      -     * 
      - */ - public Builder setTopic( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - /** - * optional string topic = 1; - * - *
      -     * The name of the topic to get.
      -     * 
      - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - /** - * optional string topic = 1; - * - *
      -     * The name of the topic to get.
      -     * 
      - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.GetTopicRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.GetTopicRequest) - private static final com.google.pubsub.v1.GetTopicRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.GetTopicRequest(); - } - - public static com.google.pubsub.v1.GetTopicRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public GetTopicRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new GetTopicRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.GetTopicRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequestOrBuilder.java deleted file mode 100644 index c26b5276c5da..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/GetTopicRequestOrBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface GetTopicRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.GetTopicRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string topic = 1; - * - *
      -   * The name of the topic to get.
      -   * 
      - */ - java.lang.String getTopic(); - /** - * optional string topic = 1; - * - *
      -   * The name of the topic to get.
      -   * 
      - */ - com.google.protobuf.ByteString - getTopicBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequest.java deleted file mode 100644 index 8b0cc2e8a04f..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequest.java +++ /dev/null @@ -1,711 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.ListSubscriptionsRequest} - * - *
      - * Request for the ListSubscriptions method.
      - * 
      - */ -public final class ListSubscriptionsRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListSubscriptionsRequest) - ListSubscriptionsRequestOrBuilder { - // Use ListSubscriptionsRequest.newBuilder() to construct. - private ListSubscriptionsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ListSubscriptionsRequest() { - project_ = ""; - pageSize_ = 0; - pageToken_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ListSubscriptionsRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - project_ = s; - break; - } - case 16: { - - pageSize_ = input.readInt32(); - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - pageToken_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListSubscriptionsRequest.class, com.google.pubsub.v1.ListSubscriptionsRequest.Builder.class); - } - - public static final int PROJECT_FIELD_NUMBER = 1; - private volatile java.lang.Object project_; - /** - * optional string project = 1; - * - *
      -   * The name of the cloud project that subscriptions belong to.
      -   * 
      - */ - public java.lang.String getProject() { - java.lang.Object ref = project_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - project_ = s; - return s; - } - } - /** - * optional string project = 1; - * - *
      -   * The name of the cloud project that subscriptions belong to.
      -   * 
      - */ - public com.google.protobuf.ByteString - getProjectBytes() { - java.lang.Object ref = project_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - project_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PAGE_SIZE_FIELD_NUMBER = 2; - private int pageSize_; - /** - * optional int32 page_size = 2; - * - *
      -   * Maximum number of subscriptions to return.
      -   * 
      - */ - public int getPageSize() { - return pageSize_; - } - - public static final int PAGE_TOKEN_FIELD_NUMBER = 3; - private volatile java.lang.Object pageToken_; - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListSubscriptionsResponse; indicates that
      -   * this is a continuation of a prior ListSubscriptions call, and that the
      -   * system should return the next page of data.
      -   * 
      - */ - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } - } - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListSubscriptionsResponse; indicates that
      -   * this is a continuation of a prior ListSubscriptions call, and that the
      -   * system should return the next page of data.
      -   * 
      - */ - public com.google.protobuf.ByteString - getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getProjectBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, project_); - } - if (pageSize_ != 0) { - output.writeInt32(2, pageSize_); - } - if (!getPageTokenBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 3, pageToken_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getProjectBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, project_); - } - if (pageSize_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, pageSize_); - } - if (!getPageTokenBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pageToken_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListSubscriptionsRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.ListSubscriptionsRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListSubscriptionsRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.ListSubscriptionsRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.ListSubscriptionsRequest} - * - *
      -   * Request for the ListSubscriptions method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListSubscriptionsRequest) - com.google.pubsub.v1.ListSubscriptionsRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListSubscriptionsRequest.class, com.google.pubsub.v1.ListSubscriptionsRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.ListSubscriptionsRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - project_ = ""; - - pageSize_ = 0; - - pageToken_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor; - } - - public com.google.pubsub.v1.ListSubscriptionsRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.ListSubscriptionsRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.ListSubscriptionsRequest build() { - com.google.pubsub.v1.ListSubscriptionsRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.ListSubscriptionsRequest buildPartial() { - com.google.pubsub.v1.ListSubscriptionsRequest result = new com.google.pubsub.v1.ListSubscriptionsRequest(this); - result.project_ = project_; - result.pageSize_ = pageSize_; - result.pageToken_ = pageToken_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.ListSubscriptionsRequest) { - return mergeFrom((com.google.pubsub.v1.ListSubscriptionsRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.ListSubscriptionsRequest other) { - if (other == com.google.pubsub.v1.ListSubscriptionsRequest.getDefaultInstance()) return this; - if (!other.getProject().isEmpty()) { - project_ = other.project_; - onChanged(); - } - if (other.getPageSize() != 0) { - setPageSize(other.getPageSize()); - } - if (!other.getPageToken().isEmpty()) { - pageToken_ = other.pageToken_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.ListSubscriptionsRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.ListSubscriptionsRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object project_ = ""; - /** - * optional string project = 1; - * - *
      -     * The name of the cloud project that subscriptions belong to.
      -     * 
      - */ - public java.lang.String getProject() { - java.lang.Object ref = project_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - project_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string project = 1; - * - *
      -     * The name of the cloud project that subscriptions belong to.
      -     * 
      - */ - public com.google.protobuf.ByteString - getProjectBytes() { - java.lang.Object ref = project_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - project_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string project = 1; - * - *
      -     * The name of the cloud project that subscriptions belong to.
      -     * 
      - */ - public Builder setProject( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - project_ = value; - onChanged(); - return this; - } - /** - * optional string project = 1; - * - *
      -     * The name of the cloud project that subscriptions belong to.
      -     * 
      - */ - public Builder clearProject() { - - project_ = getDefaultInstance().getProject(); - onChanged(); - return this; - } - /** - * optional string project = 1; - * - *
      -     * The name of the cloud project that subscriptions belong to.
      -     * 
      - */ - public Builder setProjectBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - project_ = value; - onChanged(); - return this; - } - - private int pageSize_ ; - /** - * optional int32 page_size = 2; - * - *
      -     * Maximum number of subscriptions to return.
      -     * 
      - */ - public int getPageSize() { - return pageSize_; - } - /** - * optional int32 page_size = 2; - * - *
      -     * Maximum number of subscriptions to return.
      -     * 
      - */ - public Builder setPageSize(int value) { - - pageSize_ = value; - onChanged(); - return this; - } - /** - * optional int32 page_size = 2; - * - *
      -     * Maximum number of subscriptions to return.
      -     * 
      - */ - public Builder clearPageSize() { - - pageSize_ = 0; - onChanged(); - return this; - } - - private java.lang.Object pageToken_ = ""; - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListSubscriptionsResponse; indicates that
      -     * this is a continuation of a prior ListSubscriptions call, and that the
      -     * system should return the next page of data.
      -     * 
      - */ - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListSubscriptionsResponse; indicates that
      -     * this is a continuation of a prior ListSubscriptions call, and that the
      -     * system should return the next page of data.
      -     * 
      - */ - public com.google.protobuf.ByteString - getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListSubscriptionsResponse; indicates that
      -     * this is a continuation of a prior ListSubscriptions call, and that the
      -     * system should return the next page of data.
      -     * 
      - */ - public Builder setPageToken( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - pageToken_ = value; - onChanged(); - return this; - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListSubscriptionsResponse; indicates that
      -     * this is a continuation of a prior ListSubscriptions call, and that the
      -     * system should return the next page of data.
      -     * 
      - */ - public Builder clearPageToken() { - - pageToken_ = getDefaultInstance().getPageToken(); - onChanged(); - return this; - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListSubscriptionsResponse; indicates that
      -     * this is a continuation of a prior ListSubscriptions call, and that the
      -     * system should return the next page of data.
      -     * 
      - */ - public Builder setPageTokenBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pageToken_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListSubscriptionsRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListSubscriptionsRequest) - private static final com.google.pubsub.v1.ListSubscriptionsRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.ListSubscriptionsRequest(); - } - - public static com.google.pubsub.v1.ListSubscriptionsRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ListSubscriptionsRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ListSubscriptionsRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.ListSubscriptionsRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequestOrBuilder.java deleted file mode 100644 index b8b08410f4a1..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsRequestOrBuilder.java +++ /dev/null @@ -1,58 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface ListSubscriptionsRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListSubscriptionsRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string project = 1; - * - *
      -   * The name of the cloud project that subscriptions belong to.
      -   * 
      - */ - java.lang.String getProject(); - /** - * optional string project = 1; - * - *
      -   * The name of the cloud project that subscriptions belong to.
      -   * 
      - */ - com.google.protobuf.ByteString - getProjectBytes(); - - /** - * optional int32 page_size = 2; - * - *
      -   * Maximum number of subscriptions to return.
      -   * 
      - */ - int getPageSize(); - - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListSubscriptionsResponse; indicates that
      -   * this is a continuation of a prior ListSubscriptions call, and that the
      -   * system should return the next page of data.
      -   * 
      - */ - java.lang.String getPageToken(); - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListSubscriptionsResponse; indicates that
      -   * this is a continuation of a prior ListSubscriptions call, and that the
      -   * system should return the next page of data.
      -   * 
      - */ - com.google.protobuf.ByteString - getPageTokenBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponse.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponse.java deleted file mode 100644 index 3ef3d6cea957..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponse.java +++ /dev/null @@ -1,923 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.ListSubscriptionsResponse} - * - *
      - * Response for the ListSubscriptions method.
      - * 
      - */ -public final class ListSubscriptionsResponse extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListSubscriptionsResponse) - ListSubscriptionsResponseOrBuilder { - // Use ListSubscriptionsResponse.newBuilder() to construct. - private ListSubscriptionsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ListSubscriptionsResponse() { - subscriptions_ = java.util.Collections.emptyList(); - nextPageToken_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ListSubscriptionsResponse( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - subscriptions_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - subscriptions_.add(input.readMessage(com.google.pubsub.v1.Subscription.parser(), extensionRegistry)); - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - nextPageToken_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - subscriptions_ = java.util.Collections.unmodifiableList(subscriptions_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListSubscriptionsResponse.class, com.google.pubsub.v1.ListSubscriptionsResponse.Builder.class); - } - - private int bitField0_; - public static final int SUBSCRIPTIONS_FIELD_NUMBER = 1; - private java.util.List subscriptions_; - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -   * The subscriptions that match the request.
      -   * 
      - */ - public java.util.List getSubscriptionsList() { - return subscriptions_; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -   * The subscriptions that match the request.
      -   * 
      - */ - public java.util.List - getSubscriptionsOrBuilderList() { - return subscriptions_; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -   * The subscriptions that match the request.
      -   * 
      - */ - public int getSubscriptionsCount() { - return subscriptions_.size(); - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -   * The subscriptions that match the request.
      -   * 
      - */ - public com.google.pubsub.v1.Subscription getSubscriptions(int index) { - return subscriptions_.get(index); - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -   * The subscriptions that match the request.
      -   * 
      - */ - public com.google.pubsub.v1.SubscriptionOrBuilder getSubscriptionsOrBuilder( - int index) { - return subscriptions_.get(index); - } - - public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; - private volatile java.lang.Object nextPageToken_; - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more subscriptions that match
      -   * the request; this value should be passed in a new ListSubscriptionsRequest
      -   * to get more subscriptions.
      -   * 
      - */ - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } - } - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more subscriptions that match
      -   * the request; this value should be passed in a new ListSubscriptionsRequest
      -   * to get more subscriptions.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < subscriptions_.size(); i++) { - output.writeMessage(1, subscriptions_.get(i)); - } - if (!getNextPageTokenBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < subscriptions_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, subscriptions_.get(i)); - } - if (!getNextPageTokenBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListSubscriptionsResponse parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.ListSubscriptionsResponse parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListSubscriptionsResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.ListSubscriptionsResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.ListSubscriptionsResponse} - * - *
      -   * Response for the ListSubscriptions method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListSubscriptionsResponse) - com.google.pubsub.v1.ListSubscriptionsResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListSubscriptionsResponse.class, com.google.pubsub.v1.ListSubscriptionsResponse.Builder.class); - } - - // Construct using com.google.pubsub.v1.ListSubscriptionsResponse.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getSubscriptionsFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (subscriptionsBuilder_ == null) { - subscriptions_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - subscriptionsBuilder_.clear(); - } - nextPageToken_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor; - } - - public com.google.pubsub.v1.ListSubscriptionsResponse getDefaultInstanceForType() { - return com.google.pubsub.v1.ListSubscriptionsResponse.getDefaultInstance(); - } - - public com.google.pubsub.v1.ListSubscriptionsResponse build() { - com.google.pubsub.v1.ListSubscriptionsResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.ListSubscriptionsResponse buildPartial() { - com.google.pubsub.v1.ListSubscriptionsResponse result = new com.google.pubsub.v1.ListSubscriptionsResponse(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (subscriptionsBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - subscriptions_ = java.util.Collections.unmodifiableList(subscriptions_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.subscriptions_ = subscriptions_; - } else { - result.subscriptions_ = subscriptionsBuilder_.build(); - } - result.nextPageToken_ = nextPageToken_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.ListSubscriptionsResponse) { - return mergeFrom((com.google.pubsub.v1.ListSubscriptionsResponse)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.ListSubscriptionsResponse other) { - if (other == com.google.pubsub.v1.ListSubscriptionsResponse.getDefaultInstance()) return this; - if (subscriptionsBuilder_ == null) { - if (!other.subscriptions_.isEmpty()) { - if (subscriptions_.isEmpty()) { - subscriptions_ = other.subscriptions_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureSubscriptionsIsMutable(); - subscriptions_.addAll(other.subscriptions_); - } - onChanged(); - } - } else { - if (!other.subscriptions_.isEmpty()) { - if (subscriptionsBuilder_.isEmpty()) { - subscriptionsBuilder_.dispose(); - subscriptionsBuilder_ = null; - subscriptions_ = other.subscriptions_; - bitField0_ = (bitField0_ & ~0x00000001); - subscriptionsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getSubscriptionsFieldBuilder() : null; - } else { - subscriptionsBuilder_.addAllMessages(other.subscriptions_); - } - } - } - if (!other.getNextPageToken().isEmpty()) { - nextPageToken_ = other.nextPageToken_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.ListSubscriptionsResponse parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.ListSubscriptionsResponse) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List subscriptions_ = - java.util.Collections.emptyList(); - private void ensureSubscriptionsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - subscriptions_ = new java.util.ArrayList(subscriptions_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.Subscription, com.google.pubsub.v1.Subscription.Builder, com.google.pubsub.v1.SubscriptionOrBuilder> subscriptionsBuilder_; - - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public java.util.List getSubscriptionsList() { - if (subscriptionsBuilder_ == null) { - return java.util.Collections.unmodifiableList(subscriptions_); - } else { - return subscriptionsBuilder_.getMessageList(); - } - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public int getSubscriptionsCount() { - if (subscriptionsBuilder_ == null) { - return subscriptions_.size(); - } else { - return subscriptionsBuilder_.getCount(); - } - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public com.google.pubsub.v1.Subscription getSubscriptions(int index) { - if (subscriptionsBuilder_ == null) { - return subscriptions_.get(index); - } else { - return subscriptionsBuilder_.getMessage(index); - } - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public Builder setSubscriptions( - int index, com.google.pubsub.v1.Subscription value) { - if (subscriptionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionsIsMutable(); - subscriptions_.set(index, value); - onChanged(); - } else { - subscriptionsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public Builder setSubscriptions( - int index, com.google.pubsub.v1.Subscription.Builder builderForValue) { - if (subscriptionsBuilder_ == null) { - ensureSubscriptionsIsMutable(); - subscriptions_.set(index, builderForValue.build()); - onChanged(); - } else { - subscriptionsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public Builder addSubscriptions(com.google.pubsub.v1.Subscription value) { - if (subscriptionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionsIsMutable(); - subscriptions_.add(value); - onChanged(); - } else { - subscriptionsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public Builder addSubscriptions( - int index, com.google.pubsub.v1.Subscription value) { - if (subscriptionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionsIsMutable(); - subscriptions_.add(index, value); - onChanged(); - } else { - subscriptionsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public Builder addSubscriptions( - com.google.pubsub.v1.Subscription.Builder builderForValue) { - if (subscriptionsBuilder_ == null) { - ensureSubscriptionsIsMutable(); - subscriptions_.add(builderForValue.build()); - onChanged(); - } else { - subscriptionsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public Builder addSubscriptions( - int index, com.google.pubsub.v1.Subscription.Builder builderForValue) { - if (subscriptionsBuilder_ == null) { - ensureSubscriptionsIsMutable(); - subscriptions_.add(index, builderForValue.build()); - onChanged(); - } else { - subscriptionsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public Builder addAllSubscriptions( - java.lang.Iterable values) { - if (subscriptionsBuilder_ == null) { - ensureSubscriptionsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, subscriptions_); - onChanged(); - } else { - subscriptionsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public Builder clearSubscriptions() { - if (subscriptionsBuilder_ == null) { - subscriptions_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - subscriptionsBuilder_.clear(); - } - return this; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public Builder removeSubscriptions(int index) { - if (subscriptionsBuilder_ == null) { - ensureSubscriptionsIsMutable(); - subscriptions_.remove(index); - onChanged(); - } else { - subscriptionsBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public com.google.pubsub.v1.Subscription.Builder getSubscriptionsBuilder( - int index) { - return getSubscriptionsFieldBuilder().getBuilder(index); - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public com.google.pubsub.v1.SubscriptionOrBuilder getSubscriptionsOrBuilder( - int index) { - if (subscriptionsBuilder_ == null) { - return subscriptions_.get(index); } else { - return subscriptionsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public java.util.List - getSubscriptionsOrBuilderList() { - if (subscriptionsBuilder_ != null) { - return subscriptionsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(subscriptions_); - } - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public com.google.pubsub.v1.Subscription.Builder addSubscriptionsBuilder() { - return getSubscriptionsFieldBuilder().addBuilder( - com.google.pubsub.v1.Subscription.getDefaultInstance()); - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public com.google.pubsub.v1.Subscription.Builder addSubscriptionsBuilder( - int index) { - return getSubscriptionsFieldBuilder().addBuilder( - index, com.google.pubsub.v1.Subscription.getDefaultInstance()); - } - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -     * The subscriptions that match the request.
      -     * 
      - */ - public java.util.List - getSubscriptionsBuilderList() { - return getSubscriptionsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.Subscription, com.google.pubsub.v1.Subscription.Builder, com.google.pubsub.v1.SubscriptionOrBuilder> - getSubscriptionsFieldBuilder() { - if (subscriptionsBuilder_ == null) { - subscriptionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.Subscription, com.google.pubsub.v1.Subscription.Builder, com.google.pubsub.v1.SubscriptionOrBuilder>( - subscriptions_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - subscriptions_ = null; - } - return subscriptionsBuilder_; - } - - private java.lang.Object nextPageToken_ = ""; - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more subscriptions that match
      -     * the request; this value should be passed in a new ListSubscriptionsRequest
      -     * to get more subscriptions.
      -     * 
      - */ - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more subscriptions that match
      -     * the request; this value should be passed in a new ListSubscriptionsRequest
      -     * to get more subscriptions.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more subscriptions that match
      -     * the request; this value should be passed in a new ListSubscriptionsRequest
      -     * to get more subscriptions.
      -     * 
      - */ - public Builder setNextPageToken( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - nextPageToken_ = value; - onChanged(); - return this; - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more subscriptions that match
      -     * the request; this value should be passed in a new ListSubscriptionsRequest
      -     * to get more subscriptions.
      -     * 
      - */ - public Builder clearNextPageToken() { - - nextPageToken_ = getDefaultInstance().getNextPageToken(); - onChanged(); - return this; - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more subscriptions that match
      -     * the request; this value should be passed in a new ListSubscriptionsRequest
      -     * to get more subscriptions.
      -     * 
      - */ - public Builder setNextPageTokenBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - nextPageToken_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListSubscriptionsResponse) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListSubscriptionsResponse) - private static final com.google.pubsub.v1.ListSubscriptionsResponse DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.ListSubscriptionsResponse(); - } - - public static com.google.pubsub.v1.ListSubscriptionsResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ListSubscriptionsResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ListSubscriptionsResponse(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.ListSubscriptionsResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponseOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponseOrBuilder.java deleted file mode 100644 index c931a95d7dc1..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListSubscriptionsResponseOrBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface ListSubscriptionsResponseOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListSubscriptionsResponse) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -   * The subscriptions that match the request.
      -   * 
      - */ - java.util.List - getSubscriptionsList(); - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -   * The subscriptions that match the request.
      -   * 
      - */ - com.google.pubsub.v1.Subscription getSubscriptions(int index); - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -   * The subscriptions that match the request.
      -   * 
      - */ - int getSubscriptionsCount(); - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -   * The subscriptions that match the request.
      -   * 
      - */ - java.util.List - getSubscriptionsOrBuilderList(); - /** - * repeated .google.pubsub.v1.Subscription subscriptions = 1; - * - *
      -   * The subscriptions that match the request.
      -   * 
      - */ - com.google.pubsub.v1.SubscriptionOrBuilder getSubscriptionsOrBuilder( - int index); - - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more subscriptions that match
      -   * the request; this value should be passed in a new ListSubscriptionsRequest
      -   * to get more subscriptions.
      -   * 
      - */ - java.lang.String getNextPageToken(); - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more subscriptions that match
      -   * the request; this value should be passed in a new ListSubscriptionsRequest
      -   * to get more subscriptions.
      -   * 
      - */ - com.google.protobuf.ByteString - getNextPageTokenBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequest.java deleted file mode 100644 index c0e56b784e13..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequest.java +++ /dev/null @@ -1,711 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.ListTopicSubscriptionsRequest} - * - *
      - * Request for the ListTopicSubscriptions method.
      - * 
      - */ -public final class ListTopicSubscriptionsRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListTopicSubscriptionsRequest) - ListTopicSubscriptionsRequestOrBuilder { - // Use ListTopicSubscriptionsRequest.newBuilder() to construct. - private ListTopicSubscriptionsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ListTopicSubscriptionsRequest() { - topic_ = ""; - pageSize_ = 0; - pageToken_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ListTopicSubscriptionsRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - case 16: { - - pageSize_ = input.readInt32(); - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - pageToken_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListTopicSubscriptionsRequest.class, com.google.pubsub.v1.ListTopicSubscriptionsRequest.Builder.class); - } - - public static final int TOPIC_FIELD_NUMBER = 1; - private volatile java.lang.Object topic_; - /** - * optional string topic = 1; - * - *
      -   * The name of the topic that subscriptions are attached to.
      -   * 
      - */ - public java.lang.String getTopic() { - java.lang.Object ref = topic_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - /** - * optional string topic = 1; - * - *
      -   * The name of the topic that subscriptions are attached to.
      -   * 
      - */ - public com.google.protobuf.ByteString - getTopicBytes() { - java.lang.Object ref = topic_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PAGE_SIZE_FIELD_NUMBER = 2; - private int pageSize_; - /** - * optional int32 page_size = 2; - * - *
      -   * Maximum number of subscription names to return.
      -   * 
      - */ - public int getPageSize() { - return pageSize_; - } - - public static final int PAGE_TOKEN_FIELD_NUMBER = 3; - private volatile java.lang.Object pageToken_; - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListTopicSubscriptionsResponse; indicates
      -   * that this is a continuation of a prior ListTopicSubscriptions call, and
      -   * that the system should return the next page of data.
      -   * 
      - */ - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } - } - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListTopicSubscriptionsResponse; indicates
      -   * that this is a continuation of a prior ListTopicSubscriptions call, and
      -   * that the system should return the next page of data.
      -   * 
      - */ - public com.google.protobuf.ByteString - getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, topic_); - } - if (pageSize_ != 0) { - output.writeInt32(2, pageSize_); - } - if (!getPageTokenBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 3, pageToken_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, topic_); - } - if (pageSize_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, pageSize_); - } - if (!getPageTokenBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pageToken_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.ListTopicSubscriptionsRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.ListTopicSubscriptionsRequest} - * - *
      -   * Request for the ListTopicSubscriptions method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListTopicSubscriptionsRequest) - com.google.pubsub.v1.ListTopicSubscriptionsRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListTopicSubscriptionsRequest.class, com.google.pubsub.v1.ListTopicSubscriptionsRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.ListTopicSubscriptionsRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - topic_ = ""; - - pageSize_ = 0; - - pageToken_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor; - } - - public com.google.pubsub.v1.ListTopicSubscriptionsRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.ListTopicSubscriptionsRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.ListTopicSubscriptionsRequest build() { - com.google.pubsub.v1.ListTopicSubscriptionsRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.ListTopicSubscriptionsRequest buildPartial() { - com.google.pubsub.v1.ListTopicSubscriptionsRequest result = new com.google.pubsub.v1.ListTopicSubscriptionsRequest(this); - result.topic_ = topic_; - result.pageSize_ = pageSize_; - result.pageToken_ = pageToken_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.ListTopicSubscriptionsRequest) { - return mergeFrom((com.google.pubsub.v1.ListTopicSubscriptionsRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.ListTopicSubscriptionsRequest other) { - if (other == com.google.pubsub.v1.ListTopicSubscriptionsRequest.getDefaultInstance()) return this; - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - if (other.getPageSize() != 0) { - setPageSize(other.getPageSize()); - } - if (!other.getPageToken().isEmpty()) { - pageToken_ = other.pageToken_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.ListTopicSubscriptionsRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.ListTopicSubscriptionsRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object topic_ = ""; - /** - * optional string topic = 1; - * - *
      -     * The name of the topic that subscriptions are attached to.
      -     * 
      - */ - public java.lang.String getTopic() { - java.lang.Object ref = topic_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string topic = 1; - * - *
      -     * The name of the topic that subscriptions are attached to.
      -     * 
      - */ - public com.google.protobuf.ByteString - getTopicBytes() { - java.lang.Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string topic = 1; - * - *
      -     * The name of the topic that subscriptions are attached to.
      -     * 
      - */ - public Builder setTopic( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - /** - * optional string topic = 1; - * - *
      -     * The name of the topic that subscriptions are attached to.
      -     * 
      - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - /** - * optional string topic = 1; - * - *
      -     * The name of the topic that subscriptions are attached to.
      -     * 
      - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - - private int pageSize_ ; - /** - * optional int32 page_size = 2; - * - *
      -     * Maximum number of subscription names to return.
      -     * 
      - */ - public int getPageSize() { - return pageSize_; - } - /** - * optional int32 page_size = 2; - * - *
      -     * Maximum number of subscription names to return.
      -     * 
      - */ - public Builder setPageSize(int value) { - - pageSize_ = value; - onChanged(); - return this; - } - /** - * optional int32 page_size = 2; - * - *
      -     * Maximum number of subscription names to return.
      -     * 
      - */ - public Builder clearPageSize() { - - pageSize_ = 0; - onChanged(); - return this; - } - - private java.lang.Object pageToken_ = ""; - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListTopicSubscriptionsResponse; indicates
      -     * that this is a continuation of a prior ListTopicSubscriptions call, and
      -     * that the system should return the next page of data.
      -     * 
      - */ - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListTopicSubscriptionsResponse; indicates
      -     * that this is a continuation of a prior ListTopicSubscriptions call, and
      -     * that the system should return the next page of data.
      -     * 
      - */ - public com.google.protobuf.ByteString - getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListTopicSubscriptionsResponse; indicates
      -     * that this is a continuation of a prior ListTopicSubscriptions call, and
      -     * that the system should return the next page of data.
      -     * 
      - */ - public Builder setPageToken( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - pageToken_ = value; - onChanged(); - return this; - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListTopicSubscriptionsResponse; indicates
      -     * that this is a continuation of a prior ListTopicSubscriptions call, and
      -     * that the system should return the next page of data.
      -     * 
      - */ - public Builder clearPageToken() { - - pageToken_ = getDefaultInstance().getPageToken(); - onChanged(); - return this; - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListTopicSubscriptionsResponse; indicates
      -     * that this is a continuation of a prior ListTopicSubscriptions call, and
      -     * that the system should return the next page of data.
      -     * 
      - */ - public Builder setPageTokenBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pageToken_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListTopicSubscriptionsRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListTopicSubscriptionsRequest) - private static final com.google.pubsub.v1.ListTopicSubscriptionsRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.ListTopicSubscriptionsRequest(); - } - - public static com.google.pubsub.v1.ListTopicSubscriptionsRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ListTopicSubscriptionsRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ListTopicSubscriptionsRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.ListTopicSubscriptionsRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequestOrBuilder.java deleted file mode 100644 index dafee9be2078..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsRequestOrBuilder.java +++ /dev/null @@ -1,58 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface ListTopicSubscriptionsRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListTopicSubscriptionsRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string topic = 1; - * - *
      -   * The name of the topic that subscriptions are attached to.
      -   * 
      - */ - java.lang.String getTopic(); - /** - * optional string topic = 1; - * - *
      -   * The name of the topic that subscriptions are attached to.
      -   * 
      - */ - com.google.protobuf.ByteString - getTopicBytes(); - - /** - * optional int32 page_size = 2; - * - *
      -   * Maximum number of subscription names to return.
      -   * 
      - */ - int getPageSize(); - - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListTopicSubscriptionsResponse; indicates
      -   * that this is a continuation of a prior ListTopicSubscriptions call, and
      -   * that the system should return the next page of data.
      -   * 
      - */ - java.lang.String getPageToken(); - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListTopicSubscriptionsResponse; indicates
      -   * that this is a continuation of a prior ListTopicSubscriptions call, and
      -   * that the system should return the next page of data.
      -   * 
      - */ - com.google.protobuf.ByteString - getPageTokenBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponse.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponse.java deleted file mode 100644 index 3fe8e4ccf74b..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponse.java +++ /dev/null @@ -1,711 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.ListTopicSubscriptionsResponse} - * - *
      - * Response for the ListTopicSubscriptions method.
      - * 
      - */ -public final class ListTopicSubscriptionsResponse extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListTopicSubscriptionsResponse) - ListTopicSubscriptionsResponseOrBuilder { - // Use ListTopicSubscriptionsResponse.newBuilder() to construct. - private ListTopicSubscriptionsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ListTopicSubscriptionsResponse() { - subscriptions_ = com.google.protobuf.LazyStringArrayList.EMPTY; - nextPageToken_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ListTopicSubscriptionsResponse( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - subscriptions_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; - } - subscriptions_.add(s); - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - nextPageToken_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - subscriptions_ = subscriptions_.getUnmodifiableView(); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListTopicSubscriptionsResponse.class, com.google.pubsub.v1.ListTopicSubscriptionsResponse.Builder.class); - } - - private int bitField0_; - public static final int SUBSCRIPTIONS_FIELD_NUMBER = 1; - private com.google.protobuf.LazyStringList subscriptions_; - /** - * repeated string subscriptions = 1; - * - *
      -   * The names of the subscriptions that match the request.
      -   * 
      - */ - public com.google.protobuf.ProtocolStringList - getSubscriptionsList() { - return subscriptions_; - } - /** - * repeated string subscriptions = 1; - * - *
      -   * The names of the subscriptions that match the request.
      -   * 
      - */ - public int getSubscriptionsCount() { - return subscriptions_.size(); - } - /** - * repeated string subscriptions = 1; - * - *
      -   * The names of the subscriptions that match the request.
      -   * 
      - */ - public java.lang.String getSubscriptions(int index) { - return subscriptions_.get(index); - } - /** - * repeated string subscriptions = 1; - * - *
      -   * The names of the subscriptions that match the request.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionsBytes(int index) { - return subscriptions_.getByteString(index); - } - - public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; - private volatile java.lang.Object nextPageToken_; - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more subscriptions that match
      -   * the request; this value should be passed in a new
      -   * ListTopicSubscriptionsRequest to get more subscriptions.
      -   * 
      - */ - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } - } - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more subscriptions that match
      -   * the request; this value should be passed in a new
      -   * ListTopicSubscriptionsRequest to get more subscriptions.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < subscriptions_.size(); i++) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, subscriptions_.getRaw(i)); - } - if (!getNextPageTokenBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - for (int i = 0; i < subscriptions_.size(); i++) { - dataSize += computeStringSizeNoTag(subscriptions_.getRaw(i)); - } - size += dataSize; - size += 1 * getSubscriptionsList().size(); - } - if (!getNextPageTokenBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.ListTopicSubscriptionsResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.ListTopicSubscriptionsResponse} - * - *
      -   * Response for the ListTopicSubscriptions method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListTopicSubscriptionsResponse) - com.google.pubsub.v1.ListTopicSubscriptionsResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListTopicSubscriptionsResponse.class, com.google.pubsub.v1.ListTopicSubscriptionsResponse.Builder.class); - } - - // Construct using com.google.pubsub.v1.ListTopicSubscriptionsResponse.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - subscriptions_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - nextPageToken_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor; - } - - public com.google.pubsub.v1.ListTopicSubscriptionsResponse getDefaultInstanceForType() { - return com.google.pubsub.v1.ListTopicSubscriptionsResponse.getDefaultInstance(); - } - - public com.google.pubsub.v1.ListTopicSubscriptionsResponse build() { - com.google.pubsub.v1.ListTopicSubscriptionsResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.ListTopicSubscriptionsResponse buildPartial() { - com.google.pubsub.v1.ListTopicSubscriptionsResponse result = new com.google.pubsub.v1.ListTopicSubscriptionsResponse(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - subscriptions_ = subscriptions_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.subscriptions_ = subscriptions_; - result.nextPageToken_ = nextPageToken_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.ListTopicSubscriptionsResponse) { - return mergeFrom((com.google.pubsub.v1.ListTopicSubscriptionsResponse)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.ListTopicSubscriptionsResponse other) { - if (other == com.google.pubsub.v1.ListTopicSubscriptionsResponse.getDefaultInstance()) return this; - if (!other.subscriptions_.isEmpty()) { - if (subscriptions_.isEmpty()) { - subscriptions_ = other.subscriptions_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureSubscriptionsIsMutable(); - subscriptions_.addAll(other.subscriptions_); - } - onChanged(); - } - if (!other.getNextPageToken().isEmpty()) { - nextPageToken_ = other.nextPageToken_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.ListTopicSubscriptionsResponse parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.ListTopicSubscriptionsResponse) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private com.google.protobuf.LazyStringList subscriptions_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureSubscriptionsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - subscriptions_ = new com.google.protobuf.LazyStringArrayList(subscriptions_); - bitField0_ |= 0x00000001; - } - } - /** - * repeated string subscriptions = 1; - * - *
      -     * The names of the subscriptions that match the request.
      -     * 
      - */ - public com.google.protobuf.ProtocolStringList - getSubscriptionsList() { - return subscriptions_.getUnmodifiableView(); - } - /** - * repeated string subscriptions = 1; - * - *
      -     * The names of the subscriptions that match the request.
      -     * 
      - */ - public int getSubscriptionsCount() { - return subscriptions_.size(); - } - /** - * repeated string subscriptions = 1; - * - *
      -     * The names of the subscriptions that match the request.
      -     * 
      - */ - public java.lang.String getSubscriptions(int index) { - return subscriptions_.get(index); - } - /** - * repeated string subscriptions = 1; - * - *
      -     * The names of the subscriptions that match the request.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionsBytes(int index) { - return subscriptions_.getByteString(index); - } - /** - * repeated string subscriptions = 1; - * - *
      -     * The names of the subscriptions that match the request.
      -     * 
      - */ - public Builder setSubscriptions( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionsIsMutable(); - subscriptions_.set(index, value); - onChanged(); - return this; - } - /** - * repeated string subscriptions = 1; - * - *
      -     * The names of the subscriptions that match the request.
      -     * 
      - */ - public Builder addSubscriptions( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureSubscriptionsIsMutable(); - subscriptions_.add(value); - onChanged(); - return this; - } - /** - * repeated string subscriptions = 1; - * - *
      -     * The names of the subscriptions that match the request.
      -     * 
      - */ - public Builder addAllSubscriptions( - java.lang.Iterable values) { - ensureSubscriptionsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, subscriptions_); - onChanged(); - return this; - } - /** - * repeated string subscriptions = 1; - * - *
      -     * The names of the subscriptions that match the request.
      -     * 
      - */ - public Builder clearSubscriptions() { - subscriptions_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - * repeated string subscriptions = 1; - * - *
      -     * The names of the subscriptions that match the request.
      -     * 
      - */ - public Builder addSubscriptionsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureSubscriptionsIsMutable(); - subscriptions_.add(value); - onChanged(); - return this; - } - - private java.lang.Object nextPageToken_ = ""; - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more subscriptions that match
      -     * the request; this value should be passed in a new
      -     * ListTopicSubscriptionsRequest to get more subscriptions.
      -     * 
      - */ - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more subscriptions that match
      -     * the request; this value should be passed in a new
      -     * ListTopicSubscriptionsRequest to get more subscriptions.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more subscriptions that match
      -     * the request; this value should be passed in a new
      -     * ListTopicSubscriptionsRequest to get more subscriptions.
      -     * 
      - */ - public Builder setNextPageToken( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - nextPageToken_ = value; - onChanged(); - return this; - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more subscriptions that match
      -     * the request; this value should be passed in a new
      -     * ListTopicSubscriptionsRequest to get more subscriptions.
      -     * 
      - */ - public Builder clearNextPageToken() { - - nextPageToken_ = getDefaultInstance().getNextPageToken(); - onChanged(); - return this; - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more subscriptions that match
      -     * the request; this value should be passed in a new
      -     * ListTopicSubscriptionsRequest to get more subscriptions.
      -     * 
      - */ - public Builder setNextPageTokenBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - nextPageToken_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListTopicSubscriptionsResponse) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListTopicSubscriptionsResponse) - private static final com.google.pubsub.v1.ListTopicSubscriptionsResponse DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.ListTopicSubscriptionsResponse(); - } - - public static com.google.pubsub.v1.ListTopicSubscriptionsResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ListTopicSubscriptionsResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ListTopicSubscriptionsResponse(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.ListTopicSubscriptionsResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponseOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponseOrBuilder.java deleted file mode 100644 index 7cfc77118c55..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicSubscriptionsResponseOrBuilder.java +++ /dev/null @@ -1,66 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface ListTopicSubscriptionsResponseOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListTopicSubscriptionsResponse) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated string subscriptions = 1; - * - *
      -   * The names of the subscriptions that match the request.
      -   * 
      - */ - com.google.protobuf.ProtocolStringList - getSubscriptionsList(); - /** - * repeated string subscriptions = 1; - * - *
      -   * The names of the subscriptions that match the request.
      -   * 
      - */ - int getSubscriptionsCount(); - /** - * repeated string subscriptions = 1; - * - *
      -   * The names of the subscriptions that match the request.
      -   * 
      - */ - java.lang.String getSubscriptions(int index); - /** - * repeated string subscriptions = 1; - * - *
      -   * The names of the subscriptions that match the request.
      -   * 
      - */ - com.google.protobuf.ByteString - getSubscriptionsBytes(int index); - - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more subscriptions that match
      -   * the request; this value should be passed in a new
      -   * ListTopicSubscriptionsRequest to get more subscriptions.
      -   * 
      - */ - java.lang.String getNextPageToken(); - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more subscriptions that match
      -   * the request; this value should be passed in a new
      -   * ListTopicSubscriptionsRequest to get more subscriptions.
      -   * 
      - */ - com.google.protobuf.ByteString - getNextPageTokenBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequest.java deleted file mode 100644 index 3657dfe92162..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequest.java +++ /dev/null @@ -1,711 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.ListTopicsRequest} - * - *
      - * Request for the ListTopics method.
      - * 
      - */ -public final class ListTopicsRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListTopicsRequest) - ListTopicsRequestOrBuilder { - // Use ListTopicsRequest.newBuilder() to construct. - private ListTopicsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ListTopicsRequest() { - project_ = ""; - pageSize_ = 0; - pageToken_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ListTopicsRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - project_ = s; - break; - } - case 16: { - - pageSize_ = input.readInt32(); - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - pageToken_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListTopicsRequest.class, com.google.pubsub.v1.ListTopicsRequest.Builder.class); - } - - public static final int PROJECT_FIELD_NUMBER = 1; - private volatile java.lang.Object project_; - /** - * optional string project = 1; - * - *
      -   * The name of the cloud project that topics belong to.
      -   * 
      - */ - public java.lang.String getProject() { - java.lang.Object ref = project_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - project_ = s; - return s; - } - } - /** - * optional string project = 1; - * - *
      -   * The name of the cloud project that topics belong to.
      -   * 
      - */ - public com.google.protobuf.ByteString - getProjectBytes() { - java.lang.Object ref = project_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - project_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PAGE_SIZE_FIELD_NUMBER = 2; - private int pageSize_; - /** - * optional int32 page_size = 2; - * - *
      -   * Maximum number of topics to return.
      -   * 
      - */ - public int getPageSize() { - return pageSize_; - } - - public static final int PAGE_TOKEN_FIELD_NUMBER = 3; - private volatile java.lang.Object pageToken_; - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListTopicsResponse; indicates that this is
      -   * a continuation of a prior ListTopics call, and that the system should
      -   * return the next page of data.
      -   * 
      - */ - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } - } - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListTopicsResponse; indicates that this is
      -   * a continuation of a prior ListTopics call, and that the system should
      -   * return the next page of data.
      -   * 
      - */ - public com.google.protobuf.ByteString - getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getProjectBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, project_); - } - if (pageSize_ != 0) { - output.writeInt32(2, pageSize_); - } - if (!getPageTokenBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 3, pageToken_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getProjectBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, project_); - } - if (pageSize_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, pageSize_); - } - if (!getPageTokenBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pageToken_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.ListTopicsRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListTopicsRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicsRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListTopicsRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicsRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListTopicsRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicsRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.ListTopicsRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicsRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListTopicsRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.ListTopicsRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.ListTopicsRequest} - * - *
      -   * Request for the ListTopics method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListTopicsRequest) - com.google.pubsub.v1.ListTopicsRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListTopicsRequest.class, com.google.pubsub.v1.ListTopicsRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.ListTopicsRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - project_ = ""; - - pageSize_ = 0; - - pageToken_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsRequest_descriptor; - } - - public com.google.pubsub.v1.ListTopicsRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.ListTopicsRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.ListTopicsRequest build() { - com.google.pubsub.v1.ListTopicsRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.ListTopicsRequest buildPartial() { - com.google.pubsub.v1.ListTopicsRequest result = new com.google.pubsub.v1.ListTopicsRequest(this); - result.project_ = project_; - result.pageSize_ = pageSize_; - result.pageToken_ = pageToken_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.ListTopicsRequest) { - return mergeFrom((com.google.pubsub.v1.ListTopicsRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.ListTopicsRequest other) { - if (other == com.google.pubsub.v1.ListTopicsRequest.getDefaultInstance()) return this; - if (!other.getProject().isEmpty()) { - project_ = other.project_; - onChanged(); - } - if (other.getPageSize() != 0) { - setPageSize(other.getPageSize()); - } - if (!other.getPageToken().isEmpty()) { - pageToken_ = other.pageToken_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.ListTopicsRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.ListTopicsRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object project_ = ""; - /** - * optional string project = 1; - * - *
      -     * The name of the cloud project that topics belong to.
      -     * 
      - */ - public java.lang.String getProject() { - java.lang.Object ref = project_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - project_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string project = 1; - * - *
      -     * The name of the cloud project that topics belong to.
      -     * 
      - */ - public com.google.protobuf.ByteString - getProjectBytes() { - java.lang.Object ref = project_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - project_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string project = 1; - * - *
      -     * The name of the cloud project that topics belong to.
      -     * 
      - */ - public Builder setProject( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - project_ = value; - onChanged(); - return this; - } - /** - * optional string project = 1; - * - *
      -     * The name of the cloud project that topics belong to.
      -     * 
      - */ - public Builder clearProject() { - - project_ = getDefaultInstance().getProject(); - onChanged(); - return this; - } - /** - * optional string project = 1; - * - *
      -     * The name of the cloud project that topics belong to.
      -     * 
      - */ - public Builder setProjectBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - project_ = value; - onChanged(); - return this; - } - - private int pageSize_ ; - /** - * optional int32 page_size = 2; - * - *
      -     * Maximum number of topics to return.
      -     * 
      - */ - public int getPageSize() { - return pageSize_; - } - /** - * optional int32 page_size = 2; - * - *
      -     * Maximum number of topics to return.
      -     * 
      - */ - public Builder setPageSize(int value) { - - pageSize_ = value; - onChanged(); - return this; - } - /** - * optional int32 page_size = 2; - * - *
      -     * Maximum number of topics to return.
      -     * 
      - */ - public Builder clearPageSize() { - - pageSize_ = 0; - onChanged(); - return this; - } - - private java.lang.Object pageToken_ = ""; - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListTopicsResponse; indicates that this is
      -     * a continuation of a prior ListTopics call, and that the system should
      -     * return the next page of data.
      -     * 
      - */ - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListTopicsResponse; indicates that this is
      -     * a continuation of a prior ListTopics call, and that the system should
      -     * return the next page of data.
      -     * 
      - */ - public com.google.protobuf.ByteString - getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListTopicsResponse; indicates that this is
      -     * a continuation of a prior ListTopics call, and that the system should
      -     * return the next page of data.
      -     * 
      - */ - public Builder setPageToken( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - pageToken_ = value; - onChanged(); - return this; - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListTopicsResponse; indicates that this is
      -     * a continuation of a prior ListTopics call, and that the system should
      -     * return the next page of data.
      -     * 
      - */ - public Builder clearPageToken() { - - pageToken_ = getDefaultInstance().getPageToken(); - onChanged(); - return this; - } - /** - * optional string page_token = 3; - * - *
      -     * The value returned by the last ListTopicsResponse; indicates that this is
      -     * a continuation of a prior ListTopics call, and that the system should
      -     * return the next page of data.
      -     * 
      - */ - public Builder setPageTokenBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pageToken_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListTopicsRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListTopicsRequest) - private static final com.google.pubsub.v1.ListTopicsRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.ListTopicsRequest(); - } - - public static com.google.pubsub.v1.ListTopicsRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ListTopicsRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ListTopicsRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.ListTopicsRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequestOrBuilder.java deleted file mode 100644 index 2b8d27032226..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsRequestOrBuilder.java +++ /dev/null @@ -1,58 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface ListTopicsRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListTopicsRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string project = 1; - * - *
      -   * The name of the cloud project that topics belong to.
      -   * 
      - */ - java.lang.String getProject(); - /** - * optional string project = 1; - * - *
      -   * The name of the cloud project that topics belong to.
      -   * 
      - */ - com.google.protobuf.ByteString - getProjectBytes(); - - /** - * optional int32 page_size = 2; - * - *
      -   * Maximum number of topics to return.
      -   * 
      - */ - int getPageSize(); - - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListTopicsResponse; indicates that this is
      -   * a continuation of a prior ListTopics call, and that the system should
      -   * return the next page of data.
      -   * 
      - */ - java.lang.String getPageToken(); - /** - * optional string page_token = 3; - * - *
      -   * The value returned by the last ListTopicsResponse; indicates that this is
      -   * a continuation of a prior ListTopics call, and that the system should
      -   * return the next page of data.
      -   * 
      - */ - com.google.protobuf.ByteString - getPageTokenBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponse.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponse.java deleted file mode 100644 index 80928fca5160..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponse.java +++ /dev/null @@ -1,916 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.ListTopicsResponse} - * - *
      - * Response for the ListTopics method.
      - * 
      - */ -public final class ListTopicsResponse extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.ListTopicsResponse) - ListTopicsResponseOrBuilder { - // Use ListTopicsResponse.newBuilder() to construct. - private ListTopicsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ListTopicsResponse() { - topics_ = java.util.Collections.emptyList(); - nextPageToken_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ListTopicsResponse( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - topics_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - topics_.add(input.readMessage(com.google.pubsub.v1.Topic.parser(), extensionRegistry)); - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - nextPageToken_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - topics_ = java.util.Collections.unmodifiableList(topics_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListTopicsResponse.class, com.google.pubsub.v1.ListTopicsResponse.Builder.class); - } - - private int bitField0_; - public static final int TOPICS_FIELD_NUMBER = 1; - private java.util.List topics_; - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -   * The resulting topics.
      -   * 
      - */ - public java.util.List getTopicsList() { - return topics_; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -   * The resulting topics.
      -   * 
      - */ - public java.util.List - getTopicsOrBuilderList() { - return topics_; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -   * The resulting topics.
      -   * 
      - */ - public int getTopicsCount() { - return topics_.size(); - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -   * The resulting topics.
      -   * 
      - */ - public com.google.pubsub.v1.Topic getTopics(int index) { - return topics_.get(index); - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -   * The resulting topics.
      -   * 
      - */ - public com.google.pubsub.v1.TopicOrBuilder getTopicsOrBuilder( - int index) { - return topics_.get(index); - } - - public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; - private volatile java.lang.Object nextPageToken_; - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more topics that match the
      -   * request; this value should be passed in a new ListTopicsRequest.
      -   * 
      - */ - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } - } - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more topics that match the
      -   * request; this value should be passed in a new ListTopicsRequest.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < topics_.size(); i++) { - output.writeMessage(1, topics_.get(i)); - } - if (!getNextPageTokenBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < topics_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, topics_.get(i)); - } - if (!getNextPageTokenBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.ListTopicsResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListTopicsResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicsResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ListTopicsResponse parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicsResponse parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListTopicsResponse parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicsResponse parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.ListTopicsResponse parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ListTopicsResponse parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ListTopicsResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.ListTopicsResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.ListTopicsResponse} - * - *
      -   * Response for the ListTopics method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ListTopicsResponse) - com.google.pubsub.v1.ListTopicsResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ListTopicsResponse.class, com.google.pubsub.v1.ListTopicsResponse.Builder.class); - } - - // Construct using com.google.pubsub.v1.ListTopicsResponse.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getTopicsFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (topicsBuilder_ == null) { - topics_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - topicsBuilder_.clear(); - } - nextPageToken_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ListTopicsResponse_descriptor; - } - - public com.google.pubsub.v1.ListTopicsResponse getDefaultInstanceForType() { - return com.google.pubsub.v1.ListTopicsResponse.getDefaultInstance(); - } - - public com.google.pubsub.v1.ListTopicsResponse build() { - com.google.pubsub.v1.ListTopicsResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.ListTopicsResponse buildPartial() { - com.google.pubsub.v1.ListTopicsResponse result = new com.google.pubsub.v1.ListTopicsResponse(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (topicsBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - topics_ = java.util.Collections.unmodifiableList(topics_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.topics_ = topics_; - } else { - result.topics_ = topicsBuilder_.build(); - } - result.nextPageToken_ = nextPageToken_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.ListTopicsResponse) { - return mergeFrom((com.google.pubsub.v1.ListTopicsResponse)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.ListTopicsResponse other) { - if (other == com.google.pubsub.v1.ListTopicsResponse.getDefaultInstance()) return this; - if (topicsBuilder_ == null) { - if (!other.topics_.isEmpty()) { - if (topics_.isEmpty()) { - topics_ = other.topics_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureTopicsIsMutable(); - topics_.addAll(other.topics_); - } - onChanged(); - } - } else { - if (!other.topics_.isEmpty()) { - if (topicsBuilder_.isEmpty()) { - topicsBuilder_.dispose(); - topicsBuilder_ = null; - topics_ = other.topics_; - bitField0_ = (bitField0_ & ~0x00000001); - topicsBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getTopicsFieldBuilder() : null; - } else { - topicsBuilder_.addAllMessages(other.topics_); - } - } - } - if (!other.getNextPageToken().isEmpty()) { - nextPageToken_ = other.nextPageToken_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.ListTopicsResponse parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.ListTopicsResponse) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List topics_ = - java.util.Collections.emptyList(); - private void ensureTopicsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - topics_ = new java.util.ArrayList(topics_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.Topic, com.google.pubsub.v1.Topic.Builder, com.google.pubsub.v1.TopicOrBuilder> topicsBuilder_; - - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public java.util.List getTopicsList() { - if (topicsBuilder_ == null) { - return java.util.Collections.unmodifiableList(topics_); - } else { - return topicsBuilder_.getMessageList(); - } - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public int getTopicsCount() { - if (topicsBuilder_ == null) { - return topics_.size(); - } else { - return topicsBuilder_.getCount(); - } - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public com.google.pubsub.v1.Topic getTopics(int index) { - if (topicsBuilder_ == null) { - return topics_.get(index); - } else { - return topicsBuilder_.getMessage(index); - } - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public Builder setTopics( - int index, com.google.pubsub.v1.Topic value) { - if (topicsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTopicsIsMutable(); - topics_.set(index, value); - onChanged(); - } else { - topicsBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public Builder setTopics( - int index, com.google.pubsub.v1.Topic.Builder builderForValue) { - if (topicsBuilder_ == null) { - ensureTopicsIsMutable(); - topics_.set(index, builderForValue.build()); - onChanged(); - } else { - topicsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public Builder addTopics(com.google.pubsub.v1.Topic value) { - if (topicsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTopicsIsMutable(); - topics_.add(value); - onChanged(); - } else { - topicsBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public Builder addTopics( - int index, com.google.pubsub.v1.Topic value) { - if (topicsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureTopicsIsMutable(); - topics_.add(index, value); - onChanged(); - } else { - topicsBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public Builder addTopics( - com.google.pubsub.v1.Topic.Builder builderForValue) { - if (topicsBuilder_ == null) { - ensureTopicsIsMutable(); - topics_.add(builderForValue.build()); - onChanged(); - } else { - topicsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public Builder addTopics( - int index, com.google.pubsub.v1.Topic.Builder builderForValue) { - if (topicsBuilder_ == null) { - ensureTopicsIsMutable(); - topics_.add(index, builderForValue.build()); - onChanged(); - } else { - topicsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public Builder addAllTopics( - java.lang.Iterable values) { - if (topicsBuilder_ == null) { - ensureTopicsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, topics_); - onChanged(); - } else { - topicsBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public Builder clearTopics() { - if (topicsBuilder_ == null) { - topics_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - topicsBuilder_.clear(); - } - return this; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public Builder removeTopics(int index) { - if (topicsBuilder_ == null) { - ensureTopicsIsMutable(); - topics_.remove(index); - onChanged(); - } else { - topicsBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public com.google.pubsub.v1.Topic.Builder getTopicsBuilder( - int index) { - return getTopicsFieldBuilder().getBuilder(index); - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public com.google.pubsub.v1.TopicOrBuilder getTopicsOrBuilder( - int index) { - if (topicsBuilder_ == null) { - return topics_.get(index); } else { - return topicsBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public java.util.List - getTopicsOrBuilderList() { - if (topicsBuilder_ != null) { - return topicsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(topics_); - } - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public com.google.pubsub.v1.Topic.Builder addTopicsBuilder() { - return getTopicsFieldBuilder().addBuilder( - com.google.pubsub.v1.Topic.getDefaultInstance()); - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public com.google.pubsub.v1.Topic.Builder addTopicsBuilder( - int index) { - return getTopicsFieldBuilder().addBuilder( - index, com.google.pubsub.v1.Topic.getDefaultInstance()); - } - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -     * The resulting topics.
      -     * 
      - */ - public java.util.List - getTopicsBuilderList() { - return getTopicsFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.Topic, com.google.pubsub.v1.Topic.Builder, com.google.pubsub.v1.TopicOrBuilder> - getTopicsFieldBuilder() { - if (topicsBuilder_ == null) { - topicsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.Topic, com.google.pubsub.v1.Topic.Builder, com.google.pubsub.v1.TopicOrBuilder>( - topics_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - topics_ = null; - } - return topicsBuilder_; - } - - private java.lang.Object nextPageToken_ = ""; - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more topics that match the
      -     * request; this value should be passed in a new ListTopicsRequest.
      -     * 
      - */ - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more topics that match the
      -     * request; this value should be passed in a new ListTopicsRequest.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more topics that match the
      -     * request; this value should be passed in a new ListTopicsRequest.
      -     * 
      - */ - public Builder setNextPageToken( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - nextPageToken_ = value; - onChanged(); - return this; - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more topics that match the
      -     * request; this value should be passed in a new ListTopicsRequest.
      -     * 
      - */ - public Builder clearNextPageToken() { - - nextPageToken_ = getDefaultInstance().getNextPageToken(); - onChanged(); - return this; - } - /** - * optional string next_page_token = 2; - * - *
      -     * If not empty, indicates that there may be more topics that match the
      -     * request; this value should be passed in a new ListTopicsRequest.
      -     * 
      - */ - public Builder setNextPageTokenBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - nextPageToken_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ListTopicsResponse) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.ListTopicsResponse) - private static final com.google.pubsub.v1.ListTopicsResponse DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.ListTopicsResponse(); - } - - public static com.google.pubsub.v1.ListTopicsResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ListTopicsResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ListTopicsResponse(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.ListTopicsResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponseOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponseOrBuilder.java deleted file mode 100644 index 60d5d7ac17da..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ListTopicsResponseOrBuilder.java +++ /dev/null @@ -1,73 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface ListTopicsResponseOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ListTopicsResponse) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -   * The resulting topics.
      -   * 
      - */ - java.util.List - getTopicsList(); - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -   * The resulting topics.
      -   * 
      - */ - com.google.pubsub.v1.Topic getTopics(int index); - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -   * The resulting topics.
      -   * 
      - */ - int getTopicsCount(); - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -   * The resulting topics.
      -   * 
      - */ - java.util.List - getTopicsOrBuilderList(); - /** - * repeated .google.pubsub.v1.Topic topics = 1; - * - *
      -   * The resulting topics.
      -   * 
      - */ - com.google.pubsub.v1.TopicOrBuilder getTopicsOrBuilder( - int index); - - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more topics that match the
      -   * request; this value should be passed in a new ListTopicsRequest.
      -   * 
      - */ - java.lang.String getNextPageToken(); - /** - * optional string next_page_token = 2; - * - *
      -   * If not empty, indicates that there may be more topics that match the
      -   * request; this value should be passed in a new ListTopicsRequest.
      -   * 
      - */ - com.google.protobuf.ByteString - getNextPageTokenBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequest.java deleted file mode 100644 index aa51afc2f99e..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequest.java +++ /dev/null @@ -1,783 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.ModifyAckDeadlineRequest} - * - *
      - * Request for the ModifyAckDeadline method.
      - * 
      - */ -public final class ModifyAckDeadlineRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.ModifyAckDeadlineRequest) - ModifyAckDeadlineRequestOrBuilder { - // Use ModifyAckDeadlineRequest.newBuilder() to construct. - private ModifyAckDeadlineRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ModifyAckDeadlineRequest() { - subscription_ = ""; - ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - ackDeadlineSeconds_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ModifyAckDeadlineRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - subscription_ = s; - break; - } - case 24: { - - ackDeadlineSeconds_ = input.readInt32(); - break; - } - case 34: { - String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - ackIds_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000002; - } - ackIds_.add(s); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - ackIds_ = ackIds_.getUnmodifiableView(); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ModifyAckDeadlineRequest.class, com.google.pubsub.v1.ModifyAckDeadlineRequest.Builder.class); - } - - private int bitField0_; - public static final int SUBSCRIPTION_FIELD_NUMBER = 1; - private volatile java.lang.Object subscription_; - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription.
      -   * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } - } - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int ACK_IDS_FIELD_NUMBER = 4; - private com.google.protobuf.LazyStringList ackIds_; - /** - * repeated string ack_ids = 4; - * - *
      -   * List of acknowledgment IDs.
      -   * 
      - */ - public com.google.protobuf.ProtocolStringList - getAckIdsList() { - return ackIds_; - } - /** - * repeated string ack_ids = 4; - * - *
      -   * List of acknowledgment IDs.
      -   * 
      - */ - public int getAckIdsCount() { - return ackIds_.size(); - } - /** - * repeated string ack_ids = 4; - * - *
      -   * List of acknowledgment IDs.
      -   * 
      - */ - public java.lang.String getAckIds(int index) { - return ackIds_.get(index); - } - /** - * repeated string ack_ids = 4; - * - *
      -   * List of acknowledgment IDs.
      -   * 
      - */ - public com.google.protobuf.ByteString - getAckIdsBytes(int index) { - return ackIds_.getByteString(index); - } - - public static final int ACK_DEADLINE_SECONDS_FIELD_NUMBER = 3; - private int ackDeadlineSeconds_; - /** - * optional int32 ack_deadline_seconds = 3; - * - *
      -   * The new ack deadline with respect to the time this request was sent to the
      -   * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
      -   * deadline will expire 10 seconds after the ModifyAckDeadline call was made.
      -   * Specifying zero may immediately make the message available for another pull
      -   * request.
      -   * 
      - */ - public int getAckDeadlineSeconds() { - return ackDeadlineSeconds_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSubscriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); - } - if (ackDeadlineSeconds_ != 0) { - output.writeInt32(3, ackDeadlineSeconds_); - } - for (int i = 0; i < ackIds_.size(); i++) { - com.google.protobuf.GeneratedMessage.writeString(output, 4, ackIds_.getRaw(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSubscriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); - } - if (ackDeadlineSeconds_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, ackDeadlineSeconds_); - } - { - int dataSize = 0; - for (int i = 0; i < ackIds_.size(); i++) { - dataSize += computeStringSizeNoTag(ackIds_.getRaw(i)); - } - size += dataSize; - size += 1 * getAckIdsList().size(); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ModifyAckDeadlineRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.ModifyAckDeadlineRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.ModifyAckDeadlineRequest} - * - *
      -   * Request for the ModifyAckDeadline method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ModifyAckDeadlineRequest) - com.google.pubsub.v1.ModifyAckDeadlineRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ModifyAckDeadlineRequest.class, com.google.pubsub.v1.ModifyAckDeadlineRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.ModifyAckDeadlineRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - subscription_ = ""; - - ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - ackDeadlineSeconds_ = 0; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor; - } - - public com.google.pubsub.v1.ModifyAckDeadlineRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.ModifyAckDeadlineRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.ModifyAckDeadlineRequest build() { - com.google.pubsub.v1.ModifyAckDeadlineRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.ModifyAckDeadlineRequest buildPartial() { - com.google.pubsub.v1.ModifyAckDeadlineRequest result = new com.google.pubsub.v1.ModifyAckDeadlineRequest(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.subscription_ = subscription_; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - ackIds_ = ackIds_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.ackIds_ = ackIds_; - result.ackDeadlineSeconds_ = ackDeadlineSeconds_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.ModifyAckDeadlineRequest) { - return mergeFrom((com.google.pubsub.v1.ModifyAckDeadlineRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.ModifyAckDeadlineRequest other) { - if (other == com.google.pubsub.v1.ModifyAckDeadlineRequest.getDefaultInstance()) return this; - if (!other.getSubscription().isEmpty()) { - subscription_ = other.subscription_; - onChanged(); - } - if (!other.ackIds_.isEmpty()) { - if (ackIds_.isEmpty()) { - ackIds_ = other.ackIds_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureAckIdsIsMutable(); - ackIds_.addAll(other.ackIds_); - } - onChanged(); - } - if (other.getAckDeadlineSeconds() != 0) { - setAckDeadlineSeconds(other.getAckDeadlineSeconds()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.ModifyAckDeadlineRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.ModifyAckDeadlineRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object subscription_ = ""; - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription.
      -     * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription.
      -     * 
      - */ - public Builder setSubscription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subscription_ = value; - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription.
      -     * 
      - */ - public Builder clearSubscription() { - - subscription_ = getDefaultInstance().getSubscription(); - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription.
      -     * 
      - */ - public Builder setSubscriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subscription_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.LazyStringList ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureAckIdsIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - ackIds_ = new com.google.protobuf.LazyStringArrayList(ackIds_); - bitField0_ |= 0x00000002; - } - } - /** - * repeated string ack_ids = 4; - * - *
      -     * List of acknowledgment IDs.
      -     * 
      - */ - public com.google.protobuf.ProtocolStringList - getAckIdsList() { - return ackIds_.getUnmodifiableView(); - } - /** - * repeated string ack_ids = 4; - * - *
      -     * List of acknowledgment IDs.
      -     * 
      - */ - public int getAckIdsCount() { - return ackIds_.size(); - } - /** - * repeated string ack_ids = 4; - * - *
      -     * List of acknowledgment IDs.
      -     * 
      - */ - public java.lang.String getAckIds(int index) { - return ackIds_.get(index); - } - /** - * repeated string ack_ids = 4; - * - *
      -     * List of acknowledgment IDs.
      -     * 
      - */ - public com.google.protobuf.ByteString - getAckIdsBytes(int index) { - return ackIds_.getByteString(index); - } - /** - * repeated string ack_ids = 4; - * - *
      -     * List of acknowledgment IDs.
      -     * 
      - */ - public Builder setAckIds( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureAckIdsIsMutable(); - ackIds_.set(index, value); - onChanged(); - return this; - } - /** - * repeated string ack_ids = 4; - * - *
      -     * List of acknowledgment IDs.
      -     * 
      - */ - public Builder addAckIds( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureAckIdsIsMutable(); - ackIds_.add(value); - onChanged(); - return this; - } - /** - * repeated string ack_ids = 4; - * - *
      -     * List of acknowledgment IDs.
      -     * 
      - */ - public Builder addAllAckIds( - java.lang.Iterable values) { - ensureAckIdsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, ackIds_); - onChanged(); - return this; - } - /** - * repeated string ack_ids = 4; - * - *
      -     * List of acknowledgment IDs.
      -     * 
      - */ - public Builder clearAckIds() { - ackIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - * repeated string ack_ids = 4; - * - *
      -     * List of acknowledgment IDs.
      -     * 
      - */ - public Builder addAckIdsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureAckIdsIsMutable(); - ackIds_.add(value); - onChanged(); - return this; - } - - private int ackDeadlineSeconds_ ; - /** - * optional int32 ack_deadline_seconds = 3; - * - *
      -     * The new ack deadline with respect to the time this request was sent to the
      -     * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
      -     * deadline will expire 10 seconds after the ModifyAckDeadline call was made.
      -     * Specifying zero may immediately make the message available for another pull
      -     * request.
      -     * 
      - */ - public int getAckDeadlineSeconds() { - return ackDeadlineSeconds_; - } - /** - * optional int32 ack_deadline_seconds = 3; - * - *
      -     * The new ack deadline with respect to the time this request was sent to the
      -     * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
      -     * deadline will expire 10 seconds after the ModifyAckDeadline call was made.
      -     * Specifying zero may immediately make the message available for another pull
      -     * request.
      -     * 
      - */ - public Builder setAckDeadlineSeconds(int value) { - - ackDeadlineSeconds_ = value; - onChanged(); - return this; - } - /** - * optional int32 ack_deadline_seconds = 3; - * - *
      -     * The new ack deadline with respect to the time this request was sent to the
      -     * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
      -     * deadline will expire 10 seconds after the ModifyAckDeadline call was made.
      -     * Specifying zero may immediately make the message available for another pull
      -     * request.
      -     * 
      - */ - public Builder clearAckDeadlineSeconds() { - - ackDeadlineSeconds_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ModifyAckDeadlineRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.ModifyAckDeadlineRequest) - private static final com.google.pubsub.v1.ModifyAckDeadlineRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.ModifyAckDeadlineRequest(); - } - - public static com.google.pubsub.v1.ModifyAckDeadlineRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ModifyAckDeadlineRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ModifyAckDeadlineRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.ModifyAckDeadlineRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequestOrBuilder.java deleted file mode 100644 index 1e375b70cc30..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyAckDeadlineRequestOrBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface ModifyAckDeadlineRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ModifyAckDeadlineRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription.
      -   * 
      - */ - java.lang.String getSubscription(); - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription.
      -   * 
      - */ - com.google.protobuf.ByteString - getSubscriptionBytes(); - - /** - * repeated string ack_ids = 4; - * - *
      -   * List of acknowledgment IDs.
      -   * 
      - */ - com.google.protobuf.ProtocolStringList - getAckIdsList(); - /** - * repeated string ack_ids = 4; - * - *
      -   * List of acknowledgment IDs.
      -   * 
      - */ - int getAckIdsCount(); - /** - * repeated string ack_ids = 4; - * - *
      -   * List of acknowledgment IDs.
      -   * 
      - */ - java.lang.String getAckIds(int index); - /** - * repeated string ack_ids = 4; - * - *
      -   * List of acknowledgment IDs.
      -   * 
      - */ - com.google.protobuf.ByteString - getAckIdsBytes(int index); - - /** - * optional int32 ack_deadline_seconds = 3; - * - *
      -   * The new ack deadline with respect to the time this request was sent to the
      -   * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack
      -   * deadline will expire 10 seconds after the ModifyAckDeadline call was made.
      -   * Specifying zero may immediately make the message available for another pull
      -   * request.
      -   * 
      - */ - int getAckDeadlineSeconds(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequest.java deleted file mode 100644 index d3706a1c87c4..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequest.java +++ /dev/null @@ -1,744 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.ModifyPushConfigRequest} - * - *
      - * Request for the ModifyPushConfig method.
      - * 
      - */ -public final class ModifyPushConfigRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.ModifyPushConfigRequest) - ModifyPushConfigRequestOrBuilder { - // Use ModifyPushConfigRequest.newBuilder() to construct. - private ModifyPushConfigRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ModifyPushConfigRequest() { - subscription_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ModifyPushConfigRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - subscription_ = s; - break; - } - case 18: { - com.google.pubsub.v1.PushConfig.Builder subBuilder = null; - if (pushConfig_ != null) { - subBuilder = pushConfig_.toBuilder(); - } - pushConfig_ = input.readMessage(com.google.pubsub.v1.PushConfig.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(pushConfig_); - pushConfig_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyPushConfigRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ModifyPushConfigRequest.class, com.google.pubsub.v1.ModifyPushConfigRequest.Builder.class); - } - - public static final int SUBSCRIPTION_FIELD_NUMBER = 1; - private volatile java.lang.Object subscription_; - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription.
      -   * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } - } - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PUSH_CONFIG_FIELD_NUMBER = 2; - private com.google.pubsub.v1.PushConfig pushConfig_; - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -   * The push configuration for future deliveries.
      -   * An empty pushConfig indicates that the Pub/Sub system should
      -   * stop pushing messages from the given subscription and allow
      -   * messages to be pulled and acknowledged - effectively pausing
      -   * the subscription if Pull is not called.
      -   * 
      - */ - public boolean hasPushConfig() { - return pushConfig_ != null; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -   * The push configuration for future deliveries.
      -   * An empty pushConfig indicates that the Pub/Sub system should
      -   * stop pushing messages from the given subscription and allow
      -   * messages to be pulled and acknowledged - effectively pausing
      -   * the subscription if Pull is not called.
      -   * 
      - */ - public com.google.pubsub.v1.PushConfig getPushConfig() { - return pushConfig_ == null ? com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -   * The push configuration for future deliveries.
      -   * An empty pushConfig indicates that the Pub/Sub system should
      -   * stop pushing messages from the given subscription and allow
      -   * messages to be pulled and acknowledged - effectively pausing
      -   * the subscription if Pull is not called.
      -   * 
      - */ - public com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder() { - return getPushConfig(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSubscriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); - } - if (pushConfig_ != null) { - output.writeMessage(2, getPushConfig()); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSubscriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); - } - if (pushConfig_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, getPushConfig()); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ModifyPushConfigRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.ModifyPushConfigRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ModifyPushConfigRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.ModifyPushConfigRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.ModifyPushConfigRequest} - * - *
      -   * Request for the ModifyPushConfig method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ModifyPushConfigRequest) - com.google.pubsub.v1.ModifyPushConfigRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyPushConfigRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ModifyPushConfigRequest.class, com.google.pubsub.v1.ModifyPushConfigRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.ModifyPushConfigRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - subscription_ = ""; - - if (pushConfigBuilder_ == null) { - pushConfig_ = null; - } else { - pushConfig_ = null; - pushConfigBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor; - } - - public com.google.pubsub.v1.ModifyPushConfigRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.ModifyPushConfigRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.ModifyPushConfigRequest build() { - com.google.pubsub.v1.ModifyPushConfigRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.ModifyPushConfigRequest buildPartial() { - com.google.pubsub.v1.ModifyPushConfigRequest result = new com.google.pubsub.v1.ModifyPushConfigRequest(this); - result.subscription_ = subscription_; - if (pushConfigBuilder_ == null) { - result.pushConfig_ = pushConfig_; - } else { - result.pushConfig_ = pushConfigBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.ModifyPushConfigRequest) { - return mergeFrom((com.google.pubsub.v1.ModifyPushConfigRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.ModifyPushConfigRequest other) { - if (other == com.google.pubsub.v1.ModifyPushConfigRequest.getDefaultInstance()) return this; - if (!other.getSubscription().isEmpty()) { - subscription_ = other.subscription_; - onChanged(); - } - if (other.hasPushConfig()) { - mergePushConfig(other.getPushConfig()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.ModifyPushConfigRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.ModifyPushConfigRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object subscription_ = ""; - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription.
      -     * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription.
      -     * 
      - */ - public Builder setSubscription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subscription_ = value; - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription.
      -     * 
      - */ - public Builder clearSubscription() { - - subscription_ = getDefaultInstance().getSubscription(); - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The name of the subscription.
      -     * 
      - */ - public Builder setSubscriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subscription_ = value; - onChanged(); - return this; - } - - private com.google.pubsub.v1.PushConfig pushConfig_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder> pushConfigBuilder_; - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -     * The push configuration for future deliveries.
      -     * An empty pushConfig indicates that the Pub/Sub system should
      -     * stop pushing messages from the given subscription and allow
      -     * messages to be pulled and acknowledged - effectively pausing
      -     * the subscription if Pull is not called.
      -     * 
      - */ - public boolean hasPushConfig() { - return pushConfigBuilder_ != null || pushConfig_ != null; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -     * The push configuration for future deliveries.
      -     * An empty pushConfig indicates that the Pub/Sub system should
      -     * stop pushing messages from the given subscription and allow
      -     * messages to be pulled and acknowledged - effectively pausing
      -     * the subscription if Pull is not called.
      -     * 
      - */ - public com.google.pubsub.v1.PushConfig getPushConfig() { - if (pushConfigBuilder_ == null) { - return pushConfig_ == null ? com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; - } else { - return pushConfigBuilder_.getMessage(); - } - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -     * The push configuration for future deliveries.
      -     * An empty pushConfig indicates that the Pub/Sub system should
      -     * stop pushing messages from the given subscription and allow
      -     * messages to be pulled and acknowledged - effectively pausing
      -     * the subscription if Pull is not called.
      -     * 
      - */ - public Builder setPushConfig(com.google.pubsub.v1.PushConfig value) { - if (pushConfigBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - pushConfig_ = value; - onChanged(); - } else { - pushConfigBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -     * The push configuration for future deliveries.
      -     * An empty pushConfig indicates that the Pub/Sub system should
      -     * stop pushing messages from the given subscription and allow
      -     * messages to be pulled and acknowledged - effectively pausing
      -     * the subscription if Pull is not called.
      -     * 
      - */ - public Builder setPushConfig( - com.google.pubsub.v1.PushConfig.Builder builderForValue) { - if (pushConfigBuilder_ == null) { - pushConfig_ = builderForValue.build(); - onChanged(); - } else { - pushConfigBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -     * The push configuration for future deliveries.
      -     * An empty pushConfig indicates that the Pub/Sub system should
      -     * stop pushing messages from the given subscription and allow
      -     * messages to be pulled and acknowledged - effectively pausing
      -     * the subscription if Pull is not called.
      -     * 
      - */ - public Builder mergePushConfig(com.google.pubsub.v1.PushConfig value) { - if (pushConfigBuilder_ == null) { - if (pushConfig_ != null) { - pushConfig_ = - com.google.pubsub.v1.PushConfig.newBuilder(pushConfig_).mergeFrom(value).buildPartial(); - } else { - pushConfig_ = value; - } - onChanged(); - } else { - pushConfigBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -     * The push configuration for future deliveries.
      -     * An empty pushConfig indicates that the Pub/Sub system should
      -     * stop pushing messages from the given subscription and allow
      -     * messages to be pulled and acknowledged - effectively pausing
      -     * the subscription if Pull is not called.
      -     * 
      - */ - public Builder clearPushConfig() { - if (pushConfigBuilder_ == null) { - pushConfig_ = null; - onChanged(); - } else { - pushConfig_ = null; - pushConfigBuilder_ = null; - } - - return this; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -     * The push configuration for future deliveries.
      -     * An empty pushConfig indicates that the Pub/Sub system should
      -     * stop pushing messages from the given subscription and allow
      -     * messages to be pulled and acknowledged - effectively pausing
      -     * the subscription if Pull is not called.
      -     * 
      - */ - public com.google.pubsub.v1.PushConfig.Builder getPushConfigBuilder() { - - onChanged(); - return getPushConfigFieldBuilder().getBuilder(); - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -     * The push configuration for future deliveries.
      -     * An empty pushConfig indicates that the Pub/Sub system should
      -     * stop pushing messages from the given subscription and allow
      -     * messages to be pulled and acknowledged - effectively pausing
      -     * the subscription if Pull is not called.
      -     * 
      - */ - public com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder() { - if (pushConfigBuilder_ != null) { - return pushConfigBuilder_.getMessageOrBuilder(); - } else { - return pushConfig_ == null ? - com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; - } - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -     * The push configuration for future deliveries.
      -     * An empty pushConfig indicates that the Pub/Sub system should
      -     * stop pushing messages from the given subscription and allow
      -     * messages to be pulled and acknowledged - effectively pausing
      -     * the subscription if Pull is not called.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder> - getPushConfigFieldBuilder() { - if (pushConfigBuilder_ == null) { - pushConfigBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder>( - getPushConfig(), - getParentForChildren(), - isClean()); - pushConfig_ = null; - } - return pushConfigBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ModifyPushConfigRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.ModifyPushConfigRequest) - private static final com.google.pubsub.v1.ModifyPushConfigRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.ModifyPushConfigRequest(); - } - - public static com.google.pubsub.v1.ModifyPushConfigRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ModifyPushConfigRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ModifyPushConfigRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.ModifyPushConfigRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequestOrBuilder.java deleted file mode 100644 index 50d85cc4ad08..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ModifyPushConfigRequestOrBuilder.java +++ /dev/null @@ -1,64 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface ModifyPushConfigRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ModifyPushConfigRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription.
      -   * 
      - */ - java.lang.String getSubscription(); - /** - * optional string subscription = 1; - * - *
      -   * The name of the subscription.
      -   * 
      - */ - com.google.protobuf.ByteString - getSubscriptionBytes(); - - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -   * The push configuration for future deliveries.
      -   * An empty pushConfig indicates that the Pub/Sub system should
      -   * stop pushing messages from the given subscription and allow
      -   * messages to be pulled and acknowledged - effectively pausing
      -   * the subscription if Pull is not called.
      -   * 
      - */ - boolean hasPushConfig(); - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -   * The push configuration for future deliveries.
      -   * An empty pushConfig indicates that the Pub/Sub system should
      -   * stop pushing messages from the given subscription and allow
      -   * messages to be pulled and acknowledged - effectively pausing
      -   * the subscription if Pull is not called.
      -   * 
      - */ - com.google.pubsub.v1.PushConfig getPushConfig(); - /** - * optional .google.pubsub.v1.PushConfig push_config = 2; - * - *
      -   * The push configuration for future deliveries.
      -   * An empty pushConfig indicates that the Pub/Sub system should
      -   * stop pushing messages from the given subscription and allow
      -   * messages to be pulled and acknowledged - effectively pausing
      -   * the subscription if Pull is not called.
      -   * 
      - */ - com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequest.java deleted file mode 100644 index b68d33924dd0..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequest.java +++ /dev/null @@ -1,909 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.PublishRequest} - * - *
      - * Request for the Publish method.
      - * 
      - */ -public final class PublishRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.PublishRequest) - PublishRequestOrBuilder { - // Use PublishRequest.newBuilder() to construct. - private PublishRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private PublishRequest() { - topic_ = ""; - messages_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private PublishRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - case 18: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - messages_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; - } - messages_.add(input.readMessage(com.google.pubsub.v1.PubsubMessage.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - messages_ = java.util.Collections.unmodifiableList(messages_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PublishRequest.class, com.google.pubsub.v1.PublishRequest.Builder.class); - } - - private int bitField0_; - public static final int TOPIC_FIELD_NUMBER = 1; - private volatile java.lang.Object topic_; - /** - * optional string topic = 1; - * - *
      -   * The messages in the request will be published on this topic.
      -   * 
      - */ - public java.lang.String getTopic() { - java.lang.Object ref = topic_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - /** - * optional string topic = 1; - * - *
      -   * The messages in the request will be published on this topic.
      -   * 
      - */ - public com.google.protobuf.ByteString - getTopicBytes() { - java.lang.Object ref = topic_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int MESSAGES_FIELD_NUMBER = 2; - private java.util.List messages_; - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -   * The messages to publish.
      -   * 
      - */ - public java.util.List getMessagesList() { - return messages_; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -   * The messages to publish.
      -   * 
      - */ - public java.util.List - getMessagesOrBuilderList() { - return messages_; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -   * The messages to publish.
      -   * 
      - */ - public int getMessagesCount() { - return messages_.size(); - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -   * The messages to publish.
      -   * 
      - */ - public com.google.pubsub.v1.PubsubMessage getMessages(int index) { - return messages_.get(index); - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -   * The messages to publish.
      -   * 
      - */ - public com.google.pubsub.v1.PubsubMessageOrBuilder getMessagesOrBuilder( - int index) { - return messages_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, topic_); - } - for (int i = 0; i < messages_.size(); i++) { - output.writeMessage(2, messages_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, topic_); - } - for (int i = 0; i < messages_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, messages_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.PublishRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PublishRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PublishRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PublishRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PublishRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PublishRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PublishRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.PublishRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PublishRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PublishRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.PublishRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.PublishRequest} - * - *
      -   * Request for the Publish method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PublishRequest) - com.google.pubsub.v1.PublishRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PublishRequest.class, com.google.pubsub.v1.PublishRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.PublishRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getMessagesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - topic_ = ""; - - if (messagesBuilder_ == null) { - messages_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - } else { - messagesBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishRequest_descriptor; - } - - public com.google.pubsub.v1.PublishRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.PublishRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.PublishRequest build() { - com.google.pubsub.v1.PublishRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.PublishRequest buildPartial() { - com.google.pubsub.v1.PublishRequest result = new com.google.pubsub.v1.PublishRequest(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.topic_ = topic_; - if (messagesBuilder_ == null) { - if (((bitField0_ & 0x00000002) == 0x00000002)) { - messages_ = java.util.Collections.unmodifiableList(messages_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.messages_ = messages_; - } else { - result.messages_ = messagesBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.PublishRequest) { - return mergeFrom((com.google.pubsub.v1.PublishRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.PublishRequest other) { - if (other == com.google.pubsub.v1.PublishRequest.getDefaultInstance()) return this; - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - if (messagesBuilder_ == null) { - if (!other.messages_.isEmpty()) { - if (messages_.isEmpty()) { - messages_ = other.messages_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureMessagesIsMutable(); - messages_.addAll(other.messages_); - } - onChanged(); - } - } else { - if (!other.messages_.isEmpty()) { - if (messagesBuilder_.isEmpty()) { - messagesBuilder_.dispose(); - messagesBuilder_ = null; - messages_ = other.messages_; - bitField0_ = (bitField0_ & ~0x00000002); - messagesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getMessagesFieldBuilder() : null; - } else { - messagesBuilder_.addAllMessages(other.messages_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.PublishRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.PublishRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object topic_ = ""; - /** - * optional string topic = 1; - * - *
      -     * The messages in the request will be published on this topic.
      -     * 
      - */ - public java.lang.String getTopic() { - java.lang.Object ref = topic_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string topic = 1; - * - *
      -     * The messages in the request will be published on this topic.
      -     * 
      - */ - public com.google.protobuf.ByteString - getTopicBytes() { - java.lang.Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string topic = 1; - * - *
      -     * The messages in the request will be published on this topic.
      -     * 
      - */ - public Builder setTopic( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - /** - * optional string topic = 1; - * - *
      -     * The messages in the request will be published on this topic.
      -     * 
      - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - /** - * optional string topic = 1; - * - *
      -     * The messages in the request will be published on this topic.
      -     * 
      - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - - private java.util.List messages_ = - java.util.Collections.emptyList(); - private void ensureMessagesIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - messages_ = new java.util.ArrayList(messages_); - bitField0_ |= 0x00000002; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder> messagesBuilder_; - - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public java.util.List getMessagesList() { - if (messagesBuilder_ == null) { - return java.util.Collections.unmodifiableList(messages_); - } else { - return messagesBuilder_.getMessageList(); - } - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public int getMessagesCount() { - if (messagesBuilder_ == null) { - return messages_.size(); - } else { - return messagesBuilder_.getCount(); - } - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public com.google.pubsub.v1.PubsubMessage getMessages(int index) { - if (messagesBuilder_ == null) { - return messages_.get(index); - } else { - return messagesBuilder_.getMessage(index); - } - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public Builder setMessages( - int index, com.google.pubsub.v1.PubsubMessage value) { - if (messagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureMessagesIsMutable(); - messages_.set(index, value); - onChanged(); - } else { - messagesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public Builder setMessages( - int index, com.google.pubsub.v1.PubsubMessage.Builder builderForValue) { - if (messagesBuilder_ == null) { - ensureMessagesIsMutable(); - messages_.set(index, builderForValue.build()); - onChanged(); - } else { - messagesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public Builder addMessages(com.google.pubsub.v1.PubsubMessage value) { - if (messagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureMessagesIsMutable(); - messages_.add(value); - onChanged(); - } else { - messagesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public Builder addMessages( - int index, com.google.pubsub.v1.PubsubMessage value) { - if (messagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureMessagesIsMutable(); - messages_.add(index, value); - onChanged(); - } else { - messagesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public Builder addMessages( - com.google.pubsub.v1.PubsubMessage.Builder builderForValue) { - if (messagesBuilder_ == null) { - ensureMessagesIsMutable(); - messages_.add(builderForValue.build()); - onChanged(); - } else { - messagesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public Builder addMessages( - int index, com.google.pubsub.v1.PubsubMessage.Builder builderForValue) { - if (messagesBuilder_ == null) { - ensureMessagesIsMutable(); - messages_.add(index, builderForValue.build()); - onChanged(); - } else { - messagesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public Builder addAllMessages( - java.lang.Iterable values) { - if (messagesBuilder_ == null) { - ensureMessagesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, messages_); - onChanged(); - } else { - messagesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public Builder clearMessages() { - if (messagesBuilder_ == null) { - messages_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - } else { - messagesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public Builder removeMessages(int index) { - if (messagesBuilder_ == null) { - ensureMessagesIsMutable(); - messages_.remove(index); - onChanged(); - } else { - messagesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public com.google.pubsub.v1.PubsubMessage.Builder getMessagesBuilder( - int index) { - return getMessagesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public com.google.pubsub.v1.PubsubMessageOrBuilder getMessagesOrBuilder( - int index) { - if (messagesBuilder_ == null) { - return messages_.get(index); } else { - return messagesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public java.util.List - getMessagesOrBuilderList() { - if (messagesBuilder_ != null) { - return messagesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(messages_); - } - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public com.google.pubsub.v1.PubsubMessage.Builder addMessagesBuilder() { - return getMessagesFieldBuilder().addBuilder( - com.google.pubsub.v1.PubsubMessage.getDefaultInstance()); - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public com.google.pubsub.v1.PubsubMessage.Builder addMessagesBuilder( - int index) { - return getMessagesFieldBuilder().addBuilder( - index, com.google.pubsub.v1.PubsubMessage.getDefaultInstance()); - } - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -     * The messages to publish.
      -     * 
      - */ - public java.util.List - getMessagesBuilderList() { - return getMessagesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder> - getMessagesFieldBuilder() { - if (messagesBuilder_ == null) { - messagesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder>( - messages_, - ((bitField0_ & 0x00000002) == 0x00000002), - getParentForChildren(), - isClean()); - messages_ = null; - } - return messagesBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PublishRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.PublishRequest) - private static final com.google.pubsub.v1.PublishRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.PublishRequest(); - } - - public static com.google.pubsub.v1.PublishRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public PublishRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new PublishRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.PublishRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequestOrBuilder.java deleted file mode 100644 index d862735fe6df..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishRequestOrBuilder.java +++ /dev/null @@ -1,71 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface PublishRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PublishRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string topic = 1; - * - *
      -   * The messages in the request will be published on this topic.
      -   * 
      - */ - java.lang.String getTopic(); - /** - * optional string topic = 1; - * - *
      -   * The messages in the request will be published on this topic.
      -   * 
      - */ - com.google.protobuf.ByteString - getTopicBytes(); - - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -   * The messages to publish.
      -   * 
      - */ - java.util.List - getMessagesList(); - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -   * The messages to publish.
      -   * 
      - */ - com.google.pubsub.v1.PubsubMessage getMessages(int index); - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -   * The messages to publish.
      -   * 
      - */ - int getMessagesCount(); - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -   * The messages to publish.
      -   * 
      - */ - java.util.List - getMessagesOrBuilderList(); - /** - * repeated .google.pubsub.v1.PubsubMessage messages = 2; - * - *
      -   * The messages to publish.
      -   * 
      - */ - com.google.pubsub.v1.PubsubMessageOrBuilder getMessagesOrBuilder( - int index); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponse.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponse.java deleted file mode 100644 index 9a7a30834bce..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponse.java +++ /dev/null @@ -1,569 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.PublishResponse} - * - *
      - * Response for the Publish method.
      - * 
      - */ -public final class PublishResponse extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.PublishResponse) - PublishResponseOrBuilder { - // Use PublishResponse.newBuilder() to construct. - private PublishResponse(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private PublishResponse() { - messageIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private PublishResponse( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - messageIds_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; - } - messageIds_.add(s); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - messageIds_ = messageIds_.getUnmodifiableView(); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PublishResponse.class, com.google.pubsub.v1.PublishResponse.Builder.class); - } - - public static final int MESSAGE_IDS_FIELD_NUMBER = 1; - private com.google.protobuf.LazyStringList messageIds_; - /** - * repeated string message_ids = 1; - * - *
      -   * The server-assigned ID of each published message, in the same order as
      -   * the messages in the request. IDs are guaranteed to be unique within
      -   * the topic.
      -   * 
      - */ - public com.google.protobuf.ProtocolStringList - getMessageIdsList() { - return messageIds_; - } - /** - * repeated string message_ids = 1; - * - *
      -   * The server-assigned ID of each published message, in the same order as
      -   * the messages in the request. IDs are guaranteed to be unique within
      -   * the topic.
      -   * 
      - */ - public int getMessageIdsCount() { - return messageIds_.size(); - } - /** - * repeated string message_ids = 1; - * - *
      -   * The server-assigned ID of each published message, in the same order as
      -   * the messages in the request. IDs are guaranteed to be unique within
      -   * the topic.
      -   * 
      - */ - public java.lang.String getMessageIds(int index) { - return messageIds_.get(index); - } - /** - * repeated string message_ids = 1; - * - *
      -   * The server-assigned ID of each published message, in the same order as
      -   * the messages in the request. IDs are guaranteed to be unique within
      -   * the topic.
      -   * 
      - */ - public com.google.protobuf.ByteString - getMessageIdsBytes(int index) { - return messageIds_.getByteString(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < messageIds_.size(); i++) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, messageIds_.getRaw(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - for (int i = 0; i < messageIds_.size(); i++) { - dataSize += computeStringSizeNoTag(messageIds_.getRaw(i)); - } - size += dataSize; - size += 1 * getMessageIdsList().size(); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.PublishResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PublishResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PublishResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PublishResponse parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PublishResponse parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PublishResponse parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PublishResponse parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.PublishResponse parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PublishResponse parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PublishResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.PublishResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.PublishResponse} - * - *
      -   * Response for the Publish method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PublishResponse) - com.google.pubsub.v1.PublishResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PublishResponse.class, com.google.pubsub.v1.PublishResponse.Builder.class); - } - - // Construct using com.google.pubsub.v1.PublishResponse.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - messageIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PublishResponse_descriptor; - } - - public com.google.pubsub.v1.PublishResponse getDefaultInstanceForType() { - return com.google.pubsub.v1.PublishResponse.getDefaultInstance(); - } - - public com.google.pubsub.v1.PublishResponse build() { - com.google.pubsub.v1.PublishResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.PublishResponse buildPartial() { - com.google.pubsub.v1.PublishResponse result = new com.google.pubsub.v1.PublishResponse(this); - int from_bitField0_ = bitField0_; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - messageIds_ = messageIds_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.messageIds_ = messageIds_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.PublishResponse) { - return mergeFrom((com.google.pubsub.v1.PublishResponse)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.PublishResponse other) { - if (other == com.google.pubsub.v1.PublishResponse.getDefaultInstance()) return this; - if (!other.messageIds_.isEmpty()) { - if (messageIds_.isEmpty()) { - messageIds_ = other.messageIds_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureMessageIdsIsMutable(); - messageIds_.addAll(other.messageIds_); - } - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.PublishResponse parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.PublishResponse) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private com.google.protobuf.LazyStringList messageIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureMessageIdsIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - messageIds_ = new com.google.protobuf.LazyStringArrayList(messageIds_); - bitField0_ |= 0x00000001; - } - } - /** - * repeated string message_ids = 1; - * - *
      -     * The server-assigned ID of each published message, in the same order as
      -     * the messages in the request. IDs are guaranteed to be unique within
      -     * the topic.
      -     * 
      - */ - public com.google.protobuf.ProtocolStringList - getMessageIdsList() { - return messageIds_.getUnmodifiableView(); - } - /** - * repeated string message_ids = 1; - * - *
      -     * The server-assigned ID of each published message, in the same order as
      -     * the messages in the request. IDs are guaranteed to be unique within
      -     * the topic.
      -     * 
      - */ - public int getMessageIdsCount() { - return messageIds_.size(); - } - /** - * repeated string message_ids = 1; - * - *
      -     * The server-assigned ID of each published message, in the same order as
      -     * the messages in the request. IDs are guaranteed to be unique within
      -     * the topic.
      -     * 
      - */ - public java.lang.String getMessageIds(int index) { - return messageIds_.get(index); - } - /** - * repeated string message_ids = 1; - * - *
      -     * The server-assigned ID of each published message, in the same order as
      -     * the messages in the request. IDs are guaranteed to be unique within
      -     * the topic.
      -     * 
      - */ - public com.google.protobuf.ByteString - getMessageIdsBytes(int index) { - return messageIds_.getByteString(index); - } - /** - * repeated string message_ids = 1; - * - *
      -     * The server-assigned ID of each published message, in the same order as
      -     * the messages in the request. IDs are guaranteed to be unique within
      -     * the topic.
      -     * 
      - */ - public Builder setMessageIds( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureMessageIdsIsMutable(); - messageIds_.set(index, value); - onChanged(); - return this; - } - /** - * repeated string message_ids = 1; - * - *
      -     * The server-assigned ID of each published message, in the same order as
      -     * the messages in the request. IDs are guaranteed to be unique within
      -     * the topic.
      -     * 
      - */ - public Builder addMessageIds( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureMessageIdsIsMutable(); - messageIds_.add(value); - onChanged(); - return this; - } - /** - * repeated string message_ids = 1; - * - *
      -     * The server-assigned ID of each published message, in the same order as
      -     * the messages in the request. IDs are guaranteed to be unique within
      -     * the topic.
      -     * 
      - */ - public Builder addAllMessageIds( - java.lang.Iterable values) { - ensureMessageIdsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, messageIds_); - onChanged(); - return this; - } - /** - * repeated string message_ids = 1; - * - *
      -     * The server-assigned ID of each published message, in the same order as
      -     * the messages in the request. IDs are guaranteed to be unique within
      -     * the topic.
      -     * 
      - */ - public Builder clearMessageIds() { - messageIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - /** - * repeated string message_ids = 1; - * - *
      -     * The server-assigned ID of each published message, in the same order as
      -     * the messages in the request. IDs are guaranteed to be unique within
      -     * the topic.
      -     * 
      - */ - public Builder addMessageIdsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureMessageIdsIsMutable(); - messageIds_.add(value); - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PublishResponse) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.PublishResponse) - private static final com.google.pubsub.v1.PublishResponse DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.PublishResponse(); - } - - public static com.google.pubsub.v1.PublishResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public PublishResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new PublishResponse(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.PublishResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponseOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponseOrBuilder.java deleted file mode 100644 index 6908fac0c93b..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublishResponseOrBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface PublishResponseOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PublishResponse) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated string message_ids = 1; - * - *
      -   * The server-assigned ID of each published message, in the same order as
      -   * the messages in the request. IDs are guaranteed to be unique within
      -   * the topic.
      -   * 
      - */ - com.google.protobuf.ProtocolStringList - getMessageIdsList(); - /** - * repeated string message_ids = 1; - * - *
      -   * The server-assigned ID of each published message, in the same order as
      -   * the messages in the request. IDs are guaranteed to be unique within
      -   * the topic.
      -   * 
      - */ - int getMessageIdsCount(); - /** - * repeated string message_ids = 1; - * - *
      -   * The server-assigned ID of each published message, in the same order as
      -   * the messages in the request. IDs are guaranteed to be unique within
      -   * the topic.
      -   * 
      - */ - java.lang.String getMessageIds(int index); - /** - * repeated string message_ids = 1; - * - *
      -   * The server-assigned ID of each published message, in the same order as
      -   * the messages in the request. IDs are guaranteed to be unique within
      -   * the topic.
      -   * 
      - */ - com.google.protobuf.ByteString - getMessageIdsBytes(int index); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublisherGrpc.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublisherGrpc.java deleted file mode 100644 index a2c47fcdeb01..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PublisherGrpc.java +++ /dev/null @@ -1,406 +0,0 @@ -package com.google.pubsub.v1; - -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; -import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; -import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ClientCalls.blockingUnaryCall; -import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; -import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; -import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; -import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; - -@javax.annotation.Generated("by gRPC proto compiler") -public class PublisherGrpc { - - private PublisherGrpc() {} - - public static final String SERVICE_NAME = "google.pubsub.v1.Publisher"; - - // Static method descriptors that strictly reflect the proto. - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_CREATE_TOPIC = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Publisher", "CreateTopic"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Topic.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Topic.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_PUBLISH = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Publisher", "Publish"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.PublishRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.PublishResponse.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_GET_TOPIC = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Publisher", "GetTopic"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.GetTopicRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Topic.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_LIST_TOPICS = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Publisher", "ListTopics"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListTopicsRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListTopicsResponse.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_LIST_TOPIC_SUBSCRIPTIONS = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Publisher", "ListTopicSubscriptions"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListTopicSubscriptionsRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListTopicSubscriptionsResponse.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_DELETE_TOPIC = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Publisher", "DeleteTopic"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.DeleteTopicRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); - - public static PublisherStub newStub(io.grpc.Channel channel) { - return new PublisherStub(channel); - } - - public static PublisherBlockingStub newBlockingStub( - io.grpc.Channel channel) { - return new PublisherBlockingStub(channel); - } - - public static PublisherFutureStub newFutureStub( - io.grpc.Channel channel) { - return new PublisherFutureStub(channel); - } - - public static interface Publisher { - - public void createTopic(com.google.pubsub.v1.Topic request, - io.grpc.stub.StreamObserver responseObserver); - - public void publish(com.google.pubsub.v1.PublishRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void getTopic(com.google.pubsub.v1.GetTopicRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void listTopics(com.google.pubsub.v1.ListTopicsRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void listTopicSubscriptions(com.google.pubsub.v1.ListTopicSubscriptionsRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void deleteTopic(com.google.pubsub.v1.DeleteTopicRequest request, - io.grpc.stub.StreamObserver responseObserver); - } - - public static interface PublisherBlockingClient { - - public com.google.pubsub.v1.Topic createTopic(com.google.pubsub.v1.Topic request); - - public com.google.pubsub.v1.PublishResponse publish(com.google.pubsub.v1.PublishRequest request); - - public com.google.pubsub.v1.Topic getTopic(com.google.pubsub.v1.GetTopicRequest request); - - public com.google.pubsub.v1.ListTopicsResponse listTopics(com.google.pubsub.v1.ListTopicsRequest request); - - public com.google.pubsub.v1.ListTopicSubscriptionsResponse listTopicSubscriptions(com.google.pubsub.v1.ListTopicSubscriptionsRequest request); - - public com.google.protobuf.Empty deleteTopic(com.google.pubsub.v1.DeleteTopicRequest request); - } - - public static interface PublisherFutureClient { - - public com.google.common.util.concurrent.ListenableFuture createTopic( - com.google.pubsub.v1.Topic request); - - public com.google.common.util.concurrent.ListenableFuture publish( - com.google.pubsub.v1.PublishRequest request); - - public com.google.common.util.concurrent.ListenableFuture getTopic( - com.google.pubsub.v1.GetTopicRequest request); - - public com.google.common.util.concurrent.ListenableFuture listTopics( - com.google.pubsub.v1.ListTopicsRequest request); - - public com.google.common.util.concurrent.ListenableFuture listTopicSubscriptions( - com.google.pubsub.v1.ListTopicSubscriptionsRequest request); - - public com.google.common.util.concurrent.ListenableFuture deleteTopic( - com.google.pubsub.v1.DeleteTopicRequest request); - } - - public static class PublisherStub extends io.grpc.stub.AbstractStub - implements Publisher { - private PublisherStub(io.grpc.Channel channel) { - super(channel); - } - - private PublisherStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected PublisherStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new PublisherStub(channel, callOptions); - } - - @java.lang.Override - public void createTopic(com.google.pubsub.v1.Topic request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_CREATE_TOPIC, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void publish(com.google.pubsub.v1.PublishRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_PUBLISH, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void getTopic(com.google.pubsub.v1.GetTopicRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_GET_TOPIC, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void listTopics(com.google.pubsub.v1.ListTopicsRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_LIST_TOPICS, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void listTopicSubscriptions(com.google.pubsub.v1.ListTopicSubscriptionsRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_LIST_TOPIC_SUBSCRIPTIONS, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void deleteTopic(com.google.pubsub.v1.DeleteTopicRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_DELETE_TOPIC, getCallOptions()), request, responseObserver); - } - } - - public static class PublisherBlockingStub extends io.grpc.stub.AbstractStub - implements PublisherBlockingClient { - private PublisherBlockingStub(io.grpc.Channel channel) { - super(channel); - } - - private PublisherBlockingStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected PublisherBlockingStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new PublisherBlockingStub(channel, callOptions); - } - - @java.lang.Override - public com.google.pubsub.v1.Topic createTopic(com.google.pubsub.v1.Topic request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_CREATE_TOPIC, getCallOptions()), request); - } - - @java.lang.Override - public com.google.pubsub.v1.PublishResponse publish(com.google.pubsub.v1.PublishRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_PUBLISH, getCallOptions()), request); - } - - @java.lang.Override - public com.google.pubsub.v1.Topic getTopic(com.google.pubsub.v1.GetTopicRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_GET_TOPIC, getCallOptions()), request); - } - - @java.lang.Override - public com.google.pubsub.v1.ListTopicsResponse listTopics(com.google.pubsub.v1.ListTopicsRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_LIST_TOPICS, getCallOptions()), request); - } - - @java.lang.Override - public com.google.pubsub.v1.ListTopicSubscriptionsResponse listTopicSubscriptions(com.google.pubsub.v1.ListTopicSubscriptionsRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_LIST_TOPIC_SUBSCRIPTIONS, getCallOptions()), request); - } - - @java.lang.Override - public com.google.protobuf.Empty deleteTopic(com.google.pubsub.v1.DeleteTopicRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_DELETE_TOPIC, getCallOptions()), request); - } - } - - public static class PublisherFutureStub extends io.grpc.stub.AbstractStub - implements PublisherFutureClient { - private PublisherFutureStub(io.grpc.Channel channel) { - super(channel); - } - - private PublisherFutureStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected PublisherFutureStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new PublisherFutureStub(channel, callOptions); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture createTopic( - com.google.pubsub.v1.Topic request) { - return futureUnaryCall( - getChannel().newCall(METHOD_CREATE_TOPIC, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture publish( - com.google.pubsub.v1.PublishRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_PUBLISH, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture getTopic( - com.google.pubsub.v1.GetTopicRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_GET_TOPIC, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture listTopics( - com.google.pubsub.v1.ListTopicsRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_LIST_TOPICS, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture listTopicSubscriptions( - com.google.pubsub.v1.ListTopicSubscriptionsRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_LIST_TOPIC_SUBSCRIPTIONS, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture deleteTopic( - com.google.pubsub.v1.DeleteTopicRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_DELETE_TOPIC, getCallOptions()), request); - } - } - - public static io.grpc.ServerServiceDefinition bindService( - final Publisher serviceImpl) { - return io.grpc.ServerServiceDefinition.builder(SERVICE_NAME) - .addMethod( - METHOD_CREATE_TOPIC, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.Topic, - com.google.pubsub.v1.Topic>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.Topic request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.createTopic(request, responseObserver); - } - })) - .addMethod( - METHOD_PUBLISH, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.PublishRequest, - com.google.pubsub.v1.PublishResponse>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.PublishRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.publish(request, responseObserver); - } - })) - .addMethod( - METHOD_GET_TOPIC, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.GetTopicRequest, - com.google.pubsub.v1.Topic>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.GetTopicRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.getTopic(request, responseObserver); - } - })) - .addMethod( - METHOD_LIST_TOPICS, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.ListTopicsRequest, - com.google.pubsub.v1.ListTopicsResponse>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.ListTopicsRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.listTopics(request, responseObserver); - } - })) - .addMethod( - METHOD_LIST_TOPIC_SUBSCRIPTIONS, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.ListTopicSubscriptionsRequest, - com.google.pubsub.v1.ListTopicSubscriptionsResponse>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.ListTopicSubscriptionsRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.listTopicSubscriptions(request, responseObserver); - } - })) - .addMethod( - METHOD_DELETE_TOPIC, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.DeleteTopicRequest, - com.google.protobuf.Empty>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.DeleteTopicRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.deleteTopic(request, responseObserver); - } - })).build(); - } -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessage.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessage.java deleted file mode 100644 index 5228be2f8998..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessage.java +++ /dev/null @@ -1,740 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.PubsubMessage} - * - *
      - * A message data and its attributes. The message payload must not be empty;
      - * it must contain either a non-empty data field, or at least one attribute.
      - * 
      - */ -public final class PubsubMessage extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.PubsubMessage) - PubsubMessageOrBuilder { - // Use PubsubMessage.newBuilder() to construct. - private PubsubMessage(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private PubsubMessage() { - data_ = com.google.protobuf.ByteString.EMPTY; - messageId_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private PubsubMessage( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - - data_ = input.readBytes(); - break; - } - case 18: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - attributes_ = com.google.protobuf.MapField.newMapField( - AttributesDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000002; - } - com.google.protobuf.MapEntry - attributes = input.readMessage( - AttributesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - attributes_.getMutableMap().put(attributes.getKey(), attributes.getValue()); - break; - } - case 26: { - String s = input.readStringRequireUtf8(); - - messageId_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 2: - return internalGetAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PubsubMessage.class, com.google.pubsub.v1.PubsubMessage.Builder.class); - } - - private int bitField0_; - public static final int DATA_FIELD_NUMBER = 1; - private com.google.protobuf.ByteString data_; - /** - * optional bytes data = 1; - * - *
      -   * The message payload. For JSON requests, the value of this field must be
      -   * base64-encoded.
      -   * 
      - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - public static final int ATTRIBUTES_FIELD_NUMBER = 2; - private static final class AttributesDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, java.lang.String> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.STRING, - ""); - } - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> attributes_; - private com.google.protobuf.MapField - internalGetAttributes() { - if (attributes_ == null) { - return com.google.protobuf.MapField.emptyMapField( - AttributesDefaultEntryHolder.defaultEntry); - } - return attributes_; - } - /** - * map<string, string> attributes = 2; - * - *
      -   * Optional attributes for this message.
      -   * 
      - */ - - public java.util.Map getAttributes() { - return internalGetAttributes().getMap(); - } - - public static final int MESSAGE_ID_FIELD_NUMBER = 3; - private volatile java.lang.Object messageId_; - /** - * optional string message_id = 3; - * - *
      -   * ID of this message assigned by the server at publication time. Guaranteed
      -   * to be unique within the topic. This value may be read by a subscriber
      -   * that receives a PubsubMessage via a Pull call or a push delivery. It must
      -   * not be populated by a publisher in a Publish call.
      -   * 
      - */ - public java.lang.String getMessageId() { - java.lang.Object ref = messageId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - messageId_ = s; - return s; - } - } - /** - * optional string message_id = 3; - * - *
      -   * ID of this message assigned by the server at publication time. Guaranteed
      -   * to be unique within the topic. This value may be read by a subscriber
      -   * that receives a PubsubMessage via a Pull call or a push delivery. It must
      -   * not be populated by a publisher in a Publish call.
      -   * 
      - */ - public com.google.protobuf.ByteString - getMessageIdBytes() { - java.lang.Object ref = messageId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - messageId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!data_.isEmpty()) { - output.writeBytes(1, data_); - } - for (java.util.Map.Entry entry - : internalGetAttributes().getMap().entrySet()) { - com.google.protobuf.MapEntry - attributes = AttributesDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - output.writeMessage(2, attributes); - } - if (!getMessageIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 3, messageId_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!data_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, data_); - } - for (java.util.Map.Entry entry - : internalGetAttributes().getMap().entrySet()) { - com.google.protobuf.MapEntry - attributes = AttributesDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, attributes); - } - if (!getMessageIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(3, messageId_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.PubsubMessage parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PubsubMessage parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PubsubMessage parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PubsubMessage parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PubsubMessage parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PubsubMessage parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PubsubMessage parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.PubsubMessage parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PubsubMessage parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PubsubMessage parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.PubsubMessage prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.PubsubMessage} - * - *
      -   * A message data and its attributes. The message payload must not be empty;
      -   * it must contain either a non-empty data field, or at least one attribute.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PubsubMessage) - com.google.pubsub.v1.PubsubMessageOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 2: - return internalGetAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField( - int number) { - switch (number) { - case 2: - return internalGetMutableAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PubsubMessage.class, com.google.pubsub.v1.PubsubMessage.Builder.class); - } - - // Construct using com.google.pubsub.v1.PubsubMessage.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - data_ = com.google.protobuf.ByteString.EMPTY; - - internalGetMutableAttributes().clear(); - messageId_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PubsubMessage_descriptor; - } - - public com.google.pubsub.v1.PubsubMessage getDefaultInstanceForType() { - return com.google.pubsub.v1.PubsubMessage.getDefaultInstance(); - } - - public com.google.pubsub.v1.PubsubMessage build() { - com.google.pubsub.v1.PubsubMessage result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.PubsubMessage buildPartial() { - com.google.pubsub.v1.PubsubMessage result = new com.google.pubsub.v1.PubsubMessage(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.data_ = data_; - result.attributes_ = internalGetAttributes(); - result.attributes_.makeImmutable(); - result.messageId_ = messageId_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.PubsubMessage) { - return mergeFrom((com.google.pubsub.v1.PubsubMessage)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.PubsubMessage other) { - if (other == com.google.pubsub.v1.PubsubMessage.getDefaultInstance()) return this; - if (other.getData() != com.google.protobuf.ByteString.EMPTY) { - setData(other.getData()); - } - internalGetMutableAttributes().mergeFrom( - other.internalGetAttributes()); - if (!other.getMessageId().isEmpty()) { - messageId_ = other.messageId_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.PubsubMessage parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.PubsubMessage) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes data = 1; - * - *
      -     * The message payload. For JSON requests, the value of this field must be
      -     * base64-encoded.
      -     * 
      - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - /** - * optional bytes data = 1; - * - *
      -     * The message payload. For JSON requests, the value of this field must be
      -     * base64-encoded.
      -     * 
      - */ - public Builder setData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - data_ = value; - onChanged(); - return this; - } - /** - * optional bytes data = 1; - * - *
      -     * The message payload. For JSON requests, the value of this field must be
      -     * base64-encoded.
      -     * 
      - */ - public Builder clearData() { - - data_ = getDefaultInstance().getData(); - onChanged(); - return this; - } - - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> attributes_; - private com.google.protobuf.MapField - internalGetAttributes() { - if (attributes_ == null) { - return com.google.protobuf.MapField.emptyMapField( - AttributesDefaultEntryHolder.defaultEntry); - } - return attributes_; - } - private com.google.protobuf.MapField - internalGetMutableAttributes() { - onChanged();; - if (attributes_ == null) { - attributes_ = com.google.protobuf.MapField.newMapField( - AttributesDefaultEntryHolder.defaultEntry); - } - if (!attributes_.isMutable()) { - attributes_ = attributes_.copy(); - } - return attributes_; - } - /** - * map<string, string> attributes = 2; - * - *
      -     * Optional attributes for this message.
      -     * 
      - */ - public java.util.Map getAttributes() { - return internalGetAttributes().getMap(); - } - /** - * map<string, string> attributes = 2; - * - *
      -     * Optional attributes for this message.
      -     * 
      - */ - public java.util.Map - getMutableAttributes() { - return internalGetMutableAttributes().getMutableMap(); - } - /** - * map<string, string> attributes = 2; - * - *
      -     * Optional attributes for this message.
      -     * 
      - */ - public Builder putAllAttributes( - java.util.Map values) { - getMutableAttributes().putAll(values); - return this; - } - - private java.lang.Object messageId_ = ""; - /** - * optional string message_id = 3; - * - *
      -     * ID of this message assigned by the server at publication time. Guaranteed
      -     * to be unique within the topic. This value may be read by a subscriber
      -     * that receives a PubsubMessage via a Pull call or a push delivery. It must
      -     * not be populated by a publisher in a Publish call.
      -     * 
      - */ - public java.lang.String getMessageId() { - java.lang.Object ref = messageId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - messageId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string message_id = 3; - * - *
      -     * ID of this message assigned by the server at publication time. Guaranteed
      -     * to be unique within the topic. This value may be read by a subscriber
      -     * that receives a PubsubMessage via a Pull call or a push delivery. It must
      -     * not be populated by a publisher in a Publish call.
      -     * 
      - */ - public com.google.protobuf.ByteString - getMessageIdBytes() { - java.lang.Object ref = messageId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - messageId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string message_id = 3; - * - *
      -     * ID of this message assigned by the server at publication time. Guaranteed
      -     * to be unique within the topic. This value may be read by a subscriber
      -     * that receives a PubsubMessage via a Pull call or a push delivery. It must
      -     * not be populated by a publisher in a Publish call.
      -     * 
      - */ - public Builder setMessageId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - messageId_ = value; - onChanged(); - return this; - } - /** - * optional string message_id = 3; - * - *
      -     * ID of this message assigned by the server at publication time. Guaranteed
      -     * to be unique within the topic. This value may be read by a subscriber
      -     * that receives a PubsubMessage via a Pull call or a push delivery. It must
      -     * not be populated by a publisher in a Publish call.
      -     * 
      - */ - public Builder clearMessageId() { - - messageId_ = getDefaultInstance().getMessageId(); - onChanged(); - return this; - } - /** - * optional string message_id = 3; - * - *
      -     * ID of this message assigned by the server at publication time. Guaranteed
      -     * to be unique within the topic. This value may be read by a subscriber
      -     * that receives a PubsubMessage via a Pull call or a push delivery. It must
      -     * not be populated by a publisher in a Publish call.
      -     * 
      - */ - public Builder setMessageIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - messageId_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PubsubMessage) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.PubsubMessage) - private static final com.google.pubsub.v1.PubsubMessage DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.PubsubMessage(); - } - - public static com.google.pubsub.v1.PubsubMessage getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public PubsubMessage parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new PubsubMessage(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.PubsubMessage getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessageOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessageOrBuilder.java deleted file mode 100644 index 706d17d65291..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubMessageOrBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface PubsubMessageOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PubsubMessage) - com.google.protobuf.MessageOrBuilder { - - /** - * optional bytes data = 1; - * - *
      -   * The message payload. For JSON requests, the value of this field must be
      -   * base64-encoded.
      -   * 
      - */ - com.google.protobuf.ByteString getData(); - - /** - * map<string, string> attributes = 2; - * - *
      -   * Optional attributes for this message.
      -   * 
      - */ - java.util.Map - getAttributes(); - - /** - * optional string message_id = 3; - * - *
      -   * ID of this message assigned by the server at publication time. Guaranteed
      -   * to be unique within the topic. This value may be read by a subscriber
      -   * that receives a PubsubMessage via a Pull call or a push delivery. It must
      -   * not be populated by a publisher in a Publish call.
      -   * 
      - */ - java.lang.String getMessageId(); - /** - * optional string message_id = 3; - * - *
      -   * ID of this message assigned by the server at publication time. Guaranteed
      -   * to be unique within the topic. This value may be read by a subscriber
      -   * that receives a PubsubMessage via a Pull call or a push delivery. It must
      -   * not be populated by a publisher in a Publish call.
      -   * 
      - */ - com.google.protobuf.ByteString - getMessageIdBytes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubProto.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubProto.java deleted file mode 100644 index 197384a867d9..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PubsubProto.java +++ /dev/null @@ -1,409 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public final class PubsubProto { - private PubsubProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_Topic_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_Topic_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_PubsubMessage_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_PubsubMessage_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_GetTopicRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_GetTopicRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_PublishRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_PublishRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_PublishResponse_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_PublishResponse_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_ListTopicsRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_ListTopicsRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_ListTopicsResponse_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_ListTopicsResponse_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_DeleteTopicRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_Subscription_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_Subscription_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_PushConfig_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_PushConfig_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_PushConfig_AttributesEntry_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_PushConfig_AttributesEntry_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_ReceivedMessage_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_ReceivedMessage_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_GetSubscriptionRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_ListSubscriptionsRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_ListSubscriptionsResponse_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_DeleteSubscriptionRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_ModifyPushConfigRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_PullRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_PullRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_PullResponse_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_PullResponse_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_fieldAccessorTable; - static com.google.protobuf.Descriptors.Descriptor - internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor; - static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_google_pubsub_v1_AcknowledgeRequest_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\035google/pubsub/v1/pubsub.proto\022\020google." + - "pubsub.v1\032\034google/api/annotations.proto\032" + - "\033google/protobuf/empty.proto\"\025\n\005Topic\022\014\n" + - "\004name\030\001 \001(\t\"\251\001\n\rPubsubMessage\022\014\n\004data\030\001 " + - "\001(\014\022C\n\nattributes\030\002 \003(\0132/.google.pubsub." + - "v1.PubsubMessage.AttributesEntry\022\022\n\nmess" + - "age_id\030\003 \001(\t\0321\n\017AttributesEntry\022\013\n\003key\030\001" + - " \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\" \n\017GetTopicReque" + - "st\022\r\n\005topic\030\001 \001(\t\"R\n\016PublishRequest\022\r\n\005t" + - "opic\030\001 \001(\t\0221\n\010messages\030\002 \003(\0132\037.google.pu", - "bsub.v1.PubsubMessage\"&\n\017PublishResponse" + - "\022\023\n\013message_ids\030\001 \003(\t\"K\n\021ListTopicsReque" + - "st\022\017\n\007project\030\001 \001(\t\022\021\n\tpage_size\030\002 \001(\005\022\022" + - "\n\npage_token\030\003 \001(\t\"V\n\022ListTopicsResponse" + - "\022\'\n\006topics\030\001 \003(\0132\027.google.pubsub.v1.Topi" + - "c\022\027\n\017next_page_token\030\002 \001(\t\"U\n\035ListTopicS" + - "ubscriptionsRequest\022\r\n\005topic\030\001 \001(\t\022\021\n\tpa" + - "ge_size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\"P\n\036Lis" + - "tTopicSubscriptionsResponse\022\025\n\rsubscript" + - "ions\030\001 \003(\t\022\027\n\017next_page_token\030\002 \001(\t\"#\n\022D", - "eleteTopicRequest\022\r\n\005topic\030\001 \001(\t\"|\n\014Subs" + - "cription\022\014\n\004name\030\001 \001(\t\022\r\n\005topic\030\002 \001(\t\0221\n" + - "\013push_config\030\004 \001(\0132\034.google.pubsub.v1.Pu" + - "shConfig\022\034\n\024ack_deadline_seconds\030\005 \001(\005\"\230" + - "\001\n\nPushConfig\022\025\n\rpush_endpoint\030\001 \001(\t\022@\n\n" + - "attributes\030\002 \003(\0132,.google.pubsub.v1.Push" + - "Config.AttributesEntry\0321\n\017AttributesEntr" + - "y\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"S\n\017Rec" + - "eivedMessage\022\016\n\006ack_id\030\001 \001(\t\0220\n\007message\030" + - "\002 \001(\0132\037.google.pubsub.v1.PubsubMessage\".", - "\n\026GetSubscriptionRequest\022\024\n\014subscription" + - "\030\001 \001(\t\"R\n\030ListSubscriptionsRequest\022\017\n\007pr" + - "oject\030\001 \001(\t\022\021\n\tpage_size\030\002 \001(\005\022\022\n\npage_t" + - "oken\030\003 \001(\t\"k\n\031ListSubscriptionsResponse\022" + - "5\n\rsubscriptions\030\001 \003(\0132\036.google.pubsub.v" + - "1.Subscription\022\027\n\017next_page_token\030\002 \001(\t\"" + - "1\n\031DeleteSubscriptionRequest\022\024\n\014subscrip" + - "tion\030\001 \001(\t\"b\n\027ModifyPushConfigRequest\022\024\n" + - "\014subscription\030\001 \001(\t\0221\n\013push_config\030\002 \001(\013" + - "2\034.google.pubsub.v1.PushConfig\"U\n\013PullRe", - "quest\022\024\n\014subscription\030\001 \001(\t\022\032\n\022return_im" + - "mediately\030\002 \001(\010\022\024\n\014max_messages\030\003 \001(\005\"L\n" + - "\014PullResponse\022<\n\021received_messages\030\001 \003(\013" + - "2!.google.pubsub.v1.ReceivedMessage\"_\n\030M" + - "odifyAckDeadlineRequest\022\024\n\014subscription\030" + - "\001 \001(\t\022\017\n\007ack_ids\030\004 \003(\t\022\034\n\024ack_deadline_s" + - "econds\030\003 \001(\005\";\n\022AcknowledgeRequest\022\024\n\014su" + - "bscription\030\001 \001(\t\022\017\n\007ack_ids\030\002 \003(\t2\300\t\n\nSu" + - "bscriber\022\206\001\n\022CreateSubscription\022\036.google" + - ".pubsub.v1.Subscription\032\036.google.pubsub.", - "v1.Subscription\"0\202\323\344\223\002*\032%/v1/{name=proje" + - "cts/*/subscriptions/*}:\001*\022\222\001\n\017GetSubscri" + - "ption\022(.google.pubsub.v1.GetSubscription" + - "Request\032\036.google.pubsub.v1.Subscription\"" + - "5\202\323\344\223\002/\022-/v1/{subscription=projects/*/su" + - "bscriptions/*}\022\234\001\n\021ListSubscriptions\022*.g" + - "oogle.pubsub.v1.ListSubscriptionsRequest" + - "\032+.google.pubsub.v1.ListSubscriptionsRes" + - "ponse\".\202\323\344\223\002(\022&/v1/{project=projects/*}/" + - "subscriptions\022\220\001\n\022DeleteSubscription\022+.g", - "oogle.pubsub.v1.DeleteSubscriptionReques" + - "t\032\026.google.protobuf.Empty\"5\202\323\344\223\002/*-/v1/{" + - "subscription=projects/*/subscriptions/*}" + - "\022\243\001\n\021ModifyAckDeadline\022*.google.pubsub.v" + - "1.ModifyAckDeadlineRequest\032\026.google.prot" + - "obuf.Empty\"J\202\323\344\223\002D\"?/v1/{subscription=pr" + - "ojects/*/subscriptions/*}:modifyAckDeadl" + - "ine:\001*\022\221\001\n\013Acknowledge\022$.google.pubsub.v" + - "1.AcknowledgeRequest\032\026.google.protobuf.E" + - "mpty\"D\202\323\344\223\002>\"9/v1/{subscription=projects", - "/*/subscriptions/*}:acknowledge:\001*\022\204\001\n\004P" + - "ull\022\035.google.pubsub.v1.PullRequest\032\036.goo" + - "gle.pubsub.v1.PullResponse\"=\202\323\344\223\0027\"2/v1/" + - "{subscription=projects/*/subscriptions/*" + - "}:pull:\001*\022\240\001\n\020ModifyPushConfig\022).google." + - "pubsub.v1.ModifyPushConfigRequest\032\026.goog" + - "le.protobuf.Empty\"I\202\323\344\223\002C\">/v1/{subscrip" + - "tion=projects/*/subscriptions/*}:modifyP" + - "ushConfig:\001*2\233\006\n\tPublisher\022j\n\013CreateTopi" + - "c\022\027.google.pubsub.v1.Topic\032\027.google.pubs", - "ub.v1.Topic\")\202\323\344\223\002#\032\036/v1/{name=projects/" + - "*/topics/*}:\001*\022\202\001\n\007Publish\022 .google.pubs" + - "ub.v1.PublishRequest\032!.google.pubsub.v1." + - "PublishResponse\"2\202\323\344\223\002,\"\'/v1/{topic=proj" + - "ects/*/topics/*}:publish:\001*\022o\n\010GetTopic\022" + - "!.google.pubsub.v1.GetTopicRequest\032\027.goo" + - "gle.pubsub.v1.Topic\"\'\202\323\344\223\002!\022\037/v1/{topic=" + - "projects/*/topics/*}\022\200\001\n\nListTopics\022#.go" + - "ogle.pubsub.v1.ListTopicsRequest\032$.googl" + - "e.pubsub.v1.ListTopicsResponse\"\'\202\323\344\223\002!\022\037", - "/v1/{project=projects/*}/topics\022\262\001\n\026List" + - "TopicSubscriptions\022/.google.pubsub.v1.Li" + - "stTopicSubscriptionsRequest\0320.google.pub" + - "sub.v1.ListTopicSubscriptionsResponse\"5\202" + - "\323\344\223\002/\022-/v1/{topic=projects/*/topics/*}/s" + - "ubscriptions\022t\n\013DeleteTopic\022$.google.pub" + - "sub.v1.DeleteTopicRequest\032\026.google.proto" + - "buf.Empty\"\'\202\323\344\223\002!*\037/v1/{topic=projects/*" + - "/topics/*}B%\n\024com.google.pubsub.v1B\013Pubs" + - "ubProtoP\001b\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.api.AnnotationsProto.getDescriptor(), - com.google.protobuf.EmptyProto.getDescriptor(), - }, assigner); - internal_static_google_pubsub_v1_Topic_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_pubsub_v1_Topic_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_Topic_descriptor, - new java.lang.String[] { "Name", }); - internal_static_google_pubsub_v1_PubsubMessage_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_google_pubsub_v1_PubsubMessage_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_PubsubMessage_descriptor, - new java.lang.String[] { "Data", "Attributes", "MessageId", }); - internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_descriptor = - internal_static_google_pubsub_v1_PubsubMessage_descriptor.getNestedTypes().get(0); - internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_PubsubMessage_AttributesEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - internal_static_google_pubsub_v1_GetTopicRequest_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_google_pubsub_v1_GetTopicRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_GetTopicRequest_descriptor, - new java.lang.String[] { "Topic", }); - internal_static_google_pubsub_v1_PublishRequest_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_google_pubsub_v1_PublishRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_PublishRequest_descriptor, - new java.lang.String[] { "Topic", "Messages", }); - internal_static_google_pubsub_v1_PublishResponse_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_google_pubsub_v1_PublishResponse_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_PublishResponse_descriptor, - new java.lang.String[] { "MessageIds", }); - internal_static_google_pubsub_v1_ListTopicsRequest_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_google_pubsub_v1_ListTopicsRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_ListTopicsRequest_descriptor, - new java.lang.String[] { "Project", "PageSize", "PageToken", }); - internal_static_google_pubsub_v1_ListTopicsResponse_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_google_pubsub_v1_ListTopicsResponse_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_ListTopicsResponse_descriptor, - new java.lang.String[] { "Topics", "NextPageToken", }); - internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor = - getDescriptor().getMessageTypes().get(7); - internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_ListTopicSubscriptionsRequest_descriptor, - new java.lang.String[] { "Topic", "PageSize", "PageToken", }); - internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor = - getDescriptor().getMessageTypes().get(8); - internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_ListTopicSubscriptionsResponse_descriptor, - new java.lang.String[] { "Subscriptions", "NextPageToken", }); - internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor = - getDescriptor().getMessageTypes().get(9); - internal_static_google_pubsub_v1_DeleteTopicRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_DeleteTopicRequest_descriptor, - new java.lang.String[] { "Topic", }); - internal_static_google_pubsub_v1_Subscription_descriptor = - getDescriptor().getMessageTypes().get(10); - internal_static_google_pubsub_v1_Subscription_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_Subscription_descriptor, - new java.lang.String[] { "Name", "Topic", "PushConfig", "AckDeadlineSeconds", }); - internal_static_google_pubsub_v1_PushConfig_descriptor = - getDescriptor().getMessageTypes().get(11); - internal_static_google_pubsub_v1_PushConfig_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_PushConfig_descriptor, - new java.lang.String[] { "PushEndpoint", "Attributes", }); - internal_static_google_pubsub_v1_PushConfig_AttributesEntry_descriptor = - internal_static_google_pubsub_v1_PushConfig_descriptor.getNestedTypes().get(0); - internal_static_google_pubsub_v1_PushConfig_AttributesEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_PushConfig_AttributesEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - internal_static_google_pubsub_v1_ReceivedMessage_descriptor = - getDescriptor().getMessageTypes().get(12); - internal_static_google_pubsub_v1_ReceivedMessage_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_ReceivedMessage_descriptor, - new java.lang.String[] { "AckId", "Message", }); - internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor = - getDescriptor().getMessageTypes().get(13); - internal_static_google_pubsub_v1_GetSubscriptionRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_GetSubscriptionRequest_descriptor, - new java.lang.String[] { "Subscription", }); - internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor = - getDescriptor().getMessageTypes().get(14); - internal_static_google_pubsub_v1_ListSubscriptionsRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_ListSubscriptionsRequest_descriptor, - new java.lang.String[] { "Project", "PageSize", "PageToken", }); - internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor = - getDescriptor().getMessageTypes().get(15); - internal_static_google_pubsub_v1_ListSubscriptionsResponse_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_ListSubscriptionsResponse_descriptor, - new java.lang.String[] { "Subscriptions", "NextPageToken", }); - internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor = - getDescriptor().getMessageTypes().get(16); - internal_static_google_pubsub_v1_DeleteSubscriptionRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_DeleteSubscriptionRequest_descriptor, - new java.lang.String[] { "Subscription", }); - internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor = - getDescriptor().getMessageTypes().get(17); - internal_static_google_pubsub_v1_ModifyPushConfigRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_ModifyPushConfigRequest_descriptor, - new java.lang.String[] { "Subscription", "PushConfig", }); - internal_static_google_pubsub_v1_PullRequest_descriptor = - getDescriptor().getMessageTypes().get(18); - internal_static_google_pubsub_v1_PullRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_PullRequest_descriptor, - new java.lang.String[] { "Subscription", "ReturnImmediately", "MaxMessages", }); - internal_static_google_pubsub_v1_PullResponse_descriptor = - getDescriptor().getMessageTypes().get(19); - internal_static_google_pubsub_v1_PullResponse_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_PullResponse_descriptor, - new java.lang.String[] { "ReceivedMessages", }); - internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor = - getDescriptor().getMessageTypes().get(20); - internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_ModifyAckDeadlineRequest_descriptor, - new java.lang.String[] { "Subscription", "AckIds", "AckDeadlineSeconds", }); - internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor = - getDescriptor().getMessageTypes().get(21); - internal_static_google_pubsub_v1_AcknowledgeRequest_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_google_pubsub_v1_AcknowledgeRequest_descriptor, - new java.lang.String[] { "Subscription", "AckIds", }); - com.google.protobuf.ExtensionRegistry registry = - com.google.protobuf.ExtensionRegistry.newInstance(); - registry.add(com.google.api.AnnotationsProto.http); - com.google.protobuf.Descriptors.FileDescriptor - .internalUpdateFileDescriptor(descriptor, registry); - com.google.api.AnnotationsProto.getDescriptor(); - com.google.protobuf.EmptyProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequest.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequest.java deleted file mode 100644 index faab0adbe20d..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequest.java +++ /dev/null @@ -1,636 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.PullRequest} - * - *
      - * Request for the Pull method.
      - * 
      - */ -public final class PullRequest extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.PullRequest) - PullRequestOrBuilder { - // Use PullRequest.newBuilder() to construct. - private PullRequest(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private PullRequest() { - subscription_ = ""; - returnImmediately_ = false; - maxMessages_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private PullRequest( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - subscription_ = s; - break; - } - case 16: { - - returnImmediately_ = input.readBool(); - break; - } - case 24: { - - maxMessages_ = input.readInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PullRequest.class, com.google.pubsub.v1.PullRequest.Builder.class); - } - - public static final int SUBSCRIPTION_FIELD_NUMBER = 1; - private volatile java.lang.Object subscription_; - /** - * optional string subscription = 1; - * - *
      -   * The subscription from which messages should be pulled.
      -   * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } - } - /** - * optional string subscription = 1; - * - *
      -   * The subscription from which messages should be pulled.
      -   * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RETURN_IMMEDIATELY_FIELD_NUMBER = 2; - private boolean returnImmediately_; - /** - * optional bool return_immediately = 2; - * - *
      -   * If this is specified as true the system will respond immediately even if
      -   * it is not able to return a message in the Pull response. Otherwise the
      -   * system is allowed to wait until at least one message is available rather
      -   * than returning no messages. The client may cancel the request if it does
      -   * not wish to wait any longer for the response.
      -   * 
      - */ - public boolean getReturnImmediately() { - return returnImmediately_; - } - - public static final int MAX_MESSAGES_FIELD_NUMBER = 3; - private int maxMessages_; - /** - * optional int32 max_messages = 3; - * - *
      -   * The maximum number of messages returned for this request. The Pub/Sub
      -   * system may return fewer than the number specified.
      -   * 
      - */ - public int getMaxMessages() { - return maxMessages_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSubscriptionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, subscription_); - } - if (returnImmediately_ != false) { - output.writeBool(2, returnImmediately_); - } - if (maxMessages_ != 0) { - output.writeInt32(3, maxMessages_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSubscriptionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, subscription_); - } - if (returnImmediately_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(2, returnImmediately_); - } - if (maxMessages_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, maxMessages_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.PullRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PullRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PullRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PullRequest parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PullRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PullRequest parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PullRequest parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.PullRequest parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PullRequest parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PullRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.PullRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.PullRequest} - * - *
      -   * Request for the Pull method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PullRequest) - com.google.pubsub.v1.PullRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullRequest_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PullRequest.class, com.google.pubsub.v1.PullRequest.Builder.class); - } - - // Construct using com.google.pubsub.v1.PullRequest.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - subscription_ = ""; - - returnImmediately_ = false; - - maxMessages_ = 0; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullRequest_descriptor; - } - - public com.google.pubsub.v1.PullRequest getDefaultInstanceForType() { - return com.google.pubsub.v1.PullRequest.getDefaultInstance(); - } - - public com.google.pubsub.v1.PullRequest build() { - com.google.pubsub.v1.PullRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.PullRequest buildPartial() { - com.google.pubsub.v1.PullRequest result = new com.google.pubsub.v1.PullRequest(this); - result.subscription_ = subscription_; - result.returnImmediately_ = returnImmediately_; - result.maxMessages_ = maxMessages_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.PullRequest) { - return mergeFrom((com.google.pubsub.v1.PullRequest)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.PullRequest other) { - if (other == com.google.pubsub.v1.PullRequest.getDefaultInstance()) return this; - if (!other.getSubscription().isEmpty()) { - subscription_ = other.subscription_; - onChanged(); - } - if (other.getReturnImmediately() != false) { - setReturnImmediately(other.getReturnImmediately()); - } - if (other.getMaxMessages() != 0) { - setMaxMessages(other.getMaxMessages()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.PullRequest parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.PullRequest) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object subscription_ = ""; - /** - * optional string subscription = 1; - * - *
      -     * The subscription from which messages should be pulled.
      -     * 
      - */ - public java.lang.String getSubscription() { - java.lang.Object ref = subscription_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscription_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription from which messages should be pulled.
      -     * 
      - */ - public com.google.protobuf.ByteString - getSubscriptionBytes() { - java.lang.Object ref = subscription_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscription_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription from which messages should be pulled.
      -     * 
      - */ - public Builder setSubscription( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subscription_ = value; - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription from which messages should be pulled.
      -     * 
      - */ - public Builder clearSubscription() { - - subscription_ = getDefaultInstance().getSubscription(); - onChanged(); - return this; - } - /** - * optional string subscription = 1; - * - *
      -     * The subscription from which messages should be pulled.
      -     * 
      - */ - public Builder setSubscriptionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subscription_ = value; - onChanged(); - return this; - } - - private boolean returnImmediately_ ; - /** - * optional bool return_immediately = 2; - * - *
      -     * If this is specified as true the system will respond immediately even if
      -     * it is not able to return a message in the Pull response. Otherwise the
      -     * system is allowed to wait until at least one message is available rather
      -     * than returning no messages. The client may cancel the request if it does
      -     * not wish to wait any longer for the response.
      -     * 
      - */ - public boolean getReturnImmediately() { - return returnImmediately_; - } - /** - * optional bool return_immediately = 2; - * - *
      -     * If this is specified as true the system will respond immediately even if
      -     * it is not able to return a message in the Pull response. Otherwise the
      -     * system is allowed to wait until at least one message is available rather
      -     * than returning no messages. The client may cancel the request if it does
      -     * not wish to wait any longer for the response.
      -     * 
      - */ - public Builder setReturnImmediately(boolean value) { - - returnImmediately_ = value; - onChanged(); - return this; - } - /** - * optional bool return_immediately = 2; - * - *
      -     * If this is specified as true the system will respond immediately even if
      -     * it is not able to return a message in the Pull response. Otherwise the
      -     * system is allowed to wait until at least one message is available rather
      -     * than returning no messages. The client may cancel the request if it does
      -     * not wish to wait any longer for the response.
      -     * 
      - */ - public Builder clearReturnImmediately() { - - returnImmediately_ = false; - onChanged(); - return this; - } - - private int maxMessages_ ; - /** - * optional int32 max_messages = 3; - * - *
      -     * The maximum number of messages returned for this request. The Pub/Sub
      -     * system may return fewer than the number specified.
      -     * 
      - */ - public int getMaxMessages() { - return maxMessages_; - } - /** - * optional int32 max_messages = 3; - * - *
      -     * The maximum number of messages returned for this request. The Pub/Sub
      -     * system may return fewer than the number specified.
      -     * 
      - */ - public Builder setMaxMessages(int value) { - - maxMessages_ = value; - onChanged(); - return this; - } - /** - * optional int32 max_messages = 3; - * - *
      -     * The maximum number of messages returned for this request. The Pub/Sub
      -     * system may return fewer than the number specified.
      -     * 
      - */ - public Builder clearMaxMessages() { - - maxMessages_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PullRequest) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.PullRequest) - private static final com.google.pubsub.v1.PullRequest DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.PullRequest(); - } - - public static com.google.pubsub.v1.PullRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public PullRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new PullRequest(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.PullRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequestOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequestOrBuilder.java deleted file mode 100644 index 698925a51401..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullRequestOrBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface PullRequestOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PullRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string subscription = 1; - * - *
      -   * The subscription from which messages should be pulled.
      -   * 
      - */ - java.lang.String getSubscription(); - /** - * optional string subscription = 1; - * - *
      -   * The subscription from which messages should be pulled.
      -   * 
      - */ - com.google.protobuf.ByteString - getSubscriptionBytes(); - - /** - * optional bool return_immediately = 2; - * - *
      -   * If this is specified as true the system will respond immediately even if
      -   * it is not able to return a message in the Pull response. Otherwise the
      -   * system is allowed to wait until at least one message is available rather
      -   * than returning no messages. The client may cancel the request if it does
      -   * not wish to wait any longer for the response.
      -   * 
      - */ - boolean getReturnImmediately(); - - /** - * optional int32 max_messages = 3; - * - *
      -   * The maximum number of messages returned for this request. The Pub/Sub
      -   * system may return fewer than the number specified.
      -   * 
      - */ - int getMaxMessages(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponse.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponse.java deleted file mode 100644 index 738e34b0137d..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponse.java +++ /dev/null @@ -1,824 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.PullResponse} - * - *
      - * Response for the Pull method.
      - * 
      - */ -public final class PullResponse extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.PullResponse) - PullResponseOrBuilder { - // Use PullResponse.newBuilder() to construct. - private PullResponse(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private PullResponse() { - receivedMessages_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private PullResponse( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - receivedMessages_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - receivedMessages_.add(input.readMessage(com.google.pubsub.v1.ReceivedMessage.parser(), extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - receivedMessages_ = java.util.Collections.unmodifiableList(receivedMessages_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PullResponse.class, com.google.pubsub.v1.PullResponse.Builder.class); - } - - public static final int RECEIVED_MESSAGES_FIELD_NUMBER = 1; - private java.util.List receivedMessages_; - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -   * there are no more available in the backlog. The Pub/Sub system may return
      -   * fewer than the maxMessages requested even if there are more messages
      -   * available in the backlog.
      -   * 
      - */ - public java.util.List getReceivedMessagesList() { - return receivedMessages_; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -   * there are no more available in the backlog. The Pub/Sub system may return
      -   * fewer than the maxMessages requested even if there are more messages
      -   * available in the backlog.
      -   * 
      - */ - public java.util.List - getReceivedMessagesOrBuilderList() { - return receivedMessages_; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -   * there are no more available in the backlog. The Pub/Sub system may return
      -   * fewer than the maxMessages requested even if there are more messages
      -   * available in the backlog.
      -   * 
      - */ - public int getReceivedMessagesCount() { - return receivedMessages_.size(); - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -   * there are no more available in the backlog. The Pub/Sub system may return
      -   * fewer than the maxMessages requested even if there are more messages
      -   * available in the backlog.
      -   * 
      - */ - public com.google.pubsub.v1.ReceivedMessage getReceivedMessages(int index) { - return receivedMessages_.get(index); - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -   * there are no more available in the backlog. The Pub/Sub system may return
      -   * fewer than the maxMessages requested even if there are more messages
      -   * available in the backlog.
      -   * 
      - */ - public com.google.pubsub.v1.ReceivedMessageOrBuilder getReceivedMessagesOrBuilder( - int index) { - return receivedMessages_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - for (int i = 0; i < receivedMessages_.size(); i++) { - output.writeMessage(1, receivedMessages_.get(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < receivedMessages_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, receivedMessages_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.PullResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PullResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PullResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PullResponse parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PullResponse parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PullResponse parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PullResponse parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.PullResponse parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PullResponse parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PullResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.PullResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.PullResponse} - * - *
      -   * Response for the Pull method.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PullResponse) - com.google.pubsub.v1.PullResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullResponse_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PullResponse.class, com.google.pubsub.v1.PullResponse.Builder.class); - } - - // Construct using com.google.pubsub.v1.PullResponse.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getReceivedMessagesFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - if (receivedMessagesBuilder_ == null) { - receivedMessages_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - receivedMessagesBuilder_.clear(); - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PullResponse_descriptor; - } - - public com.google.pubsub.v1.PullResponse getDefaultInstanceForType() { - return com.google.pubsub.v1.PullResponse.getDefaultInstance(); - } - - public com.google.pubsub.v1.PullResponse build() { - com.google.pubsub.v1.PullResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.PullResponse buildPartial() { - com.google.pubsub.v1.PullResponse result = new com.google.pubsub.v1.PullResponse(this); - int from_bitField0_ = bitField0_; - if (receivedMessagesBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - receivedMessages_ = java.util.Collections.unmodifiableList(receivedMessages_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.receivedMessages_ = receivedMessages_; - } else { - result.receivedMessages_ = receivedMessagesBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.PullResponse) { - return mergeFrom((com.google.pubsub.v1.PullResponse)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.PullResponse other) { - if (other == com.google.pubsub.v1.PullResponse.getDefaultInstance()) return this; - if (receivedMessagesBuilder_ == null) { - if (!other.receivedMessages_.isEmpty()) { - if (receivedMessages_.isEmpty()) { - receivedMessages_ = other.receivedMessages_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureReceivedMessagesIsMutable(); - receivedMessages_.addAll(other.receivedMessages_); - } - onChanged(); - } - } else { - if (!other.receivedMessages_.isEmpty()) { - if (receivedMessagesBuilder_.isEmpty()) { - receivedMessagesBuilder_.dispose(); - receivedMessagesBuilder_ = null; - receivedMessages_ = other.receivedMessages_; - bitField0_ = (bitField0_ & ~0x00000001); - receivedMessagesBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getReceivedMessagesFieldBuilder() : null; - } else { - receivedMessagesBuilder_.addAllMessages(other.receivedMessages_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.PullResponse parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.PullResponse) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List receivedMessages_ = - java.util.Collections.emptyList(); - private void ensureReceivedMessagesIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - receivedMessages_ = new java.util.ArrayList(receivedMessages_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.ReceivedMessage, com.google.pubsub.v1.ReceivedMessage.Builder, com.google.pubsub.v1.ReceivedMessageOrBuilder> receivedMessagesBuilder_; - - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public java.util.List getReceivedMessagesList() { - if (receivedMessagesBuilder_ == null) { - return java.util.Collections.unmodifiableList(receivedMessages_); - } else { - return receivedMessagesBuilder_.getMessageList(); - } - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public int getReceivedMessagesCount() { - if (receivedMessagesBuilder_ == null) { - return receivedMessages_.size(); - } else { - return receivedMessagesBuilder_.getCount(); - } - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public com.google.pubsub.v1.ReceivedMessage getReceivedMessages(int index) { - if (receivedMessagesBuilder_ == null) { - return receivedMessages_.get(index); - } else { - return receivedMessagesBuilder_.getMessage(index); - } - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public Builder setReceivedMessages( - int index, com.google.pubsub.v1.ReceivedMessage value) { - if (receivedMessagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureReceivedMessagesIsMutable(); - receivedMessages_.set(index, value); - onChanged(); - } else { - receivedMessagesBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public Builder setReceivedMessages( - int index, com.google.pubsub.v1.ReceivedMessage.Builder builderForValue) { - if (receivedMessagesBuilder_ == null) { - ensureReceivedMessagesIsMutable(); - receivedMessages_.set(index, builderForValue.build()); - onChanged(); - } else { - receivedMessagesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public Builder addReceivedMessages(com.google.pubsub.v1.ReceivedMessage value) { - if (receivedMessagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureReceivedMessagesIsMutable(); - receivedMessages_.add(value); - onChanged(); - } else { - receivedMessagesBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public Builder addReceivedMessages( - int index, com.google.pubsub.v1.ReceivedMessage value) { - if (receivedMessagesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureReceivedMessagesIsMutable(); - receivedMessages_.add(index, value); - onChanged(); - } else { - receivedMessagesBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public Builder addReceivedMessages( - com.google.pubsub.v1.ReceivedMessage.Builder builderForValue) { - if (receivedMessagesBuilder_ == null) { - ensureReceivedMessagesIsMutable(); - receivedMessages_.add(builderForValue.build()); - onChanged(); - } else { - receivedMessagesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public Builder addReceivedMessages( - int index, com.google.pubsub.v1.ReceivedMessage.Builder builderForValue) { - if (receivedMessagesBuilder_ == null) { - ensureReceivedMessagesIsMutable(); - receivedMessages_.add(index, builderForValue.build()); - onChanged(); - } else { - receivedMessagesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public Builder addAllReceivedMessages( - java.lang.Iterable values) { - if (receivedMessagesBuilder_ == null) { - ensureReceivedMessagesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, receivedMessages_); - onChanged(); - } else { - receivedMessagesBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public Builder clearReceivedMessages() { - if (receivedMessagesBuilder_ == null) { - receivedMessages_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - receivedMessagesBuilder_.clear(); - } - return this; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public Builder removeReceivedMessages(int index) { - if (receivedMessagesBuilder_ == null) { - ensureReceivedMessagesIsMutable(); - receivedMessages_.remove(index); - onChanged(); - } else { - receivedMessagesBuilder_.remove(index); - } - return this; - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public com.google.pubsub.v1.ReceivedMessage.Builder getReceivedMessagesBuilder( - int index) { - return getReceivedMessagesFieldBuilder().getBuilder(index); - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public com.google.pubsub.v1.ReceivedMessageOrBuilder getReceivedMessagesOrBuilder( - int index) { - if (receivedMessagesBuilder_ == null) { - return receivedMessages_.get(index); } else { - return receivedMessagesBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public java.util.List - getReceivedMessagesOrBuilderList() { - if (receivedMessagesBuilder_ != null) { - return receivedMessagesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(receivedMessages_); - } - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public com.google.pubsub.v1.ReceivedMessage.Builder addReceivedMessagesBuilder() { - return getReceivedMessagesFieldBuilder().addBuilder( - com.google.pubsub.v1.ReceivedMessage.getDefaultInstance()); - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public com.google.pubsub.v1.ReceivedMessage.Builder addReceivedMessagesBuilder( - int index) { - return getReceivedMessagesFieldBuilder().addBuilder( - index, com.google.pubsub.v1.ReceivedMessage.getDefaultInstance()); - } - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -     * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -     * there are no more available in the backlog. The Pub/Sub system may return
      -     * fewer than the maxMessages requested even if there are more messages
      -     * available in the backlog.
      -     * 
      - */ - public java.util.List - getReceivedMessagesBuilderList() { - return getReceivedMessagesFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.ReceivedMessage, com.google.pubsub.v1.ReceivedMessage.Builder, com.google.pubsub.v1.ReceivedMessageOrBuilder> - getReceivedMessagesFieldBuilder() { - if (receivedMessagesBuilder_ == null) { - receivedMessagesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.google.pubsub.v1.ReceivedMessage, com.google.pubsub.v1.ReceivedMessage.Builder, com.google.pubsub.v1.ReceivedMessageOrBuilder>( - receivedMessages_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - receivedMessages_ = null; - } - return receivedMessagesBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PullResponse) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.PullResponse) - private static final com.google.pubsub.v1.PullResponse DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.PullResponse(); - } - - public static com.google.pubsub.v1.PullResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public PullResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new PullResponse(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.PullResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponseOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponseOrBuilder.java deleted file mode 100644 index a93ac1757e3b..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PullResponseOrBuilder.java +++ /dev/null @@ -1,68 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface PullResponseOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PullResponse) - com.google.protobuf.MessageOrBuilder { - - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -   * there are no more available in the backlog. The Pub/Sub system may return
      -   * fewer than the maxMessages requested even if there are more messages
      -   * available in the backlog.
      -   * 
      - */ - java.util.List - getReceivedMessagesList(); - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -   * there are no more available in the backlog. The Pub/Sub system may return
      -   * fewer than the maxMessages requested even if there are more messages
      -   * available in the backlog.
      -   * 
      - */ - com.google.pubsub.v1.ReceivedMessage getReceivedMessages(int index); - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -   * there are no more available in the backlog. The Pub/Sub system may return
      -   * fewer than the maxMessages requested even if there are more messages
      -   * available in the backlog.
      -   * 
      - */ - int getReceivedMessagesCount(); - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -   * there are no more available in the backlog. The Pub/Sub system may return
      -   * fewer than the maxMessages requested even if there are more messages
      -   * available in the backlog.
      -   * 
      - */ - java.util.List - getReceivedMessagesOrBuilderList(); - /** - * repeated .google.pubsub.v1.ReceivedMessage received_messages = 1; - * - *
      -   * Received Pub/Sub messages. The Pub/Sub system will return zero messages if
      -   * there are no more available in the backlog. The Pub/Sub system may return
      -   * fewer than the maxMessages requested even if there are more messages
      -   * available in the backlog.
      -   * 
      - */ - com.google.pubsub.v1.ReceivedMessageOrBuilder getReceivedMessagesOrBuilder( - int index); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfig.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfig.java deleted file mode 100644 index fc8c34dc5be5..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfig.java +++ /dev/null @@ -1,711 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.PushConfig} - * - *
      - * Configuration for a push delivery endpoint.
      - * 
      - */ -public final class PushConfig extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.PushConfig) - PushConfigOrBuilder { - // Use PushConfig.newBuilder() to construct. - private PushConfig(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private PushConfig() { - pushEndpoint_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private PushConfig( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - pushEndpoint_ = s; - break; - } - case 18: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - attributes_ = com.google.protobuf.MapField.newMapField( - AttributesDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000002; - } - com.google.protobuf.MapEntry - attributes = input.readMessage( - AttributesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - attributes_.getMutableMap().put(attributes.getKey(), attributes.getValue()); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 2: - return internalGetAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PushConfig.class, com.google.pubsub.v1.PushConfig.Builder.class); - } - - private int bitField0_; - public static final int PUSH_ENDPOINT_FIELD_NUMBER = 1; - private volatile java.lang.Object pushEndpoint_; - /** - * optional string push_endpoint = 1; - * - *
      -   * A URL locating the endpoint to which messages should be pushed.
      -   * For example, a Webhook endpoint might use "https://example.com/push".
      -   * 
      - */ - public java.lang.String getPushEndpoint() { - java.lang.Object ref = pushEndpoint_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pushEndpoint_ = s; - return s; - } - } - /** - * optional string push_endpoint = 1; - * - *
      -   * A URL locating the endpoint to which messages should be pushed.
      -   * For example, a Webhook endpoint might use "https://example.com/push".
      -   * 
      - */ - public com.google.protobuf.ByteString - getPushEndpointBytes() { - java.lang.Object ref = pushEndpoint_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - pushEndpoint_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int ATTRIBUTES_FIELD_NUMBER = 2; - private static final class AttributesDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, java.lang.String> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_AttributesEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.STRING, - ""); - } - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> attributes_; - private com.google.protobuf.MapField - internalGetAttributes() { - if (attributes_ == null) { - return com.google.protobuf.MapField.emptyMapField( - AttributesDefaultEntryHolder.defaultEntry); - } - return attributes_; - } - /** - * map<string, string> attributes = 2; - * - *
      -   * Endpoint configuration attributes.
      -   * Every endpoint has a set of API supported attributes that can be used to
      -   * control different aspects of the message delivery.
      -   * The currently supported attribute is `x-goog-version`, which you can
      -   * use to change the format of the push message. This attribute
      -   * indicates the version of the data expected by the endpoint. This
      -   * controls the shape of the envelope (i.e. its fields and metadata).
      -   * The endpoint version is based on the version of the Pub/Sub
      -   * API.
      -   * If not present during the CreateSubscription call, it will default to
      -   * the version of the API used to make such call. If not present during a
      -   * ModifyPushConfig call, its value will not be changed. GetSubscription
      -   * calls will always return a valid version, even if the subscription was
      -   * created without this attribute.
      -   * The possible values for this attribute are:
      -   * * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
      -   * * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
      -   * 
      - */ - - public java.util.Map getAttributes() { - return internalGetAttributes().getMap(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getPushEndpointBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, pushEndpoint_); - } - for (java.util.Map.Entry entry - : internalGetAttributes().getMap().entrySet()) { - com.google.protobuf.MapEntry - attributes = AttributesDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - output.writeMessage(2, attributes); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getPushEndpointBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, pushEndpoint_); - } - for (java.util.Map.Entry entry - : internalGetAttributes().getMap().entrySet()) { - com.google.protobuf.MapEntry - attributes = AttributesDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, attributes); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.PushConfig parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PushConfig parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PushConfig parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.PushConfig parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.PushConfig parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PushConfig parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PushConfig parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.PushConfig parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.PushConfig parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.PushConfig parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.PushConfig prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.PushConfig} - * - *
      -   * Configuration for a push delivery endpoint.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.PushConfig) - com.google.pubsub.v1.PushConfigOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 2: - return internalGetAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField( - int number) { - switch (number) { - case 2: - return internalGetMutableAttributes(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.PushConfig.class, com.google.pubsub.v1.PushConfig.Builder.class); - } - - // Construct using com.google.pubsub.v1.PushConfig.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - pushEndpoint_ = ""; - - internalGetMutableAttributes().clear(); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_PushConfig_descriptor; - } - - public com.google.pubsub.v1.PushConfig getDefaultInstanceForType() { - return com.google.pubsub.v1.PushConfig.getDefaultInstance(); - } - - public com.google.pubsub.v1.PushConfig build() { - com.google.pubsub.v1.PushConfig result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.PushConfig buildPartial() { - com.google.pubsub.v1.PushConfig result = new com.google.pubsub.v1.PushConfig(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.pushEndpoint_ = pushEndpoint_; - result.attributes_ = internalGetAttributes(); - result.attributes_.makeImmutable(); - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.PushConfig) { - return mergeFrom((com.google.pubsub.v1.PushConfig)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.PushConfig other) { - if (other == com.google.pubsub.v1.PushConfig.getDefaultInstance()) return this; - if (!other.getPushEndpoint().isEmpty()) { - pushEndpoint_ = other.pushEndpoint_; - onChanged(); - } - internalGetMutableAttributes().mergeFrom( - other.internalGetAttributes()); - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.PushConfig parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.PushConfig) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object pushEndpoint_ = ""; - /** - * optional string push_endpoint = 1; - * - *
      -     * A URL locating the endpoint to which messages should be pushed.
      -     * For example, a Webhook endpoint might use "https://example.com/push".
      -     * 
      - */ - public java.lang.String getPushEndpoint() { - java.lang.Object ref = pushEndpoint_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pushEndpoint_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string push_endpoint = 1; - * - *
      -     * A URL locating the endpoint to which messages should be pushed.
      -     * For example, a Webhook endpoint might use "https://example.com/push".
      -     * 
      - */ - public com.google.protobuf.ByteString - getPushEndpointBytes() { - java.lang.Object ref = pushEndpoint_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - pushEndpoint_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string push_endpoint = 1; - * - *
      -     * A URL locating the endpoint to which messages should be pushed.
      -     * For example, a Webhook endpoint might use "https://example.com/push".
      -     * 
      - */ - public Builder setPushEndpoint( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - pushEndpoint_ = value; - onChanged(); - return this; - } - /** - * optional string push_endpoint = 1; - * - *
      -     * A URL locating the endpoint to which messages should be pushed.
      -     * For example, a Webhook endpoint might use "https://example.com/push".
      -     * 
      - */ - public Builder clearPushEndpoint() { - - pushEndpoint_ = getDefaultInstance().getPushEndpoint(); - onChanged(); - return this; - } - /** - * optional string push_endpoint = 1; - * - *
      -     * A URL locating the endpoint to which messages should be pushed.
      -     * For example, a Webhook endpoint might use "https://example.com/push".
      -     * 
      - */ - public Builder setPushEndpointBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pushEndpoint_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> attributes_; - private com.google.protobuf.MapField - internalGetAttributes() { - if (attributes_ == null) { - return com.google.protobuf.MapField.emptyMapField( - AttributesDefaultEntryHolder.defaultEntry); - } - return attributes_; - } - private com.google.protobuf.MapField - internalGetMutableAttributes() { - onChanged();; - if (attributes_ == null) { - attributes_ = com.google.protobuf.MapField.newMapField( - AttributesDefaultEntryHolder.defaultEntry); - } - if (!attributes_.isMutable()) { - attributes_ = attributes_.copy(); - } - return attributes_; - } - /** - * map<string, string> attributes = 2; - * - *
      -     * Endpoint configuration attributes.
      -     * Every endpoint has a set of API supported attributes that can be used to
      -     * control different aspects of the message delivery.
      -     * The currently supported attribute is `x-goog-version`, which you can
      -     * use to change the format of the push message. This attribute
      -     * indicates the version of the data expected by the endpoint. This
      -     * controls the shape of the envelope (i.e. its fields and metadata).
      -     * The endpoint version is based on the version of the Pub/Sub
      -     * API.
      -     * If not present during the CreateSubscription call, it will default to
      -     * the version of the API used to make such call. If not present during a
      -     * ModifyPushConfig call, its value will not be changed. GetSubscription
      -     * calls will always return a valid version, even if the subscription was
      -     * created without this attribute.
      -     * The possible values for this attribute are:
      -     * * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
      -     * * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
      -     * 
      - */ - public java.util.Map getAttributes() { - return internalGetAttributes().getMap(); - } - /** - * map<string, string> attributes = 2; - * - *
      -     * Endpoint configuration attributes.
      -     * Every endpoint has a set of API supported attributes that can be used to
      -     * control different aspects of the message delivery.
      -     * The currently supported attribute is `x-goog-version`, which you can
      -     * use to change the format of the push message. This attribute
      -     * indicates the version of the data expected by the endpoint. This
      -     * controls the shape of the envelope (i.e. its fields and metadata).
      -     * The endpoint version is based on the version of the Pub/Sub
      -     * API.
      -     * If not present during the CreateSubscription call, it will default to
      -     * the version of the API used to make such call. If not present during a
      -     * ModifyPushConfig call, its value will not be changed. GetSubscription
      -     * calls will always return a valid version, even if the subscription was
      -     * created without this attribute.
      -     * The possible values for this attribute are:
      -     * * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
      -     * * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
      -     * 
      - */ - public java.util.Map - getMutableAttributes() { - return internalGetMutableAttributes().getMutableMap(); - } - /** - * map<string, string> attributes = 2; - * - *
      -     * Endpoint configuration attributes.
      -     * Every endpoint has a set of API supported attributes that can be used to
      -     * control different aspects of the message delivery.
      -     * The currently supported attribute is `x-goog-version`, which you can
      -     * use to change the format of the push message. This attribute
      -     * indicates the version of the data expected by the endpoint. This
      -     * controls the shape of the envelope (i.e. its fields and metadata).
      -     * The endpoint version is based on the version of the Pub/Sub
      -     * API.
      -     * If not present during the CreateSubscription call, it will default to
      -     * the version of the API used to make such call. If not present during a
      -     * ModifyPushConfig call, its value will not be changed. GetSubscription
      -     * calls will always return a valid version, even if the subscription was
      -     * created without this attribute.
      -     * The possible values for this attribute are:
      -     * * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
      -     * * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
      -     * 
      - */ - public Builder putAllAttributes( - java.util.Map values) { - getMutableAttributes().putAll(values); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.PushConfig) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.PushConfig) - private static final com.google.pubsub.v1.PushConfig DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.PushConfig(); - } - - public static com.google.pubsub.v1.PushConfig getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public PushConfig parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new PushConfig(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.PushConfig getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfigOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfigOrBuilder.java deleted file mode 100644 index 6a4e995b8232..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/PushConfigOrBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface PushConfigOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.PushConfig) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string push_endpoint = 1; - * - *
      -   * A URL locating the endpoint to which messages should be pushed.
      -   * For example, a Webhook endpoint might use "https://example.com/push".
      -   * 
      - */ - java.lang.String getPushEndpoint(); - /** - * optional string push_endpoint = 1; - * - *
      -   * A URL locating the endpoint to which messages should be pushed.
      -   * For example, a Webhook endpoint might use "https://example.com/push".
      -   * 
      - */ - com.google.protobuf.ByteString - getPushEndpointBytes(); - - /** - * map<string, string> attributes = 2; - * - *
      -   * Endpoint configuration attributes.
      -   * Every endpoint has a set of API supported attributes that can be used to
      -   * control different aspects of the message delivery.
      -   * The currently supported attribute is `x-goog-version`, which you can
      -   * use to change the format of the push message. This attribute
      -   * indicates the version of the data expected by the endpoint. This
      -   * controls the shape of the envelope (i.e. its fields and metadata).
      -   * The endpoint version is based on the version of the Pub/Sub
      -   * API.
      -   * If not present during the CreateSubscription call, it will default to
      -   * the version of the API used to make such call. If not present during a
      -   * ModifyPushConfig call, its value will not be changed. GetSubscription
      -   * calls will always return a valid version, even if the subscription was
      -   * created without this attribute.
      -   * The possible values for this attribute are:
      -   * * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
      -   * * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
      -   * 
      - */ - java.util.Map - getAttributes(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessage.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessage.java deleted file mode 100644 index 091d0ca610b2..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessage.java +++ /dev/null @@ -1,696 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.ReceivedMessage} - * - *
      - * A message and its corresponding acknowledgment ID.
      - * 
      - */ -public final class ReceivedMessage extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.ReceivedMessage) - ReceivedMessageOrBuilder { - // Use ReceivedMessage.newBuilder() to construct. - private ReceivedMessage(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private ReceivedMessage() { - ackId_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private ReceivedMessage( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - ackId_ = s; - break; - } - case 18: { - com.google.pubsub.v1.PubsubMessage.Builder subBuilder = null; - if (message_ != null) { - subBuilder = message_.toBuilder(); - } - message_ = input.readMessage(com.google.pubsub.v1.PubsubMessage.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(message_); - message_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ReceivedMessage_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ReceivedMessage_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ReceivedMessage.class, com.google.pubsub.v1.ReceivedMessage.Builder.class); - } - - public static final int ACK_ID_FIELD_NUMBER = 1; - private volatile java.lang.Object ackId_; - /** - * optional string ack_id = 1; - * - *
      -   * This ID can be used to acknowledge the received message.
      -   * 
      - */ - public java.lang.String getAckId() { - java.lang.Object ref = ackId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - ackId_ = s; - return s; - } - } - /** - * optional string ack_id = 1; - * - *
      -   * This ID can be used to acknowledge the received message.
      -   * 
      - */ - public com.google.protobuf.ByteString - getAckIdBytes() { - java.lang.Object ref = ackId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - ackId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int MESSAGE_FIELD_NUMBER = 2; - private com.google.pubsub.v1.PubsubMessage message_; - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -   * The message.
      -   * 
      - */ - public boolean hasMessage() { - return message_ != null; - } - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -   * The message.
      -   * 
      - */ - public com.google.pubsub.v1.PubsubMessage getMessage() { - return message_ == null ? com.google.pubsub.v1.PubsubMessage.getDefaultInstance() : message_; - } - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -   * The message.
      -   * 
      - */ - public com.google.pubsub.v1.PubsubMessageOrBuilder getMessageOrBuilder() { - return getMessage(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getAckIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, ackId_); - } - if (message_ != null) { - output.writeMessage(2, getMessage()); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getAckIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, ackId_); - } - if (message_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(2, getMessage()); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.ReceivedMessage parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ReceivedMessage parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ReceivedMessage parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.ReceivedMessage parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.ReceivedMessage parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ReceivedMessage parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ReceivedMessage parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.ReceivedMessage parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.ReceivedMessage parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.ReceivedMessage parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.ReceivedMessage prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.ReceivedMessage} - * - *
      -   * A message and its corresponding acknowledgment ID.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.ReceivedMessage) - com.google.pubsub.v1.ReceivedMessageOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ReceivedMessage_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ReceivedMessage_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.ReceivedMessage.class, com.google.pubsub.v1.ReceivedMessage.Builder.class); - } - - // Construct using com.google.pubsub.v1.ReceivedMessage.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - ackId_ = ""; - - if (messageBuilder_ == null) { - message_ = null; - } else { - message_ = null; - messageBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_ReceivedMessage_descriptor; - } - - public com.google.pubsub.v1.ReceivedMessage getDefaultInstanceForType() { - return com.google.pubsub.v1.ReceivedMessage.getDefaultInstance(); - } - - public com.google.pubsub.v1.ReceivedMessage build() { - com.google.pubsub.v1.ReceivedMessage result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.ReceivedMessage buildPartial() { - com.google.pubsub.v1.ReceivedMessage result = new com.google.pubsub.v1.ReceivedMessage(this); - result.ackId_ = ackId_; - if (messageBuilder_ == null) { - result.message_ = message_; - } else { - result.message_ = messageBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.ReceivedMessage) { - return mergeFrom((com.google.pubsub.v1.ReceivedMessage)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.ReceivedMessage other) { - if (other == com.google.pubsub.v1.ReceivedMessage.getDefaultInstance()) return this; - if (!other.getAckId().isEmpty()) { - ackId_ = other.ackId_; - onChanged(); - } - if (other.hasMessage()) { - mergeMessage(other.getMessage()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.ReceivedMessage parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.ReceivedMessage) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object ackId_ = ""; - /** - * optional string ack_id = 1; - * - *
      -     * This ID can be used to acknowledge the received message.
      -     * 
      - */ - public java.lang.String getAckId() { - java.lang.Object ref = ackId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - ackId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string ack_id = 1; - * - *
      -     * This ID can be used to acknowledge the received message.
      -     * 
      - */ - public com.google.protobuf.ByteString - getAckIdBytes() { - java.lang.Object ref = ackId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - ackId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string ack_id = 1; - * - *
      -     * This ID can be used to acknowledge the received message.
      -     * 
      - */ - public Builder setAckId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - ackId_ = value; - onChanged(); - return this; - } - /** - * optional string ack_id = 1; - * - *
      -     * This ID can be used to acknowledge the received message.
      -     * 
      - */ - public Builder clearAckId() { - - ackId_ = getDefaultInstance().getAckId(); - onChanged(); - return this; - } - /** - * optional string ack_id = 1; - * - *
      -     * This ID can be used to acknowledge the received message.
      -     * 
      - */ - public Builder setAckIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - ackId_ = value; - onChanged(); - return this; - } - - private com.google.pubsub.v1.PubsubMessage message_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder> messageBuilder_; - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -     * The message.
      -     * 
      - */ - public boolean hasMessage() { - return messageBuilder_ != null || message_ != null; - } - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -     * The message.
      -     * 
      - */ - public com.google.pubsub.v1.PubsubMessage getMessage() { - if (messageBuilder_ == null) { - return message_ == null ? com.google.pubsub.v1.PubsubMessage.getDefaultInstance() : message_; - } else { - return messageBuilder_.getMessage(); - } - } - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -     * The message.
      -     * 
      - */ - public Builder setMessage(com.google.pubsub.v1.PubsubMessage value) { - if (messageBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - message_ = value; - onChanged(); - } else { - messageBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -     * The message.
      -     * 
      - */ - public Builder setMessage( - com.google.pubsub.v1.PubsubMessage.Builder builderForValue) { - if (messageBuilder_ == null) { - message_ = builderForValue.build(); - onChanged(); - } else { - messageBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -     * The message.
      -     * 
      - */ - public Builder mergeMessage(com.google.pubsub.v1.PubsubMessage value) { - if (messageBuilder_ == null) { - if (message_ != null) { - message_ = - com.google.pubsub.v1.PubsubMessage.newBuilder(message_).mergeFrom(value).buildPartial(); - } else { - message_ = value; - } - onChanged(); - } else { - messageBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -     * The message.
      -     * 
      - */ - public Builder clearMessage() { - if (messageBuilder_ == null) { - message_ = null; - onChanged(); - } else { - message_ = null; - messageBuilder_ = null; - } - - return this; - } - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -     * The message.
      -     * 
      - */ - public com.google.pubsub.v1.PubsubMessage.Builder getMessageBuilder() { - - onChanged(); - return getMessageFieldBuilder().getBuilder(); - } - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -     * The message.
      -     * 
      - */ - public com.google.pubsub.v1.PubsubMessageOrBuilder getMessageOrBuilder() { - if (messageBuilder_ != null) { - return messageBuilder_.getMessageOrBuilder(); - } else { - return message_ == null ? - com.google.pubsub.v1.PubsubMessage.getDefaultInstance() : message_; - } - } - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -     * The message.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder> - getMessageFieldBuilder() { - if (messageBuilder_ == null) { - messageBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.pubsub.v1.PubsubMessage, com.google.pubsub.v1.PubsubMessage.Builder, com.google.pubsub.v1.PubsubMessageOrBuilder>( - getMessage(), - getParentForChildren(), - isClean()); - message_ = null; - } - return messageBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.ReceivedMessage) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.ReceivedMessage) - private static final com.google.pubsub.v1.ReceivedMessage DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.ReceivedMessage(); - } - - public static com.google.pubsub.v1.ReceivedMessage getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public ReceivedMessage parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new ReceivedMessage(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.ReceivedMessage getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessageOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessageOrBuilder.java deleted file mode 100644 index c832555d57a4..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/ReceivedMessageOrBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface ReceivedMessageOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.ReceivedMessage) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string ack_id = 1; - * - *
      -   * This ID can be used to acknowledge the received message.
      -   * 
      - */ - java.lang.String getAckId(); - /** - * optional string ack_id = 1; - * - *
      -   * This ID can be used to acknowledge the received message.
      -   * 
      - */ - com.google.protobuf.ByteString - getAckIdBytes(); - - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -   * The message.
      -   * 
      - */ - boolean hasMessage(); - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -   * The message.
      -   * 
      - */ - com.google.pubsub.v1.PubsubMessage getMessage(); - /** - * optional .google.pubsub.v1.PubsubMessage message = 2; - * - *
      -   * The message.
      -   * 
      - */ - com.google.pubsub.v1.PubsubMessageOrBuilder getMessageOrBuilder(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriberGrpc.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriberGrpc.java deleted file mode 100644 index 32c81fe096a5..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriberGrpc.java +++ /dev/null @@ -1,506 +0,0 @@ -package com.google.pubsub.v1; - -import static io.grpc.stub.ClientCalls.asyncUnaryCall; -import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; -import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; -import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; -import static io.grpc.stub.ClientCalls.blockingUnaryCall; -import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; -import static io.grpc.stub.ClientCalls.futureUnaryCall; -import static io.grpc.MethodDescriptor.generateFullMethodName; -import static io.grpc.stub.ServerCalls.asyncUnaryCall; -import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; -import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; -import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; - -@javax.annotation.Generated("by gRPC proto compiler") -public class SubscriberGrpc { - - private SubscriberGrpc() {} - - public static final String SERVICE_NAME = "google.pubsub.v1.Subscriber"; - - // Static method descriptors that strictly reflect the proto. - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_CREATE_SUBSCRIPTION = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Subscriber", "CreateSubscription"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Subscription.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Subscription.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_GET_SUBSCRIPTION = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Subscriber", "GetSubscription"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.GetSubscriptionRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.Subscription.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_LIST_SUBSCRIPTIONS = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Subscriber", "ListSubscriptions"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListSubscriptionsRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ListSubscriptionsResponse.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_DELETE_SUBSCRIPTION = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Subscriber", "DeleteSubscription"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.DeleteSubscriptionRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_MODIFY_ACK_DEADLINE = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Subscriber", "ModifyAckDeadline"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ModifyAckDeadlineRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_ACKNOWLEDGE = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Subscriber", "Acknowledge"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.AcknowledgeRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_PULL = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Subscriber", "Pull"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.PullRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.PullResponse.getDefaultInstance())); - @io.grpc.ExperimentalApi - public static final io.grpc.MethodDescriptor METHOD_MODIFY_PUSH_CONFIG = - io.grpc.MethodDescriptor.create( - io.grpc.MethodDescriptor.MethodType.UNARY, - generateFullMethodName( - "google.pubsub.v1.Subscriber", "ModifyPushConfig"), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.pubsub.v1.ModifyPushConfigRequest.getDefaultInstance()), - io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.Empty.getDefaultInstance())); - - public static SubscriberStub newStub(io.grpc.Channel channel) { - return new SubscriberStub(channel); - } - - public static SubscriberBlockingStub newBlockingStub( - io.grpc.Channel channel) { - return new SubscriberBlockingStub(channel); - } - - public static SubscriberFutureStub newFutureStub( - io.grpc.Channel channel) { - return new SubscriberFutureStub(channel); - } - - public static interface Subscriber { - - public void createSubscription(com.google.pubsub.v1.Subscription request, - io.grpc.stub.StreamObserver responseObserver); - - public void getSubscription(com.google.pubsub.v1.GetSubscriptionRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void listSubscriptions(com.google.pubsub.v1.ListSubscriptionsRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void deleteSubscription(com.google.pubsub.v1.DeleteSubscriptionRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void modifyAckDeadline(com.google.pubsub.v1.ModifyAckDeadlineRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void acknowledge(com.google.pubsub.v1.AcknowledgeRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void pull(com.google.pubsub.v1.PullRequest request, - io.grpc.stub.StreamObserver responseObserver); - - public void modifyPushConfig(com.google.pubsub.v1.ModifyPushConfigRequest request, - io.grpc.stub.StreamObserver responseObserver); - } - - public static interface SubscriberBlockingClient { - - public com.google.pubsub.v1.Subscription createSubscription(com.google.pubsub.v1.Subscription request); - - public com.google.pubsub.v1.Subscription getSubscription(com.google.pubsub.v1.GetSubscriptionRequest request); - - public com.google.pubsub.v1.ListSubscriptionsResponse listSubscriptions(com.google.pubsub.v1.ListSubscriptionsRequest request); - - public com.google.protobuf.Empty deleteSubscription(com.google.pubsub.v1.DeleteSubscriptionRequest request); - - public com.google.protobuf.Empty modifyAckDeadline(com.google.pubsub.v1.ModifyAckDeadlineRequest request); - - public com.google.protobuf.Empty acknowledge(com.google.pubsub.v1.AcknowledgeRequest request); - - public com.google.pubsub.v1.PullResponse pull(com.google.pubsub.v1.PullRequest request); - - public com.google.protobuf.Empty modifyPushConfig(com.google.pubsub.v1.ModifyPushConfigRequest request); - } - - public static interface SubscriberFutureClient { - - public com.google.common.util.concurrent.ListenableFuture createSubscription( - com.google.pubsub.v1.Subscription request); - - public com.google.common.util.concurrent.ListenableFuture getSubscription( - com.google.pubsub.v1.GetSubscriptionRequest request); - - public com.google.common.util.concurrent.ListenableFuture listSubscriptions( - com.google.pubsub.v1.ListSubscriptionsRequest request); - - public com.google.common.util.concurrent.ListenableFuture deleteSubscription( - com.google.pubsub.v1.DeleteSubscriptionRequest request); - - public com.google.common.util.concurrent.ListenableFuture modifyAckDeadline( - com.google.pubsub.v1.ModifyAckDeadlineRequest request); - - public com.google.common.util.concurrent.ListenableFuture acknowledge( - com.google.pubsub.v1.AcknowledgeRequest request); - - public com.google.common.util.concurrent.ListenableFuture pull( - com.google.pubsub.v1.PullRequest request); - - public com.google.common.util.concurrent.ListenableFuture modifyPushConfig( - com.google.pubsub.v1.ModifyPushConfigRequest request); - } - - public static class SubscriberStub extends io.grpc.stub.AbstractStub - implements Subscriber { - private SubscriberStub(io.grpc.Channel channel) { - super(channel); - } - - private SubscriberStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected SubscriberStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new SubscriberStub(channel, callOptions); - } - - @java.lang.Override - public void createSubscription(com.google.pubsub.v1.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_CREATE_SUBSCRIPTION, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void getSubscription(com.google.pubsub.v1.GetSubscriptionRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_GET_SUBSCRIPTION, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void listSubscriptions(com.google.pubsub.v1.ListSubscriptionsRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_LIST_SUBSCRIPTIONS, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void deleteSubscription(com.google.pubsub.v1.DeleteSubscriptionRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_DELETE_SUBSCRIPTION, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void modifyAckDeadline(com.google.pubsub.v1.ModifyAckDeadlineRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_MODIFY_ACK_DEADLINE, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void acknowledge(com.google.pubsub.v1.AcknowledgeRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_ACKNOWLEDGE, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void pull(com.google.pubsub.v1.PullRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_PULL, getCallOptions()), request, responseObserver); - } - - @java.lang.Override - public void modifyPushConfig(com.google.pubsub.v1.ModifyPushConfigRequest request, - io.grpc.stub.StreamObserver responseObserver) { - asyncUnaryCall( - getChannel().newCall(METHOD_MODIFY_PUSH_CONFIG, getCallOptions()), request, responseObserver); - } - } - - public static class SubscriberBlockingStub extends io.grpc.stub.AbstractStub - implements SubscriberBlockingClient { - private SubscriberBlockingStub(io.grpc.Channel channel) { - super(channel); - } - - private SubscriberBlockingStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected SubscriberBlockingStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new SubscriberBlockingStub(channel, callOptions); - } - - @java.lang.Override - public com.google.pubsub.v1.Subscription createSubscription(com.google.pubsub.v1.Subscription request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_CREATE_SUBSCRIPTION, getCallOptions()), request); - } - - @java.lang.Override - public com.google.pubsub.v1.Subscription getSubscription(com.google.pubsub.v1.GetSubscriptionRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_GET_SUBSCRIPTION, getCallOptions()), request); - } - - @java.lang.Override - public com.google.pubsub.v1.ListSubscriptionsResponse listSubscriptions(com.google.pubsub.v1.ListSubscriptionsRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_LIST_SUBSCRIPTIONS, getCallOptions()), request); - } - - @java.lang.Override - public com.google.protobuf.Empty deleteSubscription(com.google.pubsub.v1.DeleteSubscriptionRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_DELETE_SUBSCRIPTION, getCallOptions()), request); - } - - @java.lang.Override - public com.google.protobuf.Empty modifyAckDeadline(com.google.pubsub.v1.ModifyAckDeadlineRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_MODIFY_ACK_DEADLINE, getCallOptions()), request); - } - - @java.lang.Override - public com.google.protobuf.Empty acknowledge(com.google.pubsub.v1.AcknowledgeRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_ACKNOWLEDGE, getCallOptions()), request); - } - - @java.lang.Override - public com.google.pubsub.v1.PullResponse pull(com.google.pubsub.v1.PullRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_PULL, getCallOptions()), request); - } - - @java.lang.Override - public com.google.protobuf.Empty modifyPushConfig(com.google.pubsub.v1.ModifyPushConfigRequest request) { - return blockingUnaryCall( - getChannel().newCall(METHOD_MODIFY_PUSH_CONFIG, getCallOptions()), request); - } - } - - public static class SubscriberFutureStub extends io.grpc.stub.AbstractStub - implements SubscriberFutureClient { - private SubscriberFutureStub(io.grpc.Channel channel) { - super(channel); - } - - private SubscriberFutureStub(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected SubscriberFutureStub build(io.grpc.Channel channel, - io.grpc.CallOptions callOptions) { - return new SubscriberFutureStub(channel, callOptions); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture createSubscription( - com.google.pubsub.v1.Subscription request) { - return futureUnaryCall( - getChannel().newCall(METHOD_CREATE_SUBSCRIPTION, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture getSubscription( - com.google.pubsub.v1.GetSubscriptionRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_GET_SUBSCRIPTION, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture listSubscriptions( - com.google.pubsub.v1.ListSubscriptionsRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_LIST_SUBSCRIPTIONS, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture deleteSubscription( - com.google.pubsub.v1.DeleteSubscriptionRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_DELETE_SUBSCRIPTION, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture modifyAckDeadline( - com.google.pubsub.v1.ModifyAckDeadlineRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_MODIFY_ACK_DEADLINE, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture acknowledge( - com.google.pubsub.v1.AcknowledgeRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_ACKNOWLEDGE, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture pull( - com.google.pubsub.v1.PullRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_PULL, getCallOptions()), request); - } - - @java.lang.Override - public com.google.common.util.concurrent.ListenableFuture modifyPushConfig( - com.google.pubsub.v1.ModifyPushConfigRequest request) { - return futureUnaryCall( - getChannel().newCall(METHOD_MODIFY_PUSH_CONFIG, getCallOptions()), request); - } - } - - public static io.grpc.ServerServiceDefinition bindService( - final Subscriber serviceImpl) { - return io.grpc.ServerServiceDefinition.builder(SERVICE_NAME) - .addMethod( - METHOD_CREATE_SUBSCRIPTION, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.Subscription, - com.google.pubsub.v1.Subscription>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.Subscription request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.createSubscription(request, responseObserver); - } - })) - .addMethod( - METHOD_GET_SUBSCRIPTION, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.GetSubscriptionRequest, - com.google.pubsub.v1.Subscription>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.GetSubscriptionRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.getSubscription(request, responseObserver); - } - })) - .addMethod( - METHOD_LIST_SUBSCRIPTIONS, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.ListSubscriptionsRequest, - com.google.pubsub.v1.ListSubscriptionsResponse>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.ListSubscriptionsRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.listSubscriptions(request, responseObserver); - } - })) - .addMethod( - METHOD_DELETE_SUBSCRIPTION, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.DeleteSubscriptionRequest, - com.google.protobuf.Empty>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.DeleteSubscriptionRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.deleteSubscription(request, responseObserver); - } - })) - .addMethod( - METHOD_MODIFY_ACK_DEADLINE, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.ModifyAckDeadlineRequest, - com.google.protobuf.Empty>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.ModifyAckDeadlineRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.modifyAckDeadline(request, responseObserver); - } - })) - .addMethod( - METHOD_ACKNOWLEDGE, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.AcknowledgeRequest, - com.google.protobuf.Empty>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.AcknowledgeRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.acknowledge(request, responseObserver); - } - })) - .addMethod( - METHOD_PULL, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.PullRequest, - com.google.pubsub.v1.PullResponse>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.PullRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.pull(request, responseObserver); - } - })) - .addMethod( - METHOD_MODIFY_PUSH_CONFIG, - asyncUnaryCall( - new io.grpc.stub.ServerCalls.UnaryMethod< - com.google.pubsub.v1.ModifyPushConfigRequest, - com.google.protobuf.Empty>() { - @java.lang.Override - public void invoke( - com.google.pubsub.v1.ModifyPushConfigRequest request, - io.grpc.stub.StreamObserver responseObserver) { - serviceImpl.modifyPushConfig(request, responseObserver); - } - })).build(); - } -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Subscription.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Subscription.java deleted file mode 100644 index 45175301338d..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Subscription.java +++ /dev/null @@ -1,1038 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.Subscription} - * - *
      - * A subscription resource.
      - * 
      - */ -public final class Subscription extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.Subscription) - SubscriptionOrBuilder { - // Use Subscription.newBuilder() to construct. - private Subscription(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Subscription() { - name_ = ""; - topic_ = ""; - ackDeadlineSeconds_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Subscription( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - name_ = s; - break; - } - case 18: { - String s = input.readStringRequireUtf8(); - - topic_ = s; - break; - } - case 34: { - com.google.pubsub.v1.PushConfig.Builder subBuilder = null; - if (pushConfig_ != null) { - subBuilder = pushConfig_.toBuilder(); - } - pushConfig_ = input.readMessage(com.google.pubsub.v1.PushConfig.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(pushConfig_); - pushConfig_ = subBuilder.buildPartial(); - } - - break; - } - case 40: { - - ackDeadlineSeconds_ = input.readInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Subscription_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Subscription_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.Subscription.class, com.google.pubsub.v1.Subscription.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * optional string name = 1; - * - *
      -   * The name of the subscription. It must have the format
      -   * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      -   * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      -   * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      -   * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      -   * in length, and it must not start with `"goog"`.
      -   * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * optional string name = 1; - * - *
      -   * The name of the subscription. It must have the format
      -   * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      -   * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      -   * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      -   * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      -   * in length, and it must not start with `"goog"`.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TOPIC_FIELD_NUMBER = 2; - private volatile java.lang.Object topic_; - /** - * optional string topic = 2; - * - *
      -   * The name of the topic from which this subscription is receiving messages.
      -   * The value of this field will be `_deleted-topic_` if the topic has been
      -   * deleted.
      -   * 
      - */ - public java.lang.String getTopic() { - java.lang.Object ref = topic_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - topic_ = s; - return s; - } - } - /** - * optional string topic = 2; - * - *
      -   * The name of the topic from which this subscription is receiving messages.
      -   * The value of this field will be `_deleted-topic_` if the topic has been
      -   * deleted.
      -   * 
      - */ - public com.google.protobuf.ByteString - getTopicBytes() { - java.lang.Object ref = topic_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PUSH_CONFIG_FIELD_NUMBER = 4; - private com.google.pubsub.v1.PushConfig pushConfig_; - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -   * If push delivery is used with this subscription, this field is
      -   * used to configure it. An empty pushConfig signifies that the subscriber
      -   * will pull and ack messages using API methods.
      -   * 
      - */ - public boolean hasPushConfig() { - return pushConfig_ != null; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -   * If push delivery is used with this subscription, this field is
      -   * used to configure it. An empty pushConfig signifies that the subscriber
      -   * will pull and ack messages using API methods.
      -   * 
      - */ - public com.google.pubsub.v1.PushConfig getPushConfig() { - return pushConfig_ == null ? com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -   * If push delivery is used with this subscription, this field is
      -   * used to configure it. An empty pushConfig signifies that the subscriber
      -   * will pull and ack messages using API methods.
      -   * 
      - */ - public com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder() { - return getPushConfig(); - } - - public static final int ACK_DEADLINE_SECONDS_FIELD_NUMBER = 5; - private int ackDeadlineSeconds_; - /** - * optional int32 ack_deadline_seconds = 5; - * - *
      -   * This value is the maximum time after a subscriber receives a message
      -   * before the subscriber should acknowledge the message. After message
      -   * delivery but before the ack deadline expires and before the message is
      -   * acknowledged, it is an outstanding message and will not be delivered
      -   * again during that time (on a best-effort basis).
      -   * For pull delivery this value is used as the initial value for the ack
      -   * deadline. To override this value for a given message, call
      -   * ModifyAckDeadline with the corresponding ack_id.
      -   * For push delivery, this value is also used to set the request timeout for
      -   * the call to the push endpoint.
      -   * If the subscriber never acknowledges the message, the Pub/Sub
      -   * system will eventually redeliver the message.
      -   * If this parameter is not set, the default value of 10 seconds is used.
      -   * 
      - */ - public int getAckDeadlineSeconds() { - return ackDeadlineSeconds_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); - } - if (!getTopicBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, topic_); - } - if (pushConfig_ != null) { - output.writeMessage(4, getPushConfig()); - } - if (ackDeadlineSeconds_ != 0) { - output.writeInt32(5, ackDeadlineSeconds_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); - } - if (!getTopicBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, topic_); - } - if (pushConfig_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, getPushConfig()); - } - if (ackDeadlineSeconds_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(5, ackDeadlineSeconds_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.Subscription parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.Subscription parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.Subscription parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.Subscription parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.Subscription parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.Subscription parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.Subscription parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.Subscription parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.Subscription parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.Subscription parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.Subscription prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.Subscription} - * - *
      -   * A subscription resource.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.Subscription) - com.google.pubsub.v1.SubscriptionOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Subscription_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Subscription_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.Subscription.class, com.google.pubsub.v1.Subscription.Builder.class); - } - - // Construct using com.google.pubsub.v1.Subscription.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - name_ = ""; - - topic_ = ""; - - if (pushConfigBuilder_ == null) { - pushConfig_ = null; - } else { - pushConfig_ = null; - pushConfigBuilder_ = null; - } - ackDeadlineSeconds_ = 0; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Subscription_descriptor; - } - - public com.google.pubsub.v1.Subscription getDefaultInstanceForType() { - return com.google.pubsub.v1.Subscription.getDefaultInstance(); - } - - public com.google.pubsub.v1.Subscription build() { - com.google.pubsub.v1.Subscription result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.Subscription buildPartial() { - com.google.pubsub.v1.Subscription result = new com.google.pubsub.v1.Subscription(this); - result.name_ = name_; - result.topic_ = topic_; - if (pushConfigBuilder_ == null) { - result.pushConfig_ = pushConfig_; - } else { - result.pushConfig_ = pushConfigBuilder_.build(); - } - result.ackDeadlineSeconds_ = ackDeadlineSeconds_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.Subscription) { - return mergeFrom((com.google.pubsub.v1.Subscription)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.Subscription other) { - if (other == com.google.pubsub.v1.Subscription.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (!other.getTopic().isEmpty()) { - topic_ = other.topic_; - onChanged(); - } - if (other.hasPushConfig()) { - mergePushConfig(other.getPushConfig()); - } - if (other.getAckDeadlineSeconds() != 0) { - setAckDeadlineSeconds(other.getAckDeadlineSeconds()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.Subscription parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.Subscription) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object name_ = ""; - /** - * optional string name = 1; - * - *
      -     * The name of the subscription. It must have the format
      -     * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      -     * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      -     * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      -     * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      -     * in length, and it must not start with `"goog"`.
      -     * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the subscription. It must have the format
      -     * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      -     * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      -     * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      -     * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      -     * in length, and it must not start with `"goog"`.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the subscription. It must have the format
      -     * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      -     * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      -     * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      -     * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      -     * in length, and it must not start with `"goog"`.
      -     * 
      - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the subscription. It must have the format
      -     * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      -     * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      -     * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      -     * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      -     * in length, and it must not start with `"goog"`.
      -     * 
      - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the subscription. It must have the format
      -     * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      -     * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      -     * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      -     * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      -     * in length, and it must not start with `"goog"`.
      -     * 
      - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private java.lang.Object topic_ = ""; - /** - * optional string topic = 2; - * - *
      -     * The name of the topic from which this subscription is receiving messages.
      -     * The value of this field will be `_deleted-topic_` if the topic has been
      -     * deleted.
      -     * 
      - */ - public java.lang.String getTopic() { - java.lang.Object ref = topic_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - topic_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string topic = 2; - * - *
      -     * The name of the topic from which this subscription is receiving messages.
      -     * The value of this field will be `_deleted-topic_` if the topic has been
      -     * deleted.
      -     * 
      - */ - public com.google.protobuf.ByteString - getTopicBytes() { - java.lang.Object ref = topic_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - topic_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string topic = 2; - * - *
      -     * The name of the topic from which this subscription is receiving messages.
      -     * The value of this field will be `_deleted-topic_` if the topic has been
      -     * deleted.
      -     * 
      - */ - public Builder setTopic( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - topic_ = value; - onChanged(); - return this; - } - /** - * optional string topic = 2; - * - *
      -     * The name of the topic from which this subscription is receiving messages.
      -     * The value of this field will be `_deleted-topic_` if the topic has been
      -     * deleted.
      -     * 
      - */ - public Builder clearTopic() { - - topic_ = getDefaultInstance().getTopic(); - onChanged(); - return this; - } - /** - * optional string topic = 2; - * - *
      -     * The name of the topic from which this subscription is receiving messages.
      -     * The value of this field will be `_deleted-topic_` if the topic has been
      -     * deleted.
      -     * 
      - */ - public Builder setTopicBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - topic_ = value; - onChanged(); - return this; - } - - private com.google.pubsub.v1.PushConfig pushConfig_ = null; - private com.google.protobuf.SingleFieldBuilder< - com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder> pushConfigBuilder_; - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -     * If push delivery is used with this subscription, this field is
      -     * used to configure it. An empty pushConfig signifies that the subscriber
      -     * will pull and ack messages using API methods.
      -     * 
      - */ - public boolean hasPushConfig() { - return pushConfigBuilder_ != null || pushConfig_ != null; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -     * If push delivery is used with this subscription, this field is
      -     * used to configure it. An empty pushConfig signifies that the subscriber
      -     * will pull and ack messages using API methods.
      -     * 
      - */ - public com.google.pubsub.v1.PushConfig getPushConfig() { - if (pushConfigBuilder_ == null) { - return pushConfig_ == null ? com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; - } else { - return pushConfigBuilder_.getMessage(); - } - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -     * If push delivery is used with this subscription, this field is
      -     * used to configure it. An empty pushConfig signifies that the subscriber
      -     * will pull and ack messages using API methods.
      -     * 
      - */ - public Builder setPushConfig(com.google.pubsub.v1.PushConfig value) { - if (pushConfigBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - pushConfig_ = value; - onChanged(); - } else { - pushConfigBuilder_.setMessage(value); - } - - return this; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -     * If push delivery is used with this subscription, this field is
      -     * used to configure it. An empty pushConfig signifies that the subscriber
      -     * will pull and ack messages using API methods.
      -     * 
      - */ - public Builder setPushConfig( - com.google.pubsub.v1.PushConfig.Builder builderForValue) { - if (pushConfigBuilder_ == null) { - pushConfig_ = builderForValue.build(); - onChanged(); - } else { - pushConfigBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -     * If push delivery is used with this subscription, this field is
      -     * used to configure it. An empty pushConfig signifies that the subscriber
      -     * will pull and ack messages using API methods.
      -     * 
      - */ - public Builder mergePushConfig(com.google.pubsub.v1.PushConfig value) { - if (pushConfigBuilder_ == null) { - if (pushConfig_ != null) { - pushConfig_ = - com.google.pubsub.v1.PushConfig.newBuilder(pushConfig_).mergeFrom(value).buildPartial(); - } else { - pushConfig_ = value; - } - onChanged(); - } else { - pushConfigBuilder_.mergeFrom(value); - } - - return this; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -     * If push delivery is used with this subscription, this field is
      -     * used to configure it. An empty pushConfig signifies that the subscriber
      -     * will pull and ack messages using API methods.
      -     * 
      - */ - public Builder clearPushConfig() { - if (pushConfigBuilder_ == null) { - pushConfig_ = null; - onChanged(); - } else { - pushConfig_ = null; - pushConfigBuilder_ = null; - } - - return this; - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -     * If push delivery is used with this subscription, this field is
      -     * used to configure it. An empty pushConfig signifies that the subscriber
      -     * will pull and ack messages using API methods.
      -     * 
      - */ - public com.google.pubsub.v1.PushConfig.Builder getPushConfigBuilder() { - - onChanged(); - return getPushConfigFieldBuilder().getBuilder(); - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -     * If push delivery is used with this subscription, this field is
      -     * used to configure it. An empty pushConfig signifies that the subscriber
      -     * will pull and ack messages using API methods.
      -     * 
      - */ - public com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder() { - if (pushConfigBuilder_ != null) { - return pushConfigBuilder_.getMessageOrBuilder(); - } else { - return pushConfig_ == null ? - com.google.pubsub.v1.PushConfig.getDefaultInstance() : pushConfig_; - } - } - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -     * If push delivery is used with this subscription, this field is
      -     * used to configure it. An empty pushConfig signifies that the subscriber
      -     * will pull and ack messages using API methods.
      -     * 
      - */ - private com.google.protobuf.SingleFieldBuilder< - com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder> - getPushConfigFieldBuilder() { - if (pushConfigBuilder_ == null) { - pushConfigBuilder_ = new com.google.protobuf.SingleFieldBuilder< - com.google.pubsub.v1.PushConfig, com.google.pubsub.v1.PushConfig.Builder, com.google.pubsub.v1.PushConfigOrBuilder>( - getPushConfig(), - getParentForChildren(), - isClean()); - pushConfig_ = null; - } - return pushConfigBuilder_; - } - - private int ackDeadlineSeconds_ ; - /** - * optional int32 ack_deadline_seconds = 5; - * - *
      -     * This value is the maximum time after a subscriber receives a message
      -     * before the subscriber should acknowledge the message. After message
      -     * delivery but before the ack deadline expires and before the message is
      -     * acknowledged, it is an outstanding message and will not be delivered
      -     * again during that time (on a best-effort basis).
      -     * For pull delivery this value is used as the initial value for the ack
      -     * deadline. To override this value for a given message, call
      -     * ModifyAckDeadline with the corresponding ack_id.
      -     * For push delivery, this value is also used to set the request timeout for
      -     * the call to the push endpoint.
      -     * If the subscriber never acknowledges the message, the Pub/Sub
      -     * system will eventually redeliver the message.
      -     * If this parameter is not set, the default value of 10 seconds is used.
      -     * 
      - */ - public int getAckDeadlineSeconds() { - return ackDeadlineSeconds_; - } - /** - * optional int32 ack_deadline_seconds = 5; - * - *
      -     * This value is the maximum time after a subscriber receives a message
      -     * before the subscriber should acknowledge the message. After message
      -     * delivery but before the ack deadline expires and before the message is
      -     * acknowledged, it is an outstanding message and will not be delivered
      -     * again during that time (on a best-effort basis).
      -     * For pull delivery this value is used as the initial value for the ack
      -     * deadline. To override this value for a given message, call
      -     * ModifyAckDeadline with the corresponding ack_id.
      -     * For push delivery, this value is also used to set the request timeout for
      -     * the call to the push endpoint.
      -     * If the subscriber never acknowledges the message, the Pub/Sub
      -     * system will eventually redeliver the message.
      -     * If this parameter is not set, the default value of 10 seconds is used.
      -     * 
      - */ - public Builder setAckDeadlineSeconds(int value) { - - ackDeadlineSeconds_ = value; - onChanged(); - return this; - } - /** - * optional int32 ack_deadline_seconds = 5; - * - *
      -     * This value is the maximum time after a subscriber receives a message
      -     * before the subscriber should acknowledge the message. After message
      -     * delivery but before the ack deadline expires and before the message is
      -     * acknowledged, it is an outstanding message and will not be delivered
      -     * again during that time (on a best-effort basis).
      -     * For pull delivery this value is used as the initial value for the ack
      -     * deadline. To override this value for a given message, call
      -     * ModifyAckDeadline with the corresponding ack_id.
      -     * For push delivery, this value is also used to set the request timeout for
      -     * the call to the push endpoint.
      -     * If the subscriber never acknowledges the message, the Pub/Sub
      -     * system will eventually redeliver the message.
      -     * If this parameter is not set, the default value of 10 seconds is used.
      -     * 
      - */ - public Builder clearAckDeadlineSeconds() { - - ackDeadlineSeconds_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.Subscription) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.Subscription) - private static final com.google.pubsub.v1.Subscription DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.Subscription(); - } - - public static com.google.pubsub.v1.Subscription getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Subscription parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Subscription(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.Subscription getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriptionOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriptionOrBuilder.java deleted file mode 100644 index b74cbb696209..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/SubscriptionOrBuilder.java +++ /dev/null @@ -1,111 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface SubscriptionOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.Subscription) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string name = 1; - * - *
      -   * The name of the subscription. It must have the format
      -   * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      -   * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      -   * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      -   * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      -   * in length, and it must not start with `"goog"`.
      -   * 
      - */ - java.lang.String getName(); - /** - * optional string name = 1; - * - *
      -   * The name of the subscription. It must have the format
      -   * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
      -   * start with a letter, and contain only letters (`[A-Za-z]`), numbers
      -   * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
      -   * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
      -   * in length, and it must not start with `"goog"`.
      -   * 
      - */ - com.google.protobuf.ByteString - getNameBytes(); - - /** - * optional string topic = 2; - * - *
      -   * The name of the topic from which this subscription is receiving messages.
      -   * The value of this field will be `_deleted-topic_` if the topic has been
      -   * deleted.
      -   * 
      - */ - java.lang.String getTopic(); - /** - * optional string topic = 2; - * - *
      -   * The name of the topic from which this subscription is receiving messages.
      -   * The value of this field will be `_deleted-topic_` if the topic has been
      -   * deleted.
      -   * 
      - */ - com.google.protobuf.ByteString - getTopicBytes(); - - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -   * If push delivery is used with this subscription, this field is
      -   * used to configure it. An empty pushConfig signifies that the subscriber
      -   * will pull and ack messages using API methods.
      -   * 
      - */ - boolean hasPushConfig(); - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -   * If push delivery is used with this subscription, this field is
      -   * used to configure it. An empty pushConfig signifies that the subscriber
      -   * will pull and ack messages using API methods.
      -   * 
      - */ - com.google.pubsub.v1.PushConfig getPushConfig(); - /** - * optional .google.pubsub.v1.PushConfig push_config = 4; - * - *
      -   * If push delivery is used with this subscription, this field is
      -   * used to configure it. An empty pushConfig signifies that the subscriber
      -   * will pull and ack messages using API methods.
      -   * 
      - */ - com.google.pubsub.v1.PushConfigOrBuilder getPushConfigOrBuilder(); - - /** - * optional int32 ack_deadline_seconds = 5; - * - *
      -   * This value is the maximum time after a subscriber receives a message
      -   * before the subscriber should acknowledge the message. After message
      -   * delivery but before the ack deadline expires and before the message is
      -   * acknowledged, it is an outstanding message and will not be delivered
      -   * again during that time (on a best-effort basis).
      -   * For pull delivery this value is used as the initial value for the ack
      -   * deadline. To override this value for a given message, call
      -   * ModifyAckDeadline with the corresponding ack_id.
      -   * For push delivery, this value is also used to set the request timeout for
      -   * the call to the push endpoint.
      -   * If the subscriber never acknowledges the message, the Pub/Sub
      -   * system will eventually redeliver the message.
      -   * If this parameter is not set, the default value of 10 seconds is used.
      -   * 
      - */ - int getAckDeadlineSeconds(); -} diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Topic.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Topic.java deleted file mode 100644 index d1317aed31ef..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/Topic.java +++ /dev/null @@ -1,511 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -/** - * Protobuf type {@code google.pubsub.v1.Topic} - * - *
      - * A topic resource.
      - * 
      - */ -public final class Topic extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:google.pubsub.v1.Topic) - TopicOrBuilder { - // Use Topic.newBuilder() to construct. - private Topic(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Topic() { - name_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Topic( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - String s = input.readStringRequireUtf8(); - - name_ = s; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw new RuntimeException(e.setUnfinishedMessage(this)); - } catch (java.io.IOException e) { - throw new RuntimeException( - new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this)); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Topic_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Topic_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.Topic.class, com.google.pubsub.v1.Topic.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * optional string name = 1; - * - *
      -   * The name of the topic. It must have the format
      -   * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      -   * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      -   * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      -   * signs (`%`). It must be between 3 and 255 characters in length, and it
      -   * must not start with `"goog"`.
      -   * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * optional string name = 1; - * - *
      -   * The name of the topic. It must have the format
      -   * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      -   * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      -   * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      -   * signs (`%`). It must be between 3 and 255 characters in length, and it
      -   * must not start with `"goog"`.
      -   * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.google.pubsub.v1.Topic parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.Topic parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.Topic parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.google.pubsub.v1.Topic parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.google.pubsub.v1.Topic parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.Topic parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.Topic parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static com.google.pubsub.v1.Topic parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static com.google.pubsub.v1.Topic parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static com.google.pubsub.v1.Topic parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.google.pubsub.v1.Topic prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code google.pubsub.v1.Topic} - * - *
      -   * A topic resource.
      -   * 
      - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:google.pubsub.v1.Topic) - com.google.pubsub.v1.TopicOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Topic_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Topic_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.pubsub.v1.Topic.class, com.google.pubsub.v1.Topic.Builder.class); - } - - // Construct using com.google.pubsub.v1.Topic.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - name_ = ""; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.google.pubsub.v1.PubsubProto.internal_static_google_pubsub_v1_Topic_descriptor; - } - - public com.google.pubsub.v1.Topic getDefaultInstanceForType() { - return com.google.pubsub.v1.Topic.getDefaultInstance(); - } - - public com.google.pubsub.v1.Topic build() { - com.google.pubsub.v1.Topic result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public com.google.pubsub.v1.Topic buildPartial() { - com.google.pubsub.v1.Topic result = new com.google.pubsub.v1.Topic(this); - result.name_ = name_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.pubsub.v1.Topic) { - return mergeFrom((com.google.pubsub.v1.Topic)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.pubsub.v1.Topic other) { - if (other == com.google.pubsub.v1.Topic.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.pubsub.v1.Topic parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.google.pubsub.v1.Topic) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object name_ = ""; - /** - * optional string name = 1; - * - *
      -     * The name of the topic. It must have the format
      -     * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      -     * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      -     * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      -     * signs (`%`). It must be between 3 and 255 characters in length, and it
      -     * must not start with `"goog"`.
      -     * 
      - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the topic. It must have the format
      -     * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      -     * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      -     * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      -     * signs (`%`). It must be between 3 and 255 characters in length, and it
      -     * must not start with `"goog"`.
      -     * 
      - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string name = 1; - * - *
      -     * The name of the topic. It must have the format
      -     * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      -     * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      -     * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      -     * signs (`%`). It must be between 3 and 255 characters in length, and it
      -     * must not start with `"goog"`.
      -     * 
      - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the topic. It must have the format
      -     * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      -     * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      -     * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      -     * signs (`%`). It must be between 3 and 255 characters in length, and it
      -     * must not start with `"goog"`.
      -     * 
      - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * optional string name = 1; - * - *
      -     * The name of the topic. It must have the format
      -     * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      -     * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      -     * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      -     * signs (`%`). It must be between 3 and 255 characters in length, and it
      -     * must not start with `"goog"`.
      -     * 
      - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:google.pubsub.v1.Topic) - } - - // @@protoc_insertion_point(class_scope:google.pubsub.v1.Topic) - private static final com.google.pubsub.v1.Topic DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.google.pubsub.v1.Topic(); - } - - public static com.google.pubsub.v1.Topic getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Topic parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - try { - return new Topic(input, extensionRegistry); - } catch (RuntimeException e) { - if (e.getCause() instanceof - com.google.protobuf.InvalidProtocolBufferException) { - throw (com.google.protobuf.InvalidProtocolBufferException) - e.getCause(); - } - throw e; - } - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.google.pubsub.v1.Topic getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - -} - diff --git a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/TopicOrBuilder.java b/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/TopicOrBuilder.java deleted file mode 100644 index 9a80b8a4512b..000000000000 --- a/gcloud-java-pubsub/generated/src/main/java/com/google/pubsub/v1/TopicOrBuilder.java +++ /dev/null @@ -1,37 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/pubsub/v1/pubsub.proto - -package com.google.pubsub.v1; - -public interface TopicOrBuilder extends - // @@protoc_insertion_point(interface_extends:google.pubsub.v1.Topic) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string name = 1; - * - *
      -   * The name of the topic. It must have the format
      -   * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      -   * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      -   * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      -   * signs (`%`). It must be between 3 and 255 characters in length, and it
      -   * must not start with `"goog"`.
      -   * 
      - */ - java.lang.String getName(); - /** - * optional string name = 1; - * - *
      -   * The name of the topic. It must have the format
      -   * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
      -   * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
      -   * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
      -   * signs (`%`). It must be between 3 and 255 characters in length, and it
      -   * must not start with `"goog"`.
      -   * 
      - */ - com.google.protobuf.ByteString - getNameBytes(); -} From 8b4ba845c1bad53e1edbc37088f0be1f62913346 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Thu, 18 Feb 2016 14:05:54 -0800 Subject: [PATCH 188/203] Switching dependencies, regenerating code * Add dependency on gax-java * Add dependency on grpc-pubsub-v1 * Regenerating the *Api classes * Using the emulator runner from GAX * Updating the test accordingly --- gcloud-java-pubsub/pom.xml | 11 +- .../gcloud/pubsub/spi/PublisherApi.java | 511 ++++++++++----- .../gcloud/pubsub/spi/SubscriberApi.java | 614 +++++++++++++----- .../pubsub/testing/LocalPubsubHelper.java | 116 ++-- .../gcloud/pubsub/spi/PublisherApiTest.java | 73 ++- 5 files changed, 931 insertions(+), 394 deletions(-) diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index 289580c9eeb2..cec635adca31 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -17,9 +17,14 @@ - ${project.groupId} - gcloud-java-gax - ${project.version} + com.google.api + gax + 0.0.1 + + + com.google.api.grpc + grpc-pubsub-v1 + 0.0.0 io.grpc diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index 54572afa2e6d..632d84cfe5de 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -26,11 +26,25 @@ * Allowed modifications - currently these are the only types allowed: * 1. New methods (these should be added to the end of the class) * 2. New imports + * 3. Additional documentation between "manual edit" demarcations * * Happy editing! */ package com.google.gcloud.pubsub.spi; +import com.google.api.gax.core.BackoffParams; +import com.google.api.gax.core.ConnectionSettings; +import com.google.api.gax.core.RetryParams; +import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.PageDescriptor; +import com.google.api.gax.grpc.ServiceApiSettings; +import com.google.api.gax.protobuf.PathTemplate; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import com.google.protobuf.Empty; import com.google.pubsub.v1.DeleteTopicRequest; import com.google.pubsub.v1.GetTopicRequest; @@ -43,129 +57,228 @@ import com.google.pubsub.v1.PublisherGrpc; import com.google.pubsub.v1.PubsubMessage; import com.google.pubsub.v1.Topic; - -import io.gapi.gax.grpc.ApiCallable; -import io.gapi.gax.grpc.PageDescriptor; -import io.gapi.gax.grpc.ServiceApiSettings; -import io.gapi.gax.internal.ApiUtils; -import io.gapi.gax.protobuf.PathTemplate; import io.grpc.ManagedChannel; - +import io.grpc.Status; import java.io.IOException; +import java.util.EnumMap; +import java.util.HashMap; import java.util.List; +import java.util.Map; // Manually-added imports: add custom (non-generated) imports after this point. - - // AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. /** * The service that an application uses to manipulate topics, and to send * messages to a topic. + * + * + * */ @javax.annotation.Generated("by the veneer generator") public class PublisherApi implements AutoCloseable { + public enum MethodIdentifier { + CREATE_TOPIC, + PUBLISH, + GET_TOPIC, + LIST_TOPICS, + LIST_TOPIC_SUBSCRIPTIONS, + DELETE_TOPIC + } + // ========= // Constants // ========= /** * The default address of the service. + * + * + * */ - public static final String SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; + public static final String DEFAULT_SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; /** * The default port of the service. + * + * + * */ public static final int DEFAULT_SERVICE_PORT = 443; + /** + * The default scopes of the service. + */ + public static ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder() + .add("https://www.googleapis.com/auth/pubsub") + .add("https://www.googleapis.com/auth/cloud-platform") + .build(); + + /** + * The default settings for the service. + */ + public static ServiceApiSettings DEFAULT_SETTINGS = + ServiceApiSettings.builder() + .provideChannelWith( + ConnectionSettings.builder() + .setServiceAddress(DEFAULT_SERVICE_ADDRESS) + .setPort(DEFAULT_SERVICE_PORT) + .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) + .build()) + .build(); + + private static final ImmutableMap> + DEFAULT_RETRY_CONFIG; + + static { + Map> definition = new HashMap<>(); + definition.put( + "idempotent", + Sets.immutableEnumSet( + Lists.newArrayList( + Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE))); + definition.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList())); + + Map> retryableCodes = + new EnumMap<>(MethodIdentifier.class); + retryableCodes.put(MethodIdentifier.CREATE_TOPIC, definition.get("idempotent")); + retryableCodes.put(MethodIdentifier.PUBLISH, definition.get("non_idempotent")); + retryableCodes.put(MethodIdentifier.GET_TOPIC, definition.get("idempotent")); + retryableCodes.put(MethodIdentifier.LIST_TOPICS, definition.get("idempotent")); + retryableCodes.put(MethodIdentifier.LIST_TOPIC_SUBSCRIPTIONS, definition.get("idempotent")); + retryableCodes.put(MethodIdentifier.DELETE_TOPIC, definition.get("idempotent")); + DEFAULT_RETRY_CONFIG = + Maps.>immutableEnumMap(retryableCodes); + } + + private static final ImmutableMap DEFAULT_RETRY_PARAMS; + + static { + Map definition = new HashMap<>(); + RetryParams params = null; + params = + RetryParams.newBuilder() + .setRetryBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(100L) + .setDelayMultiplier(1.2) + .setMaxDelayMillis(1000L) + .build()) + .setTimeoutBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(300L) + .setDelayMultiplier(1.3) + .setMaxDelayMillis(3000L) + .build()) + .setTotalTimeout(30000L) + .build(); + definition.put("default", params); + + Map retryParams = new EnumMap<>(MethodIdentifier.class); + retryParams.put(MethodIdentifier.CREATE_TOPIC, definition.get("default")); + retryParams.put(MethodIdentifier.PUBLISH, definition.get("default")); + retryParams.put(MethodIdentifier.GET_TOPIC, definition.get("default")); + retryParams.put(MethodIdentifier.LIST_TOPICS, definition.get("default")); + retryParams.put(MethodIdentifier.LIST_TOPIC_SUBSCRIPTIONS, definition.get("default")); + retryParams.put(MethodIdentifier.DELETE_TOPIC, definition.get("default")); + DEFAULT_RETRY_PARAMS = Maps.immutableEnumMap(retryParams); + } - private static final ApiCallable - CREATE_TOPIC = ApiCallable.create(PublisherGrpc.METHOD_CREATE_TOPIC); - private static final ApiCallable - PUBLISH = ApiCallable.create(PublisherGrpc.METHOD_PUBLISH); - private static final ApiCallable - GET_TOPIC = ApiCallable.create(PublisherGrpc.METHOD_GET_TOPIC); - private static final ApiCallable - LIST_TOPICS = ApiCallable.create(PublisherGrpc.METHOD_LIST_TOPICS); + private static final ApiCallable CREATE_TOPIC = + ApiCallable.create(PublisherGrpc.METHOD_CREATE_TOPIC); + private static final ApiCallable PUBLISH = + ApiCallable.create(PublisherGrpc.METHOD_PUBLISH); + private static final ApiCallable GET_TOPIC = + ApiCallable.create(PublisherGrpc.METHOD_GET_TOPIC); + private static final ApiCallable LIST_TOPICS = + ApiCallable.create(PublisherGrpc.METHOD_LIST_TOPICS); private static final ApiCallable LIST_TOPIC_SUBSCRIPTIONS = ApiCallable.create(PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS); - private static final ApiCallable - DELETE_TOPIC = ApiCallable.create(PublisherGrpc.METHOD_DELETE_TOPIC); - - private static PageDescriptor LIST_TOPICS_PAGE_DESC = - new PageDescriptor() { - @Override - public Object emptyToken() { - return ""; - } - @Override - public ListTopicsRequest injectToken( - ListTopicsRequest payload, Object token) { - return ListTopicsRequest - .newBuilder(payload) - .setPageToken((String) token) - .build(); - } - @Override - public Object extractNextToken(ListTopicsResponse payload) { - return payload.getNextPageToken(); - } - @Override - public Iterable extractResources(ListTopicsResponse payload) { - return payload.getTopicsList(); - } - }; - - private static PageDescriptor LIST_TOPIC_SUBSCRIPTIONS_PAGE_DESC = - new PageDescriptor() { - @Override - public Object emptyToken() { - return ""; - } - @Override - public ListTopicSubscriptionsRequest injectToken( - ListTopicSubscriptionsRequest payload, Object token) { - return ListTopicSubscriptionsRequest - .newBuilder(payload) - .setPageToken((String) token) - .build(); - } - @Override - public Object extractNextToken(ListTopicSubscriptionsResponse payload) { - return payload.getNextPageToken(); - } - @Override - public Iterable extractResources(ListTopicSubscriptionsResponse payload) { - return payload.getSubscriptionsList(); - } - }; - - private static String ALL_SCOPES[] = { - "https://www.googleapis.com/auth/pubsub" - }; + private static final ApiCallable DELETE_TOPIC = + ApiCallable.create(PublisherGrpc.METHOD_DELETE_TOPIC); + + private static PageDescriptor + LIST_TOPICS_PAGE_DESC = + new PageDescriptor() { + @Override + public Object emptyToken() { + return ""; + } + + @Override + public ListTopicsRequest injectToken(ListTopicsRequest payload, Object token) { + return ListTopicsRequest.newBuilder(payload).setPageToken((String) token).build(); + } + + @Override + public Object extractNextToken(ListTopicsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListTopicsResponse payload) { + return payload.getTopicsList(); + } + }; + + private static PageDescriptor< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + LIST_TOPIC_SUBSCRIPTIONS_PAGE_DESC = + new PageDescriptor< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>() { + @Override + public Object emptyToken() { + return ""; + } + + @Override + public ListTopicSubscriptionsRequest injectToken( + ListTopicSubscriptionsRequest payload, Object token) { + return ListTopicSubscriptionsRequest.newBuilder(payload) + .setPageToken((String) token) + .build(); + } + + @Override + public Object extractNextToken(ListTopicSubscriptionsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListTopicSubscriptionsResponse payload) { + return payload.getSubscriptionsList(); + } + }; /** * A PathTemplate representing the fully-qualified path to represent * a project resource. + * + * + * */ private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.create("/projects/{project}"); - + PathTemplate.create("projects/{project}"); /** * A PathTemplate representing the fully-qualified path to represent * a topic resource. + * + * + * */ private static final PathTemplate TOPIC_PATH_TEMPLATE = - PathTemplate.create("/projects/{project}/topics/{topic}"); + PathTemplate.create("projects/{project}/topics/{topic}"); // ======== // Members // ======== private final ManagedChannel channel; - private final ServiceApiSettings settings; + private final ServiceApiSettings settings; + private final ImmutableMap> retryCodesConfig; + private final ImmutableMap retryParamsConfig; // =============== // Factory Methods @@ -173,28 +286,47 @@ public Iterable extractResources(ListTopicSubscriptionsResponse payload) /** * Constructs an instance of PublisherApi with default settings. + * + * + * */ public static PublisherApi create() throws IOException { - return create(new ServiceApiSettings()); + return create(DEFAULT_SETTINGS); } /** * Constructs an instance of PublisherApi, using the given settings. The channels are created based * on the settings passed in, or defaults for any settings that are not set. + * + * + * */ - public static PublisherApi create(ServiceApiSettings settings) throws IOException { + public static PublisherApi create(ServiceApiSettings settings) + throws IOException { return new PublisherApi(settings); } /** * Constructs an instance of PublisherApi, using the given settings. This is protected so that it * easy to make a subclass, but otherwise, the static factory methods should be preferred. - */ - protected PublisherApi(ServiceApiSettings settings) throws IOException { - ServiceApiSettings internalSettings = ApiUtils.populateSettings(settings, - SERVICE_ADDRESS, DEFAULT_SERVICE_PORT, ALL_SCOPES); - this.settings = internalSettings; - this.channel = internalSettings.getChannel(); + * + * + * + */ + protected PublisherApi(ServiceApiSettings settings) throws IOException { + this.settings = settings; + this.channel = settings.getChannel(); + + Map> retryCodesConfig = + new EnumMap<>(DEFAULT_RETRY_CONFIG); + retryCodesConfig.putAll(settings.getRetryableCodes()); + this.retryCodesConfig = + Maps.>immutableEnumMap(retryCodesConfig); + + Map retryParamsConfig = new EnumMap<>(DEFAULT_RETRY_PARAMS); + retryParamsConfig.putAll(settings.getRetryParams()); + this.retryParamsConfig = + Maps.immutableEnumMap(retryParamsConfig); } // ============================== @@ -204,24 +336,31 @@ protected PublisherApi(ServiceApiSettings settings) throws IOException { /** * Creates a string containing the fully-qualified path to represent * a project resource. + * + * + * */ public static final String createProjectPath(String project) { - return PROJECT_PATH_TEMPLATE.instantiate( - "project", project); + return PROJECT_PATH_TEMPLATE.instantiate("project", project); } /** * Creates a string containing the fully-qualified path to represent * a topic resource. + * + * + * */ public static final String createTopicPath(String project, String topic) { - return TOPIC_PATH_TEMPLATE.instantiate( - "project", project,"topic", topic); + return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic); } /** * Extracts the project from the given fully-qualified path which * represents a project resource. + * + * + * */ public static final String extractProjectFromProjectPath(String projectPath) { return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); @@ -230,6 +369,9 @@ public static final String extractProjectFromProjectPath(String projectPath) { /** * Extracts the project from the given fully-qualified path which * represents a topic resource. + * + * + * */ public static final String extractProjectFromTopicPath(String topicPath) { return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project"); @@ -238,12 +380,14 @@ public static final String extractProjectFromTopicPath(String topicPath) { /** * Extracts the topic from the given fully-qualified path which * represents a topic resource. + * + * + * */ public static final String extractTopicFromTopicPath(String topicPath) { return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic"); } - // ============= // Service Calls // ============= @@ -254,6 +398,9 @@ public static final String extractTopicFromTopicPath(String topicPath) { /** * Creates the given topic with the given name. * + * + * + * * @param name The name of the topic. It must have the format * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), @@ -262,10 +409,7 @@ public static final String extractTopicFromTopicPath(String topicPath) { * must not start with `"goog"`. */ public Topic createTopic(String name) { - Topic request = - Topic.newBuilder() - .setName(name) - .build(); + Topic request = Topic.newBuilder().setName(name).build(); return createTopic(request); } @@ -274,6 +418,9 @@ public Topic createTopic(String name) { /** * Creates the given topic with the given name. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public Topic createTopic(Topic request) { @@ -283,37 +430,48 @@ public Topic createTopic(Topic request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Creates the given topic with the given name. + * + * + * */ public ApiCallable createTopicCallable() { - return ApiUtils.prepareIdempotentCallable(CREATE_TOPIC, settings).bind(channel); + ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.CREATE_TOPIC); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.CREATE_TOPIC); + return CREATE_TOPIC + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- publish ----- // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Adds one or more messages to the topic. Returns NOT_FOUND if the topic does - * not exist. The message payload must not be empty; it must contain either a - * non-empty data field, or at least one attribute. + * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic + * does not exist. The message payload must not be empty; it must contain + * either a non-empty data field, or at least one attribute. + * + * + * * * @param topic The messages in the request will be published on this topic. * @param messages The messages to publish. */ public PublishResponse publish(String topic, List messages) { PublishRequest request = - PublishRequest.newBuilder() - .setTopic(topic) - .addAllMessages(messages) - .build(); + PublishRequest.newBuilder().setTopic(topic).addAllMessages(messages).build(); return publish(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Adds one or more messages to the topic. Returns NOT_FOUND if the topic does - * not exist. The message payload must not be empty; it must contain either a - * non-empty data field, or at least one attribute. + * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic + * does not exist. The message payload must not be empty; it must contain + * either a non-empty data field, or at least one attribute. + * + * + * * * @param request The request object containing all of the parameters for the API call. */ @@ -323,12 +481,20 @@ public PublishResponse publish(PublishRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Adds one or more messages to the topic. Returns NOT_FOUND if the topic does - * not exist. The message payload must not be empty; it must contain either a - * non-empty data field, or at least one attribute. + * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic + * does not exist. The message payload must not be empty; it must contain + * either a non-empty data field, or at least one attribute. + * + * + * */ public ApiCallable publishCallable() { - return PUBLISH.bind(channel); + ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.PUBLISH); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.PUBLISH); + return PUBLISH + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- getTopic ----- @@ -337,13 +503,13 @@ public ApiCallable publishCallable() { /** * Gets the configuration of a topic. * + * + * + * * @param topic The name of the topic to get. */ public Topic getTopic(String topic) { - GetTopicRequest request = - GetTopicRequest.newBuilder() - .setTopic(topic) - .build(); + GetTopicRequest request = GetTopicRequest.newBuilder().setTopic(topic).build(); return getTopic(request); } @@ -352,6 +518,9 @@ public Topic getTopic(String topic) { /** * Gets the configuration of a topic. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public Topic getTopic(GetTopicRequest request) { @@ -361,9 +530,17 @@ public Topic getTopic(GetTopicRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Gets the configuration of a topic. + * + * + * */ public ApiCallable getTopicCallable() { - return ApiUtils.prepareIdempotentCallable(GET_TOPIC, settings).bind(channel); + ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.GET_TOPIC); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.GET_TOPIC); + return GET_TOPIC + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- listTopics ----- @@ -371,12 +548,12 @@ public ApiCallable getTopicCallable() { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Lists matching topics. + * + * + * */ public Iterable listTopics(String project) { - ListTopicsRequest request = - ListTopicsRequest.newBuilder() - .setProject(project) - .build(); + ListTopicsRequest request = ListTopicsRequest.newBuilder().setProject(project).build(); return listTopics(request); } @@ -384,27 +561,40 @@ public Iterable listTopics(String project) { /** * Lists matching topics. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public Iterable listTopics(ListTopicsRequest request) { - return listTopicsStreamingCallable() - .iterableResponseStreamCall(request); + return listTopicsStreamingCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Lists matching topics. + * + * + * */ - public ApiCallable listTopicsStreamingCallable() { + public ApiCallable> listTopicsStreamingCallable() { return listTopicsCallable().pageStreaming(LIST_TOPICS_PAGE_DESC); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Lists matching topics. + * + * + * */ public ApiCallable listTopicsCallable() { - return ApiUtils.prepareIdempotentCallable(LIST_TOPICS, settings).bind(channel); + ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.LIST_TOPICS); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.LIST_TOPICS); + return LIST_TOPICS + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- listTopicSubscriptions ----- @@ -412,12 +602,13 @@ public ApiCallable listTopicsCallable() { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Lists the name of the subscriptions for this topic. + * + * + * */ public Iterable listTopicSubscriptions(String topic) { ListTopicSubscriptionsRequest request = - ListTopicSubscriptionsRequest.newBuilder() - .setTopic(topic) - .build(); + ListTopicSubscriptionsRequest.newBuilder().setTopic(topic).build(); return listTopicSubscriptions(request); } @@ -425,58 +616,77 @@ public Iterable listTopicSubscriptions(String topic) { /** * Lists the name of the subscriptions for this topic. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public Iterable listTopicSubscriptions(ListTopicSubscriptionsRequest request) { - return listTopicSubscriptionsStreamingCallable() - .iterableResponseStreamCall(request); + return listTopicSubscriptionsStreamingCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Lists the name of the subscriptions for this topic. + * + * + * */ - public ApiCallable listTopicSubscriptionsStreamingCallable() { + public ApiCallable> + listTopicSubscriptionsStreamingCallable() { return listTopicSubscriptionsCallable().pageStreaming(LIST_TOPIC_SUBSCRIPTIONS_PAGE_DESC); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Lists the name of the subscriptions for this topic. - */ - public ApiCallable listTopicSubscriptionsCallable() { - return ApiUtils.prepareIdempotentCallable(LIST_TOPIC_SUBSCRIPTIONS, settings).bind(channel); + * + * + * + */ + public ApiCallable + listTopicSubscriptionsCallable() { + ImmutableSet retryableCodes = + retryCodesConfig.get(MethodIdentifier.LIST_TOPIC_SUBSCRIPTIONS); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.LIST_TOPIC_SUBSCRIPTIONS); + return LIST_TOPIC_SUBSCRIPTIONS + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- deleteTopic ----- // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Deletes the topic with the given name. Returns NOT_FOUND if the topic does - * not exist. After a topic is deleted, a new topic may be created with the - * same name; this is an entirely new topic with none of the old + * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic + * does not exist. After a topic is deleted, a new topic may be created with + * the same name; this is an entirely new topic with none of the old * configuration or subscriptions. Existing subscriptions to this topic are * not deleted, but their `topic` field is set to `_deleted-topic_`. * + * + * + * * @param topic Name of the topic to delete. */ public void deleteTopic(String topic) { - DeleteTopicRequest request = - DeleteTopicRequest.newBuilder() - .setTopic(topic) - .build(); + DeleteTopicRequest request = DeleteTopicRequest.newBuilder().setTopic(topic).build(); deleteTopic(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Deletes the topic with the given name. Returns NOT_FOUND if the topic does - * not exist. After a topic is deleted, a new topic may be created with the - * same name; this is an entirely new topic with none of the old + * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic + * does not exist. After a topic is deleted, a new topic may be created with + * the same name; this is an entirely new topic with none of the old * configuration or subscriptions. Existing subscriptions to this topic are * not deleted, but their `topic` field is set to `_deleted-topic_`. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public void deleteTopic(DeleteTopicRequest request) { @@ -485,17 +695,24 @@ public void deleteTopic(DeleteTopicRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Deletes the topic with the given name. Returns NOT_FOUND if the topic does - * not exist. After a topic is deleted, a new topic may be created with the - * same name; this is an entirely new topic with none of the old + * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic + * does not exist. After a topic is deleted, a new topic may be created with + * the same name; this is an entirely new topic with none of the old * configuration or subscriptions. Existing subscriptions to this topic are * not deleted, but their `topic` field is set to `_deleted-topic_`. + * + * + * */ public ApiCallable deleteTopicCallable() { - return ApiUtils.prepareIdempotentCallable(DELETE_TOPIC, settings).bind(channel); + ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.DELETE_TOPIC); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.DELETE_TOPIC); + return DELETE_TOPIC + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } - // ======== // Cleanup // ======== @@ -503,6 +720,9 @@ public ApiCallable deleteTopicCallable() { /** * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately * cancelled. + * + * + * */ @Override public void close() { @@ -514,7 +734,6 @@ public void close() { // Manually-added shutdown code } - // ======== // Manually-added methods: add custom (non-generated) methods after this point. // ======== diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index ff320597ddf7..91387c8a9771 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -26,11 +26,25 @@ * Allowed modifications - currently these are the only types allowed: * 1. New methods (these should be added to the end of the class) * 2. New imports + * 3. Additional documentation between "manual edit" demarcations * * Happy editing! */ package com.google.gcloud.pubsub.spi; +import com.google.api.gax.core.BackoffParams; +import com.google.api.gax.core.ConnectionSettings; +import com.google.api.gax.core.RetryParams; +import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.PageDescriptor; +import com.google.api.gax.grpc.ServiceApiSettings; +import com.google.api.gax.protobuf.PathTemplate; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import com.google.protobuf.Empty; import com.google.pubsub.v1.AcknowledgeRequest; import com.google.pubsub.v1.DeleteSubscriptionRequest; @@ -44,109 +58,212 @@ import com.google.pubsub.v1.PushConfig; import com.google.pubsub.v1.SubscriberGrpc; import com.google.pubsub.v1.Subscription; - -import io.gapi.gax.grpc.ApiCallable; -import io.gapi.gax.grpc.PageDescriptor; -import io.gapi.gax.grpc.ServiceApiSettings; -import io.gapi.gax.internal.ApiUtils; -import io.gapi.gax.protobuf.PathTemplate; import io.grpc.ManagedChannel; - +import io.grpc.Status; import java.io.IOException; +import java.util.EnumMap; +import java.util.HashMap; import java.util.List; +import java.util.Map; // Manually-added imports: add custom (non-generated) imports after this point. - - // AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. /** * The service that an application uses to manipulate subscriptions and to - * consume messages from a subscription via the Pull method. + * consume messages from a subscription via the `Pull` method. + * + * + * */ @javax.annotation.Generated("by the veneer generator") public class SubscriberApi implements AutoCloseable { + public enum MethodIdentifier { + CREATE_SUBSCRIPTION, + GET_SUBSCRIPTION, + LIST_SUBSCRIPTIONS, + DELETE_SUBSCRIPTION, + MODIFY_ACK_DEADLINE, + ACKNOWLEDGE, + PULL, + MODIFY_PUSH_CONFIG + } + // ========= // Constants // ========= /** * The default address of the service. + * + * + * */ - public static final String SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; + public static final String DEFAULT_SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; /** * The default port of the service. + * + * + * */ public static final int DEFAULT_SERVICE_PORT = 443; - - private static final ApiCallable - CREATE_SUBSCRIPTION = ApiCallable.create(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); - private static final ApiCallable - GET_SUBSCRIPTION = ApiCallable.create(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); + /** + * The default scopes of the service. + */ + public static ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder() + .add("https://www.googleapis.com/auth/pubsub") + .add("https://www.googleapis.com/auth/cloud-platform") + .build(); + + /** + * The default settings for the service. + */ + public static ServiceApiSettings DEFAULT_SETTINGS = + ServiceApiSettings.builder() + .provideChannelWith( + ConnectionSettings.builder() + .setServiceAddress(DEFAULT_SERVICE_ADDRESS) + .setPort(DEFAULT_SERVICE_PORT) + .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) + .build()) + .build(); + + private static final ImmutableMap> + DEFAULT_RETRY_CONFIG; + + static { + Map> definition = new HashMap<>(); + definition.put( + "idempotent", + Sets.immutableEnumSet( + Lists.newArrayList( + Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE))); + definition.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList())); + + Map> retryableCodes = + new EnumMap<>(MethodIdentifier.class); + retryableCodes.put(MethodIdentifier.CREATE_SUBSCRIPTION, definition.get("non_idempotent")); + retryableCodes.put(MethodIdentifier.GET_SUBSCRIPTION, definition.get("idempotent")); + retryableCodes.put(MethodIdentifier.LIST_SUBSCRIPTIONS, definition.get("idempotent")); + retryableCodes.put(MethodIdentifier.DELETE_SUBSCRIPTION, definition.get("idempotent")); + retryableCodes.put(MethodIdentifier.MODIFY_ACK_DEADLINE, definition.get("non_idempotent")); + retryableCodes.put(MethodIdentifier.ACKNOWLEDGE, definition.get("non_idempotent")); + retryableCodes.put(MethodIdentifier.PULL, definition.get("non_idempotent")); + retryableCodes.put(MethodIdentifier.MODIFY_PUSH_CONFIG, definition.get("non_idempotent")); + DEFAULT_RETRY_CONFIG = + Maps.>immutableEnumMap(retryableCodes); + } + + private static final ImmutableMap DEFAULT_RETRY_PARAMS; + + static { + Map definition = new HashMap<>(); + RetryParams params = null; + params = + RetryParams.newBuilder() + .setRetryBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(100L) + .setDelayMultiplier(1.2) + .setMaxDelayMillis(1000L) + .build()) + .setTimeoutBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(300L) + .setDelayMultiplier(1.3) + .setMaxDelayMillis(3000L) + .build()) + .setTotalTimeout(30000L) + .build(); + definition.put("default", params); + + Map retryParams = new EnumMap<>(MethodIdentifier.class); + retryParams.put(MethodIdentifier.CREATE_SUBSCRIPTION, definition.get("default")); + retryParams.put(MethodIdentifier.GET_SUBSCRIPTION, definition.get("default")); + retryParams.put(MethodIdentifier.LIST_SUBSCRIPTIONS, definition.get("default")); + retryParams.put(MethodIdentifier.DELETE_SUBSCRIPTION, definition.get("default")); + retryParams.put(MethodIdentifier.MODIFY_ACK_DEADLINE, definition.get("default")); + retryParams.put(MethodIdentifier.ACKNOWLEDGE, definition.get("default")); + retryParams.put(MethodIdentifier.PULL, definition.get("default")); + retryParams.put(MethodIdentifier.MODIFY_PUSH_CONFIG, definition.get("default")); + DEFAULT_RETRY_PARAMS = Maps.immutableEnumMap(retryParams); + } + + private static final ApiCallable CREATE_SUBSCRIPTION = + ApiCallable.create(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); + private static final ApiCallable GET_SUBSCRIPTION = + ApiCallable.create(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); private static final ApiCallable LIST_SUBSCRIPTIONS = ApiCallable.create(SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS); - private static final ApiCallable - DELETE_SUBSCRIPTION = ApiCallable.create(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); - private static final ApiCallable - MODIFY_ACK_DEADLINE = ApiCallable.create(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); - private static final ApiCallable - ACKNOWLEDGE = ApiCallable.create(SubscriberGrpc.METHOD_ACKNOWLEDGE); - private static final ApiCallable - PULL = ApiCallable.create(SubscriberGrpc.METHOD_PULL); - private static final ApiCallable - MODIFY_PUSH_CONFIG = ApiCallable.create(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); - - private static PageDescriptor LIST_SUBSCRIPTIONS_PAGE_DESC = - new PageDescriptor() { - @Override - public Object emptyToken() { - return ""; - } - @Override - public ListSubscriptionsRequest injectToken( - ListSubscriptionsRequest payload, Object token) { - return ListSubscriptionsRequest - .newBuilder(payload) - .setPageToken((String) token) - .build(); - } - @Override - public Object extractNextToken(ListSubscriptionsResponse payload) { - return payload.getNextPageToken(); - } - @Override - public Iterable extractResources(ListSubscriptionsResponse payload) { - return payload.getSubscriptionsList(); - } - }; - - private static String ALL_SCOPES[] = { - "https://www.googleapis.com/auth/pubsub" - }; + private static final ApiCallable DELETE_SUBSCRIPTION = + ApiCallable.create(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); + private static final ApiCallable MODIFY_ACK_DEADLINE = + ApiCallable.create(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); + private static final ApiCallable ACKNOWLEDGE = + ApiCallable.create(SubscriberGrpc.METHOD_ACKNOWLEDGE); + private static final ApiCallable PULL = + ApiCallable.create(SubscriberGrpc.METHOD_PULL); + private static final ApiCallable MODIFY_PUSH_CONFIG = + ApiCallable.create(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); + + private static PageDescriptor + LIST_SUBSCRIPTIONS_PAGE_DESC = + new PageDescriptor() { + @Override + public Object emptyToken() { + return ""; + } + + @Override + public ListSubscriptionsRequest injectToken( + ListSubscriptionsRequest payload, Object token) { + return ListSubscriptionsRequest.newBuilder(payload) + .setPageToken((String) token) + .build(); + } + + @Override + public Object extractNextToken(ListSubscriptionsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListSubscriptionsResponse payload) { + return payload.getSubscriptionsList(); + } + }; /** * A PathTemplate representing the fully-qualified path to represent * a project resource. + * + * + * */ private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.create("/projects/{project}"); - + PathTemplate.create("projects/{project}"); /** * A PathTemplate representing the fully-qualified path to represent * a subscription resource. + * + * + * */ private static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = - PathTemplate.create("/projects/{project}/subscriptions/{subscription}"); + PathTemplate.create("projects/{project}/subscriptions/{subscription}"); // ======== // Members // ======== private final ManagedChannel channel; - private final ServiceApiSettings settings; + private final ServiceApiSettings settings; + private final ImmutableMap> retryCodesConfig; + private final ImmutableMap retryParamsConfig; // =============== // Factory Methods @@ -154,28 +271,47 @@ public Iterable extractResources(ListSubscriptionsResponse payload /** * Constructs an instance of SubscriberApi with default settings. + * + * + * */ public static SubscriberApi create() throws IOException { - return create(new ServiceApiSettings()); + return create(DEFAULT_SETTINGS); } /** * Constructs an instance of SubscriberApi, using the given settings. The channels are created based * on the settings passed in, or defaults for any settings that are not set. + * + * + * */ - public static SubscriberApi create(ServiceApiSettings settings) throws IOException { + public static SubscriberApi create(ServiceApiSettings settings) + throws IOException { return new SubscriberApi(settings); } /** * Constructs an instance of SubscriberApi, using the given settings. This is protected so that it * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * + * + * */ - protected SubscriberApi(ServiceApiSettings settings) throws IOException { - ServiceApiSettings internalSettings = ApiUtils.populateSettings(settings, - SERVICE_ADDRESS, DEFAULT_SERVICE_PORT, ALL_SCOPES); - this.settings = internalSettings; - this.channel = internalSettings.getChannel(); + protected SubscriberApi(ServiceApiSettings settings) throws IOException { + this.settings = settings; + this.channel = settings.getChannel(); + + Map> retryCodesConfig = + new EnumMap<>(DEFAULT_RETRY_CONFIG); + retryCodesConfig.putAll(settings.getRetryableCodes()); + this.retryCodesConfig = + Maps.>immutableEnumMap(retryCodesConfig); + + Map retryParamsConfig = new EnumMap<>(DEFAULT_RETRY_PARAMS); + retryParamsConfig.putAll(settings.getRetryParams()); + this.retryParamsConfig = + Maps.immutableEnumMap(retryParamsConfig); } // ============================== @@ -185,24 +321,31 @@ protected SubscriberApi(ServiceApiSettings settings) throws IOException { /** * Creates a string containing the fully-qualified path to represent * a project resource. + * + * + * */ public static final String createProjectPath(String project) { - return PROJECT_PATH_TEMPLATE.instantiate( - "project", project); + return PROJECT_PATH_TEMPLATE.instantiate("project", project); } /** * Creates a string containing the fully-qualified path to represent * a subscription resource. + * + * + * */ public static final String createSubscriptionPath(String project, String subscription) { - return SUBSCRIPTION_PATH_TEMPLATE.instantiate( - "project", project,"subscription", subscription); + return SUBSCRIPTION_PATH_TEMPLATE.instantiate("project", project, "subscription", subscription); } /** * Extracts the project from the given fully-qualified path which * represents a project resource. + * + * + * */ public static final String extractProjectFromProjectPath(String projectPath) { return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); @@ -211,6 +354,9 @@ public static final String extractProjectFromProjectPath(String projectPath) { /** * Extracts the project from the given fully-qualified path which * represents a subscription resource. + * + * + * */ public static final String extractProjectFromSubscriptionPath(String subscriptionPath) { return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("project"); @@ -219,12 +365,14 @@ public static final String extractProjectFromSubscriptionPath(String subscriptio /** * Extracts the subscription from the given fully-qualified path which * represents a subscription resource. + * + * + * */ public static final String extractSubscriptionFromSubscriptionPath(String subscriptionPath) { return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("subscription"); } - // ============= // Service Calls // ============= @@ -234,12 +382,15 @@ public static final String extractSubscriptionFromSubscriptionPath(String subscr // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Creates a subscription to a given topic for a given subscriber. - * If the subscription already exists, returns ALREADY_EXISTS. - * If the corresponding topic doesn't exist, returns NOT_FOUND. + * If the subscription already exists, returns `ALREADY_EXISTS`. + * If the corresponding topic doesn't exist, returns `NOT_FOUND`. * * If the name is not provided in the request, the server will assign a random * name for this subscription on the same project as the topic. * + * + * + * * @param name The name of the subscription. It must have the format * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must * start with a letter, and contain only letters (`[A-Za-z]`), numbers @@ -250,7 +401,7 @@ public static final String extractSubscriptionFromSubscriptionPath(String subscr * The value of this field will be `_deleted-topic_` if the topic has been * deleted. * @param pushConfig If push delivery is used with this subscription, this field is - * used to configure it. An empty pushConfig signifies that the subscriber + * used to configure it. An empty `pushConfig` signifies that the subscriber * will pull and ack messages using API methods. * @param ackDeadlineSeconds This value is the maximum time after a subscriber receives a message * before the subscriber should acknowledge the message. After message @@ -258,9 +409,10 @@ public static final String extractSubscriptionFromSubscriptionPath(String subscr * acknowledged, it is an outstanding message and will not be delivered * again during that time (on a best-effort basis). * - * For pull delivery this value is used as the initial value for the ack + * For pull subscriptions, this value is used as the initial value for the ack * deadline. To override this value for a given message, call - * ModifyAckDeadline with the corresponding ack_id. + * `ModifyAckDeadline` with the corresponding `ack_id` if using + * pull. * * For push delivery, this value is also used to set the request timeout for * the call to the push endpoint. @@ -270,14 +422,15 @@ public static final String extractSubscriptionFromSubscriptionPath(String subscr * * If this parameter is not set, the default value of 10 seconds is used. */ - public Subscription createSubscription(String name, String topic, PushConfig pushConfig, int ackDeadlineSeconds) { + public Subscription createSubscription( + String name, String topic, PushConfig pushConfig, int ackDeadlineSeconds) { Subscription request = Subscription.newBuilder() - .setName(name) - .setTopic(topic) - .setPushConfig(pushConfig) - .setAckDeadlineSeconds(ackDeadlineSeconds) - .build(); + .setName(name) + .setTopic(topic) + .setPushConfig(pushConfig) + .setAckDeadlineSeconds(ackDeadlineSeconds) + .build(); return createSubscription(request); } @@ -285,12 +438,15 @@ public Subscription createSubscription(String name, String topic, PushConfig pus // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Creates a subscription to a given topic for a given subscriber. - * If the subscription already exists, returns ALREADY_EXISTS. - * If the corresponding topic doesn't exist, returns NOT_FOUND. + * If the subscription already exists, returns `ALREADY_EXISTS`. + * If the corresponding topic doesn't exist, returns `NOT_FOUND`. * * If the name is not provided in the request, the server will assign a random * name for this subscription on the same project as the topic. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public Subscription createSubscription(Subscription request) { @@ -300,14 +456,23 @@ public Subscription createSubscription(Subscription request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Creates a subscription to a given topic for a given subscriber. - * If the subscription already exists, returns ALREADY_EXISTS. - * If the corresponding topic doesn't exist, returns NOT_FOUND. + * If the subscription already exists, returns `ALREADY_EXISTS`. + * If the corresponding topic doesn't exist, returns `NOT_FOUND`. * * If the name is not provided in the request, the server will assign a random * name for this subscription on the same project as the topic. + * + * + * */ public ApiCallable createSubscriptionCallable() { - return ApiUtils.prepareIdempotentCallable(CREATE_SUBSCRIPTION, settings).bind(channel); + ImmutableSet retryableCodes = + retryCodesConfig.get(MethodIdentifier.CREATE_SUBSCRIPTION); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.CREATE_SUBSCRIPTION); + return CREATE_SUBSCRIPTION + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- getSubscription ----- @@ -316,13 +481,14 @@ public ApiCallable createSubscriptionCallable() { /** * Gets the configuration details of a subscription. * + * + * + * * @param subscription The name of the subscription to get. */ public Subscription getSubscription(String subscription) { GetSubscriptionRequest request = - GetSubscriptionRequest.newBuilder() - .setSubscription(subscription) - .build(); + GetSubscriptionRequest.newBuilder().setSubscription(subscription).build(); return getSubscription(request); } @@ -331,6 +497,9 @@ public Subscription getSubscription(String subscription) { /** * Gets the configuration details of a subscription. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public Subscription getSubscription(GetSubscriptionRequest request) { @@ -340,9 +509,18 @@ public Subscription getSubscription(GetSubscriptionRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Gets the configuration details of a subscription. + * + * + * */ public ApiCallable getSubscriptionCallable() { - return ApiUtils.prepareIdempotentCallable(GET_SUBSCRIPTION, settings).bind(channel); + ImmutableSet retryableCodes = + retryCodesConfig.get(MethodIdentifier.GET_SUBSCRIPTION); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.GET_SUBSCRIPTION); + return GET_SUBSCRIPTION + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- listSubscriptions ----- @@ -350,12 +528,13 @@ public ApiCallable getSubscriptionCallable // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Lists matching subscriptions. + * + * + * */ public Iterable listSubscriptions(String project) { ListSubscriptionsRequest request = - ListSubscriptionsRequest.newBuilder() - .setProject(project) - .build(); + ListSubscriptionsRequest.newBuilder().setProject(project).build(); return listSubscriptions(request); } @@ -363,27 +542,43 @@ public Iterable listSubscriptions(String project) { /** * Lists matching subscriptions. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public Iterable listSubscriptions(ListSubscriptionsRequest request) { - return listSubscriptionsStreamingCallable() - .iterableResponseStreamCall(request); + return listSubscriptionsStreamingCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Lists matching subscriptions. + * + * + * */ - public ApiCallable listSubscriptionsStreamingCallable() { + public ApiCallable> + listSubscriptionsStreamingCallable() { return listSubscriptionsCallable().pageStreaming(LIST_SUBSCRIPTIONS_PAGE_DESC); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Lists matching subscriptions. + * + * + * */ - public ApiCallable listSubscriptionsCallable() { - return ApiUtils.prepareIdempotentCallable(LIST_SUBSCRIPTIONS, settings).bind(channel); + public ApiCallable + listSubscriptionsCallable() { + ImmutableSet retryableCodes = + retryCodesConfig.get(MethodIdentifier.LIST_SUBSCRIPTIONS); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.LIST_SUBSCRIPTIONS); + return LIST_SUBSCRIPTIONS + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- deleteSubscription ----- @@ -391,18 +586,19 @@ public ApiCallable listSubs // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Deletes an existing subscription. All pending messages in the subscription - * are immediately dropped. Calls to Pull after deletion will return - * NOT_FOUND. After a subscription is deleted, a new one may be created with + * are immediately dropped. Calls to `Pull` after deletion will return + * `NOT_FOUND`. After a subscription is deleted, a new one may be created with * the same name, but the new one has no association with the old * subscription, or its topic unless the same topic is specified. * + * + * + * * @param subscription The subscription to delete. */ public void deleteSubscription(String subscription) { DeleteSubscriptionRequest request = - DeleteSubscriptionRequest.newBuilder() - .setSubscription(subscription) - .build(); + DeleteSubscriptionRequest.newBuilder().setSubscription(subscription).build(); deleteSubscription(request); } @@ -410,11 +606,14 @@ public void deleteSubscription(String subscription) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Deletes an existing subscription. All pending messages in the subscription - * are immediately dropped. Calls to Pull after deletion will return - * NOT_FOUND. After a subscription is deleted, a new one may be created with + * are immediately dropped. Calls to `Pull` after deletion will return + * `NOT_FOUND`. After a subscription is deleted, a new one may be created with * the same name, but the new one has no association with the old * subscription, or its topic unless the same topic is specified. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public void deleteSubscription(DeleteSubscriptionRequest request) { @@ -424,49 +623,64 @@ public void deleteSubscription(DeleteSubscriptionRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Deletes an existing subscription. All pending messages in the subscription - * are immediately dropped. Calls to Pull after deletion will return - * NOT_FOUND. After a subscription is deleted, a new one may be created with + * are immediately dropped. Calls to `Pull` after deletion will return + * `NOT_FOUND`. After a subscription is deleted, a new one may be created with * the same name, but the new one has no association with the old * subscription, or its topic unless the same topic is specified. + * + * + * */ public ApiCallable deleteSubscriptionCallable() { - return ApiUtils.prepareIdempotentCallable(DELETE_SUBSCRIPTION, settings).bind(channel); + ImmutableSet retryableCodes = + retryCodesConfig.get(MethodIdentifier.DELETE_SUBSCRIPTION); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.DELETE_SUBSCRIPTION); + return DELETE_SUBSCRIPTION + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- modifyAckDeadline ----- // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Modifies the ack deadline for a specific message. This method is useful to - * indicate that more time is needed to process a message by the subscriber, - * or to make the message available for redelivery if the processing was - * interrupted. + * Modifies the ack deadline for a specific message. This method is useful + * to indicate that more time is needed to process a message by the + * subscriber, or to make the message available for redelivery if the + * processing was interrupted. + * + * + * * * @param subscription The name of the subscription. * @param ackIds List of acknowledgment IDs. - * @param ackDeadlineSeconds The new ack deadline with respect to the time this request was sent to the - * Pub/Sub system. Must be >= 0. For example, if the value is 10, the new ack - * deadline will expire 10 seconds after the ModifyAckDeadline call was made. - * Specifying zero may immediately make the message available for another pull - * request. + * @param ackDeadlineSeconds The new ack deadline with respect to the time this request was sent to + * the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new + * ack deadline will expire 10 seconds after the `ModifyAckDeadline` call + * was made. Specifying zero may immediately make the message available for + * another pull request. */ public void modifyAckDeadline(String subscription, List ackIds, int ackDeadlineSeconds) { ModifyAckDeadlineRequest request = ModifyAckDeadlineRequest.newBuilder() - .setSubscription(subscription) - .addAllAckIds(ackIds) - .setAckDeadlineSeconds(ackDeadlineSeconds) - .build(); + .setSubscription(subscription) + .addAllAckIds(ackIds) + .setAckDeadlineSeconds(ackDeadlineSeconds) + .build(); modifyAckDeadline(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Modifies the ack deadline for a specific message. This method is useful to - * indicate that more time is needed to process a message by the subscriber, - * or to make the message available for redelivery if the processing was - * interrupted. + * Modifies the ack deadline for a specific message. This method is useful + * to indicate that more time is needed to process a message by the + * subscriber, or to make the message available for redelivery if the + * processing was interrupted. + * + * + * * * @param request The request object containing all of the parameters for the API call. */ @@ -476,51 +690,63 @@ public void modifyAckDeadline(ModifyAckDeadlineRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Modifies the ack deadline for a specific message. This method is useful to - * indicate that more time is needed to process a message by the subscriber, - * or to make the message available for redelivery if the processing was - * interrupted. + * Modifies the ack deadline for a specific message. This method is useful + * to indicate that more time is needed to process a message by the + * subscriber, or to make the message available for redelivery if the + * processing was interrupted. + * + * + * */ public ApiCallable modifyAckDeadlineCallable() { - return MODIFY_ACK_DEADLINE.bind(channel); + ImmutableSet retryableCodes = + retryCodesConfig.get(MethodIdentifier.MODIFY_ACK_DEADLINE); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.MODIFY_ACK_DEADLINE); + return MODIFY_ACK_DEADLINE + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- acknowledge ----- // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Acknowledges the messages associated with the ack tokens in the - * AcknowledgeRequest. The Pub/Sub system can remove the relevant messages + * Acknowledges the messages associated with the `ack_ids` in the + * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages * from the subscription. * * Acknowledging a message whose ack deadline has expired may succeed, * but such a message may be redelivered later. Acknowledging a message more * than once will not result in an error. * + * + * + * * @param subscription The subscription whose message is being acknowledged. * @param ackIds The acknowledgment ID for the messages being acknowledged that was returned - * by the Pub/Sub system in the Pull response. Must not be empty. + * by the Pub/Sub system in the `Pull` response. Must not be empty. */ public void acknowledge(String subscription, List ackIds) { AcknowledgeRequest request = - AcknowledgeRequest.newBuilder() - .setSubscription(subscription) - .addAllAckIds(ackIds) - .build(); + AcknowledgeRequest.newBuilder().setSubscription(subscription).addAllAckIds(ackIds).build(); acknowledge(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Acknowledges the messages associated with the ack tokens in the - * AcknowledgeRequest. The Pub/Sub system can remove the relevant messages + * Acknowledges the messages associated with the `ack_ids` in the + * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages * from the subscription. * * Acknowledging a message whose ack deadline has expired may succeed, * but such a message may be redelivered later. Acknowledging a message more * than once will not result in an error. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public void acknowledge(AcknowledgeRequest request) { @@ -529,16 +755,24 @@ public void acknowledge(AcknowledgeRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Acknowledges the messages associated with the ack tokens in the - * AcknowledgeRequest. The Pub/Sub system can remove the relevant messages + * Acknowledges the messages associated with the `ack_ids` in the + * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages * from the subscription. * * Acknowledging a message whose ack deadline has expired may succeed, * but such a message may be redelivered later. Acknowledging a message more * than once will not result in an error. + * + * + * */ public ApiCallable acknowledgeCallable() { - return ACKNOWLEDGE.bind(channel); + ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.ACKNOWLEDGE); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.ACKNOWLEDGE); + return ACKNOWLEDGE + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- pull ----- @@ -546,13 +780,16 @@ public ApiCallable acknowledgeCallable() { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Pulls messages from the server. Returns an empty list if there are no - * messages available in the backlog. The server may return UNAVAILABLE if + * messages available in the backlog. The server may return `UNAVAILABLE` if * there are too many concurrent pull requests pending for the given * subscription. * + * + * + * * @param subscription The subscription from which messages should be pulled. * @param returnImmediately If this is specified as true the system will respond immediately even if - * it is not able to return a message in the Pull response. Otherwise the + * it is not able to return a message in the `Pull` response. Otherwise the * system is allowed to wait until at least one message is available rather * than returning no messages. The client may cancel the request if it does * not wish to wait any longer for the response. @@ -562,10 +799,10 @@ public ApiCallable acknowledgeCallable() { public PullResponse pull(String subscription, boolean returnImmediately, int maxMessages) { PullRequest request = PullRequest.newBuilder() - .setSubscription(subscription) - .setReturnImmediately(returnImmediately) - .setMaxMessages(maxMessages) - .build(); + .setSubscription(subscription) + .setReturnImmediately(returnImmediately) + .setMaxMessages(maxMessages) + .build(); return pull(request); } @@ -573,10 +810,13 @@ public PullResponse pull(String subscription, boolean returnImmediately, int max // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Pulls messages from the server. Returns an empty list if there are no - * messages available in the backlog. The server may return UNAVAILABLE if + * messages available in the backlog. The server may return `UNAVAILABLE` if * there are too many concurrent pull requests pending for the given * subscription. * + * + * + * * @param request The request object containing all of the parameters for the API call. */ public PullResponse pull(PullRequest request) { @@ -586,53 +826,64 @@ public PullResponse pull(PullRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Pulls messages from the server. Returns an empty list if there are no - * messages available in the backlog. The server may return UNAVAILABLE if + * messages available in the backlog. The server may return `UNAVAILABLE` if * there are too many concurrent pull requests pending for the given * subscription. + * + * + * */ public ApiCallable pullCallable() { - return PULL.bind(channel); + ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.PULL); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.PULL); + return PULL.retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } // ----- modifyPushConfig ----- // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Modifies the PushConfig for a specified subscription. + * Modifies the `PushConfig` for a specified subscription. * - * This may be used to change a push subscription to a pull one (signified - * by an empty PushConfig) or vice versa, or change the endpoint URL and other - * attributes of a push subscription. Messages will accumulate for - * delivery continuously through the call regardless of changes to the - * PushConfig. + * This may be used to change a push subscription to a pull one (signified by + * an empty `PushConfig`) or vice versa, or change the endpoint URL and other + * attributes of a push subscription. Messages will accumulate for delivery + * continuously through the call regardless of changes to the `PushConfig`. + * + * + * * * @param subscription The name of the subscription. * @param pushConfig The push configuration for future deliveries. * - * An empty pushConfig indicates that the Pub/Sub system should + * An empty `pushConfig` indicates that the Pub/Sub system should * stop pushing messages from the given subscription and allow * messages to be pulled and acknowledged - effectively pausing - * the subscription if Pull is not called. + * the subscription if `Pull` is not called. */ public void modifyPushConfig(String subscription, PushConfig pushConfig) { ModifyPushConfigRequest request = ModifyPushConfigRequest.newBuilder() - .setSubscription(subscription) - .setPushConfig(pushConfig) - .build(); + .setSubscription(subscription) + .setPushConfig(pushConfig) + .build(); modifyPushConfig(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Modifies the PushConfig for a specified subscription. + * Modifies the `PushConfig` for a specified subscription. * - * This may be used to change a push subscription to a pull one (signified - * by an empty PushConfig) or vice versa, or change the endpoint URL and other - * attributes of a push subscription. Messages will accumulate for - * delivery continuously through the call regardless of changes to the - * PushConfig. + * This may be used to change a push subscription to a pull one (signified by + * an empty `PushConfig`) or vice versa, or change the endpoint URL and other + * attributes of a push subscription. Messages will accumulate for delivery + * continuously through the call regardless of changes to the `PushConfig`. + * + * + * * * @param request The request object containing all of the parameters for the API call. */ @@ -642,19 +893,26 @@ public void modifyPushConfig(ModifyPushConfigRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Modifies the PushConfig for a specified subscription. + * Modifies the `PushConfig` for a specified subscription. + * + * This may be used to change a push subscription to a pull one (signified by + * an empty `PushConfig`) or vice versa, or change the endpoint URL and other + * attributes of a push subscription. Messages will accumulate for delivery + * continuously through the call regardless of changes to the `PushConfig`. * - * This may be used to change a push subscription to a pull one (signified - * by an empty PushConfig) or vice versa, or change the endpoint URL and other - * attributes of a push subscription. Messages will accumulate for - * delivery continuously through the call regardless of changes to the - * PushConfig. + * + * */ public ApiCallable modifyPushConfigCallable() { - return MODIFY_PUSH_CONFIG.bind(channel); + ImmutableSet retryableCodes = + retryCodesConfig.get(MethodIdentifier.MODIFY_PUSH_CONFIG); + RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.MODIFY_PUSH_CONFIG); + return MODIFY_PUSH_CONFIG + .retryableOn(retryableCodes) + .retrying(retryParams, settings.getExecutor()) + .bind(channel); } - // ======== // Cleanup // ======== @@ -662,6 +920,9 @@ public ApiCallable modifyPushConfigCallable() { /** * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately * cancelled. + * + * + * */ @Override public void close() { @@ -673,7 +934,6 @@ public void close() { // Manually-added shutdown code } - // ======== // Manually-added methods: add custom (non-generated) methods after this point. // ======== diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java index b9c17e0f0831..823edba0d5a6 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java @@ -1,68 +1,104 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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.gcloud.pubsub.testing; -import com.google.gcloud.pubsub.spi.testing.LocalPublisherImpl; -import com.google.pubsub.v1.PublisherGrpc; +import com.google.api.gax.testing.DownloadableEmulatorRunner; +import com.google.api.gax.testing.GCloudEmulatorRunner; +import com.google.api.gax.testing.LocalServiceHelper; import io.grpc.ManagedChannel; -import io.grpc.Server; import io.grpc.netty.NegotiationType; import io.grpc.netty.NettyChannelBuilder; -import io.grpc.netty.NettyServerBuilder; -import io.netty.channel.local.LocalAddress; -import io.netty.channel.local.LocalChannel; -import io.netty.channel.local.LocalServerChannel; import java.io.IOException; -import java.net.SocketAddress; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; /** - * A class that runs an in-memory Publisher instance for use in tests. + * A class that runs a Pubsub emulator instance for use in tests. */ public class LocalPubsubHelper { - private static int FLOW_CONTROL_WINDOW = 65 * 1024; + private final LocalServiceHelper serviceHelper; + private final List gcloudCommand; + private final URL emulatorUrl; + + // Local server settings + private static final int DEFAULT_PORT = 8080; + private static final String DEFAULT_HOST = "localhost"; + + // GCloud emulator settings + private static final String GCLOUD_CMD_TEXT = "gcloud beta emulators pubsub start --host-port"; + private static final String VERSION_PREFIX = "pubsub-emulator"; + private static final String MIN_VERSION = "2016.01.13"; - private final SocketAddress address; - private final Server server; - private final LocalPublisherImpl publisherImpl; + // Downloadable emulator settings + private static final String FILENAME = "pubsub-emulator-20160113-2.zip"; + private static final String BIN_NAME = "pubsub-emulator/bin/cloud-pubsub-fake"; + private static final String MD5_CHECKSUM = "20943e9defa300f2de101568459c133d"; /** * Constructs a new LocalPubsubHelper. The method start() must * be called before it is used. + * @throws MalformedURLException */ - public LocalPubsubHelper(String addressString) { - address = new LocalAddress(addressString); - publisherImpl = new LocalPublisherImpl(); - NettyServerBuilder builder = NettyServerBuilder - .forAddress(address) - .flowControlWindow(FLOW_CONTROL_WINDOW) - .channelType(LocalServerChannel.class); - builder.addService(PublisherGrpc.bindService(publisherImpl)); - server = builder.build(); + public LocalPubsubHelper() throws MalformedURLException { + gcloudCommand = new ArrayList<>(Arrays.asList(GCLOUD_CMD_TEXT.split(" "))); + gcloudCommand.add(DEFAULT_HOST); + emulatorUrl = + new URL("http://storage.googleapis.com/pubsub/tools/" + FILENAME); + GCloudEmulatorRunner gcloudRunner = + new GCloudEmulatorRunner(gcloudCommand, VERSION_PREFIX, MIN_VERSION); + DownloadableEmulatorRunner downloadRunner = + new DownloadableEmulatorRunner(Arrays.asList(BIN_NAME), emulatorUrl, MD5_CHECKSUM); + serviceHelper = + new LocalServiceHelper(Arrays.asList(gcloudRunner, downloadRunner), DEFAULT_PORT); } /** - * Starts the in-memory service. + * Start the local pubsub emulator through gcloud, download the zip file if user does not have + * gcloud installed. + * @throws InterruptedException + * @throws IOException */ - public void start() { - try { - server.start(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } + public void start() throws IOException, InterruptedException { + String blockUntilOutput = Integer.toString(DEFAULT_PORT); + serviceHelper.start(blockUntilOutput); } /** - * Resets the state of the in-memory service. + * Reset the internal state of the emulator. + * @throws InterruptedException + * @throws IOException */ - public void reset() { - publisherImpl.reset(); + public void reset() throws IOException, InterruptedException { + this.serviceHelper.sendPostRequest("/reset"); } /** - * Returns the internal in-memory service. + * Quit the local emulator and related local service. + * @throws InterruptedException + * @throws IOException */ - public LocalPublisherImpl getPublisherImpl() { - return publisherImpl; + public void stop() throws IOException, InterruptedException { + this.serviceHelper.sendPostRequest("/shutdown"); + this.serviceHelper.stop(); } /** @@ -70,16 +106,8 @@ public LocalPublisherImpl getPublisherImpl() { */ public ManagedChannel createChannel() { return NettyChannelBuilder - .forAddress(address) + .forAddress(DEFAULT_HOST, DEFAULT_PORT) .negotiationType(NegotiationType.PLAINTEXT) - .channelType(LocalChannel.class) .build(); } - - /** - * Shuts down the in-memory service. - */ - public void shutdownNow() { - server.shutdownNow(); - } } diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java index 38e337890aa1..05a2f2acb9e2 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java @@ -17,14 +17,10 @@ import com.google.gcloud.pubsub.testing.LocalPubsubHelper; import com.google.protobuf.ByteString; import com.google.pubsub.v1.PubsubMessage; +import com.google.pubsub.v1.PullResponse; +import com.google.pubsub.v1.PushConfig; import com.google.pubsub.v1.Topic; -import io.gapi.gax.grpc.ServiceApiSettings; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -32,27 +28,45 @@ import org.junit.BeforeClass; import org.junit.Test; +import com.google.api.gax.grpc.ServiceApiSettings; + +import io.grpc.ManagedChannel; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public class PublisherApiTest { private static LocalPubsubHelper pubsubHelper; private PublisherApi publisherApi; + private SubscriberApi subscriberApi; @BeforeClass - public static void startStaticServer() { - pubsubHelper = new LocalPubsubHelper("in-process-1"); + public static void startServer() throws IOException, InterruptedException { + pubsubHelper = new LocalPubsubHelper(); pubsubHelper.start(); } @AfterClass - public static void stopServer() { - pubsubHelper.shutdownNow(); + public static void stopServer() throws IOException, InterruptedException { + pubsubHelper.stop(); } @Before public void setUp() throws Exception { - pubsubHelper.reset(); - ServiceApiSettings settings = new ServiceApiSettings(); - settings.setChannel(pubsubHelper.createChannel()); - publisherApi = PublisherApi.create(settings); + ManagedChannel channel = pubsubHelper.createChannel(); + + publisherApi = + PublisherApi.create( + ServiceApiSettings.builder() + .provideChannelWith(channel) + .build()); + subscriberApi = + SubscriberApi.create( + ServiceApiSettings.builder() + .provideChannelWith(channel) + .build()); } @After @@ -60,6 +74,9 @@ public void tearDown() throws Exception { if (publisherApi != null) { publisherApi.close(); } + if (subscriberApi != null) { + subscriberApi.close(); + } pubsubHelper.reset(); } @@ -68,22 +85,25 @@ public void testCreateTopic() throws Exception { String topicName = PublisherApi.createTopicPath("my-project", "my-topic"); Topic result = publisherApi.createTopic(topicName); Assert.assertEquals(topicName, result.getName()); - Assert.assertEquals(1, pubsubHelper.getPublisherImpl().getTopics().size()); - Assert.assertNotNull(pubsubHelper.getPublisherImpl().getTopics().get(topicName)); } @Test public void testPublish() throws Exception { String topicName = PublisherApi.createTopicPath("my-project", "publish-topic"); publisherApi.createTopic(topicName); - PubsubMessage msg = PubsubMessage.newBuilder() - .setData(ByteString.copyFromUtf8("pubsub-message")) - .build(); + + String subscriberName = SubscriberApi.createSubscriptionPath("my-project", "my-subscribe"); + PushConfig config = PushConfig.getDefaultInstance(); + subscriberApi.createSubscription(subscriberName, topicName, config, 5); + + PubsubMessage msg = + PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("pubsub-message")).build(); publisherApi.publish(topicName, Collections.singletonList(msg)); - List publishedMessages = - pubsubHelper.getPublisherImpl().getTopics().get(topicName); - Assert.assertEquals(1, publishedMessages.size()); - Assert.assertEquals("pubsub-message", publishedMessages.get(0).getData().toStringUtf8()); + + PullResponse response = subscriberApi.pull(subscriberName, true, 100); + Assert.assertEquals(1, response.getReceivedMessagesCount()); + Assert.assertEquals( + "pubsub-message", response.getReceivedMessages(0).getMessage().getData().toStringUtf8()); } @Test @@ -115,9 +135,14 @@ public void testListTopics() throws Exception { @Test public void testDeleteTopic() throws Exception { + String project = PublisherApi.createProjectPath("project.1"); String topicName = PublisherApi.createTopicPath("my-project", "fun-topic"); publisherApi.createTopic(topicName); publisherApi.deleteTopic(topicName); - Assert.assertEquals(0, pubsubHelper.getPublisherImpl().getTopics().size()); + List topics = new ArrayList<>(); + for (Topic topic : publisherApi.listTopics(project)) { + topics.add(topic); + } + Assert.assertEquals(0, topics.size()); } } From 35b015ae7b105a0773533e62ced488f0a4240149 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Tue, 23 Feb 2016 16:12:11 -0800 Subject: [PATCH 189/203] Fixing root build --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index b9aeb421b87e..9f15cd46baf3 100644 --- a/pom.xml +++ b/pom.xml @@ -99,6 +99,7 @@ gcloud-java-core gcloud-java-gax gcloud-java-datastore + gcloud-java-examples gcloud-java-pubsub gcloud-java-examples gcloud-java-resourcemanager From cd6f0760497ab1a1a5fedd4b90e6893a2314ef82 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Wed, 24 Feb 2016 10:37:44 -0800 Subject: [PATCH 190/203] Using version of GAX compatible with Java 1.7 --- gcloud-java-pubsub/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index cec635adca31..d8a1f905633e 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -19,7 +19,7 @@ com.google.api gax - 0.0.1 + 0.0.2 com.google.api.grpc From 927f2bdf5be4cb78edfb3f8ec6f1f57ce6be1d8f Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Thu, 25 Feb 2016 10:10:19 -0800 Subject: [PATCH 191/203] Fixing doc problems, improving formatting fixes #387 - Moving references of delete topics to get/list calls fixes #386 - Removing the problematic wording fixes #385 - Changing 'returns' to 'generates' when referencing errors --- .../gcloud/pubsub/spi/PublisherApi.java | 12 ++--- .../gcloud/pubsub/spi/SubscriberApi.java | 50 +++++++++++++------ .../spi/testing/LocalPublisherImpl.java | 19 ++++--- .../pubsub/testing/LocalPubsubHelper.java | 6 +-- 4 files changed, 54 insertions(+), 33 deletions(-) diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index 632d84cfe5de..98ff96ce61dd 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -447,7 +447,7 @@ public ApiCallable createTopicCallable() { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic + * Adds one or more messages to the topic. Generates `NOT_FOUND` if the topic * does not exist. The message payload must not be empty; it must contain * either a non-empty data field, or at least one attribute. * @@ -466,7 +466,7 @@ public PublishResponse publish(String topic, List messages) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic + * Adds one or more messages to the topic. Generates `NOT_FOUND` if the topic * does not exist. The message payload must not be empty; it must contain * either a non-empty data field, or at least one attribute. * @@ -481,7 +481,7 @@ public PublishResponse publish(PublishRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic + * Adds one or more messages to the topic. Generates `NOT_FOUND` if the topic * does not exist. The message payload must not be empty; it must contain * either a non-empty data field, or at least one attribute. * @@ -659,7 +659,7 @@ public Iterable listTopicSubscriptions(ListTopicSubscriptionsRequest req // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic + * Deletes the topic with the given name. Generates `NOT_FOUND` if the topic * does not exist. After a topic is deleted, a new topic may be created with * the same name; this is an entirely new topic with none of the old * configuration or subscriptions. Existing subscriptions to this topic are @@ -678,7 +678,7 @@ public void deleteTopic(String topic) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic + * Deletes the topic with the given name. Generates `NOT_FOUND` if the topic * does not exist. After a topic is deleted, a new topic may be created with * the same name; this is an entirely new topic with none of the old * configuration or subscriptions. Existing subscriptions to this topic are @@ -695,7 +695,7 @@ public void deleteTopic(DeleteTopicRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** - * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic + * Deletes the topic with the given name. Generates `NOT_FOUND` if the topic * does not exist. After a topic is deleted, a new topic may be created with * the same name; this is an entirely new topic with none of the old * configuration or subscriptions. Existing subscriptions to this topic are diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index 91387c8a9771..97f8ced85d2b 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -382,8 +382,8 @@ public static final String extractSubscriptionFromSubscriptionPath(String subscr // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Creates a subscription to a given topic for a given subscriber. - * If the subscription already exists, returns `ALREADY_EXISTS`. - * If the corresponding topic doesn't exist, returns `NOT_FOUND`. + * If the subscription already exists, generates `ALREADY_EXISTS`. + * If the corresponding topic doesn't exist, generates `NOT_FOUND`. * * If the name is not provided in the request, the server will assign a random * name for this subscription on the same project as the topic. @@ -398,8 +398,6 @@ public static final String extractSubscriptionFromSubscriptionPath(String subscr * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters * in length, and it must not start with `"goog"`. * @param topic The name of the topic from which this subscription is receiving messages. - * The value of this field will be `_deleted-topic_` if the topic has been - * deleted. * @param pushConfig If push delivery is used with this subscription, this field is * used to configure it. An empty `pushConfig` signifies that the subscriber * will pull and ack messages using API methods. @@ -438,8 +436,8 @@ public Subscription createSubscription( // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Creates a subscription to a given topic for a given subscriber. - * If the subscription already exists, returns `ALREADY_EXISTS`. - * If the corresponding topic doesn't exist, returns `NOT_FOUND`. + * If the subscription already exists, generates `ALREADY_EXISTS`. + * If the corresponding topic doesn't exist, generates `NOT_FOUND`. * * If the name is not provided in the request, the server will assign a random * name for this subscription on the same project as the topic. @@ -456,8 +454,8 @@ public Subscription createSubscription(Subscription request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Creates a subscription to a given topic for a given subscriber. - * If the subscription already exists, returns `ALREADY_EXISTS`. - * If the corresponding topic doesn't exist, returns `NOT_FOUND`. + * If the subscription already exists, generates `ALREADY_EXISTS`. + * If the corresponding topic doesn't exist, generates `NOT_FOUND`. * * If the name is not provided in the request, the server will assign a random * name for this subscription on the same project as the topic. @@ -481,6 +479,9 @@ public ApiCallable createSubscriptionCallable() { /** * Gets the configuration details of a subscription. * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * * * * @@ -497,6 +498,9 @@ public Subscription getSubscription(String subscription) { /** * Gets the configuration details of a subscription. * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * * * * @@ -510,6 +514,9 @@ public Subscription getSubscription(GetSubscriptionRequest request) { /** * Gets the configuration details of a subscription. * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * * * */ @@ -529,6 +536,9 @@ public ApiCallable getSubscriptionCallable /** * Lists matching subscriptions. * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * * * */ @@ -542,6 +552,9 @@ public Iterable listSubscriptions(String project) { /** * Lists matching subscriptions. * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * * * * @@ -555,6 +568,9 @@ public Iterable listSubscriptions(ListSubscriptionsRequest request /** * Lists matching subscriptions. * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * * * */ @@ -567,6 +583,9 @@ public Iterable listSubscriptions(ListSubscriptionsRequest request /** * Lists matching subscriptions. * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * * * */ @@ -586,7 +605,7 @@ public Iterable listSubscriptions(ListSubscriptionsRequest request // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Deletes an existing subscription. All pending messages in the subscription - * are immediately dropped. Calls to `Pull` after deletion will return + * are immediately dropped. Calls to `Pull` after deletion will generate * `NOT_FOUND`. After a subscription is deleted, a new one may be created with * the same name, but the new one has no association with the old * subscription, or its topic unless the same topic is specified. @@ -606,7 +625,7 @@ public void deleteSubscription(String subscription) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Deletes an existing subscription. All pending messages in the subscription - * are immediately dropped. Calls to `Pull` after deletion will return + * are immediately dropped. Calls to `Pull` after deletion will generate * `NOT_FOUND`. After a subscription is deleted, a new one may be created with * the same name, but the new one has no association with the old * subscription, or its topic unless the same topic is specified. @@ -623,7 +642,7 @@ public void deleteSubscription(DeleteSubscriptionRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Deletes an existing subscription. All pending messages in the subscription - * are immediately dropped. Calls to `Pull` after deletion will return + * are immediately dropped. Calls to `Pull` after deletion will generate * `NOT_FOUND`. After a subscription is deleted, a new one may be created with * the same name, but the new one has no association with the old * subscription, or its topic unless the same topic is specified. @@ -780,7 +799,7 @@ public ApiCallable acknowledgeCallable() { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Pulls messages from the server. Returns an empty list if there are no - * messages available in the backlog. The server may return `UNAVAILABLE` if + * messages available in the backlog. The server may generate `UNAVAILABLE` if * there are too many concurrent pull requests pending for the given * subscription. * @@ -791,8 +810,7 @@ public ApiCallable acknowledgeCallable() { * @param returnImmediately If this is specified as true the system will respond immediately even if * it is not able to return a message in the `Pull` response. Otherwise the * system is allowed to wait until at least one message is available rather - * than returning no messages. The client may cancel the request if it does - * not wish to wait any longer for the response. + * than returning no messages. * @param maxMessages The maximum number of messages returned for this request. The Pub/Sub * system may return fewer than the number specified. */ @@ -810,7 +828,7 @@ public PullResponse pull(String subscription, boolean returnImmediately, int max // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Pulls messages from the server. Returns an empty list if there are no - * messages available in the backlog. The server may return `UNAVAILABLE` if + * messages available in the backlog. The server may generate `UNAVAILABLE` if * there are too many concurrent pull requests pending for the given * subscription. * @@ -826,7 +844,7 @@ public PullResponse pull(PullRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. /** * Pulls messages from the server. Returns an empty list if there are no - * messages available in the backlog. The server may return `UNAVAILABLE` if + * messages available in the backlog. The server may generate `UNAVAILABLE` if * there are too many concurrent pull requests pending for the given * subscription. * diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java index 6ec1c008f6d0..45c5dc947d4d 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java @@ -74,7 +74,8 @@ public void getTopic(GetTopicRequest request, StreamObserver responseObse } @Override - public void listTopics(ListTopicsRequest request, StreamObserver responseObserver) { + public void listTopics( + ListTopicsRequest request, StreamObserver responseObserver) { List responseTopics = new ArrayList<>(); for (String topicName : topics.keySet()) { String projectOfTopic = PublisherApi.extractProjectFromTopicPath(topicName); @@ -84,11 +85,14 @@ public void listTopics(ListTopicsRequest request, StreamObserver() { - @Override public int compare(Topic o1, Topic o2) { - return o1.getName().compareTo(o2.getName()); - } - }); + Collections.sort( + responseTopics, + new Comparator() { + @Override + public int compare(Topic o1, Topic o2) { + return o1.getName().compareTo(o2.getName()); + } + }); ListTopicsResponse.Builder response = ListTopicsResponse.newBuilder(); response.setNextPageToken(""); response.addAllTopics(responseTopics); @@ -97,7 +101,8 @@ public void listTopics(ListTopicsRequest request, StreamObserver responseObserver) { responseObserver.onNext(ListTopicSubscriptionsResponse.getDefaultInstance()); responseObserver.onCompleted(); diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java index 823edba0d5a6..76de1a6d3cc7 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/testing/LocalPubsubHelper.java @@ -61,8 +61,7 @@ public class LocalPubsubHelper { public LocalPubsubHelper() throws MalformedURLException { gcloudCommand = new ArrayList<>(Arrays.asList(GCLOUD_CMD_TEXT.split(" "))); gcloudCommand.add(DEFAULT_HOST); - emulatorUrl = - new URL("http://storage.googleapis.com/pubsub/tools/" + FILENAME); + emulatorUrl = new URL("http://storage.googleapis.com/pubsub/tools/" + FILENAME); GCloudEmulatorRunner gcloudRunner = new GCloudEmulatorRunner(gcloudCommand, VERSION_PREFIX, MIN_VERSION); DownloadableEmulatorRunner downloadRunner = @@ -105,8 +104,7 @@ public void stop() throws IOException, InterruptedException { * Creates a channel for making requests to the in-memory service. */ public ManagedChannel createChannel() { - return NettyChannelBuilder - .forAddress(DEFAULT_HOST, DEFAULT_PORT) + return NettyChannelBuilder.forAddress(DEFAULT_HOST, DEFAULT_PORT) .negotiationType(NegotiationType.PLAINTEXT) .build(); } From f9fa43ac7345644ddf4a81b53f0b54a4f6b2ec6e Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Thu, 25 Feb 2016 10:24:51 -0800 Subject: [PATCH 192/203] Fixing javadoc error --- .../main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index 97f8ced85d2b..39f7a786e474 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -675,7 +675,7 @@ public ApiCallable deleteSubscriptionCallable( * @param subscription The name of the subscription. * @param ackIds List of acknowledgment IDs. * @param ackDeadlineSeconds The new ack deadline with respect to the time this request was sent to - * the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new + * the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new * ack deadline will expire 10 seconds after the `ModifyAckDeadline` call * was made. Specifying zero may immediately make the message available for * another pull request. From c5f93b7104e704254ece05d9a16d6431a23dce0c Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Fri, 4 Mar 2016 11:00:11 -0800 Subject: [PATCH 193/203] Regenerating code, new settings classes * Moving settings constants and data into new settings classes * Making use of ApiCallableBuilder in the new settings classes * Simplifying the Api classes --- .../gcloud/pubsub/spi/PublisherApi.java | 555 +++++++++++++ .../gcloud/pubsub/spi/PublisherSettings.java | 333 ++++++++ .../gcloud/pubsub/spi/SubscriberApi.java | 777 ++++++++++++++++++ .../gcloud/pubsub/spi/SubscriberSettings.java | 336 ++++++++ gcloud-java-pubsub/pom.xml | 2 +- .../gcloud/pubsub/spi/PublisherApi.java | 310 ++----- .../gcloud/pubsub/spi/PublisherSettings.java | 333 ++++++++ .../gcloud/pubsub/spi/SubscriberApi.java | 310 ++----- .../gcloud/pubsub/spi/SubscriberSettings.java | 336 ++++++++ .../gcloud/pubsub/spi/PublisherApiTest.java | 33 +- 10 files changed, 2811 insertions(+), 514 deletions(-) create mode 100644 gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java create mode 100644 gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java create mode 100644 gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java create mode 100644 gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java create mode 100644 gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java create mode 100644 gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java new file mode 100644 index 000000000000..f7011dcd0240 --- /dev/null +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -0,0 +1,555 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google engineers. + * Manual additions are allowed because the refresh process performs + * a 3-way merge in order to preserve those manual additions. In order to not + * break the refresh process, only certain types of modifications are + * allowed. + * + * Allowed modifications - currently these are the only types allowed: + * 1. New methods (these should be added to the end of the class) + * 2. New imports + * 3. Additional documentation between "manual edit" demarcations + * + * Happy editing! + */ + +package com.google.gcloud.pubsub.spi; + +import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.protobuf.PathTemplate; +import com.google.protobuf.Empty; +import com.google.pubsub.v1.DeleteTopicRequest; +import com.google.pubsub.v1.GetTopicRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsResponse; +import com.google.pubsub.v1.ListTopicsRequest; +import com.google.pubsub.v1.ListTopicsResponse; +import com.google.pubsub.v1.PublishRequest; +import com.google.pubsub.v1.PublishResponse; +import com.google.pubsub.v1.PubsubMessage; +import com.google.pubsub.v1.Topic; +import io.grpc.ManagedChannel; +import java.io.Closeable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +// Manually-added imports: add custom (non-generated) imports after this point. + +// AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. +/** + * The service that an application uses to manipulate topics, and to send + * messages to a topic. + * + * + * + */ +@javax.annotation.Generated("by GAPIC") +public class PublisherApi implements AutoCloseable { + + // ========= + // Constants + // ========= + + /** + * A PathTemplate representing the fully-qualified path to represent + * a project resource. + * + * + * + */ + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.create("projects/{project}"); + /** + * A PathTemplate representing the fully-qualified path to represent + * a topic resource. + * + * + * + */ + private static final PathTemplate TOPIC_PATH_TEMPLATE = + PathTemplate.create("projects/{project}/topics/{topic}"); + + // ======== + // Members + // ======== + + private final ManagedChannel channel; + private final List closeables = new ArrayList<>(); + + private final ApiCallable createTopicCallable; + private final ApiCallable publishCallable; + private final ApiCallable getTopicCallable; + private final ApiCallable listTopicsCallable; + private final ApiCallable> listTopicsIterableCallable; + private final ApiCallable + listTopicSubscriptionsCallable; + private final ApiCallable> + listTopicSubscriptionsIterableCallable; + private final ApiCallable deleteTopicCallable; + + // =============== + // Factory Methods + // =============== + + /** + * Constructs an instance of PublisherSettings with default settings. + */ + public static PublisherSettings newSettings() { + return PublisherSettings.create(); + } + + /** + * Constructs an instance of PublisherApi with default settings. + * + * + * + */ + public static PublisherApi create() throws IOException { + return create(newSettings()); + } + + /** + * Constructs an instance of PublisherApi, using the given settings. The channels are created based + * on the settings passed in, or defaults for any settings that are not set. + * + * + * + */ + public static PublisherApi create(PublisherSettings settings) throws IOException { + return new PublisherApi(settings); + } + + /** + * Constructs an instance of PublisherApi, using the given settings. This is protected so that it + * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * + * + * + */ + protected PublisherApi(PublisherSettings settings) throws IOException { + this.channel = settings.getChannel(); + + for (ApiCallSettings method : settings.allMethods()) { + if (method.getExecutor() == null) { + method.setExecutor(settings.getExecutor()); + } + } + + this.createTopicCallable = settings.createTopicMethod().build(settings); + this.publishCallable = settings.publishMethod().build(settings); + this.getTopicCallable = settings.getTopicMethod().build(settings); + this.listTopicsCallable = settings.listTopicsMethod().build(settings); + this.listTopicsIterableCallable = settings.listTopicsMethod().buildPageStreaming(settings); + this.listTopicSubscriptionsCallable = settings.listTopicSubscriptionsMethod().build(settings); + this.listTopicSubscriptionsIterableCallable = + settings.listTopicSubscriptionsMethod().buildPageStreaming(settings); + this.deleteTopicCallable = settings.deleteTopicMethod().build(settings); + + closeables.add( + new Closeable() { + @Override + public void close() throws IOException { + channel.shutdown(); + } + }); + } + + // ============================== + // Resource Name Helper Functions + // ============================== + + /** + * Creates a string containing the fully-qualified path to represent + * a project resource. + * + * + * + */ + public static final String createProjectPath(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } + + /** + * Creates a string containing the fully-qualified path to represent + * a topic resource. + * + * + * + */ + public static final String createTopicPath(String project, String topic) { + return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic); + } + + /** + * Extracts the project from the given fully-qualified path which + * represents a project resource. + * + * + * + */ + public static final String extractProjectFromProjectPath(String projectPath) { + return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); + } + + /** + * Extracts the project from the given fully-qualified path which + * represents a topic resource. + * + * + * + */ + public static final String extractProjectFromTopicPath(String topicPath) { + return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project"); + } + + /** + * Extracts the topic from the given fully-qualified path which + * represents a topic resource. + * + * + * + */ + public static final String extractTopicFromTopicPath(String topicPath) { + return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic"); + } + + // ============= + // Service Calls + // ============= + + // ----- createTopic ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates the given topic with the given name. + * + * + * + * + * @param name The name of the topic. It must have the format + * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter, + * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), + * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent + * signs (`%`). It must be between 3 and 255 characters in length, and it + * must not start with `"goog"`. + */ + public Topic createTopic(String name) { + Topic request = Topic.newBuilder().setName(name).build(); + + return createTopic(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates the given topic with the given name. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public Topic createTopic(Topic request) { + return createTopicCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates the given topic with the given name. + * + * + * + */ + public ApiCallable createTopicCallable() { + return createTopicCallable; + } + + // ----- publish ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Adds one or more messages to the topic. Generates `NOT_FOUND` if the topic + * does not exist. The message payload must not be empty; it must contain + * either a non-empty data field, or at least one attribute. + * + * + * + * + * @param topic The messages in the request will be published on this topic. + * @param messages The messages to publish. + */ + public PublishResponse publish(String topic, List messages) { + PublishRequest request = + PublishRequest.newBuilder().setTopic(topic).addAllMessages(messages).build(); + + return publish(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Adds one or more messages to the topic. Generates `NOT_FOUND` if the topic + * does not exist. The message payload must not be empty; it must contain + * either a non-empty data field, or at least one attribute. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public PublishResponse publish(PublishRequest request) { + return publishCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Adds one or more messages to the topic. Generates `NOT_FOUND` if the topic + * does not exist. The message payload must not be empty; it must contain + * either a non-empty data field, or at least one attribute. + * + * + * + */ + public ApiCallable publishCallable() { + return publishCallable; + } + + // ----- getTopic ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration of a topic. + * + * + * + * + * @param topic The name of the topic to get. + */ + public Topic getTopic(String topic) { + GetTopicRequest request = GetTopicRequest.newBuilder().setTopic(topic).build(); + + return getTopic(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration of a topic. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public Topic getTopic(GetTopicRequest request) { + return getTopicCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration of a topic. + * + * + * + */ + public ApiCallable getTopicCallable() { + return getTopicCallable; + } + + // ----- listTopics ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching topics. + * + * + * + */ + public Iterable listTopics(String project) { + ListTopicsRequest request = ListTopicsRequest.newBuilder().setProject(project).build(); + return listTopics(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching topics. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public Iterable listTopics(ListTopicsRequest request) { + return listTopicsIterableCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching topics. + * + * + * + */ + public ApiCallable> listTopicsIterableCallable() { + return listTopicsIterableCallable; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching topics. + * + * + * + */ + public ApiCallable listTopicsCallable() { + return listTopicsCallable; + } + + // ----- listTopicSubscriptions ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists the name of the subscriptions for this topic. + * + * + * + */ + public Iterable listTopicSubscriptions(String topic) { + ListTopicSubscriptionsRequest request = + ListTopicSubscriptionsRequest.newBuilder().setTopic(topic).build(); + return listTopicSubscriptions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists the name of the subscriptions for this topic. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public Iterable listTopicSubscriptions(ListTopicSubscriptionsRequest request) { + return listTopicSubscriptionsIterableCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists the name of the subscriptions for this topic. + * + * + * + */ + public ApiCallable> + listTopicSubscriptionsIterableCallable() { + return listTopicSubscriptionsIterableCallable; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists the name of the subscriptions for this topic. + * + * + * + */ + public ApiCallable + listTopicSubscriptionsCallable() { + return listTopicSubscriptionsCallable; + } + + // ----- deleteTopic ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes the topic with the given name. Generates `NOT_FOUND` if the topic + * does not exist. After a topic is deleted, a new topic may be created with + * the same name; this is an entirely new topic with none of the old + * configuration or subscriptions. Existing subscriptions to this topic are + * not deleted, but their `topic` field is set to `_deleted-topic_`. + * + * + * + * + * @param topic Name of the topic to delete. + */ + public void deleteTopic(String topic) { + DeleteTopicRequest request = DeleteTopicRequest.newBuilder().setTopic(topic).build(); + + deleteTopic(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes the topic with the given name. Generates `NOT_FOUND` if the topic + * does not exist. After a topic is deleted, a new topic may be created with + * the same name; this is an entirely new topic with none of the old + * configuration or subscriptions. Existing subscriptions to this topic are + * not deleted, but their `topic` field is set to `_deleted-topic_`. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public void deleteTopic(DeleteTopicRequest request) { + deleteTopicCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes the topic with the given name. Generates `NOT_FOUND` if the topic + * does not exist. After a topic is deleted, a new topic may be created with + * the same name; this is an entirely new topic with none of the old + * configuration or subscriptions. Existing subscriptions to this topic are + * not deleted, but their `topic` field is set to `_deleted-topic_`. + * + * + * + */ + public ApiCallable deleteTopicCallable() { + return deleteTopicCallable; + } + + // ======== + // Cleanup + // ======== + + /** + * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately + * cancelled. + * + * + * + */ + @Override + public void close() { + // Manually-added shutdown code + + // Auto-generated shutdown code + channel.shutdown(); + + // Manually-added shutdown code + } + + // ======== + // Manually-added methods: add custom (non-generated) methods after this point. + // ======== + +} diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java new file mode 100644 index 000000000000..b1985fc40b53 --- /dev/null +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java @@ -0,0 +1,333 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google engineers. + * Manual additions are allowed because the refresh process performs + * a 3-way merge in order to preserve those manual additions. In order to not + * break the refresh process, only certain types of modifications are + * allowed. + * + * Allowed modifications - currently these are the only types allowed: + * 1. New methods (these should be added to the end of the class) + * 2. New imports + * 3. Additional documentation between "manual edit" demarcations + * + * Happy editing! + */ + +package com.google.gcloud.pubsub.spi; + +import com.google.api.gax.core.BackoffParams; +import com.google.api.gax.core.ConnectionSettings; +import com.google.api.gax.core.RetryParams; +import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; +import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; +import com.google.api.gax.grpc.PageDescriptor; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import com.google.protobuf.Empty; +import com.google.pubsub.v1.DeleteTopicRequest; +import com.google.pubsub.v1.GetTopicRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsResponse; +import com.google.pubsub.v1.ListTopicsRequest; +import com.google.pubsub.v1.ListTopicsResponse; +import com.google.pubsub.v1.PublishRequest; +import com.google.pubsub.v1.PublishResponse; +import com.google.pubsub.v1.PublisherGrpc; +import com.google.pubsub.v1.Topic; +import io.grpc.Status; + +// Manually-added imports: add custom (non-generated) imports after this point. + +// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing. +@javax.annotation.Generated("by GAPIC") +public class PublisherSettings extends ApiCallSettings { + + // ========= + // Constants + // ========= + + /** + * The default address of the service. + * + * + * + */ + public static final String DEFAULT_SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; + + /** + * The default port of the service. + * + * + * + */ + public static final int DEFAULT_SERVICE_PORT = 443; + + /** + * The default scopes of the service. + */ + public static ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder() + .add("https://www.googleapis.com/auth/pubsub") + .add("https://www.googleapis.com/auth/cloud-platform") + .build(); + + private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = ImmutableMap.builder(); + definitions.put( + "idempotent", + Sets.immutableEnumSet( + Lists.newArrayList( + Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE))); + definitions.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetryParams params = null; + params = + RetryParams.newBuilder() + .setRetryBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(100L) + .setDelayMultiplier(1.2) + .setMaxDelayMillis(1000L) + .build()) + .setTimeoutBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(300L) + .setDelayMultiplier(1.3) + .setMaxDelayMillis(3000L) + .build()) + .setTotalTimeout(30000L) + .build(); + definitions.put("default", params); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + private final ApiCallableBuilder createTopicMethod; + private final ApiCallableBuilder publishMethod; + private final ApiCallableBuilder getTopicMethod; + private final PageStreamingApiCallableBuilder + listTopicsMethod; + private final PageStreamingApiCallableBuilder< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + listTopicSubscriptionsMethod; + private final ApiCallableBuilder deleteTopicMethod; + private final ImmutableList allMethods; + + // =============== + // Factory Methods + // =============== + + /** + * Constructs an instance of PublisherSettings with default settings. + * + * + * + */ + public static PublisherSettings create() { + PublisherSettings settings = new PublisherSettings(); + settings.provideChannelWith( + ConnectionSettings.builder() + .setServiceAddress(DEFAULT_SERVICE_ADDRESS) + .setPort(DEFAULT_SERVICE_PORT) + .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) + .build()); + return settings; + } + + /** + * Constructs an instance of PublisherSettings with default settings. This is protected so that it + * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * + * + * + */ + protected PublisherSettings() { + createTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_CREATE_TOPIC); + createTopicMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH); + publishMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + getTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_GET_TOPIC); + getTopicMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + listTopicsMethod = + new PageStreamingApiCallableBuilder<>( + PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC); + listTopicsMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + listTopicSubscriptionsMethod = + new PageStreamingApiCallableBuilder<>( + PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS, LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC); + listTopicSubscriptionsMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + deleteTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_DELETE_TOPIC); + deleteTopicMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + allMethods = + ImmutableList.builder() + .add( + createTopicMethod, + publishMethod, + getTopicMethod, + listTopicsMethod, + listTopicSubscriptionsMethod, + deleteTopicMethod) + .build(); + } + + /** + * Returns the ApiCallableBuilder for the API method createTopic. + * + * + * + */ + public ApiCallableBuilder createTopicMethod() { + return createTopicMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method publish. + * + * + * + */ + public ApiCallableBuilder publishMethod() { + return publishMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method getTopic. + * + * + * + */ + public ApiCallableBuilder getTopicMethod() { + return getTopicMethod; + } + + /** + * Returns the PageStreamingApiCallableBuilder for the API method listTopics. + * + * + * + */ + public PageStreamingApiCallableBuilder + listTopicsMethod() { + return listTopicsMethod; + } + + /** + * Returns the PageStreamingApiCallableBuilder for the API method listTopicSubscriptions. + * + * + * + */ + public PageStreamingApiCallableBuilder< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + listTopicSubscriptionsMethod() { + return listTopicSubscriptionsMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method deleteTopic. + * + * + * + */ + public ApiCallableBuilder deleteTopicMethod() { + return deleteTopicMethod; + } + + public ImmutableList allMethods() { + return allMethods; + } + + private static PageDescriptor + LIST_TOPICS_PAGE_STR_DESC = + new PageDescriptor() { + @Override + public Object emptyToken() { + return ""; + } + + @Override + public ListTopicsRequest injectToken(ListTopicsRequest payload, Object token) { + return ListTopicsRequest.newBuilder(payload).setPageToken((String) token).build(); + } + + @Override + public Object extractNextToken(ListTopicsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListTopicsResponse payload) { + return payload.getTopicsList(); + } + }; + + private static PageDescriptor< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC = + new PageDescriptor< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>() { + @Override + public Object emptyToken() { + return ""; + } + + @Override + public ListTopicSubscriptionsRequest injectToken( + ListTopicSubscriptionsRequest payload, Object token) { + return ListTopicSubscriptionsRequest.newBuilder(payload) + .setPageToken((String) token) + .build(); + } + + @Override + public Object extractNextToken(ListTopicSubscriptionsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListTopicSubscriptionsResponse payload) { + return payload.getSubscriptionsList(); + } + }; +} diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java new file mode 100644 index 000000000000..c50e6b6aaaed --- /dev/null +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -0,0 +1,777 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google engineers. + * Manual additions are allowed because the refresh process performs + * a 3-way merge in order to preserve those manual additions. In order to not + * break the refresh process, only certain types of modifications are + * allowed. + * + * Allowed modifications - currently these are the only types allowed: + * 1. New methods (these should be added to the end of the class) + * 2. New imports + * 3. Additional documentation between "manual edit" demarcations + * + * Happy editing! + */ + +package com.google.gcloud.pubsub.spi; + +import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.protobuf.PathTemplate; +import com.google.protobuf.Empty; +import com.google.pubsub.v1.AcknowledgeRequest; +import com.google.pubsub.v1.DeleteSubscriptionRequest; +import com.google.pubsub.v1.GetSubscriptionRequest; +import com.google.pubsub.v1.ListSubscriptionsRequest; +import com.google.pubsub.v1.ListSubscriptionsResponse; +import com.google.pubsub.v1.ModifyAckDeadlineRequest; +import com.google.pubsub.v1.ModifyPushConfigRequest; +import com.google.pubsub.v1.PullRequest; +import com.google.pubsub.v1.PullResponse; +import com.google.pubsub.v1.PushConfig; +import com.google.pubsub.v1.Subscription; +import io.grpc.ManagedChannel; +import java.io.Closeable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +// Manually-added imports: add custom (non-generated) imports after this point. + +// AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. +/** + * The service that an application uses to manipulate subscriptions and to + * consume messages from a subscription via the `Pull` method. + * + * + * + */ +@javax.annotation.Generated("by GAPIC") +public class SubscriberApi implements AutoCloseable { + + // ========= + // Constants + // ========= + + /** + * A PathTemplate representing the fully-qualified path to represent + * a project resource. + * + * + * + */ + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.create("projects/{project}"); + /** + * A PathTemplate representing the fully-qualified path to represent + * a subscription resource. + * + * + * + */ + private static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = + PathTemplate.create("projects/{project}/subscriptions/{subscription}"); + + // ======== + // Members + // ======== + + private final ManagedChannel channel; + private final List closeables = new ArrayList<>(); + + private final ApiCallable createSubscriptionCallable; + private final ApiCallable getSubscriptionCallable; + private final ApiCallable + listSubscriptionsCallable; + private final ApiCallable> + listSubscriptionsIterableCallable; + private final ApiCallable deleteSubscriptionCallable; + private final ApiCallable modifyAckDeadlineCallable; + private final ApiCallable acknowledgeCallable; + private final ApiCallable pullCallable; + private final ApiCallable modifyPushConfigCallable; + + // =============== + // Factory Methods + // =============== + + /** + * Constructs an instance of SubscriberSettings with default settings. + */ + public static SubscriberSettings newSettings() { + return SubscriberSettings.create(); + } + + /** + * Constructs an instance of SubscriberApi with default settings. + * + * + * + */ + public static SubscriberApi create() throws IOException { + return create(newSettings()); + } + + /** + * Constructs an instance of SubscriberApi, using the given settings. The channels are created based + * on the settings passed in, or defaults for any settings that are not set. + * + * + * + */ + public static SubscriberApi create(SubscriberSettings settings) throws IOException { + return new SubscriberApi(settings); + } + + /** + * Constructs an instance of SubscriberApi, using the given settings. This is protected so that it + * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * + * + * + */ + protected SubscriberApi(SubscriberSettings settings) throws IOException { + this.channel = settings.getChannel(); + + for (ApiCallSettings method : settings.allMethods()) { + if (method.getExecutor() == null) { + method.setExecutor(settings.getExecutor()); + } + } + + this.createSubscriptionCallable = settings.createSubscriptionMethod().build(settings); + this.getSubscriptionCallable = settings.getSubscriptionMethod().build(settings); + this.listSubscriptionsCallable = settings.listSubscriptionsMethod().build(settings); + this.listSubscriptionsIterableCallable = + settings.listSubscriptionsMethod().buildPageStreaming(settings); + this.deleteSubscriptionCallable = settings.deleteSubscriptionMethod().build(settings); + this.modifyAckDeadlineCallable = settings.modifyAckDeadlineMethod().build(settings); + this.acknowledgeCallable = settings.acknowledgeMethod().build(settings); + this.pullCallable = settings.pullMethod().build(settings); + this.modifyPushConfigCallable = settings.modifyPushConfigMethod().build(settings); + + closeables.add( + new Closeable() { + @Override + public void close() throws IOException { + channel.shutdown(); + } + }); + } + + // ============================== + // Resource Name Helper Functions + // ============================== + + /** + * Creates a string containing the fully-qualified path to represent + * a project resource. + * + * + * + */ + public static final String createProjectPath(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } + + /** + * Creates a string containing the fully-qualified path to represent + * a subscription resource. + * + * + * + */ + public static final String createSubscriptionPath(String project, String subscription) { + return SUBSCRIPTION_PATH_TEMPLATE.instantiate("project", project, "subscription", subscription); + } + + /** + * Extracts the project from the given fully-qualified path which + * represents a project resource. + * + * + * + */ + public static final String extractProjectFromProjectPath(String projectPath) { + return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); + } + + /** + * Extracts the project from the given fully-qualified path which + * represents a subscription resource. + * + * + * + */ + public static final String extractProjectFromSubscriptionPath(String subscriptionPath) { + return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("project"); + } + + /** + * Extracts the subscription from the given fully-qualified path which + * represents a subscription resource. + * + * + * + */ + public static final String extractSubscriptionFromSubscriptionPath(String subscriptionPath) { + return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("subscription"); + } + + // ============= + // Service Calls + // ============= + + // ----- createSubscription ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates a subscription to a given topic for a given subscriber. + * If the subscription already exists, generates `ALREADY_EXISTS`. + * If the corresponding topic doesn't exist, generates `NOT_FOUND`. + * + * If the name is not provided in the request, the server will assign a random + * name for this subscription on the same project as the topic. + * + * + * + * + * @param name The name of the subscription. It must have the format + * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must + * start with a letter, and contain only letters (`[A-Za-z]`), numbers + * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), + * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters + * in length, and it must not start with `"goog"`. + * @param topic The name of the topic from which this subscription is receiving messages. + * @param pushConfig If push delivery is used with this subscription, this field is + * used to configure it. An empty `pushConfig` signifies that the subscriber + * will pull and ack messages using API methods. + * @param ackDeadlineSeconds This value is the maximum time after a subscriber receives a message + * before the subscriber should acknowledge the message. After message + * delivery but before the ack deadline expires and before the message is + * acknowledged, it is an outstanding message and will not be delivered + * again during that time (on a best-effort basis). + * + * For pull subscriptions, this value is used as the initial value for the ack + * deadline. To override this value for a given message, call + * `ModifyAckDeadline` with the corresponding `ack_id` if using + * pull. + * + * For push delivery, this value is also used to set the request timeout for + * the call to the push endpoint. + * + * If the subscriber never acknowledges the message, the Pub/Sub + * system will eventually redeliver the message. + * + * If this parameter is not set, the default value of 10 seconds is used. + */ + public Subscription createSubscription( + String name, String topic, PushConfig pushConfig, int ackDeadlineSeconds) { + Subscription request = + Subscription.newBuilder() + .setName(name) + .setTopic(topic) + .setPushConfig(pushConfig) + .setAckDeadlineSeconds(ackDeadlineSeconds) + .build(); + + return createSubscription(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates a subscription to a given topic for a given subscriber. + * If the subscription already exists, generates `ALREADY_EXISTS`. + * If the corresponding topic doesn't exist, generates `NOT_FOUND`. + * + * If the name is not provided in the request, the server will assign a random + * name for this subscription on the same project as the topic. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public Subscription createSubscription(Subscription request) { + return createSubscriptionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Creates a subscription to a given topic for a given subscriber. + * If the subscription already exists, generates `ALREADY_EXISTS`. + * If the corresponding topic doesn't exist, generates `NOT_FOUND`. + * + * If the name is not provided in the request, the server will assign a random + * name for this subscription on the same project as the topic. + * + * + * + */ + public ApiCallable createSubscriptionCallable() { + return createSubscriptionCallable; + } + + // ----- getSubscription ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration details of a subscription. + * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * + * + * + * + * @param subscription The name of the subscription to get. + */ + public Subscription getSubscription(String subscription) { + GetSubscriptionRequest request = + GetSubscriptionRequest.newBuilder().setSubscription(subscription).build(); + + return getSubscription(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration details of a subscription. + * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public Subscription getSubscription(GetSubscriptionRequest request) { + return getSubscriptionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Gets the configuration details of a subscription. + * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * + * + * + */ + public ApiCallable getSubscriptionCallable() { + return getSubscriptionCallable; + } + + // ----- listSubscriptions ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching subscriptions. + * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * + * + * + */ + public Iterable listSubscriptions(String project) { + ListSubscriptionsRequest request = + ListSubscriptionsRequest.newBuilder().setProject(project).build(); + return listSubscriptions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching subscriptions. + * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public Iterable listSubscriptions(ListSubscriptionsRequest request) { + return listSubscriptionsIterableCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching subscriptions. + * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * + * + * + */ + public ApiCallable> + listSubscriptionsIterableCallable() { + return listSubscriptionsIterableCallable; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Lists matching subscriptions. + * + * If the topic of a subscription has been deleted, the subscription itself is + * not deleted, but the value of the `topic` field is set to `_deleted-topic_`. + * + * + * + */ + public ApiCallable + listSubscriptionsCallable() { + return listSubscriptionsCallable; + } + + // ----- deleteSubscription ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes an existing subscription. All pending messages in the subscription + * are immediately dropped. Calls to `Pull` after deletion will generate + * `NOT_FOUND`. After a subscription is deleted, a new one may be created with + * the same name, but the new one has no association with the old + * subscription, or its topic unless the same topic is specified. + * + * + * + * + * @param subscription The subscription to delete. + */ + public void deleteSubscription(String subscription) { + DeleteSubscriptionRequest request = + DeleteSubscriptionRequest.newBuilder().setSubscription(subscription).build(); + + deleteSubscription(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes an existing subscription. All pending messages in the subscription + * are immediately dropped. Calls to `Pull` after deletion will generate + * `NOT_FOUND`. After a subscription is deleted, a new one may be created with + * the same name, but the new one has no association with the old + * subscription, or its topic unless the same topic is specified. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public void deleteSubscription(DeleteSubscriptionRequest request) { + deleteSubscriptionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Deletes an existing subscription. All pending messages in the subscription + * are immediately dropped. Calls to `Pull` after deletion will generate + * `NOT_FOUND`. After a subscription is deleted, a new one may be created with + * the same name, but the new one has no association with the old + * subscription, or its topic unless the same topic is specified. + * + * + * + */ + public ApiCallable deleteSubscriptionCallable() { + return deleteSubscriptionCallable; + } + + // ----- modifyAckDeadline ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the ack deadline for a specific message. This method is useful + * to indicate that more time is needed to process a message by the + * subscriber, or to make the message available for redelivery if the + * processing was interrupted. + * + * + * + * + * @param subscription The name of the subscription. + * @param ackIds List of acknowledgment IDs. + * @param ackDeadlineSeconds The new ack deadline with respect to the time this request was sent to + * the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new + * ack deadline will expire 10 seconds after the `ModifyAckDeadline` call + * was made. Specifying zero may immediately make the message available for + * another pull request. + */ + public void modifyAckDeadline(String subscription, List ackIds, int ackDeadlineSeconds) { + ModifyAckDeadlineRequest request = + ModifyAckDeadlineRequest.newBuilder() + .setSubscription(subscription) + .addAllAckIds(ackIds) + .setAckDeadlineSeconds(ackDeadlineSeconds) + .build(); + + modifyAckDeadline(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the ack deadline for a specific message. This method is useful + * to indicate that more time is needed to process a message by the + * subscriber, or to make the message available for redelivery if the + * processing was interrupted. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public void modifyAckDeadline(ModifyAckDeadlineRequest request) { + modifyAckDeadlineCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the ack deadline for a specific message. This method is useful + * to indicate that more time is needed to process a message by the + * subscriber, or to make the message available for redelivery if the + * processing was interrupted. + * + * + * + */ + public ApiCallable modifyAckDeadlineCallable() { + return modifyAckDeadlineCallable; + } + + // ----- acknowledge ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Acknowledges the messages associated with the `ack_ids` in the + * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages + * from the subscription. + * + * Acknowledging a message whose ack deadline has expired may succeed, + * but such a message may be redelivered later. Acknowledging a message more + * than once will not result in an error. + * + * + * + * + * @param subscription The subscription whose message is being acknowledged. + * @param ackIds The acknowledgment ID for the messages being acknowledged that was returned + * by the Pub/Sub system in the `Pull` response. Must not be empty. + */ + public void acknowledge(String subscription, List ackIds) { + AcknowledgeRequest request = + AcknowledgeRequest.newBuilder().setSubscription(subscription).addAllAckIds(ackIds).build(); + + acknowledge(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Acknowledges the messages associated with the `ack_ids` in the + * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages + * from the subscription. + * + * Acknowledging a message whose ack deadline has expired may succeed, + * but such a message may be redelivered later. Acknowledging a message more + * than once will not result in an error. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public void acknowledge(AcknowledgeRequest request) { + acknowledgeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Acknowledges the messages associated with the `ack_ids` in the + * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages + * from the subscription. + * + * Acknowledging a message whose ack deadline has expired may succeed, + * but such a message may be redelivered later. Acknowledging a message more + * than once will not result in an error. + * + * + * + */ + public ApiCallable acknowledgeCallable() { + return acknowledgeCallable; + } + + // ----- pull ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Pulls messages from the server. Returns an empty list if there are no + * messages available in the backlog. The server may generate `UNAVAILABLE` if + * there are too many concurrent pull requests pending for the given + * subscription. + * + * + * + * + * @param subscription The subscription from which messages should be pulled. + * @param returnImmediately If this is specified as true the system will respond immediately even if + * it is not able to return a message in the `Pull` response. Otherwise the + * system is allowed to wait until at least one message is available rather + * than returning no messages. + * @param maxMessages The maximum number of messages returned for this request. The Pub/Sub + * system may return fewer than the number specified. + */ + public PullResponse pull(String subscription, boolean returnImmediately, int maxMessages) { + PullRequest request = + PullRequest.newBuilder() + .setSubscription(subscription) + .setReturnImmediately(returnImmediately) + .setMaxMessages(maxMessages) + .build(); + + return pull(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Pulls messages from the server. Returns an empty list if there are no + * messages available in the backlog. The server may generate `UNAVAILABLE` if + * there are too many concurrent pull requests pending for the given + * subscription. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public PullResponse pull(PullRequest request) { + return pullCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Pulls messages from the server. Returns an empty list if there are no + * messages available in the backlog. The server may generate `UNAVAILABLE` if + * there are too many concurrent pull requests pending for the given + * subscription. + * + * + * + */ + public ApiCallable pullCallable() { + return pullCallable; + } + + // ----- modifyPushConfig ----- + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the `PushConfig` for a specified subscription. + * + * This may be used to change a push subscription to a pull one (signified by + * an empty `PushConfig`) or vice versa, or change the endpoint URL and other + * attributes of a push subscription. Messages will accumulate for delivery + * continuously through the call regardless of changes to the `PushConfig`. + * + * + * + * + * @param subscription The name of the subscription. + * @param pushConfig The push configuration for future deliveries. + * + * An empty `pushConfig` indicates that the Pub/Sub system should + * stop pushing messages from the given subscription and allow + * messages to be pulled and acknowledged - effectively pausing + * the subscription if `Pull` is not called. + */ + public void modifyPushConfig(String subscription, PushConfig pushConfig) { + ModifyPushConfigRequest request = + ModifyPushConfigRequest.newBuilder() + .setSubscription(subscription) + .setPushConfig(pushConfig) + .build(); + + modifyPushConfig(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the `PushConfig` for a specified subscription. + * + * This may be used to change a push subscription to a pull one (signified by + * an empty `PushConfig`) or vice versa, or change the endpoint URL and other + * attributes of a push subscription. Messages will accumulate for delivery + * continuously through the call regardless of changes to the `PushConfig`. + * + * + * + * + * @param request The request object containing all of the parameters for the API call. + */ + public void modifyPushConfig(ModifyPushConfigRequest request) { + modifyPushConfigCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. + /** + * Modifies the `PushConfig` for a specified subscription. + * + * This may be used to change a push subscription to a pull one (signified by + * an empty `PushConfig`) or vice versa, or change the endpoint URL and other + * attributes of a push subscription. Messages will accumulate for delivery + * continuously through the call regardless of changes to the `PushConfig`. + * + * + * + */ + public ApiCallable modifyPushConfigCallable() { + return modifyPushConfigCallable; + } + + // ======== + // Cleanup + // ======== + + /** + * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately + * cancelled. + * + * + * + */ + @Override + public void close() { + // Manually-added shutdown code + + // Auto-generated shutdown code + channel.shutdown(); + + // Manually-added shutdown code + } + + // ======== + // Manually-added methods: add custom (non-generated) methods after this point. + // ======== + +} diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java new file mode 100644 index 000000000000..0d78a4b45fb8 --- /dev/null +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java @@ -0,0 +1,336 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google engineers. + * Manual additions are allowed because the refresh process performs + * a 3-way merge in order to preserve those manual additions. In order to not + * break the refresh process, only certain types of modifications are + * allowed. + * + * Allowed modifications - currently these are the only types allowed: + * 1. New methods (these should be added to the end of the class) + * 2. New imports + * 3. Additional documentation between "manual edit" demarcations + * + * Happy editing! + */ + +package com.google.gcloud.pubsub.spi; + +import com.google.api.gax.core.BackoffParams; +import com.google.api.gax.core.ConnectionSettings; +import com.google.api.gax.core.RetryParams; +import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; +import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; +import com.google.api.gax.grpc.PageDescriptor; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import com.google.protobuf.Empty; +import com.google.pubsub.v1.AcknowledgeRequest; +import com.google.pubsub.v1.DeleteSubscriptionRequest; +import com.google.pubsub.v1.GetSubscriptionRequest; +import com.google.pubsub.v1.ListSubscriptionsRequest; +import com.google.pubsub.v1.ListSubscriptionsResponse; +import com.google.pubsub.v1.ModifyAckDeadlineRequest; +import com.google.pubsub.v1.ModifyPushConfigRequest; +import com.google.pubsub.v1.PullRequest; +import com.google.pubsub.v1.PullResponse; +import com.google.pubsub.v1.SubscriberGrpc; +import com.google.pubsub.v1.Subscription; +import io.grpc.Status; + +// Manually-added imports: add custom (non-generated) imports after this point. + +// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing. +@javax.annotation.Generated("by GAPIC") +public class SubscriberSettings extends ApiCallSettings { + + // ========= + // Constants + // ========= + + /** + * The default address of the service. + * + * + * + */ + public static final String DEFAULT_SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; + + /** + * The default port of the service. + * + * + * + */ + public static final int DEFAULT_SERVICE_PORT = 443; + + /** + * The default scopes of the service. + */ + public static ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder() + .add("https://www.googleapis.com/auth/pubsub") + .add("https://www.googleapis.com/auth/cloud-platform") + .build(); + + private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = ImmutableMap.builder(); + definitions.put( + "idempotent", + Sets.immutableEnumSet( + Lists.newArrayList( + Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE))); + definitions.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetryParams params = null; + params = + RetryParams.newBuilder() + .setRetryBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(100L) + .setDelayMultiplier(1.2) + .setMaxDelayMillis(1000L) + .build()) + .setTimeoutBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(300L) + .setDelayMultiplier(1.3) + .setMaxDelayMillis(3000L) + .build()) + .setTotalTimeout(30000L) + .build(); + definitions.put("default", params); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + private final ApiCallableBuilder createSubscriptionMethod; + private final ApiCallableBuilder getSubscriptionMethod; + private final PageStreamingApiCallableBuilder< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> + listSubscriptionsMethod; + private final ApiCallableBuilder deleteSubscriptionMethod; + private final ApiCallableBuilder modifyAckDeadlineMethod; + private final ApiCallableBuilder acknowledgeMethod; + private final ApiCallableBuilder pullMethod; + private final ApiCallableBuilder modifyPushConfigMethod; + private final ImmutableList allMethods; + + // =============== + // Factory Methods + // =============== + + /** + * Constructs an instance of SubscriberSettings with default settings. + * + * + * + */ + public static SubscriberSettings create() { + SubscriberSettings settings = new SubscriberSettings(); + settings.provideChannelWith( + ConnectionSettings.builder() + .setServiceAddress(DEFAULT_SERVICE_ADDRESS) + .setPort(DEFAULT_SERVICE_PORT) + .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) + .build()); + return settings; + } + + /** + * Constructs an instance of SubscriberSettings with default settings. This is protected so that it + * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * + * + * + */ + protected SubscriberSettings() { + createSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); + createSubscriptionMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + getSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); + getSubscriptionMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + listSubscriptionsMethod = + new PageStreamingApiCallableBuilder<>( + SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS, LIST_SUBSCRIPTIONS_PAGE_STR_DESC); + listSubscriptionsMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + deleteSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); + deleteSubscriptionMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + modifyAckDeadlineMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); + modifyAckDeadlineMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + acknowledgeMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_ACKNOWLEDGE); + acknowledgeMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + pullMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_PULL); + pullMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + modifyPushConfigMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); + modifyPushConfigMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + allMethods = + ImmutableList.builder() + .add( + createSubscriptionMethod, + getSubscriptionMethod, + listSubscriptionsMethod, + deleteSubscriptionMethod, + modifyAckDeadlineMethod, + acknowledgeMethod, + pullMethod, + modifyPushConfigMethod) + .build(); + } + + /** + * Returns the ApiCallableBuilder for the API method createSubscription. + * + * + * + */ + public ApiCallableBuilder createSubscriptionMethod() { + return createSubscriptionMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method getSubscription. + * + * + * + */ + public ApiCallableBuilder getSubscriptionMethod() { + return getSubscriptionMethod; + } + + /** + * Returns the PageStreamingApiCallableBuilder for the API method listSubscriptions. + * + * + * + */ + public PageStreamingApiCallableBuilder< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> + listSubscriptionsMethod() { + return listSubscriptionsMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method deleteSubscription. + * + * + * + */ + public ApiCallableBuilder deleteSubscriptionMethod() { + return deleteSubscriptionMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method modifyAckDeadline. + * + * + * + */ + public ApiCallableBuilder modifyAckDeadlineMethod() { + return modifyAckDeadlineMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method acknowledge. + * + * + * + */ + public ApiCallableBuilder acknowledgeMethod() { + return acknowledgeMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method pull. + * + * + * + */ + public ApiCallableBuilder pullMethod() { + return pullMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method modifyPushConfig. + * + * + * + */ + public ApiCallableBuilder modifyPushConfigMethod() { + return modifyPushConfigMethod; + } + + public ImmutableList allMethods() { + return allMethods; + } + + private static PageDescriptor + LIST_SUBSCRIPTIONS_PAGE_STR_DESC = + new PageDescriptor() { + @Override + public Object emptyToken() { + return ""; + } + + @Override + public ListSubscriptionsRequest injectToken( + ListSubscriptionsRequest payload, Object token) { + return ListSubscriptionsRequest.newBuilder(payload) + .setPageToken((String) token) + .build(); + } + + @Override + public Object extractNextToken(ListSubscriptionsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListSubscriptionsResponse payload) { + return payload.getSubscriptionsList(); + } + }; +} diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index d8a1f905633e..fb81bdbfa618 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -19,7 +19,7 @@ com.google.api gax - 0.0.2 + 0.0.3-SNAPSHOT com.google.api.grpc diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index 98ff96ce61dd..f7011dcd0240 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -30,21 +30,12 @@ * * Happy editing! */ + package com.google.gcloud.pubsub.spi; -import com.google.api.gax.core.BackoffParams; -import com.google.api.gax.core.ConnectionSettings; -import com.google.api.gax.core.RetryParams; +import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; -import com.google.api.gax.grpc.PageDescriptor; -import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.protobuf.PathTemplate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.google.protobuf.Empty; import com.google.pubsub.v1.DeleteTopicRequest; import com.google.pubsub.v1.GetTopicRequest; @@ -54,16 +45,13 @@ import com.google.pubsub.v1.ListTopicsResponse; import com.google.pubsub.v1.PublishRequest; import com.google.pubsub.v1.PublishResponse; -import com.google.pubsub.v1.PublisherGrpc; import com.google.pubsub.v1.PubsubMessage; import com.google.pubsub.v1.Topic; import io.grpc.ManagedChannel; -import io.grpc.Status; +import java.io.Closeable; import java.io.IOException; -import java.util.EnumMap; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; // Manually-added imports: add custom (non-generated) imports after this point. @@ -75,183 +63,13 @@ * * */ -@javax.annotation.Generated("by the veneer generator") +@javax.annotation.Generated("by GAPIC") public class PublisherApi implements AutoCloseable { - public enum MethodIdentifier { - CREATE_TOPIC, - PUBLISH, - GET_TOPIC, - LIST_TOPICS, - LIST_TOPIC_SUBSCRIPTIONS, - DELETE_TOPIC - } - // ========= // Constants // ========= - /** - * The default address of the service. - * - * - * - */ - public static final String DEFAULT_SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; - - /** - * The default port of the service. - * - * - * - */ - public static final int DEFAULT_SERVICE_PORT = 443; - - /** - * The default scopes of the service. - */ - public static ImmutableList DEFAULT_SERVICE_SCOPES = - ImmutableList.builder() - .add("https://www.googleapis.com/auth/pubsub") - .add("https://www.googleapis.com/auth/cloud-platform") - .build(); - - /** - * The default settings for the service. - */ - public static ServiceApiSettings DEFAULT_SETTINGS = - ServiceApiSettings.builder() - .provideChannelWith( - ConnectionSettings.builder() - .setServiceAddress(DEFAULT_SERVICE_ADDRESS) - .setPort(DEFAULT_SERVICE_PORT) - .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) - .build()) - .build(); - - private static final ImmutableMap> - DEFAULT_RETRY_CONFIG; - - static { - Map> definition = new HashMap<>(); - definition.put( - "idempotent", - Sets.immutableEnumSet( - Lists.newArrayList( - Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE))); - definition.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList())); - - Map> retryableCodes = - new EnumMap<>(MethodIdentifier.class); - retryableCodes.put(MethodIdentifier.CREATE_TOPIC, definition.get("idempotent")); - retryableCodes.put(MethodIdentifier.PUBLISH, definition.get("non_idempotent")); - retryableCodes.put(MethodIdentifier.GET_TOPIC, definition.get("idempotent")); - retryableCodes.put(MethodIdentifier.LIST_TOPICS, definition.get("idempotent")); - retryableCodes.put(MethodIdentifier.LIST_TOPIC_SUBSCRIPTIONS, definition.get("idempotent")); - retryableCodes.put(MethodIdentifier.DELETE_TOPIC, definition.get("idempotent")); - DEFAULT_RETRY_CONFIG = - Maps.>immutableEnumMap(retryableCodes); - } - - private static final ImmutableMap DEFAULT_RETRY_PARAMS; - - static { - Map definition = new HashMap<>(); - RetryParams params = null; - params = - RetryParams.newBuilder() - .setRetryBackoff( - BackoffParams.newBuilder() - .setInitialDelayMillis(100L) - .setDelayMultiplier(1.2) - .setMaxDelayMillis(1000L) - .build()) - .setTimeoutBackoff( - BackoffParams.newBuilder() - .setInitialDelayMillis(300L) - .setDelayMultiplier(1.3) - .setMaxDelayMillis(3000L) - .build()) - .setTotalTimeout(30000L) - .build(); - definition.put("default", params); - - Map retryParams = new EnumMap<>(MethodIdentifier.class); - retryParams.put(MethodIdentifier.CREATE_TOPIC, definition.get("default")); - retryParams.put(MethodIdentifier.PUBLISH, definition.get("default")); - retryParams.put(MethodIdentifier.GET_TOPIC, definition.get("default")); - retryParams.put(MethodIdentifier.LIST_TOPICS, definition.get("default")); - retryParams.put(MethodIdentifier.LIST_TOPIC_SUBSCRIPTIONS, definition.get("default")); - retryParams.put(MethodIdentifier.DELETE_TOPIC, definition.get("default")); - DEFAULT_RETRY_PARAMS = Maps.immutableEnumMap(retryParams); - } - - private static final ApiCallable CREATE_TOPIC = - ApiCallable.create(PublisherGrpc.METHOD_CREATE_TOPIC); - private static final ApiCallable PUBLISH = - ApiCallable.create(PublisherGrpc.METHOD_PUBLISH); - private static final ApiCallable GET_TOPIC = - ApiCallable.create(PublisherGrpc.METHOD_GET_TOPIC); - private static final ApiCallable LIST_TOPICS = - ApiCallable.create(PublisherGrpc.METHOD_LIST_TOPICS); - private static final ApiCallable - LIST_TOPIC_SUBSCRIPTIONS = ApiCallable.create(PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS); - private static final ApiCallable DELETE_TOPIC = - ApiCallable.create(PublisherGrpc.METHOD_DELETE_TOPIC); - - private static PageDescriptor - LIST_TOPICS_PAGE_DESC = - new PageDescriptor() { - @Override - public Object emptyToken() { - return ""; - } - - @Override - public ListTopicsRequest injectToken(ListTopicsRequest payload, Object token) { - return ListTopicsRequest.newBuilder(payload).setPageToken((String) token).build(); - } - - @Override - public Object extractNextToken(ListTopicsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListTopicsResponse payload) { - return payload.getTopicsList(); - } - }; - - private static PageDescriptor< - ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> - LIST_TOPIC_SUBSCRIPTIONS_PAGE_DESC = - new PageDescriptor< - ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>() { - @Override - public Object emptyToken() { - return ""; - } - - @Override - public ListTopicSubscriptionsRequest injectToken( - ListTopicSubscriptionsRequest payload, Object token) { - return ListTopicSubscriptionsRequest.newBuilder(payload) - .setPageToken((String) token) - .build(); - } - - @Override - public Object extractNextToken(ListTopicSubscriptionsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListTopicSubscriptionsResponse payload) { - return payload.getSubscriptionsList(); - } - }; - /** * A PathTemplate representing the fully-qualified path to represent * a project resource. @@ -276,14 +94,30 @@ public Iterable extractResources(ListTopicSubscriptionsResponse payload) // ======== private final ManagedChannel channel; - private final ServiceApiSettings settings; - private final ImmutableMap> retryCodesConfig; - private final ImmutableMap retryParamsConfig; + private final List closeables = new ArrayList<>(); + + private final ApiCallable createTopicCallable; + private final ApiCallable publishCallable; + private final ApiCallable getTopicCallable; + private final ApiCallable listTopicsCallable; + private final ApiCallable> listTopicsIterableCallable; + private final ApiCallable + listTopicSubscriptionsCallable; + private final ApiCallable> + listTopicSubscriptionsIterableCallable; + private final ApiCallable deleteTopicCallable; // =============== // Factory Methods // =============== + /** + * Constructs an instance of PublisherSettings with default settings. + */ + public static PublisherSettings newSettings() { + return PublisherSettings.create(); + } + /** * Constructs an instance of PublisherApi with default settings. * @@ -291,7 +125,7 @@ public Iterable extractResources(ListTopicSubscriptionsResponse payload) * */ public static PublisherApi create() throws IOException { - return create(DEFAULT_SETTINGS); + return create(newSettings()); } /** @@ -301,8 +135,7 @@ public static PublisherApi create() throws IOException { * * */ - public static PublisherApi create(ServiceApiSettings settings) - throws IOException { + public static PublisherApi create(PublisherSettings settings) throws IOException { return new PublisherApi(settings); } @@ -313,20 +146,32 @@ public static PublisherApi create(ServiceApiSettings settings) * * */ - protected PublisherApi(ServiceApiSettings settings) throws IOException { - this.settings = settings; + protected PublisherApi(PublisherSettings settings) throws IOException { this.channel = settings.getChannel(); - Map> retryCodesConfig = - new EnumMap<>(DEFAULT_RETRY_CONFIG); - retryCodesConfig.putAll(settings.getRetryableCodes()); - this.retryCodesConfig = - Maps.>immutableEnumMap(retryCodesConfig); - - Map retryParamsConfig = new EnumMap<>(DEFAULT_RETRY_PARAMS); - retryParamsConfig.putAll(settings.getRetryParams()); - this.retryParamsConfig = - Maps.immutableEnumMap(retryParamsConfig); + for (ApiCallSettings method : settings.allMethods()) { + if (method.getExecutor() == null) { + method.setExecutor(settings.getExecutor()); + } + } + + this.createTopicCallable = settings.createTopicMethod().build(settings); + this.publishCallable = settings.publishMethod().build(settings); + this.getTopicCallable = settings.getTopicMethod().build(settings); + this.listTopicsCallable = settings.listTopicsMethod().build(settings); + this.listTopicsIterableCallable = settings.listTopicsMethod().buildPageStreaming(settings); + this.listTopicSubscriptionsCallable = settings.listTopicSubscriptionsMethod().build(settings); + this.listTopicSubscriptionsIterableCallable = + settings.listTopicSubscriptionsMethod().buildPageStreaming(settings); + this.deleteTopicCallable = settings.deleteTopicMethod().build(settings); + + closeables.add( + new Closeable() { + @Override + public void close() throws IOException { + channel.shutdown(); + } + }); } // ============================== @@ -435,12 +280,7 @@ public Topic createTopic(Topic request) { * */ public ApiCallable createTopicCallable() { - ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.CREATE_TOPIC); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.CREATE_TOPIC); - return CREATE_TOPIC - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return createTopicCallable; } // ----- publish ----- @@ -489,12 +329,7 @@ public PublishResponse publish(PublishRequest request) { * */ public ApiCallable publishCallable() { - ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.PUBLISH); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.PUBLISH); - return PUBLISH - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return publishCallable; } // ----- getTopic ----- @@ -535,12 +370,7 @@ public Topic getTopic(GetTopicRequest request) { * */ public ApiCallable getTopicCallable() { - ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.GET_TOPIC); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.GET_TOPIC); - return GET_TOPIC - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return getTopicCallable; } // ----- listTopics ----- @@ -567,7 +397,7 @@ public Iterable listTopics(String project) { * @param request The request object containing all of the parameters for the API call. */ public Iterable listTopics(ListTopicsRequest request) { - return listTopicsStreamingCallable().call(request); + return listTopicsIterableCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. @@ -577,8 +407,8 @@ public Iterable listTopics(ListTopicsRequest request) { * * */ - public ApiCallable> listTopicsStreamingCallable() { - return listTopicsCallable().pageStreaming(LIST_TOPICS_PAGE_DESC); + public ApiCallable> listTopicsIterableCallable() { + return listTopicsIterableCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. @@ -589,12 +419,7 @@ public ApiCallable> listTopicsStreamingCallab * */ public ApiCallable listTopicsCallable() { - ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.LIST_TOPICS); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.LIST_TOPICS); - return LIST_TOPICS - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return listTopicsCallable; } // ----- listTopicSubscriptions ----- @@ -622,7 +447,7 @@ public Iterable listTopicSubscriptions(String topic) { * @param request The request object containing all of the parameters for the API call. */ public Iterable listTopicSubscriptions(ListTopicSubscriptionsRequest request) { - return listTopicSubscriptionsStreamingCallable().call(request); + return listTopicSubscriptionsIterableCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. @@ -633,8 +458,8 @@ public Iterable listTopicSubscriptions(ListTopicSubscriptionsRequest req * */ public ApiCallable> - listTopicSubscriptionsStreamingCallable() { - return listTopicSubscriptionsCallable().pageStreaming(LIST_TOPIC_SUBSCRIPTIONS_PAGE_DESC); + listTopicSubscriptionsIterableCallable() { + return listTopicSubscriptionsIterableCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. @@ -646,13 +471,7 @@ public Iterable listTopicSubscriptions(ListTopicSubscriptionsRequest req */ public ApiCallable listTopicSubscriptionsCallable() { - ImmutableSet retryableCodes = - retryCodesConfig.get(MethodIdentifier.LIST_TOPIC_SUBSCRIPTIONS); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.LIST_TOPIC_SUBSCRIPTIONS); - return LIST_TOPIC_SUBSCRIPTIONS - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return listTopicSubscriptionsCallable; } // ----- deleteTopic ----- @@ -705,12 +524,7 @@ public void deleteTopic(DeleteTopicRequest request) { * */ public ApiCallable deleteTopicCallable() { - ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.DELETE_TOPIC); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.DELETE_TOPIC); - return DELETE_TOPIC - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return deleteTopicCallable; } // ======== diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java new file mode 100644 index 000000000000..b1985fc40b53 --- /dev/null +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java @@ -0,0 +1,333 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google engineers. + * Manual additions are allowed because the refresh process performs + * a 3-way merge in order to preserve those manual additions. In order to not + * break the refresh process, only certain types of modifications are + * allowed. + * + * Allowed modifications - currently these are the only types allowed: + * 1. New methods (these should be added to the end of the class) + * 2. New imports + * 3. Additional documentation between "manual edit" demarcations + * + * Happy editing! + */ + +package com.google.gcloud.pubsub.spi; + +import com.google.api.gax.core.BackoffParams; +import com.google.api.gax.core.ConnectionSettings; +import com.google.api.gax.core.RetryParams; +import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; +import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; +import com.google.api.gax.grpc.PageDescriptor; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import com.google.protobuf.Empty; +import com.google.pubsub.v1.DeleteTopicRequest; +import com.google.pubsub.v1.GetTopicRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsResponse; +import com.google.pubsub.v1.ListTopicsRequest; +import com.google.pubsub.v1.ListTopicsResponse; +import com.google.pubsub.v1.PublishRequest; +import com.google.pubsub.v1.PublishResponse; +import com.google.pubsub.v1.PublisherGrpc; +import com.google.pubsub.v1.Topic; +import io.grpc.Status; + +// Manually-added imports: add custom (non-generated) imports after this point. + +// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing. +@javax.annotation.Generated("by GAPIC") +public class PublisherSettings extends ApiCallSettings { + + // ========= + // Constants + // ========= + + /** + * The default address of the service. + * + * + * + */ + public static final String DEFAULT_SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; + + /** + * The default port of the service. + * + * + * + */ + public static final int DEFAULT_SERVICE_PORT = 443; + + /** + * The default scopes of the service. + */ + public static ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder() + .add("https://www.googleapis.com/auth/pubsub") + .add("https://www.googleapis.com/auth/cloud-platform") + .build(); + + private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = ImmutableMap.builder(); + definitions.put( + "idempotent", + Sets.immutableEnumSet( + Lists.newArrayList( + Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE))); + definitions.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetryParams params = null; + params = + RetryParams.newBuilder() + .setRetryBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(100L) + .setDelayMultiplier(1.2) + .setMaxDelayMillis(1000L) + .build()) + .setTimeoutBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(300L) + .setDelayMultiplier(1.3) + .setMaxDelayMillis(3000L) + .build()) + .setTotalTimeout(30000L) + .build(); + definitions.put("default", params); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + private final ApiCallableBuilder createTopicMethod; + private final ApiCallableBuilder publishMethod; + private final ApiCallableBuilder getTopicMethod; + private final PageStreamingApiCallableBuilder + listTopicsMethod; + private final PageStreamingApiCallableBuilder< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + listTopicSubscriptionsMethod; + private final ApiCallableBuilder deleteTopicMethod; + private final ImmutableList allMethods; + + // =============== + // Factory Methods + // =============== + + /** + * Constructs an instance of PublisherSettings with default settings. + * + * + * + */ + public static PublisherSettings create() { + PublisherSettings settings = new PublisherSettings(); + settings.provideChannelWith( + ConnectionSettings.builder() + .setServiceAddress(DEFAULT_SERVICE_ADDRESS) + .setPort(DEFAULT_SERVICE_PORT) + .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) + .build()); + return settings; + } + + /** + * Constructs an instance of PublisherSettings with default settings. This is protected so that it + * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * + * + * + */ + protected PublisherSettings() { + createTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_CREATE_TOPIC); + createTopicMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH); + publishMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + getTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_GET_TOPIC); + getTopicMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + listTopicsMethod = + new PageStreamingApiCallableBuilder<>( + PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC); + listTopicsMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + listTopicSubscriptionsMethod = + new PageStreamingApiCallableBuilder<>( + PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS, LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC); + listTopicSubscriptionsMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + deleteTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_DELETE_TOPIC); + deleteTopicMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + allMethods = + ImmutableList.builder() + .add( + createTopicMethod, + publishMethod, + getTopicMethod, + listTopicsMethod, + listTopicSubscriptionsMethod, + deleteTopicMethod) + .build(); + } + + /** + * Returns the ApiCallableBuilder for the API method createTopic. + * + * + * + */ + public ApiCallableBuilder createTopicMethod() { + return createTopicMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method publish. + * + * + * + */ + public ApiCallableBuilder publishMethod() { + return publishMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method getTopic. + * + * + * + */ + public ApiCallableBuilder getTopicMethod() { + return getTopicMethod; + } + + /** + * Returns the PageStreamingApiCallableBuilder for the API method listTopics. + * + * + * + */ + public PageStreamingApiCallableBuilder + listTopicsMethod() { + return listTopicsMethod; + } + + /** + * Returns the PageStreamingApiCallableBuilder for the API method listTopicSubscriptions. + * + * + * + */ + public PageStreamingApiCallableBuilder< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + listTopicSubscriptionsMethod() { + return listTopicSubscriptionsMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method deleteTopic. + * + * + * + */ + public ApiCallableBuilder deleteTopicMethod() { + return deleteTopicMethod; + } + + public ImmutableList allMethods() { + return allMethods; + } + + private static PageDescriptor + LIST_TOPICS_PAGE_STR_DESC = + new PageDescriptor() { + @Override + public Object emptyToken() { + return ""; + } + + @Override + public ListTopicsRequest injectToken(ListTopicsRequest payload, Object token) { + return ListTopicsRequest.newBuilder(payload).setPageToken((String) token).build(); + } + + @Override + public Object extractNextToken(ListTopicsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListTopicsResponse payload) { + return payload.getTopicsList(); + } + }; + + private static PageDescriptor< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC = + new PageDescriptor< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>() { + @Override + public Object emptyToken() { + return ""; + } + + @Override + public ListTopicSubscriptionsRequest injectToken( + ListTopicSubscriptionsRequest payload, Object token) { + return ListTopicSubscriptionsRequest.newBuilder(payload) + .setPageToken((String) token) + .build(); + } + + @Override + public Object extractNextToken(ListTopicSubscriptionsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListTopicSubscriptionsResponse payload) { + return payload.getSubscriptionsList(); + } + }; +} diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index 39f7a786e474..c50e6b6aaaed 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -30,21 +30,12 @@ * * Happy editing! */ + package com.google.gcloud.pubsub.spi; -import com.google.api.gax.core.BackoffParams; -import com.google.api.gax.core.ConnectionSettings; -import com.google.api.gax.core.RetryParams; +import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; -import com.google.api.gax.grpc.PageDescriptor; -import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.protobuf.PathTemplate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.google.protobuf.Empty; import com.google.pubsub.v1.AcknowledgeRequest; import com.google.pubsub.v1.DeleteSubscriptionRequest; @@ -56,15 +47,12 @@ import com.google.pubsub.v1.PullRequest; import com.google.pubsub.v1.PullResponse; import com.google.pubsub.v1.PushConfig; -import com.google.pubsub.v1.SubscriberGrpc; import com.google.pubsub.v1.Subscription; import io.grpc.ManagedChannel; -import io.grpc.Status; +import java.io.Closeable; import java.io.IOException; -import java.util.EnumMap; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; // Manually-added imports: add custom (non-generated) imports after this point. @@ -76,167 +64,13 @@ * * */ -@javax.annotation.Generated("by the veneer generator") +@javax.annotation.Generated("by GAPIC") public class SubscriberApi implements AutoCloseable { - public enum MethodIdentifier { - CREATE_SUBSCRIPTION, - GET_SUBSCRIPTION, - LIST_SUBSCRIPTIONS, - DELETE_SUBSCRIPTION, - MODIFY_ACK_DEADLINE, - ACKNOWLEDGE, - PULL, - MODIFY_PUSH_CONFIG - } - // ========= // Constants // ========= - /** - * The default address of the service. - * - * - * - */ - public static final String DEFAULT_SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; - - /** - * The default port of the service. - * - * - * - */ - public static final int DEFAULT_SERVICE_PORT = 443; - - /** - * The default scopes of the service. - */ - public static ImmutableList DEFAULT_SERVICE_SCOPES = - ImmutableList.builder() - .add("https://www.googleapis.com/auth/pubsub") - .add("https://www.googleapis.com/auth/cloud-platform") - .build(); - - /** - * The default settings for the service. - */ - public static ServiceApiSettings DEFAULT_SETTINGS = - ServiceApiSettings.builder() - .provideChannelWith( - ConnectionSettings.builder() - .setServiceAddress(DEFAULT_SERVICE_ADDRESS) - .setPort(DEFAULT_SERVICE_PORT) - .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) - .build()) - .build(); - - private static final ImmutableMap> - DEFAULT_RETRY_CONFIG; - - static { - Map> definition = new HashMap<>(); - definition.put( - "idempotent", - Sets.immutableEnumSet( - Lists.newArrayList( - Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE))); - definition.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList())); - - Map> retryableCodes = - new EnumMap<>(MethodIdentifier.class); - retryableCodes.put(MethodIdentifier.CREATE_SUBSCRIPTION, definition.get("non_idempotent")); - retryableCodes.put(MethodIdentifier.GET_SUBSCRIPTION, definition.get("idempotent")); - retryableCodes.put(MethodIdentifier.LIST_SUBSCRIPTIONS, definition.get("idempotent")); - retryableCodes.put(MethodIdentifier.DELETE_SUBSCRIPTION, definition.get("idempotent")); - retryableCodes.put(MethodIdentifier.MODIFY_ACK_DEADLINE, definition.get("non_idempotent")); - retryableCodes.put(MethodIdentifier.ACKNOWLEDGE, definition.get("non_idempotent")); - retryableCodes.put(MethodIdentifier.PULL, definition.get("non_idempotent")); - retryableCodes.put(MethodIdentifier.MODIFY_PUSH_CONFIG, definition.get("non_idempotent")); - DEFAULT_RETRY_CONFIG = - Maps.>immutableEnumMap(retryableCodes); - } - - private static final ImmutableMap DEFAULT_RETRY_PARAMS; - - static { - Map definition = new HashMap<>(); - RetryParams params = null; - params = - RetryParams.newBuilder() - .setRetryBackoff( - BackoffParams.newBuilder() - .setInitialDelayMillis(100L) - .setDelayMultiplier(1.2) - .setMaxDelayMillis(1000L) - .build()) - .setTimeoutBackoff( - BackoffParams.newBuilder() - .setInitialDelayMillis(300L) - .setDelayMultiplier(1.3) - .setMaxDelayMillis(3000L) - .build()) - .setTotalTimeout(30000L) - .build(); - definition.put("default", params); - - Map retryParams = new EnumMap<>(MethodIdentifier.class); - retryParams.put(MethodIdentifier.CREATE_SUBSCRIPTION, definition.get("default")); - retryParams.put(MethodIdentifier.GET_SUBSCRIPTION, definition.get("default")); - retryParams.put(MethodIdentifier.LIST_SUBSCRIPTIONS, definition.get("default")); - retryParams.put(MethodIdentifier.DELETE_SUBSCRIPTION, definition.get("default")); - retryParams.put(MethodIdentifier.MODIFY_ACK_DEADLINE, definition.get("default")); - retryParams.put(MethodIdentifier.ACKNOWLEDGE, definition.get("default")); - retryParams.put(MethodIdentifier.PULL, definition.get("default")); - retryParams.put(MethodIdentifier.MODIFY_PUSH_CONFIG, definition.get("default")); - DEFAULT_RETRY_PARAMS = Maps.immutableEnumMap(retryParams); - } - - private static final ApiCallable CREATE_SUBSCRIPTION = - ApiCallable.create(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); - private static final ApiCallable GET_SUBSCRIPTION = - ApiCallable.create(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); - private static final ApiCallable - LIST_SUBSCRIPTIONS = ApiCallable.create(SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS); - private static final ApiCallable DELETE_SUBSCRIPTION = - ApiCallable.create(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); - private static final ApiCallable MODIFY_ACK_DEADLINE = - ApiCallable.create(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); - private static final ApiCallable ACKNOWLEDGE = - ApiCallable.create(SubscriberGrpc.METHOD_ACKNOWLEDGE); - private static final ApiCallable PULL = - ApiCallable.create(SubscriberGrpc.METHOD_PULL); - private static final ApiCallable MODIFY_PUSH_CONFIG = - ApiCallable.create(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); - - private static PageDescriptor - LIST_SUBSCRIPTIONS_PAGE_DESC = - new PageDescriptor() { - @Override - public Object emptyToken() { - return ""; - } - - @Override - public ListSubscriptionsRequest injectToken( - ListSubscriptionsRequest payload, Object token) { - return ListSubscriptionsRequest.newBuilder(payload) - .setPageToken((String) token) - .build(); - } - - @Override - public Object extractNextToken(ListSubscriptionsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListSubscriptionsResponse payload) { - return payload.getSubscriptionsList(); - } - }; - /** * A PathTemplate representing the fully-qualified path to represent * a project resource. @@ -261,14 +95,31 @@ public Iterable extractResources(ListSubscriptionsResponse payload // ======== private final ManagedChannel channel; - private final ServiceApiSettings settings; - private final ImmutableMap> retryCodesConfig; - private final ImmutableMap retryParamsConfig; + private final List closeables = new ArrayList<>(); + + private final ApiCallable createSubscriptionCallable; + private final ApiCallable getSubscriptionCallable; + private final ApiCallable + listSubscriptionsCallable; + private final ApiCallable> + listSubscriptionsIterableCallable; + private final ApiCallable deleteSubscriptionCallable; + private final ApiCallable modifyAckDeadlineCallable; + private final ApiCallable acknowledgeCallable; + private final ApiCallable pullCallable; + private final ApiCallable modifyPushConfigCallable; // =============== // Factory Methods // =============== + /** + * Constructs an instance of SubscriberSettings with default settings. + */ + public static SubscriberSettings newSettings() { + return SubscriberSettings.create(); + } + /** * Constructs an instance of SubscriberApi with default settings. * @@ -276,7 +127,7 @@ public Iterable extractResources(ListSubscriptionsResponse payload * */ public static SubscriberApi create() throws IOException { - return create(DEFAULT_SETTINGS); + return create(newSettings()); } /** @@ -286,8 +137,7 @@ public static SubscriberApi create() throws IOException { * * */ - public static SubscriberApi create(ServiceApiSettings settings) - throws IOException { + public static SubscriberApi create(SubscriberSettings settings) throws IOException { return new SubscriberApi(settings); } @@ -298,20 +148,33 @@ public static SubscriberApi create(ServiceApiSettings settings * * */ - protected SubscriberApi(ServiceApiSettings settings) throws IOException { - this.settings = settings; + protected SubscriberApi(SubscriberSettings settings) throws IOException { this.channel = settings.getChannel(); - Map> retryCodesConfig = - new EnumMap<>(DEFAULT_RETRY_CONFIG); - retryCodesConfig.putAll(settings.getRetryableCodes()); - this.retryCodesConfig = - Maps.>immutableEnumMap(retryCodesConfig); - - Map retryParamsConfig = new EnumMap<>(DEFAULT_RETRY_PARAMS); - retryParamsConfig.putAll(settings.getRetryParams()); - this.retryParamsConfig = - Maps.immutableEnumMap(retryParamsConfig); + for (ApiCallSettings method : settings.allMethods()) { + if (method.getExecutor() == null) { + method.setExecutor(settings.getExecutor()); + } + } + + this.createSubscriptionCallable = settings.createSubscriptionMethod().build(settings); + this.getSubscriptionCallable = settings.getSubscriptionMethod().build(settings); + this.listSubscriptionsCallable = settings.listSubscriptionsMethod().build(settings); + this.listSubscriptionsIterableCallable = + settings.listSubscriptionsMethod().buildPageStreaming(settings); + this.deleteSubscriptionCallable = settings.deleteSubscriptionMethod().build(settings); + this.modifyAckDeadlineCallable = settings.modifyAckDeadlineMethod().build(settings); + this.acknowledgeCallable = settings.acknowledgeMethod().build(settings); + this.pullCallable = settings.pullMethod().build(settings); + this.modifyPushConfigCallable = settings.modifyPushConfigMethod().build(settings); + + closeables.add( + new Closeable() { + @Override + public void close() throws IOException { + channel.shutdown(); + } + }); } // ============================== @@ -464,13 +327,7 @@ public Subscription createSubscription(Subscription request) { * */ public ApiCallable createSubscriptionCallable() { - ImmutableSet retryableCodes = - retryCodesConfig.get(MethodIdentifier.CREATE_SUBSCRIPTION); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.CREATE_SUBSCRIPTION); - return CREATE_SUBSCRIPTION - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return createSubscriptionCallable; } // ----- getSubscription ----- @@ -521,13 +378,7 @@ public Subscription getSubscription(GetSubscriptionRequest request) { * */ public ApiCallable getSubscriptionCallable() { - ImmutableSet retryableCodes = - retryCodesConfig.get(MethodIdentifier.GET_SUBSCRIPTION); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.GET_SUBSCRIPTION); - return GET_SUBSCRIPTION - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return getSubscriptionCallable; } // ----- listSubscriptions ----- @@ -561,7 +412,7 @@ public Iterable listSubscriptions(String project) { * @param request The request object containing all of the parameters for the API call. */ public Iterable listSubscriptions(ListSubscriptionsRequest request) { - return listSubscriptionsStreamingCallable().call(request); + return listSubscriptionsIterableCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. @@ -575,8 +426,8 @@ public Iterable listSubscriptions(ListSubscriptionsRequest request * */ public ApiCallable> - listSubscriptionsStreamingCallable() { - return listSubscriptionsCallable().pageStreaming(LIST_SUBSCRIPTIONS_PAGE_DESC); + listSubscriptionsIterableCallable() { + return listSubscriptionsIterableCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. @@ -591,13 +442,7 @@ public Iterable listSubscriptions(ListSubscriptionsRequest request */ public ApiCallable listSubscriptionsCallable() { - ImmutableSet retryableCodes = - retryCodesConfig.get(MethodIdentifier.LIST_SUBSCRIPTIONS); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.LIST_SUBSCRIPTIONS); - return LIST_SUBSCRIPTIONS - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return listSubscriptionsCallable; } // ----- deleteSubscription ----- @@ -651,13 +496,7 @@ public void deleteSubscription(DeleteSubscriptionRequest request) { * */ public ApiCallable deleteSubscriptionCallable() { - ImmutableSet retryableCodes = - retryCodesConfig.get(MethodIdentifier.DELETE_SUBSCRIPTION); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.DELETE_SUBSCRIPTION); - return DELETE_SUBSCRIPTION - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return deleteSubscriptionCallable; } // ----- modifyAckDeadline ----- @@ -675,7 +514,7 @@ public ApiCallable deleteSubscriptionCallable( * @param subscription The name of the subscription. * @param ackIds List of acknowledgment IDs. * @param ackDeadlineSeconds The new ack deadline with respect to the time this request was sent to - * the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new + * the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new * ack deadline will expire 10 seconds after the `ModifyAckDeadline` call * was made. Specifying zero may immediately make the message available for * another pull request. @@ -718,13 +557,7 @@ public void modifyAckDeadline(ModifyAckDeadlineRequest request) { * */ public ApiCallable modifyAckDeadlineCallable() { - ImmutableSet retryableCodes = - retryCodesConfig.get(MethodIdentifier.MODIFY_ACK_DEADLINE); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.MODIFY_ACK_DEADLINE); - return MODIFY_ACK_DEADLINE - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return modifyAckDeadlineCallable; } // ----- acknowledge ----- @@ -786,12 +619,7 @@ public void acknowledge(AcknowledgeRequest request) { * */ public ApiCallable acknowledgeCallable() { - ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.ACKNOWLEDGE); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.ACKNOWLEDGE); - return ACKNOWLEDGE - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return acknowledgeCallable; } // ----- pull ----- @@ -852,11 +680,7 @@ public PullResponse pull(PullRequest request) { * */ public ApiCallable pullCallable() { - ImmutableSet retryableCodes = retryCodesConfig.get(MethodIdentifier.PULL); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.PULL); - return PULL.retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return pullCallable; } // ----- modifyPushConfig ----- @@ -922,13 +746,7 @@ public void modifyPushConfig(ModifyPushConfigRequest request) { * */ public ApiCallable modifyPushConfigCallable() { - ImmutableSet retryableCodes = - retryCodesConfig.get(MethodIdentifier.MODIFY_PUSH_CONFIG); - RetryParams retryParams = retryParamsConfig.get(MethodIdentifier.MODIFY_PUSH_CONFIG); - return MODIFY_PUSH_CONFIG - .retryableOn(retryableCodes) - .retrying(retryParams, settings.getExecutor()) - .bind(channel); + return modifyPushConfigCallable; } // ======== diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java new file mode 100644 index 000000000000..0d78a4b45fb8 --- /dev/null +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java @@ -0,0 +1,336 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * 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. + */ + +/* + * EDITING INSTRUCTIONS + * This file was generated from the file + * https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto + * and updates to that file get reflected here through a refresh process. + * For the short term, the refresh process will only be runnable by Google engineers. + * Manual additions are allowed because the refresh process performs + * a 3-way merge in order to preserve those manual additions. In order to not + * break the refresh process, only certain types of modifications are + * allowed. + * + * Allowed modifications - currently these are the only types allowed: + * 1. New methods (these should be added to the end of the class) + * 2. New imports + * 3. Additional documentation between "manual edit" demarcations + * + * Happy editing! + */ + +package com.google.gcloud.pubsub.spi; + +import com.google.api.gax.core.BackoffParams; +import com.google.api.gax.core.ConnectionSettings; +import com.google.api.gax.core.RetryParams; +import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; +import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; +import com.google.api.gax.grpc.PageDescriptor; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import com.google.protobuf.Empty; +import com.google.pubsub.v1.AcknowledgeRequest; +import com.google.pubsub.v1.DeleteSubscriptionRequest; +import com.google.pubsub.v1.GetSubscriptionRequest; +import com.google.pubsub.v1.ListSubscriptionsRequest; +import com.google.pubsub.v1.ListSubscriptionsResponse; +import com.google.pubsub.v1.ModifyAckDeadlineRequest; +import com.google.pubsub.v1.ModifyPushConfigRequest; +import com.google.pubsub.v1.PullRequest; +import com.google.pubsub.v1.PullResponse; +import com.google.pubsub.v1.SubscriberGrpc; +import com.google.pubsub.v1.Subscription; +import io.grpc.Status; + +// Manually-added imports: add custom (non-generated) imports after this point. + +// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing. +@javax.annotation.Generated("by GAPIC") +public class SubscriberSettings extends ApiCallSettings { + + // ========= + // Constants + // ========= + + /** + * The default address of the service. + * + * + * + */ + public static final String DEFAULT_SERVICE_ADDRESS = "pubsub-experimental.googleapis.com"; + + /** + * The default port of the service. + * + * + * + */ + public static final int DEFAULT_SERVICE_PORT = 443; + + /** + * The default scopes of the service. + */ + public static ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder() + .add("https://www.googleapis.com/auth/pubsub") + .add("https://www.googleapis.com/auth/cloud-platform") + .build(); + + private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = ImmutableMap.builder(); + definitions.put( + "idempotent", + Sets.immutableEnumSet( + Lists.newArrayList( + Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE))); + definitions.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetryParams params = null; + params = + RetryParams.newBuilder() + .setRetryBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(100L) + .setDelayMultiplier(1.2) + .setMaxDelayMillis(1000L) + .build()) + .setTimeoutBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(300L) + .setDelayMultiplier(1.3) + .setMaxDelayMillis(3000L) + .build()) + .setTotalTimeout(30000L) + .build(); + definitions.put("default", params); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + private final ApiCallableBuilder createSubscriptionMethod; + private final ApiCallableBuilder getSubscriptionMethod; + private final PageStreamingApiCallableBuilder< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> + listSubscriptionsMethod; + private final ApiCallableBuilder deleteSubscriptionMethod; + private final ApiCallableBuilder modifyAckDeadlineMethod; + private final ApiCallableBuilder acknowledgeMethod; + private final ApiCallableBuilder pullMethod; + private final ApiCallableBuilder modifyPushConfigMethod; + private final ImmutableList allMethods; + + // =============== + // Factory Methods + // =============== + + /** + * Constructs an instance of SubscriberSettings with default settings. + * + * + * + */ + public static SubscriberSettings create() { + SubscriberSettings settings = new SubscriberSettings(); + settings.provideChannelWith( + ConnectionSettings.builder() + .setServiceAddress(DEFAULT_SERVICE_ADDRESS) + .setPort(DEFAULT_SERVICE_PORT) + .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) + .build()); + return settings; + } + + /** + * Constructs an instance of SubscriberSettings with default settings. This is protected so that it + * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * + * + * + */ + protected SubscriberSettings() { + createSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); + createSubscriptionMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + getSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); + getSubscriptionMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + listSubscriptionsMethod = + new PageStreamingApiCallableBuilder<>( + SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS, LIST_SUBSCRIPTIONS_PAGE_STR_DESC); + listSubscriptionsMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + deleteSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); + deleteSubscriptionMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + modifyAckDeadlineMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); + modifyAckDeadlineMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + acknowledgeMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_ACKNOWLEDGE); + acknowledgeMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + pullMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_PULL); + pullMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + modifyPushConfigMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); + modifyPushConfigMethod.setRetryDefaults( + RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); + + allMethods = + ImmutableList.builder() + .add( + createSubscriptionMethod, + getSubscriptionMethod, + listSubscriptionsMethod, + deleteSubscriptionMethod, + modifyAckDeadlineMethod, + acknowledgeMethod, + pullMethod, + modifyPushConfigMethod) + .build(); + } + + /** + * Returns the ApiCallableBuilder for the API method createSubscription. + * + * + * + */ + public ApiCallableBuilder createSubscriptionMethod() { + return createSubscriptionMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method getSubscription. + * + * + * + */ + public ApiCallableBuilder getSubscriptionMethod() { + return getSubscriptionMethod; + } + + /** + * Returns the PageStreamingApiCallableBuilder for the API method listSubscriptions. + * + * + * + */ + public PageStreamingApiCallableBuilder< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> + listSubscriptionsMethod() { + return listSubscriptionsMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method deleteSubscription. + * + * + * + */ + public ApiCallableBuilder deleteSubscriptionMethod() { + return deleteSubscriptionMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method modifyAckDeadline. + * + * + * + */ + public ApiCallableBuilder modifyAckDeadlineMethod() { + return modifyAckDeadlineMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method acknowledge. + * + * + * + */ + public ApiCallableBuilder acknowledgeMethod() { + return acknowledgeMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method pull. + * + * + * + */ + public ApiCallableBuilder pullMethod() { + return pullMethod; + } + + /** + * Returns the ApiCallableBuilder for the API method modifyPushConfig. + * + * + * + */ + public ApiCallableBuilder modifyPushConfigMethod() { + return modifyPushConfigMethod; + } + + public ImmutableList allMethods() { + return allMethods; + } + + private static PageDescriptor + LIST_SUBSCRIPTIONS_PAGE_STR_DESC = + new PageDescriptor() { + @Override + public Object emptyToken() { + return ""; + } + + @Override + public ListSubscriptionsRequest injectToken( + ListSubscriptionsRequest payload, Object token) { + return ListSubscriptionsRequest.newBuilder(payload) + .setPageToken((String) token) + .build(); + } + + @Override + public Object extractNextToken(ListSubscriptionsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListSubscriptionsResponse payload) { + return payload.getSubscriptionsList(); + } + }; +} diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java index 05a2f2acb9e2..79546855b3c3 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java @@ -21,15 +21,6 @@ import com.google.pubsub.v1.PushConfig; import com.google.pubsub.v1.Topic; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.google.api.gax.grpc.ServiceApiSettings; - import io.grpc.ManagedChannel; import java.io.IOException; @@ -37,6 +28,13 @@ import java.util.Collections; import java.util.List; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + public class PublisherApiTest { private static LocalPubsubHelper pubsubHelper; private PublisherApi publisherApi; @@ -57,16 +55,13 @@ public static void stopServer() throws IOException, InterruptedException { public void setUp() throws Exception { ManagedChannel channel = pubsubHelper.createChannel(); - publisherApi = - PublisherApi.create( - ServiceApiSettings.builder() - .provideChannelWith(channel) - .build()); - subscriberApi = - SubscriberApi.create( - ServiceApiSettings.builder() - .provideChannelWith(channel) - .build()); + PublisherSettings publisherSettings = PublisherApi.newSettings(); + publisherSettings.provideChannelWith(channel); + publisherApi = PublisherApi.create(publisherSettings); + + SubscriberSettings subscriberSettings = SubscriberApi.newSettings(); + subscriberSettings.provideChannelWith(channel); + subscriberApi = SubscriberApi.create(subscriberSettings); } @After From db77058d2df080e46cbecfbb8167f723e35af7d9 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Tue, 8 Mar 2016 11:33:27 -0800 Subject: [PATCH 194/203] Updating to GAX 0.0.3 --- gcloud-java-pubsub/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index fb81bdbfa618..64d2bca4e58e 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -19,7 +19,7 @@ com.google.api gax - 0.0.3-SNAPSHOT + 0.0.3 com.google.api.grpc From 58b09d37b319b05481a8969502f0c3ce18c5e597 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Wed, 9 Mar 2016 17:47:15 -0800 Subject: [PATCH 195/203] Surface updates from internal review --- .../gcloud/pubsub/spi/PublisherApi.java | 184 +++++++++--------- .../gcloud/pubsub/spi/PublisherSettings.java | 2 +- .../gcloud/pubsub/spi/SubscriberApi.java | 183 ++++++++--------- .../gcloud/pubsub/spi/SubscriberSettings.java | 2 +- .../gcloud/pubsub/spi/PublisherApi.java | 184 +++++++++--------- .../gcloud/pubsub/spi/PublisherSettings.java | 2 +- .../gcloud/pubsub/spi/SubscriberApi.java | 183 ++++++++--------- .../gcloud/pubsub/spi/SubscriberSettings.java | 2 +- .../spi/testing/LocalPublisherImpl.java | 4 +- .../gcloud/pubsub/spi/PublisherApiTest.java | 20 +- 10 files changed, 388 insertions(+), 378 deletions(-) diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index f7011dcd0240..3aa8bb6cae92 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -57,7 +57,7 @@ // AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. /** - * The service that an application uses to manipulate topics, and to send + * Service Description: The service that an application uses to manipulate topics, and to send * messages to a topic. * * @@ -66,28 +66,92 @@ @javax.annotation.Generated("by GAPIC") public class PublisherApi implements AutoCloseable { - // ========= - // Constants - // ========= + public static class ResourceNames { + private ResourceNames() {} + + // ======================= + // ResourceNames Constants + // ======================= + + /** + * A PathTemplate representing the fully-qualified path to represent + * a project resource. + * + * + * + */ + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.create("projects/{project}"); + + /** + * A PathTemplate representing the fully-qualified path to represent + * a topic resource. + * + * + * + */ + private static final PathTemplate TOPIC_PATH_TEMPLATE = + PathTemplate.create("projects/{project}/topics/{topic}"); + + // ============================== + // Resource Name Helper Functions + // ============================== + + /** + * Formats a string containing the fully-qualified path to represent + * a project resource. + * + * + * + */ + public static final String formatProjectPath(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } - /** - * A PathTemplate representing the fully-qualified path to represent - * a project resource. - * - * - * - */ - private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.create("projects/{project}"); - /** - * A PathTemplate representing the fully-qualified path to represent - * a topic resource. - * - * - * - */ - private static final PathTemplate TOPIC_PATH_TEMPLATE = - PathTemplate.create("projects/{project}/topics/{topic}"); + /** + * Formats a string containing the fully-qualified path to represent + * a topic resource. + * + * + * + */ + public static final String formatTopicPath(String project, String topic) { + return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic); + } + + /** + * Parses the project from the given fully-qualified path which + * represents a project resource. + * + * + * + */ + public static final String parseProjectFromProjectPath(String projectPath) { + return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); + } + + /** + * Parses the project from the given fully-qualified path which + * represents a topic resource. + * + * + * + */ + public static final String parseProjectFromTopicPath(String topicPath) { + return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project"); + } + + /** + * Parses the topic from the given fully-qualified path which + * represents a topic resource. + * + * + * + */ + public static final String parseTopicFromTopicPath(String topicPath) { + return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic"); + } + } // ======== // Members @@ -174,65 +238,6 @@ public void close() throws IOException { }); } - // ============================== - // Resource Name Helper Functions - // ============================== - - /** - * Creates a string containing the fully-qualified path to represent - * a project resource. - * - * - * - */ - public static final String createProjectPath(String project) { - return PROJECT_PATH_TEMPLATE.instantiate("project", project); - } - - /** - * Creates a string containing the fully-qualified path to represent - * a topic resource. - * - * - * - */ - public static final String createTopicPath(String project, String topic) { - return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic); - } - - /** - * Extracts the project from the given fully-qualified path which - * represents a project resource. - * - * - * - */ - public static final String extractProjectFromProjectPath(String projectPath) { - return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); - } - - /** - * Extracts the project from the given fully-qualified path which - * represents a topic resource. - * - * - * - */ - public static final String extractProjectFromTopicPath(String topicPath) { - return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project"); - } - - /** - * Extracts the topic from the given fully-qualified path which - * represents a topic resource. - * - * - * - */ - public static final String extractTopicFromTopicPath(String topicPath) { - return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic"); - } - // ============= // Service Calls // ============= @@ -268,7 +273,7 @@ public Topic createTopic(String name) { * * @param request The request object containing all of the parameters for the API call. */ - public Topic createTopic(Topic request) { + private Topic createTopic(Topic request) { return createTopicCallable().call(request); } @@ -358,7 +363,7 @@ public Topic getTopic(String topic) { * * @param request The request object containing all of the parameters for the API call. */ - public Topic getTopic(GetTopicRequest request) { + private Topic getTopic(GetTopicRequest request) { return getTopicCallable().call(request); } @@ -508,7 +513,7 @@ public void deleteTopic(String topic) { * * @param request The request object containing all of the parameters for the API call. */ - public void deleteTopic(DeleteTopicRequest request) { + private void deleteTopic(DeleteTopicRequest request) { deleteTopicCallable().call(request); } @@ -539,13 +544,10 @@ public ApiCallable deleteTopicCallable() { * */ @Override - public void close() { - // Manually-added shutdown code - - // Auto-generated shutdown code - channel.shutdown(); - - // Manually-added shutdown code + public void close() throws Exception { + for (AutoCloseable closeable : closeables) { + closeable.close(); + } } // ======== diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java index b1985fc40b53..f10a7b7357f3 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java @@ -87,7 +87,7 @@ public class PublisherSettings extends ApiCallSettings { /** * The default scopes of the service. */ - public static ImmutableList DEFAULT_SERVICE_SCOPES = + public static final ImmutableList DEFAULT_SERVICE_SCOPES = ImmutableList.builder() .add("https://www.googleapis.com/auth/pubsub") .add("https://www.googleapis.com/auth/cloud-platform") diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index c50e6b6aaaed..5b8dd746bdda 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -58,7 +58,7 @@ // AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. /** - * The service that an application uses to manipulate subscriptions and to + * Service Description: The service that an application uses to manipulate subscriptions and to * consume messages from a subscription via the `Pull` method. * * @@ -67,28 +67,93 @@ @javax.annotation.Generated("by GAPIC") public class SubscriberApi implements AutoCloseable { - // ========= - // Constants - // ========= + public static class ResourceNames { + private ResourceNames() {} + + // ======================= + // ResourceNames Constants + // ======================= + + /** + * A PathTemplate representing the fully-qualified path to represent + * a project resource. + * + * + * + */ + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.create("projects/{project}"); + + /** + * A PathTemplate representing the fully-qualified path to represent + * a subscription resource. + * + * + * + */ + private static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = + PathTemplate.create("projects/{project}/subscriptions/{subscription}"); + + // ============================== + // Resource Name Helper Functions + // ============================== + + /** + * Formats a string containing the fully-qualified path to represent + * a project resource. + * + * + * + */ + public static final String formatProjectPath(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } - /** - * A PathTemplate representing the fully-qualified path to represent - * a project resource. - * - * - * - */ - private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.create("projects/{project}"); - /** - * A PathTemplate representing the fully-qualified path to represent - * a subscription resource. - * - * - * - */ - private static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = - PathTemplate.create("projects/{project}/subscriptions/{subscription}"); + /** + * Formats a string containing the fully-qualified path to represent + * a subscription resource. + * + * + * + */ + public static final String formatSubscriptionPath(String project, String subscription) { + return SUBSCRIPTION_PATH_TEMPLATE.instantiate( + "project", project, "subscription", subscription); + } + + /** + * Parses the project from the given fully-qualified path which + * represents a project resource. + * + * + * + */ + public static final String parseProjectFromProjectPath(String projectPath) { + return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); + } + + /** + * Parses the project from the given fully-qualified path which + * represents a subscription resource. + * + * + * + */ + public static final String parseProjectFromSubscriptionPath(String subscriptionPath) { + return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("project"); + } + + /** + * Parses the subscription from the given fully-qualified path which + * represents a subscription resource. + * + * + * + */ + public static final String parseSubscriptionFromSubscriptionPath(String subscriptionPath) { + return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("subscription"); + } + } // ======== // Members @@ -177,65 +242,6 @@ public void close() throws IOException { }); } - // ============================== - // Resource Name Helper Functions - // ============================== - - /** - * Creates a string containing the fully-qualified path to represent - * a project resource. - * - * - * - */ - public static final String createProjectPath(String project) { - return PROJECT_PATH_TEMPLATE.instantiate("project", project); - } - - /** - * Creates a string containing the fully-qualified path to represent - * a subscription resource. - * - * - * - */ - public static final String createSubscriptionPath(String project, String subscription) { - return SUBSCRIPTION_PATH_TEMPLATE.instantiate("project", project, "subscription", subscription); - } - - /** - * Extracts the project from the given fully-qualified path which - * represents a project resource. - * - * - * - */ - public static final String extractProjectFromProjectPath(String projectPath) { - return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); - } - - /** - * Extracts the project from the given fully-qualified path which - * represents a subscription resource. - * - * - * - */ - public static final String extractProjectFromSubscriptionPath(String subscriptionPath) { - return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("project"); - } - - /** - * Extracts the subscription from the given fully-qualified path which - * represents a subscription resource. - * - * - * - */ - public static final String extractSubscriptionFromSubscriptionPath(String subscriptionPath) { - return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("subscription"); - } - // ============= // Service Calls // ============= @@ -363,7 +369,7 @@ public Subscription getSubscription(String subscription) { * * @param request The request object containing all of the parameters for the API call. */ - public Subscription getSubscription(GetSubscriptionRequest request) { + private Subscription getSubscription(GetSubscriptionRequest request) { return getSubscriptionCallable().call(request); } @@ -480,7 +486,7 @@ public void deleteSubscription(String subscription) { * * @param request The request object containing all of the parameters for the API call. */ - public void deleteSubscription(DeleteSubscriptionRequest request) { + private void deleteSubscription(DeleteSubscriptionRequest request) { deleteSubscriptionCallable().call(request); } @@ -761,13 +767,10 @@ public ApiCallable modifyPushConfigCallable() { * */ @Override - public void close() { - // Manually-added shutdown code - - // Auto-generated shutdown code - channel.shutdown(); - - // Manually-added shutdown code + public void close() throws Exception { + for (AutoCloseable closeable : closeables) { + closeable.close(); + } } // ======== diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java index 0d78a4b45fb8..e5cfd1d4a9b1 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java @@ -88,7 +88,7 @@ public class SubscriberSettings extends ApiCallSettings { /** * The default scopes of the service. */ - public static ImmutableList DEFAULT_SERVICE_SCOPES = + public static final ImmutableList DEFAULT_SERVICE_SCOPES = ImmutableList.builder() .add("https://www.googleapis.com/auth/pubsub") .add("https://www.googleapis.com/auth/cloud-platform") diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index f7011dcd0240..3aa8bb6cae92 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -57,7 +57,7 @@ // AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. /** - * The service that an application uses to manipulate topics, and to send + * Service Description: The service that an application uses to manipulate topics, and to send * messages to a topic. * * @@ -66,28 +66,92 @@ @javax.annotation.Generated("by GAPIC") public class PublisherApi implements AutoCloseable { - // ========= - // Constants - // ========= + public static class ResourceNames { + private ResourceNames() {} + + // ======================= + // ResourceNames Constants + // ======================= + + /** + * A PathTemplate representing the fully-qualified path to represent + * a project resource. + * + * + * + */ + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.create("projects/{project}"); + + /** + * A PathTemplate representing the fully-qualified path to represent + * a topic resource. + * + * + * + */ + private static final PathTemplate TOPIC_PATH_TEMPLATE = + PathTemplate.create("projects/{project}/topics/{topic}"); + + // ============================== + // Resource Name Helper Functions + // ============================== + + /** + * Formats a string containing the fully-qualified path to represent + * a project resource. + * + * + * + */ + public static final String formatProjectPath(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } - /** - * A PathTemplate representing the fully-qualified path to represent - * a project resource. - * - * - * - */ - private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.create("projects/{project}"); - /** - * A PathTemplate representing the fully-qualified path to represent - * a topic resource. - * - * - * - */ - private static final PathTemplate TOPIC_PATH_TEMPLATE = - PathTemplate.create("projects/{project}/topics/{topic}"); + /** + * Formats a string containing the fully-qualified path to represent + * a topic resource. + * + * + * + */ + public static final String formatTopicPath(String project, String topic) { + return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic); + } + + /** + * Parses the project from the given fully-qualified path which + * represents a project resource. + * + * + * + */ + public static final String parseProjectFromProjectPath(String projectPath) { + return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); + } + + /** + * Parses the project from the given fully-qualified path which + * represents a topic resource. + * + * + * + */ + public static final String parseProjectFromTopicPath(String topicPath) { + return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project"); + } + + /** + * Parses the topic from the given fully-qualified path which + * represents a topic resource. + * + * + * + */ + public static final String parseTopicFromTopicPath(String topicPath) { + return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic"); + } + } // ======== // Members @@ -174,65 +238,6 @@ public void close() throws IOException { }); } - // ============================== - // Resource Name Helper Functions - // ============================== - - /** - * Creates a string containing the fully-qualified path to represent - * a project resource. - * - * - * - */ - public static final String createProjectPath(String project) { - return PROJECT_PATH_TEMPLATE.instantiate("project", project); - } - - /** - * Creates a string containing the fully-qualified path to represent - * a topic resource. - * - * - * - */ - public static final String createTopicPath(String project, String topic) { - return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic); - } - - /** - * Extracts the project from the given fully-qualified path which - * represents a project resource. - * - * - * - */ - public static final String extractProjectFromProjectPath(String projectPath) { - return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); - } - - /** - * Extracts the project from the given fully-qualified path which - * represents a topic resource. - * - * - * - */ - public static final String extractProjectFromTopicPath(String topicPath) { - return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project"); - } - - /** - * Extracts the topic from the given fully-qualified path which - * represents a topic resource. - * - * - * - */ - public static final String extractTopicFromTopicPath(String topicPath) { - return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic"); - } - // ============= // Service Calls // ============= @@ -268,7 +273,7 @@ public Topic createTopic(String name) { * * @param request The request object containing all of the parameters for the API call. */ - public Topic createTopic(Topic request) { + private Topic createTopic(Topic request) { return createTopicCallable().call(request); } @@ -358,7 +363,7 @@ public Topic getTopic(String topic) { * * @param request The request object containing all of the parameters for the API call. */ - public Topic getTopic(GetTopicRequest request) { + private Topic getTopic(GetTopicRequest request) { return getTopicCallable().call(request); } @@ -508,7 +513,7 @@ public void deleteTopic(String topic) { * * @param request The request object containing all of the parameters for the API call. */ - public void deleteTopic(DeleteTopicRequest request) { + private void deleteTopic(DeleteTopicRequest request) { deleteTopicCallable().call(request); } @@ -539,13 +544,10 @@ public ApiCallable deleteTopicCallable() { * */ @Override - public void close() { - // Manually-added shutdown code - - // Auto-generated shutdown code - channel.shutdown(); - - // Manually-added shutdown code + public void close() throws Exception { + for (AutoCloseable closeable : closeables) { + closeable.close(); + } } // ======== diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java index b1985fc40b53..f10a7b7357f3 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java @@ -87,7 +87,7 @@ public class PublisherSettings extends ApiCallSettings { /** * The default scopes of the service. */ - public static ImmutableList DEFAULT_SERVICE_SCOPES = + public static final ImmutableList DEFAULT_SERVICE_SCOPES = ImmutableList.builder() .add("https://www.googleapis.com/auth/pubsub") .add("https://www.googleapis.com/auth/cloud-platform") diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index c50e6b6aaaed..5b8dd746bdda 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -58,7 +58,7 @@ // AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. /** - * The service that an application uses to manipulate subscriptions and to + * Service Description: The service that an application uses to manipulate subscriptions and to * consume messages from a subscription via the `Pull` method. * * @@ -67,28 +67,93 @@ @javax.annotation.Generated("by GAPIC") public class SubscriberApi implements AutoCloseable { - // ========= - // Constants - // ========= + public static class ResourceNames { + private ResourceNames() {} + + // ======================= + // ResourceNames Constants + // ======================= + + /** + * A PathTemplate representing the fully-qualified path to represent + * a project resource. + * + * + * + */ + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.create("projects/{project}"); + + /** + * A PathTemplate representing the fully-qualified path to represent + * a subscription resource. + * + * + * + */ + private static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = + PathTemplate.create("projects/{project}/subscriptions/{subscription}"); + + // ============================== + // Resource Name Helper Functions + // ============================== + + /** + * Formats a string containing the fully-qualified path to represent + * a project resource. + * + * + * + */ + public static final String formatProjectPath(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } - /** - * A PathTemplate representing the fully-qualified path to represent - * a project resource. - * - * - * - */ - private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.create("projects/{project}"); - /** - * A PathTemplate representing the fully-qualified path to represent - * a subscription resource. - * - * - * - */ - private static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = - PathTemplate.create("projects/{project}/subscriptions/{subscription}"); + /** + * Formats a string containing the fully-qualified path to represent + * a subscription resource. + * + * + * + */ + public static final String formatSubscriptionPath(String project, String subscription) { + return SUBSCRIPTION_PATH_TEMPLATE.instantiate( + "project", project, "subscription", subscription); + } + + /** + * Parses the project from the given fully-qualified path which + * represents a project resource. + * + * + * + */ + public static final String parseProjectFromProjectPath(String projectPath) { + return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); + } + + /** + * Parses the project from the given fully-qualified path which + * represents a subscription resource. + * + * + * + */ + public static final String parseProjectFromSubscriptionPath(String subscriptionPath) { + return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("project"); + } + + /** + * Parses the subscription from the given fully-qualified path which + * represents a subscription resource. + * + * + * + */ + public static final String parseSubscriptionFromSubscriptionPath(String subscriptionPath) { + return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("subscription"); + } + } // ======== // Members @@ -177,65 +242,6 @@ public void close() throws IOException { }); } - // ============================== - // Resource Name Helper Functions - // ============================== - - /** - * Creates a string containing the fully-qualified path to represent - * a project resource. - * - * - * - */ - public static final String createProjectPath(String project) { - return PROJECT_PATH_TEMPLATE.instantiate("project", project); - } - - /** - * Creates a string containing the fully-qualified path to represent - * a subscription resource. - * - * - * - */ - public static final String createSubscriptionPath(String project, String subscription) { - return SUBSCRIPTION_PATH_TEMPLATE.instantiate("project", project, "subscription", subscription); - } - - /** - * Extracts the project from the given fully-qualified path which - * represents a project resource. - * - * - * - */ - public static final String extractProjectFromProjectPath(String projectPath) { - return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); - } - - /** - * Extracts the project from the given fully-qualified path which - * represents a subscription resource. - * - * - * - */ - public static final String extractProjectFromSubscriptionPath(String subscriptionPath) { - return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("project"); - } - - /** - * Extracts the subscription from the given fully-qualified path which - * represents a subscription resource. - * - * - * - */ - public static final String extractSubscriptionFromSubscriptionPath(String subscriptionPath) { - return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionPath).get("subscription"); - } - // ============= // Service Calls // ============= @@ -363,7 +369,7 @@ public Subscription getSubscription(String subscription) { * * @param request The request object containing all of the parameters for the API call. */ - public Subscription getSubscription(GetSubscriptionRequest request) { + private Subscription getSubscription(GetSubscriptionRequest request) { return getSubscriptionCallable().call(request); } @@ -480,7 +486,7 @@ public void deleteSubscription(String subscription) { * * @param request The request object containing all of the parameters for the API call. */ - public void deleteSubscription(DeleteSubscriptionRequest request) { + private void deleteSubscription(DeleteSubscriptionRequest request) { deleteSubscriptionCallable().call(request); } @@ -761,13 +767,10 @@ public ApiCallable modifyPushConfigCallable() { * */ @Override - public void close() { - // Manually-added shutdown code - - // Auto-generated shutdown code - channel.shutdown(); - - // Manually-added shutdown code + public void close() throws Exception { + for (AutoCloseable closeable : closeables) { + closeable.close(); + } } // ======== diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java index 0d78a4b45fb8..e5cfd1d4a9b1 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java @@ -88,7 +88,7 @@ public class SubscriberSettings extends ApiCallSettings { /** * The default scopes of the service. */ - public static ImmutableList DEFAULT_SERVICE_SCOPES = + public static final ImmutableList DEFAULT_SERVICE_SCOPES = ImmutableList.builder() .add("https://www.googleapis.com/auth/pubsub") .add("https://www.googleapis.com/auth/cloud-platform") diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java index 45c5dc947d4d..13aeb26cafe0 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java @@ -78,8 +78,8 @@ public void listTopics( ListTopicsRequest request, StreamObserver responseObserver) { List responseTopics = new ArrayList<>(); for (String topicName : topics.keySet()) { - String projectOfTopic = PublisherApi.extractProjectFromTopicPath(topicName); - String projectOfRequest = PublisherApi.extractProjectFromProjectPath(request.getProject()); + String projectOfTopic = PublisherApi.ResourceNames.parseProjectFromTopicPath(topicName); + String projectOfRequest = PublisherApi.ResourceNames.parseProjectFromProjectPath(request.getProject()); if (projectOfTopic.equals(projectOfRequest)) { Topic topicObj = Topic.newBuilder().setName(topicName).build(); responseTopics.add(topicObj); diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java index 79546855b3c3..4b4c91ebe797 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java @@ -77,17 +77,17 @@ public void tearDown() throws Exception { @Test public void testCreateTopic() throws Exception { - String topicName = PublisherApi.createTopicPath("my-project", "my-topic"); + String topicName = PublisherApi.ResourceNames.formatTopicPath("my-project", "my-topic"); Topic result = publisherApi.createTopic(topicName); Assert.assertEquals(topicName, result.getName()); } @Test public void testPublish() throws Exception { - String topicName = PublisherApi.createTopicPath("my-project", "publish-topic"); + String topicName = PublisherApi.ResourceNames.formatTopicPath("my-project", "publish-topic"); publisherApi.createTopic(topicName); - String subscriberName = SubscriberApi.createSubscriptionPath("my-project", "my-subscribe"); + String subscriberName = SubscriberApi.ResourceNames.formatSubscriptionPath("my-project", "my-subscribe"); PushConfig config = PushConfig.getDefaultInstance(); subscriberApi.createSubscription(subscriberName, topicName, config, 5); @@ -103,7 +103,7 @@ public void testPublish() throws Exception { @Test public void testGetTopic() throws Exception { - String topicName = PublisherApi.createTopicPath("my-project", "fun-topic"); + String topicName = PublisherApi.ResourceNames.formatTopicPath("my-project", "fun-topic"); publisherApi.createTopic(topicName); Topic result = publisherApi.getTopic(topicName); Assert.assertNotNull(result); @@ -112,10 +112,10 @@ public void testGetTopic() throws Exception { @Test public void testListTopics() throws Exception { - String project1 = PublisherApi.createProjectPath("project.1"); - String topicName1 = PublisherApi.createTopicPath("project.1", "topic.1"); - String topicName2 = PublisherApi.createTopicPath("project.1", "topic.2"); - String topicName3 = PublisherApi.createTopicPath("project.2", "topic.3"); + String project1 = PublisherApi.ResourceNames.formatProjectPath("project.1"); + String topicName1 = PublisherApi.ResourceNames.formatTopicPath("project.1", "topic.1"); + String topicName2 = PublisherApi.ResourceNames.formatTopicPath("project.1", "topic.2"); + String topicName3 = PublisherApi.ResourceNames.formatTopicPath("project.2", "topic.3"); publisherApi.createTopic(topicName1); publisherApi.createTopic(topicName2); publisherApi.createTopic(topicName3); @@ -130,8 +130,8 @@ public void testListTopics() throws Exception { @Test public void testDeleteTopic() throws Exception { - String project = PublisherApi.createProjectPath("project.1"); - String topicName = PublisherApi.createTopicPath("my-project", "fun-topic"); + String project = PublisherApi.ResourceNames.formatProjectPath("project.1"); + String topicName = PublisherApi.ResourceNames.formatTopicPath("my-project", "fun-topic"); publisherApi.createTopic(topicName); publisherApi.deleteTopic(topicName); List topics = new ArrayList<>(); From e629e1256fb1a21038e6bd2f04e04826642a0c10 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Thu, 10 Mar 2016 16:08:49 -0800 Subject: [PATCH 196/203] Using resurrected ServiceApiSettings in Settings classes --- gcloud-java-pubsub/pom.xml | 2 +- .../gcloud/pubsub/spi/PublisherApi.java | 6 - .../gcloud/pubsub/spi/PublisherSettings.java | 128 ++++++++------- .../gcloud/pubsub/spi/SubscriberApi.java | 6 - .../gcloud/pubsub/spi/SubscriberSettings.java | 151 +++++++++--------- .../gcloud/pubsub/spi/PublisherApiTest.java | 22 +++ 6 files changed, 169 insertions(+), 146 deletions(-) diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index 64d2bca4e58e..2fccc5a6560c 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -19,7 +19,7 @@ com.google.api gax - 0.0.3 + 0.0.4 com.google.api.grpc diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index 3aa8bb6cae92..7f456396501a 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -213,12 +213,6 @@ public static PublisherApi create(PublisherSettings settings) throws IOException protected PublisherApi(PublisherSettings settings) throws IOException { this.channel = settings.getChannel(); - for (ApiCallSettings method : settings.allMethods()) { - if (method.getExecutor() == null) { - method.setExecutor(settings.getExecutor()); - } - } - this.createTopicCallable = settings.createTopicMethod().build(settings); this.publishCallable = settings.publishMethod().build(settings); this.getTopicCallable = settings.getTopicMethod().build(settings); diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java index f10a7b7357f3..a8e76ccf586c 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java @@ -40,6 +40,7 @@ import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; import com.google.api.gax.grpc.PageDescriptor; +import com.google.api.gax.grpc.ServiceApiSettings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -62,7 +63,7 @@ // AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing. @javax.annotation.Generated("by GAPIC") -public class PublisherSettings extends ApiCallSettings { +public class PublisherSettings extends ServiceApiSettings { // ========= // Constants @@ -131,16 +132,61 @@ public class PublisherSettings extends ApiCallSettings { RETRY_PARAM_DEFINITIONS = definitions.build(); } - private final ApiCallableBuilder createTopicMethod; - private final ApiCallableBuilder publishMethod; - private final ApiCallableBuilder getTopicMethod; - private final PageStreamingApiCallableBuilder - listTopicsMethod; - private final PageStreamingApiCallableBuilder< - ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> - listTopicSubscriptionsMethod; - private final ApiCallableBuilder deleteTopicMethod; - private final ImmutableList allMethods; + private static class MethodBuilders { + public final ApiCallableBuilder createTopicMethod; + public final ApiCallableBuilder publishMethod; + public final ApiCallableBuilder getTopicMethod; + public final PageStreamingApiCallableBuilder + listTopicsMethod; + public final PageStreamingApiCallableBuilder< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + listTopicSubscriptionsMethod; + public final ApiCallableBuilder deleteTopicMethod; + public final ImmutableList allMethods; + + public MethodBuilders() { + createTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_CREATE_TOPIC); + createTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + createTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH); + publishMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + publishMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + getTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_GET_TOPIC); + getTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + getTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + listTopicsMethod = + new PageStreamingApiCallableBuilder<>( + PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC); + listTopicsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + listTopicsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + listTopicSubscriptionsMethod = + new PageStreamingApiCallableBuilder<>( + PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS, LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC); + listTopicsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + listTopicsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + deleteTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_DELETE_TOPIC); + deleteTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + deleteTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + allMethods = + ImmutableList.builder() + .add( + createTopicMethod, + publishMethod, + getTopicMethod, + listTopicsMethod, + listTopicSubscriptionsMethod, + deleteTopicMethod) + .build(); + } + } + + private final MethodBuilders methods; // =============== // Factory Methods @@ -153,7 +199,7 @@ public class PublisherSettings extends ApiCallSettings { * */ public static PublisherSettings create() { - PublisherSettings settings = new PublisherSettings(); + PublisherSettings settings = new PublisherSettings(new MethodBuilders()); settings.provideChannelWith( ConnectionSettings.builder() .setServiceAddress(DEFAULT_SERVICE_ADDRESS) @@ -170,45 +216,9 @@ public static PublisherSettings create() { * * */ - protected PublisherSettings() { - createTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_CREATE_TOPIC); - createTopicMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH); - publishMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - getTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_GET_TOPIC); - getTopicMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - listTopicsMethod = - new PageStreamingApiCallableBuilder<>( - PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC); - listTopicsMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - listTopicSubscriptionsMethod = - new PageStreamingApiCallableBuilder<>( - PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS, LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC); - listTopicSubscriptionsMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - deleteTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_DELETE_TOPIC); - deleteTopicMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - allMethods = - ImmutableList.builder() - .add( - createTopicMethod, - publishMethod, - getTopicMethod, - listTopicsMethod, - listTopicSubscriptionsMethod, - deleteTopicMethod) - .build(); + protected PublisherSettings(MethodBuilders methods) { + super(methods.allMethods); + this.methods = methods; } /** @@ -218,7 +228,7 @@ protected PublisherSettings() { * */ public ApiCallableBuilder createTopicMethod() { - return createTopicMethod; + return methods.createTopicMethod; } /** @@ -228,7 +238,7 @@ public ApiCallableBuilder createTopicMethod() { * */ public ApiCallableBuilder publishMethod() { - return publishMethod; + return methods.publishMethod; } /** @@ -238,7 +248,7 @@ public ApiCallableBuilder publishMethod() { * */ public ApiCallableBuilder getTopicMethod() { - return getTopicMethod; + return methods.getTopicMethod; } /** @@ -249,7 +259,7 @@ public ApiCallableBuilder getTopicMethod() { */ public PageStreamingApiCallableBuilder listTopicsMethod() { - return listTopicsMethod; + return methods.listTopicsMethod; } /** @@ -261,7 +271,7 @@ public ApiCallableBuilder getTopicMethod() { public PageStreamingApiCallableBuilder< ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> listTopicSubscriptionsMethod() { - return listTopicSubscriptionsMethod; + return methods.listTopicSubscriptionsMethod; } /** @@ -271,11 +281,7 @@ public ApiCallableBuilder getTopicMethod() { * */ public ApiCallableBuilder deleteTopicMethod() { - return deleteTopicMethod; - } - - public ImmutableList allMethods() { - return allMethods; + return methods.deleteTopicMethod; } private static PageDescriptor diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index 5b8dd746bdda..db69a80c750e 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -216,12 +216,6 @@ public static SubscriberApi create(SubscriberSettings settings) throws IOExcepti protected SubscriberApi(SubscriberSettings settings) throws IOException { this.channel = settings.getChannel(); - for (ApiCallSettings method : settings.allMethods()) { - if (method.getExecutor() == null) { - method.setExecutor(settings.getExecutor()); - } - } - this.createSubscriptionCallable = settings.createSubscriptionMethod().build(settings); this.getSubscriptionCallable = settings.getSubscriptionMethod().build(settings); this.listSubscriptionsCallable = settings.listSubscriptionsMethod().build(settings); diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java index e5cfd1d4a9b1..75ad0b2fbdbe 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java @@ -40,6 +40,7 @@ import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; import com.google.api.gax.grpc.PageDescriptor; +import com.google.api.gax.grpc.ServiceApiSettings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -57,13 +58,14 @@ import com.google.pubsub.v1.PullResponse; import com.google.pubsub.v1.SubscriberGrpc; import com.google.pubsub.v1.Subscription; + import io.grpc.Status; // Manually-added imports: add custom (non-generated) imports after this point. // AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing. @javax.annotation.Generated("by GAPIC") -public class SubscriberSettings extends ApiCallSettings { +public class SubscriberSettings extends ServiceApiSettings { // ========= // Constants @@ -132,17 +134,70 @@ public class SubscriberSettings extends ApiCallSettings { RETRY_PARAM_DEFINITIONS = definitions.build(); } - private final ApiCallableBuilder createSubscriptionMethod; - private final ApiCallableBuilder getSubscriptionMethod; - private final PageStreamingApiCallableBuilder< - ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> - listSubscriptionsMethod; - private final ApiCallableBuilder deleteSubscriptionMethod; - private final ApiCallableBuilder modifyAckDeadlineMethod; - private final ApiCallableBuilder acknowledgeMethod; - private final ApiCallableBuilder pullMethod; - private final ApiCallableBuilder modifyPushConfigMethod; - private final ImmutableList allMethods; + private static class MethodBuilders { + private final ApiCallableBuilder createSubscriptionMethod; + private final ApiCallableBuilder getSubscriptionMethod; + private final PageStreamingApiCallableBuilder< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> + listSubscriptionsMethod; + private final ApiCallableBuilder deleteSubscriptionMethod; + private final ApiCallableBuilder modifyAckDeadlineMethod; + private final ApiCallableBuilder acknowledgeMethod; + private final ApiCallableBuilder pullMethod; + private final ApiCallableBuilder modifyPushConfigMethod; + private final ImmutableList allMethods; + + public MethodBuilders() { + createSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); + createSubscriptionMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + createSubscriptionMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + getSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); + getSubscriptionMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + getSubscriptionMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + listSubscriptionsMethod = + new PageStreamingApiCallableBuilder<>( + SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS, LIST_SUBSCRIPTIONS_PAGE_STR_DESC); + listSubscriptionsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + listSubscriptionsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + deleteSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); + deleteSubscriptionMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + deleteSubscriptionMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + modifyAckDeadlineMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); + modifyAckDeadlineMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + modifyAckDeadlineMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + acknowledgeMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_ACKNOWLEDGE); + acknowledgeMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + acknowledgeMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + pullMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_PULL); + pullMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + pullMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + modifyPushConfigMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); + modifyPushConfigMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + modifyPushConfigMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + allMethods = + ImmutableList.builder() + .add( + createSubscriptionMethod, + getSubscriptionMethod, + listSubscriptionsMethod, + deleteSubscriptionMethod, + modifyAckDeadlineMethod, + acknowledgeMethod, + pullMethod, + modifyPushConfigMethod) + .build(); + } + } + + private final MethodBuilders methods; // =============== // Factory Methods @@ -155,7 +210,7 @@ public class SubscriberSettings extends ApiCallSettings { * */ public static SubscriberSettings create() { - SubscriberSettings settings = new SubscriberSettings(); + SubscriberSettings settings = new SubscriberSettings(new MethodBuilders()); settings.provideChannelWith( ConnectionSettings.builder() .setServiceAddress(DEFAULT_SERVICE_ADDRESS) @@ -172,53 +227,9 @@ public static SubscriberSettings create() { * * */ - protected SubscriberSettings() { - createSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); - createSubscriptionMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - getSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); - getSubscriptionMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - listSubscriptionsMethod = - new PageStreamingApiCallableBuilder<>( - SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS, LIST_SUBSCRIPTIONS_PAGE_STR_DESC); - listSubscriptionsMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - deleteSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); - deleteSubscriptionMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - modifyAckDeadlineMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); - modifyAckDeadlineMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - acknowledgeMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_ACKNOWLEDGE); - acknowledgeMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - pullMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_PULL); - pullMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - modifyPushConfigMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); - modifyPushConfigMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - allMethods = - ImmutableList.builder() - .add( - createSubscriptionMethod, - getSubscriptionMethod, - listSubscriptionsMethod, - deleteSubscriptionMethod, - modifyAckDeadlineMethod, - acknowledgeMethod, - pullMethod, - modifyPushConfigMethod) - .build(); + protected SubscriberSettings(MethodBuilders methods) { + super(methods.allMethods); + this.methods = methods; } /** @@ -228,7 +239,7 @@ protected SubscriberSettings() { * */ public ApiCallableBuilder createSubscriptionMethod() { - return createSubscriptionMethod; + return methods.createSubscriptionMethod; } /** @@ -238,7 +249,7 @@ public ApiCallableBuilder createSubscriptionMethod() * */ public ApiCallableBuilder getSubscriptionMethod() { - return getSubscriptionMethod; + return methods.getSubscriptionMethod; } /** @@ -250,7 +261,7 @@ public ApiCallableBuilder getSubscriptionM public PageStreamingApiCallableBuilder< ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> listSubscriptionsMethod() { - return listSubscriptionsMethod; + return methods.listSubscriptionsMethod; } /** @@ -260,7 +271,7 @@ public ApiCallableBuilder getSubscriptionM * */ public ApiCallableBuilder deleteSubscriptionMethod() { - return deleteSubscriptionMethod; + return methods.deleteSubscriptionMethod; } /** @@ -270,7 +281,7 @@ public ApiCallableBuilder deleteSubscriptionMe * */ public ApiCallableBuilder modifyAckDeadlineMethod() { - return modifyAckDeadlineMethod; + return methods.modifyAckDeadlineMethod; } /** @@ -280,7 +291,7 @@ public ApiCallableBuilder modifyAckDeadlineMeth * */ public ApiCallableBuilder acknowledgeMethod() { - return acknowledgeMethod; + return methods.acknowledgeMethod; } /** @@ -290,7 +301,7 @@ public ApiCallableBuilder acknowledgeMethod() { * */ public ApiCallableBuilder pullMethod() { - return pullMethod; + return methods.pullMethod; } /** @@ -300,11 +311,7 @@ public ApiCallableBuilder pullMethod() { * */ public ApiCallableBuilder modifyPushConfigMethod() { - return modifyPushConfigMethod; - } - - public ImmutableList allMethods() { - return allMethods; + return methods.modifyPushConfigMethod; } private static PageDescriptor diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java index 4b4c91ebe797..981170db930f 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java @@ -14,6 +14,9 @@ package com.google.gcloud.pubsub.spi; +import com.google.api.gax.core.BackoffParams; +import com.google.api.gax.core.RetryParams; +import com.google.api.gax.grpc.ApiCallSettings; import com.google.gcloud.pubsub.testing.LocalPubsubHelper; import com.google.protobuf.ByteString; import com.google.pubsub.v1.PubsubMessage; @@ -55,11 +58,30 @@ public static void stopServer() throws IOException, InterruptedException { public void setUp() throws Exception { ManagedChannel channel = pubsubHelper.createChannel(); + RetryParams retryParams = + RetryParams.newBuilder() + .setRetryBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(1000L) + .setDelayMultiplier(1.2) + .setMaxDelayMillis(10000L) + .build()) + .setTimeoutBackoff( + BackoffParams.newBuilder() + .setInitialDelayMillis(3000L) + .setDelayMultiplier(1.3) + .setMaxDelayMillis(30000L) + .build()) + .setTotalTimeout(30000L) + .build(); + PublisherSettings publisherSettings = PublisherApi.newSettings(); + publisherSettings.setRetryParamsOnAllMethods(retryParams); publisherSettings.provideChannelWith(channel); publisherApi = PublisherApi.create(publisherSettings); SubscriberSettings subscriberSettings = SubscriberApi.newSettings(); + subscriberSettings.setRetryParamsOnAllMethods(retryParams); subscriberSettings.provideChannelWith(channel); subscriberApi = SubscriberApi.create(subscriberSettings); } From 387c893f08bad99615bf19a77704a076c9b53019 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Fri, 11 Mar 2016 14:47:06 -0800 Subject: [PATCH 197/203] Updates due to code gen --- .../gcloud/pubsub/spi/PublisherApi.java | 6 - .../gcloud/pubsub/spi/PublisherSettings.java | 129 ++++++++------- .../gcloud/pubsub/spi/SubscriberApi.java | 6 - .../gcloud/pubsub/spi/SubscriberSettings.java | 152 +++++++++--------- .../gcloud/pubsub/spi/PublisherSettings.java | 21 +-- .../gcloud/pubsub/spi/SubscriberSettings.java | 7 +- 6 files changed, 163 insertions(+), 158 deletions(-) diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index 3aa8bb6cae92..7f456396501a 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -213,12 +213,6 @@ public static PublisherApi create(PublisherSettings settings) throws IOException protected PublisherApi(PublisherSettings settings) throws IOException { this.channel = settings.getChannel(); - for (ApiCallSettings method : settings.allMethods()) { - if (method.getExecutor() == null) { - method.setExecutor(settings.getExecutor()); - } - } - this.createTopicCallable = settings.createTopicMethod().build(settings); this.publishCallable = settings.publishMethod().build(settings); this.getTopicCallable = settings.getTopicMethod().build(settings); diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java index f10a7b7357f3..83ac11d19526 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java @@ -40,6 +40,7 @@ import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; import com.google.api.gax.grpc.PageDescriptor; +import com.google.api.gax.grpc.ServiceApiSettings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -62,7 +63,7 @@ // AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing. @javax.annotation.Generated("by GAPIC") -public class PublisherSettings extends ApiCallSettings { +public class PublisherSettings extends ServiceApiSettings { // ========= // Constants @@ -131,16 +132,62 @@ public class PublisherSettings extends ApiCallSettings { RETRY_PARAM_DEFINITIONS = definitions.build(); } - private final ApiCallableBuilder createTopicMethod; - private final ApiCallableBuilder publishMethod; - private final ApiCallableBuilder getTopicMethod; - private final PageStreamingApiCallableBuilder - listTopicsMethod; - private final PageStreamingApiCallableBuilder< - ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> - listTopicSubscriptionsMethod; - private final ApiCallableBuilder deleteTopicMethod; - private final ImmutableList allMethods; + private static class MethodBuilders { + private final ApiCallableBuilder createTopicMethod; + private final ApiCallableBuilder publishMethod; + private final ApiCallableBuilder getTopicMethod; + private final PageStreamingApiCallableBuilder + listTopicsMethod; + private final PageStreamingApiCallableBuilder< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + listTopicSubscriptionsMethod; + private final ApiCallableBuilder deleteTopicMethod; + private final ImmutableList allMethods; + + public MethodBuilders() { + createTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_CREATE_TOPIC); + createTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + createTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH); + publishMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + publishMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + getTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_GET_TOPIC); + getTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + getTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + listTopicsMethod = + new PageStreamingApiCallableBuilder<>( + PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC); + listTopicsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + listTopicsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + listTopicSubscriptionsMethod = + new PageStreamingApiCallableBuilder<>( + PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS, + LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC); + listTopicSubscriptionsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + listTopicSubscriptionsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + deleteTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_DELETE_TOPIC); + deleteTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + deleteTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + allMethods = + ImmutableList.builder() + .add( + createTopicMethod, + publishMethod, + getTopicMethod, + listTopicsMethod, + listTopicSubscriptionsMethod, + deleteTopicMethod) + .build(); + } + } + + private final MethodBuilders methods; // =============== // Factory Methods @@ -153,7 +200,7 @@ public class PublisherSettings extends ApiCallSettings { * */ public static PublisherSettings create() { - PublisherSettings settings = new PublisherSettings(); + PublisherSettings settings = new PublisherSettings(new MethodBuilders()); settings.provideChannelWith( ConnectionSettings.builder() .setServiceAddress(DEFAULT_SERVICE_ADDRESS) @@ -170,45 +217,9 @@ public static PublisherSettings create() { * * */ - protected PublisherSettings() { - createTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_CREATE_TOPIC); - createTopicMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH); - publishMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - getTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_GET_TOPIC); - getTopicMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - listTopicsMethod = - new PageStreamingApiCallableBuilder<>( - PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC); - listTopicsMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - listTopicSubscriptionsMethod = - new PageStreamingApiCallableBuilder<>( - PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS, LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC); - listTopicSubscriptionsMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - deleteTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_DELETE_TOPIC); - deleteTopicMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - allMethods = - ImmutableList.builder() - .add( - createTopicMethod, - publishMethod, - getTopicMethod, - listTopicsMethod, - listTopicSubscriptionsMethod, - deleteTopicMethod) - .build(); + protected PublisherSettings(MethodBuilders methods) { + super(methods.allMethods); + this.methods = methods; } /** @@ -218,7 +229,7 @@ protected PublisherSettings() { * */ public ApiCallableBuilder createTopicMethod() { - return createTopicMethod; + return methods.createTopicMethod; } /** @@ -228,7 +239,7 @@ public ApiCallableBuilder createTopicMethod() { * */ public ApiCallableBuilder publishMethod() { - return publishMethod; + return methods.publishMethod; } /** @@ -238,7 +249,7 @@ public ApiCallableBuilder publishMethod() { * */ public ApiCallableBuilder getTopicMethod() { - return getTopicMethod; + return methods.getTopicMethod; } /** @@ -249,7 +260,7 @@ public ApiCallableBuilder getTopicMethod() { */ public PageStreamingApiCallableBuilder listTopicsMethod() { - return listTopicsMethod; + return methods.listTopicsMethod; } /** @@ -261,7 +272,7 @@ public ApiCallableBuilder getTopicMethod() { public PageStreamingApiCallableBuilder< ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> listTopicSubscriptionsMethod() { - return listTopicSubscriptionsMethod; + return methods.listTopicSubscriptionsMethod; } /** @@ -271,11 +282,7 @@ public ApiCallableBuilder getTopicMethod() { * */ public ApiCallableBuilder deleteTopicMethod() { - return deleteTopicMethod; - } - - public ImmutableList allMethods() { - return allMethods; + return methods.deleteTopicMethod; } private static PageDescriptor diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index 5b8dd746bdda..db69a80c750e 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -216,12 +216,6 @@ public static SubscriberApi create(SubscriberSettings settings) throws IOExcepti protected SubscriberApi(SubscriberSettings settings) throws IOException { this.channel = settings.getChannel(); - for (ApiCallSettings method : settings.allMethods()) { - if (method.getExecutor() == null) { - method.setExecutor(settings.getExecutor()); - } - } - this.createSubscriptionCallable = settings.createSubscriptionMethod().build(settings); this.getSubscriptionCallable = settings.getSubscriptionMethod().build(settings); this.listSubscriptionsCallable = settings.listSubscriptionsMethod().build(settings); diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java index e5cfd1d4a9b1..12242dc47005 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java @@ -40,6 +40,7 @@ import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; import com.google.api.gax.grpc.PageDescriptor; +import com.google.api.gax.grpc.ServiceApiSettings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -63,7 +64,7 @@ // AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing. @javax.annotation.Generated("by GAPIC") -public class SubscriberSettings extends ApiCallSettings { +public class SubscriberSettings extends ServiceApiSettings { // ========= // Constants @@ -132,17 +133,72 @@ public class SubscriberSettings extends ApiCallSettings { RETRY_PARAM_DEFINITIONS = definitions.build(); } - private final ApiCallableBuilder createSubscriptionMethod; - private final ApiCallableBuilder getSubscriptionMethod; - private final PageStreamingApiCallableBuilder< - ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> - listSubscriptionsMethod; - private final ApiCallableBuilder deleteSubscriptionMethod; - private final ApiCallableBuilder modifyAckDeadlineMethod; - private final ApiCallableBuilder acknowledgeMethod; - private final ApiCallableBuilder pullMethod; - private final ApiCallableBuilder modifyPushConfigMethod; - private final ImmutableList allMethods; + private static class MethodBuilders { + private final ApiCallableBuilder createSubscriptionMethod; + private final ApiCallableBuilder getSubscriptionMethod; + private final PageStreamingApiCallableBuilder< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> + listSubscriptionsMethod; + private final ApiCallableBuilder deleteSubscriptionMethod; + private final ApiCallableBuilder modifyAckDeadlineMethod; + private final ApiCallableBuilder acknowledgeMethod; + private final ApiCallableBuilder pullMethod; + private final ApiCallableBuilder modifyPushConfigMethod; + private final ImmutableList allMethods; + + public MethodBuilders() { + createSubscriptionMethod = + new ApiCallableBuilder<>(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); + createSubscriptionMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + createSubscriptionMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + getSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); + getSubscriptionMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + getSubscriptionMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + listSubscriptionsMethod = + new PageStreamingApiCallableBuilder<>( + SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS, LIST_SUBSCRIPTIONS_PAGE_STR_DESC); + listSubscriptionsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + listSubscriptionsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + deleteSubscriptionMethod = + new ApiCallableBuilder<>(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); + deleteSubscriptionMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + deleteSubscriptionMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + modifyAckDeadlineMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); + modifyAckDeadlineMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + modifyAckDeadlineMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + acknowledgeMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_ACKNOWLEDGE); + acknowledgeMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + acknowledgeMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + pullMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_PULL); + pullMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + pullMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + modifyPushConfigMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); + modifyPushConfigMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); + modifyPushConfigMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + + allMethods = + ImmutableList.builder() + .add( + createSubscriptionMethod, + getSubscriptionMethod, + listSubscriptionsMethod, + deleteSubscriptionMethod, + modifyAckDeadlineMethod, + acknowledgeMethod, + pullMethod, + modifyPushConfigMethod) + .build(); + } + } + + private final MethodBuilders methods; // =============== // Factory Methods @@ -155,7 +211,7 @@ public class SubscriberSettings extends ApiCallSettings { * */ public static SubscriberSettings create() { - SubscriberSettings settings = new SubscriberSettings(); + SubscriberSettings settings = new SubscriberSettings(new MethodBuilders()); settings.provideChannelWith( ConnectionSettings.builder() .setServiceAddress(DEFAULT_SERVICE_ADDRESS) @@ -172,53 +228,9 @@ public static SubscriberSettings create() { * * */ - protected SubscriberSettings() { - createSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); - createSubscriptionMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - getSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_GET_SUBSCRIPTION); - getSubscriptionMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - listSubscriptionsMethod = - new PageStreamingApiCallableBuilder<>( - SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS, LIST_SUBSCRIPTIONS_PAGE_STR_DESC); - listSubscriptionsMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - deleteSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); - deleteSubscriptionMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - modifyAckDeadlineMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_ACK_DEADLINE); - modifyAckDeadlineMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - acknowledgeMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_ACKNOWLEDGE); - acknowledgeMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - pullMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_PULL); - pullMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - modifyPushConfigMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_MODIFY_PUSH_CONFIG); - modifyPushConfigMethod.setRetryDefaults( - RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default")); - - allMethods = - ImmutableList.builder() - .add( - createSubscriptionMethod, - getSubscriptionMethod, - listSubscriptionsMethod, - deleteSubscriptionMethod, - modifyAckDeadlineMethod, - acknowledgeMethod, - pullMethod, - modifyPushConfigMethod) - .build(); + protected SubscriberSettings(MethodBuilders methods) { + super(methods.allMethods); + this.methods = methods; } /** @@ -228,7 +240,7 @@ protected SubscriberSettings() { * */ public ApiCallableBuilder createSubscriptionMethod() { - return createSubscriptionMethod; + return methods.createSubscriptionMethod; } /** @@ -238,7 +250,7 @@ public ApiCallableBuilder createSubscriptionMethod() * */ public ApiCallableBuilder getSubscriptionMethod() { - return getSubscriptionMethod; + return methods.getSubscriptionMethod; } /** @@ -250,7 +262,7 @@ public ApiCallableBuilder getSubscriptionM public PageStreamingApiCallableBuilder< ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> listSubscriptionsMethod() { - return listSubscriptionsMethod; + return methods.listSubscriptionsMethod; } /** @@ -260,7 +272,7 @@ public ApiCallableBuilder getSubscriptionM * */ public ApiCallableBuilder deleteSubscriptionMethod() { - return deleteSubscriptionMethod; + return methods.deleteSubscriptionMethod; } /** @@ -270,7 +282,7 @@ public ApiCallableBuilder deleteSubscriptionMe * */ public ApiCallableBuilder modifyAckDeadlineMethod() { - return modifyAckDeadlineMethod; + return methods.modifyAckDeadlineMethod; } /** @@ -280,7 +292,7 @@ public ApiCallableBuilder modifyAckDeadlineMeth * */ public ApiCallableBuilder acknowledgeMethod() { - return acknowledgeMethod; + return methods.acknowledgeMethod; } /** @@ -290,7 +302,7 @@ public ApiCallableBuilder acknowledgeMethod() { * */ public ApiCallableBuilder pullMethod() { - return pullMethod; + return methods.pullMethod; } /** @@ -300,11 +312,7 @@ public ApiCallableBuilder pullMethod() { * */ public ApiCallableBuilder modifyPushConfigMethod() { - return modifyPushConfigMethod; - } - - public ImmutableList allMethods() { - return allMethods; + return methods.modifyPushConfigMethod; } private static PageDescriptor diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java index a8e76ccf586c..83ac11d19526 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java @@ -133,16 +133,16 @@ public class PublisherSettings extends ServiceApiSettings { } private static class MethodBuilders { - public final ApiCallableBuilder createTopicMethod; - public final ApiCallableBuilder publishMethod; - public final ApiCallableBuilder getTopicMethod; - public final PageStreamingApiCallableBuilder + private final ApiCallableBuilder createTopicMethod; + private final ApiCallableBuilder publishMethod; + private final ApiCallableBuilder getTopicMethod; + private final PageStreamingApiCallableBuilder listTopicsMethod; - public final PageStreamingApiCallableBuilder< + private final PageStreamingApiCallableBuilder< ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> listTopicSubscriptionsMethod; - public final ApiCallableBuilder deleteTopicMethod; - public final ImmutableList allMethods; + private final ApiCallableBuilder deleteTopicMethod; + private final ImmutableList allMethods; public MethodBuilders() { createTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_CREATE_TOPIC); @@ -165,9 +165,10 @@ public MethodBuilders() { listTopicSubscriptionsMethod = new PageStreamingApiCallableBuilder<>( - PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS, LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC); - listTopicsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); - listTopicsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); + PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS, + LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC); + listTopicSubscriptionsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); + listTopicSubscriptionsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); deleteTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_DELETE_TOPIC); deleteTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java index 75ad0b2fbdbe..12242dc47005 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java @@ -58,7 +58,6 @@ import com.google.pubsub.v1.PullResponse; import com.google.pubsub.v1.SubscriberGrpc; import com.google.pubsub.v1.Subscription; - import io.grpc.Status; // Manually-added imports: add custom (non-generated) imports after this point. @@ -148,7 +147,8 @@ private static class MethodBuilders { private final ImmutableList allMethods; public MethodBuilders() { - createSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); + createSubscriptionMethod = + new ApiCallableBuilder<>(SubscriberGrpc.METHOD_CREATE_SUBSCRIPTION); createSubscriptionMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); createSubscriptionMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); @@ -162,7 +162,8 @@ public MethodBuilders() { listSubscriptionsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); listSubscriptionsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); - deleteSubscriptionMethod = new ApiCallableBuilder<>(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); + deleteSubscriptionMethod = + new ApiCallableBuilder<>(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); deleteSubscriptionMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); deleteSubscriptionMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); From bbf33393e80346f9b73d3c811afbf65f292cd446 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Tue, 15 Mar 2016 20:59:46 -0700 Subject: [PATCH 198/203] Removing newSettings() method from XApi classes --- .../java/com/google/gcloud/pubsub/spi/PublisherApi.java | 7 ------- .../java/com/google/gcloud/pubsub/spi/SubscriberApi.java | 7 ------- .../java/com/google/gcloud/pubsub/spi/PublisherApi.java | 7 ------- .../java/com/google/gcloud/pubsub/spi/SubscriberApi.java | 7 ------- 4 files changed, 28 deletions(-) diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index 7f456396501a..ce34fb6f8380 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -175,13 +175,6 @@ public static final String parseTopicFromTopicPath(String topicPath) { // Factory Methods // =============== - /** - * Constructs an instance of PublisherSettings with default settings. - */ - public static PublisherSettings newSettings() { - return PublisherSettings.create(); - } - /** * Constructs an instance of PublisherApi with default settings. * diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index db69a80c750e..0a16a41e9c24 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -178,13 +178,6 @@ public static final String parseSubscriptionFromSubscriptionPath(String subscrip // Factory Methods // =============== - /** - * Constructs an instance of SubscriberSettings with default settings. - */ - public static SubscriberSettings newSettings() { - return SubscriberSettings.create(); - } - /** * Constructs an instance of SubscriberApi with default settings. * diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index 7f456396501a..ce34fb6f8380 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -175,13 +175,6 @@ public static final String parseTopicFromTopicPath(String topicPath) { // Factory Methods // =============== - /** - * Constructs an instance of PublisherSettings with default settings. - */ - public static PublisherSettings newSettings() { - return PublisherSettings.create(); - } - /** * Constructs an instance of PublisherApi with default settings. * diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index db69a80c750e..0a16a41e9c24 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -178,13 +178,6 @@ public static final String parseSubscriptionFromSubscriptionPath(String subscrip // Factory Methods // =============== - /** - * Constructs an instance of SubscriberSettings with default settings. - */ - public static SubscriberSettings newSettings() { - return SubscriberSettings.create(); - } - /** * Constructs an instance of SubscriberApi with default settings. * From 1647f9e883a1cd7ff9191925b4a8ad164c44dbb3 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Tue, 15 Mar 2016 21:04:06 -0700 Subject: [PATCH 199/203] Fixing build from last change --- .../main/java/com/google/gcloud/pubsub/spi/PublisherApi.java | 2 +- .../main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java | 2 +- .../main/java/com/google/gcloud/pubsub/spi/PublisherApi.java | 2 +- .../main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java | 2 +- .../java/com/google/gcloud/pubsub/spi/PublisherApiTest.java | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index ce34fb6f8380..78ccc1f6e026 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -182,7 +182,7 @@ public static final String parseTopicFromTopicPath(String topicPath) { * */ public static PublisherApi create() throws IOException { - return create(newSettings()); + return create(PublisherSettings.create()); } /** diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index 0a16a41e9c24..191c0006f12b 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -185,7 +185,7 @@ public static final String parseSubscriptionFromSubscriptionPath(String subscrip * */ public static SubscriberApi create() throws IOException { - return create(newSettings()); + return create(SubscriberSettings.create()); } /** diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java index ce34fb6f8380..78ccc1f6e026 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java @@ -182,7 +182,7 @@ public static final String parseTopicFromTopicPath(String topicPath) { * */ public static PublisherApi create() throws IOException { - return create(newSettings()); + return create(PublisherSettings.create()); } /** diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java index 0a16a41e9c24..191c0006f12b 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java @@ -185,7 +185,7 @@ public static final String parseSubscriptionFromSubscriptionPath(String subscrip * */ public static SubscriberApi create() throws IOException { - return create(newSettings()); + return create(SubscriberSettings.create()); } /** diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java index 981170db930f..4330c590a182 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java @@ -75,12 +75,12 @@ public void setUp() throws Exception { .setTotalTimeout(30000L) .build(); - PublisherSettings publisherSettings = PublisherApi.newSettings(); + PublisherSettings publisherSettings = PublisherSettings.create(); publisherSettings.setRetryParamsOnAllMethods(retryParams); publisherSettings.provideChannelWith(channel); publisherApi = PublisherApi.create(publisherSettings); - SubscriberSettings subscriberSettings = SubscriberApi.newSettings(); + SubscriberSettings subscriberSettings = SubscriberSettings.create(); subscriberSettings.setRetryParamsOnAllMethods(retryParams); subscriberSettings.provideChannelWith(channel); subscriberApi = SubscriberApi.create(subscriberSettings); From 1c4a73ebe822e69b86af1bd4a6101e3c18f74683 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Wed, 16 Mar 2016 16:25:15 -0700 Subject: [PATCH 200/203] Putting spi files under spi.v1 --- .../pubsub/spi/{ => v1}/PublisherApi.java | 2 +- .../pubsub/spi/v1}/PublisherSettings.java | 2 +- .../pubsub/spi/{ => v1}/SubscriberApi.java | 2 +- .../pubsub/spi/v1}/SubscriberSettings.java | 2 +- .../spi/testing/LocalPublisherImpl.java | 125 ------------------ .../pubsub/spi/{ => v1}/PublisherApi.java | 2 +- .../pubsub/spi/v1}/PublisherSettings.java | 2 +- .../pubsub/spi/{ => v1}/SubscriberApi.java | 2 +- .../pubsub/spi/v1}/SubscriberSettings.java | 2 +- .../pubsub/spi/{ => v1}/PublisherApiTest.java | 3 +- 10 files changed, 9 insertions(+), 135 deletions(-) rename gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/{ => v1}/PublisherApi.java (99%) rename gcloud-java-pubsub/{src/main/java/com/google/gcloud/pubsub/spi => baseline/src/main/java/com/google/gcloud/pubsub/spi/v1}/PublisherSettings.java (99%) rename gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/{ => v1}/SubscriberApi.java (99%) rename gcloud-java-pubsub/{src/main/java/com/google/gcloud/pubsub/spi => baseline/src/main/java/com/google/gcloud/pubsub/spi/v1}/SubscriberSettings.java (99%) delete mode 100644 gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java rename gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/{ => v1}/PublisherApi.java (99%) rename gcloud-java-pubsub/{baseline/src/main/java/com/google/gcloud/pubsub/spi => src/main/java/com/google/gcloud/pubsub/spi/v1}/PublisherSettings.java (99%) rename gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/{ => v1}/SubscriberApi.java (99%) rename gcloud-java-pubsub/{baseline/src/main/java/com/google/gcloud/pubsub/spi => src/main/java/com/google/gcloud/pubsub/spi/v1}/SubscriberSettings.java (99%) rename gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/{ => v1}/PublisherApiTest.java (98%) diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java similarity index 99% rename from gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java rename to gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java index 78ccc1f6e026..6ace2998698b 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java similarity index 99% rename from gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java rename to gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java index 83ac11d19526..70b188735890 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.ConnectionSettings; diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java similarity index 99% rename from gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java rename to gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java index 191c0006f12b..16e1435b8582 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java similarity index 99% rename from gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java rename to gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java index 12242dc47005..2680d8429938 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.ConnectionSettings; diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java deleted file mode 100644 index 13aeb26cafe0..000000000000 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2015 Google Inc. All Rights Reserved. - * - * 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.gcloud.pubsub.spi.testing; - -import com.google.gcloud.pubsub.spi.PublisherApi; -import com.google.protobuf.Empty; -import com.google.pubsub.v1.DeleteTopicRequest; -import com.google.pubsub.v1.GetTopicRequest; -import com.google.pubsub.v1.ListTopicSubscriptionsRequest; -import com.google.pubsub.v1.ListTopicSubscriptionsResponse; -import com.google.pubsub.v1.ListTopicsRequest; -import com.google.pubsub.v1.ListTopicsResponse; -import com.google.pubsub.v1.PublishRequest; -import com.google.pubsub.v1.PublishResponse; -import com.google.pubsub.v1.PublisherGrpc.Publisher; -import com.google.pubsub.v1.PubsubMessage; -import com.google.pubsub.v1.Topic; - -import io.grpc.stub.StreamObserver; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class LocalPublisherImpl implements Publisher { - - private Map> topics = new HashMap<>(); - - @Override - public void createTopic(Topic request, StreamObserver responseObserver) { - topics.put(request.getName(), new ArrayList()); - - Topic response = Topic.newBuilder().setName(request.getName()).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); - } - - @Override - public void publish(PublishRequest request, StreamObserver responseObserver) { - List topicMessages = topics.get(request.getTopic()); - List ids = new ArrayList<>(); - int index = 0; - for (PubsubMessage msg : request.getMessagesList()) { - topicMessages.add(msg); - ids.add(new Integer(index).toString()); - } - responseObserver.onNext(PublishResponse.newBuilder().addAllMessageIds(ids).build()); - responseObserver.onCompleted(); - } - - @Override - public void getTopic(GetTopicRequest request, StreamObserver responseObserver) { - if (topics.get(request.getTopic()) == null) { - throw new IllegalArgumentException("topic doesn't exist: " + request.getTopic()); - } - Topic response = Topic.newBuilder().setName(request.getTopic()).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); - } - - @Override - public void listTopics( - ListTopicsRequest request, StreamObserver responseObserver) { - List responseTopics = new ArrayList<>(); - for (String topicName : topics.keySet()) { - String projectOfTopic = PublisherApi.ResourceNames.parseProjectFromTopicPath(topicName); - String projectOfRequest = PublisherApi.ResourceNames.parseProjectFromProjectPath(request.getProject()); - if (projectOfTopic.equals(projectOfRequest)) { - Topic topicObj = Topic.newBuilder().setName(topicName).build(); - responseTopics.add(topicObj); - } - } - Collections.sort( - responseTopics, - new Comparator() { - @Override - public int compare(Topic o1, Topic o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - ListTopicsResponse.Builder response = ListTopicsResponse.newBuilder(); - response.setNextPageToken(""); - response.addAllTopics(responseTopics); - responseObserver.onNext(response.build()); - responseObserver.onCompleted(); - } - - @Override - public void listTopicSubscriptions( - ListTopicSubscriptionsRequest request, - StreamObserver responseObserver) { - responseObserver.onNext(ListTopicSubscriptionsResponse.getDefaultInstance()); - responseObserver.onCompleted(); - } - - @Override - public void deleteTopic(DeleteTopicRequest request, StreamObserver responseObserver) { - topics.remove(request.getTopic()); - responseObserver.onNext(Empty.getDefaultInstance()); - responseObserver.onCompleted(); - } - - public Map> getTopics() { - return topics; - } - - public void reset() { - topics = new HashMap<>(); - } -} diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java similarity index 99% rename from gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java rename to gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java index 78ccc1f6e026..6ace2998698b 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java similarity index 99% rename from gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java rename to gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java index 83ac11d19526..70b188735890 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.ConnectionSettings; diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java similarity index 99% rename from gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java rename to gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java index 191c0006f12b..16e1435b8582 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java similarity index 99% rename from gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java rename to gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java index 12242dc47005..2680d8429938 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.ConnectionSettings; diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java similarity index 98% rename from gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java rename to gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java index 4330c590a182..aaf292ff917d 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java @@ -12,11 +12,10 @@ * the License. */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.RetryParams; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.gcloud.pubsub.testing.LocalPubsubHelper; import com.google.protobuf.ByteString; import com.google.pubsub.v1.PubsubMessage; From 2f12265aad444c309d77dabb9fca81177f4b8316 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Fri, 18 Mar 2016 11:01:47 -0700 Subject: [PATCH 201/203] Bundling descriptor for Publish --- .../gcloud/pubsub/spi/v1/PublisherApi.java | 12 ++- .../pubsub/spi/v1/PublisherSettings.java | 98 ++++++++++++++++--- .../gcloud/pubsub/spi/v1/SubscriberApi.java | 1 - .../pubsub/spi/v1/SubscriberSettings.java | 24 ++--- gcloud-java-pubsub/pom.xml | 2 +- .../gcloud/pubsub/spi/v1/PublisherApi.java | 12 ++- .../pubsub/spi/v1/PublisherSettings.java | 98 ++++++++++++++++--- .../gcloud/pubsub/spi/v1/SubscriberApi.java | 1 - .../pubsub/spi/v1/SubscriberSettings.java | 24 ++--- .../pubsub/spi/v1/PublisherApiTest.java | 38 +++++++ 10 files changed, 253 insertions(+), 57 deletions(-) diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java index 6ace2998698b..1930702f9e84 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java @@ -33,8 +33,9 @@ package com.google.gcloud.pubsub.spi.v1; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.ApiCallable.BundlableApiCallableInfo; +import com.google.api.gax.grpc.BundlerFactory; import com.google.api.gax.protobuf.PathTemplate; import com.google.protobuf.Empty; import com.google.pubsub.v1.DeleteTopicRequest; @@ -207,7 +208,14 @@ protected PublisherApi(PublisherSettings settings) throws IOException { this.channel = settings.getChannel(); this.createTopicCallable = settings.createTopicMethod().build(settings); - this.publishCallable = settings.publishMethod().build(settings); + BundlableApiCallableInfo bundlablePublish = + settings.publishMethod().buildBundlable(settings); + this.publishCallable = bundlablePublish.getApiCallable(); + BundlerFactory publishBundlerFactory = + bundlablePublish.getBundlerFactory(); + if (publishBundlerFactory != null) { + this.closeables.add(publishBundlerFactory); + } this.getTopicCallable = settings.getTopicMethod().build(settings); this.listTopicsCallable = settings.listTopicsMethod().build(settings); this.listTopicsIterableCallable = settings.listTopicsMethod().buildPageStreaming(settings); diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java index 70b188735890..5f60fa374553 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java @@ -38,8 +38,11 @@ import com.google.api.gax.core.RetryParams; import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; +import com.google.api.gax.grpc.ApiCallable.BundlableApiCallableBuilder; import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; -import com.google.api.gax.grpc.PageDescriptor; +import com.google.api.gax.grpc.BundlingDescriptor; +import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.RequestIssuer; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -56,8 +59,12 @@ import com.google.pubsub.v1.PublishRequest; import com.google.pubsub.v1.PublishResponse; import com.google.pubsub.v1.PublisherGrpc; +import com.google.pubsub.v1.PubsubMessage; import com.google.pubsub.v1.Topic; import io.grpc.Status; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; // Manually-added imports: add custom (non-generated) imports after this point. @@ -134,7 +141,7 @@ public class PublisherSettings extends ServiceApiSettings { private static class MethodBuilders { private final ApiCallableBuilder createTopicMethod; - private final ApiCallableBuilder publishMethod; + private final BundlableApiCallableBuilder publishMethod; private final ApiCallableBuilder getTopicMethod; private final PageStreamingApiCallableBuilder listTopicsMethod; @@ -149,7 +156,8 @@ public MethodBuilders() { createTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); createTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); - publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH); + publishMethod = + new BundlableApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH, PUBLISH_BUNDLING_DESC); publishMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); publishMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); @@ -223,7 +231,7 @@ protected PublisherSettings(MethodBuilders methods) { } /** - * Returns the ApiCallableBuilder for the API method createTopic. + * Returns the builder for the API method createTopic. * * * @@ -233,17 +241,17 @@ public ApiCallableBuilder createTopicMethod() { } /** - * Returns the ApiCallableBuilder for the API method publish. + * Returns the builder for the API method publish. * * * */ - public ApiCallableBuilder publishMethod() { + public BundlableApiCallableBuilder publishMethod() { return methods.publishMethod; } /** - * Returns the ApiCallableBuilder for the API method getTopic. + * Returns the builder for the API method getTopic. * * * @@ -253,7 +261,7 @@ public ApiCallableBuilder getTopicMethod() { } /** - * Returns the PageStreamingApiCallableBuilder for the API method listTopics. + * Returns the builder for the API method listTopics. * * * @@ -264,7 +272,7 @@ public ApiCallableBuilder getTopicMethod() { } /** - * Returns the PageStreamingApiCallableBuilder for the API method listTopicSubscriptions. + * Returns the builder for the API method listTopicSubscriptions. * * * @@ -276,7 +284,7 @@ public ApiCallableBuilder getTopicMethod() { } /** - * Returns the ApiCallableBuilder for the API method deleteTopic. + * Returns the builder for the API method deleteTopic. * * * @@ -285,9 +293,9 @@ public ApiCallableBuilder deleteTopicMethod() { return methods.deleteTopicMethod; } - private static PageDescriptor + private static PageStreamingDescriptor LIST_TOPICS_PAGE_STR_DESC = - new PageDescriptor() { + new PageStreamingDescriptor() { @Override public Object emptyToken() { return ""; @@ -309,10 +317,10 @@ public Iterable extractResources(ListTopicsResponse payload) { } }; - private static PageDescriptor< + private static PageStreamingDescriptor< ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC = - new PageDescriptor< + new PageStreamingDescriptor< ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>() { @Override public Object emptyToken() { @@ -337,4 +345,66 @@ public Iterable extractResources(ListTopicSubscriptionsResponse payload) return payload.getSubscriptionsList(); } }; + + private static BundlingDescriptor PUBLISH_BUNDLING_DESC = + new BundlingDescriptor() { + @Override + public String getBundlePartitionKey(PublishRequest request) { + return request.getTopic(); + } + + @Override + public PublishRequest mergeRequests(Collection requests) { + PublishRequest firstRequest = requests.iterator().next(); + + List elements = new ArrayList<>(); + for (PublishRequest request : requests) { + elements.addAll(request.getMessagesList()); + } + + PublishRequest bundleRequest = + PublishRequest.newBuilder() + .setTopic(firstRequest.getTopic()) + .addAllMessages(elements) + .build(); + return bundleRequest; + } + + @Override + public void splitResponse( + PublishResponse bundleResponse, + Collection> bundle) { + int bundleMessageIndex = 0; + for (RequestIssuer responder : bundle) { + List subresponseElements = new ArrayList<>(); + int subresponseCount = responder.getRequest().getMessagesCount(); + for (int i = 0; i < subresponseCount; i++) { + subresponseElements.add(bundleResponse.getMessageIds(bundleMessageIndex)); + bundleMessageIndex += 1; + } + PublishResponse response = + PublishResponse.newBuilder().addAllMessageIds(subresponseElements).build(); + responder.setResponse(response); + } + } + + @Override + public void splitException( + Throwable throwable, + Collection> bundle) { + for (RequestIssuer responder : bundle) { + responder.setException(throwable); + } + } + + @Override + public long countElements(PublishRequest request) { + return request.getMessagesCount(); + } + + @Override + public long countBytes(PublishRequest request) { + return request.getSerializedSize(); + } + }; } diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java index 16e1435b8582..c794fddb1943 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java @@ -33,7 +33,6 @@ package com.google.gcloud.pubsub.spi.v1; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.protobuf.Empty; diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java index 2680d8429938..df9ea36e69b8 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java @@ -39,7 +39,7 @@ import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; -import com.google.api.gax.grpc.PageDescriptor; +import com.google.api.gax.grpc.PageStreamingDescriptor; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -234,7 +234,7 @@ protected SubscriberSettings(MethodBuilders methods) { } /** - * Returns the ApiCallableBuilder for the API method createSubscription. + * Returns the builder for the API method createSubscription. * * * @@ -244,7 +244,7 @@ public ApiCallableBuilder createSubscriptionMethod() } /** - * Returns the ApiCallableBuilder for the API method getSubscription. + * Returns the builder for the API method getSubscription. * * * @@ -254,7 +254,7 @@ public ApiCallableBuilder getSubscriptionM } /** - * Returns the PageStreamingApiCallableBuilder for the API method listSubscriptions. + * Returns the builder for the API method listSubscriptions. * * * @@ -266,7 +266,7 @@ public ApiCallableBuilder getSubscriptionM } /** - * Returns the ApiCallableBuilder for the API method deleteSubscription. + * Returns the builder for the API method deleteSubscription. * * * @@ -276,7 +276,7 @@ public ApiCallableBuilder deleteSubscriptionMe } /** - * Returns the ApiCallableBuilder for the API method modifyAckDeadline. + * Returns the builder for the API method modifyAckDeadline. * * * @@ -286,7 +286,7 @@ public ApiCallableBuilder modifyAckDeadlineMeth } /** - * Returns the ApiCallableBuilder for the API method acknowledge. + * Returns the builder for the API method acknowledge. * * * @@ -296,7 +296,7 @@ public ApiCallableBuilder acknowledgeMethod() { } /** - * Returns the ApiCallableBuilder for the API method pull. + * Returns the builder for the API method pull. * * * @@ -306,7 +306,7 @@ public ApiCallableBuilder pullMethod() { } /** - * Returns the ApiCallableBuilder for the API method modifyPushConfig. + * Returns the builder for the API method modifyPushConfig. * * * @@ -315,9 +315,11 @@ public ApiCallableBuilder modifyPushConfigMethod return methods.modifyPushConfigMethod; } - private static PageDescriptor + private static PageStreamingDescriptor< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> LIST_SUBSCRIPTIONS_PAGE_STR_DESC = - new PageDescriptor() { + new PageStreamingDescriptor< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription>() { @Override public Object emptyToken() { return ""; diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index 2fccc5a6560c..987aa99667c9 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -19,7 +19,7 @@ com.google.api gax - 0.0.4 + 0.0.5-SNAPSHOT com.google.api.grpc diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java index 6ace2998698b..1930702f9e84 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java @@ -33,8 +33,9 @@ package com.google.gcloud.pubsub.spi.v1; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.ApiCallable.BundlableApiCallableInfo; +import com.google.api.gax.grpc.BundlerFactory; import com.google.api.gax.protobuf.PathTemplate; import com.google.protobuf.Empty; import com.google.pubsub.v1.DeleteTopicRequest; @@ -207,7 +208,14 @@ protected PublisherApi(PublisherSettings settings) throws IOException { this.channel = settings.getChannel(); this.createTopicCallable = settings.createTopicMethod().build(settings); - this.publishCallable = settings.publishMethod().build(settings); + BundlableApiCallableInfo bundlablePublish = + settings.publishMethod().buildBundlable(settings); + this.publishCallable = bundlablePublish.getApiCallable(); + BundlerFactory publishBundlerFactory = + bundlablePublish.getBundlerFactory(); + if (publishBundlerFactory != null) { + this.closeables.add(publishBundlerFactory); + } this.getTopicCallable = settings.getTopicMethod().build(settings); this.listTopicsCallable = settings.listTopicsMethod().build(settings); this.listTopicsIterableCallable = settings.listTopicsMethod().buildPageStreaming(settings); diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java index 70b188735890..5f60fa374553 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java @@ -38,8 +38,11 @@ import com.google.api.gax.core.RetryParams; import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; +import com.google.api.gax.grpc.ApiCallable.BundlableApiCallableBuilder; import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; -import com.google.api.gax.grpc.PageDescriptor; +import com.google.api.gax.grpc.BundlingDescriptor; +import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.RequestIssuer; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -56,8 +59,12 @@ import com.google.pubsub.v1.PublishRequest; import com.google.pubsub.v1.PublishResponse; import com.google.pubsub.v1.PublisherGrpc; +import com.google.pubsub.v1.PubsubMessage; import com.google.pubsub.v1.Topic; import io.grpc.Status; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; // Manually-added imports: add custom (non-generated) imports after this point. @@ -134,7 +141,7 @@ public class PublisherSettings extends ServiceApiSettings { private static class MethodBuilders { private final ApiCallableBuilder createTopicMethod; - private final ApiCallableBuilder publishMethod; + private final BundlableApiCallableBuilder publishMethod; private final ApiCallableBuilder getTopicMethod; private final PageStreamingApiCallableBuilder listTopicsMethod; @@ -149,7 +156,8 @@ public MethodBuilders() { createTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")); createTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); - publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH); + publishMethod = + new BundlableApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH, PUBLISH_BUNDLING_DESC); publishMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")); publishMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default")); @@ -223,7 +231,7 @@ protected PublisherSettings(MethodBuilders methods) { } /** - * Returns the ApiCallableBuilder for the API method createTopic. + * Returns the builder for the API method createTopic. * * * @@ -233,17 +241,17 @@ public ApiCallableBuilder createTopicMethod() { } /** - * Returns the ApiCallableBuilder for the API method publish. + * Returns the builder for the API method publish. * * * */ - public ApiCallableBuilder publishMethod() { + public BundlableApiCallableBuilder publishMethod() { return methods.publishMethod; } /** - * Returns the ApiCallableBuilder for the API method getTopic. + * Returns the builder for the API method getTopic. * * * @@ -253,7 +261,7 @@ public ApiCallableBuilder getTopicMethod() { } /** - * Returns the PageStreamingApiCallableBuilder for the API method listTopics. + * Returns the builder for the API method listTopics. * * * @@ -264,7 +272,7 @@ public ApiCallableBuilder getTopicMethod() { } /** - * Returns the PageStreamingApiCallableBuilder for the API method listTopicSubscriptions. + * Returns the builder for the API method listTopicSubscriptions. * * * @@ -276,7 +284,7 @@ public ApiCallableBuilder getTopicMethod() { } /** - * Returns the ApiCallableBuilder for the API method deleteTopic. + * Returns the builder for the API method deleteTopic. * * * @@ -285,9 +293,9 @@ public ApiCallableBuilder deleteTopicMethod() { return methods.deleteTopicMethod; } - private static PageDescriptor + private static PageStreamingDescriptor LIST_TOPICS_PAGE_STR_DESC = - new PageDescriptor() { + new PageStreamingDescriptor() { @Override public Object emptyToken() { return ""; @@ -309,10 +317,10 @@ public Iterable extractResources(ListTopicsResponse payload) { } }; - private static PageDescriptor< + private static PageStreamingDescriptor< ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC = - new PageDescriptor< + new PageStreamingDescriptor< ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>() { @Override public Object emptyToken() { @@ -337,4 +345,66 @@ public Iterable extractResources(ListTopicSubscriptionsResponse payload) return payload.getSubscriptionsList(); } }; + + private static BundlingDescriptor PUBLISH_BUNDLING_DESC = + new BundlingDescriptor() { + @Override + public String getBundlePartitionKey(PublishRequest request) { + return request.getTopic(); + } + + @Override + public PublishRequest mergeRequests(Collection requests) { + PublishRequest firstRequest = requests.iterator().next(); + + List elements = new ArrayList<>(); + for (PublishRequest request : requests) { + elements.addAll(request.getMessagesList()); + } + + PublishRequest bundleRequest = + PublishRequest.newBuilder() + .setTopic(firstRequest.getTopic()) + .addAllMessages(elements) + .build(); + return bundleRequest; + } + + @Override + public void splitResponse( + PublishResponse bundleResponse, + Collection> bundle) { + int bundleMessageIndex = 0; + for (RequestIssuer responder : bundle) { + List subresponseElements = new ArrayList<>(); + int subresponseCount = responder.getRequest().getMessagesCount(); + for (int i = 0; i < subresponseCount; i++) { + subresponseElements.add(bundleResponse.getMessageIds(bundleMessageIndex)); + bundleMessageIndex += 1; + } + PublishResponse response = + PublishResponse.newBuilder().addAllMessageIds(subresponseElements).build(); + responder.setResponse(response); + } + } + + @Override + public void splitException( + Throwable throwable, + Collection> bundle) { + for (RequestIssuer responder : bundle) { + responder.setException(throwable); + } + } + + @Override + public long countElements(PublishRequest request) { + return request.getMessagesCount(); + } + + @Override + public long countBytes(PublishRequest request) { + return request.getSerializedSize(); + } + }; } diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java index 16e1435b8582..c794fddb1943 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java @@ -33,7 +33,6 @@ package com.google.gcloud.pubsub.spi.v1; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.protobuf.Empty; diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java index 2680d8429938..df9ea36e69b8 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java @@ -39,7 +39,7 @@ import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder; import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder; -import com.google.api.gax.grpc.PageDescriptor; +import com.google.api.gax.grpc.PageStreamingDescriptor; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -234,7 +234,7 @@ protected SubscriberSettings(MethodBuilders methods) { } /** - * Returns the ApiCallableBuilder for the API method createSubscription. + * Returns the builder for the API method createSubscription. * * * @@ -244,7 +244,7 @@ public ApiCallableBuilder createSubscriptionMethod() } /** - * Returns the ApiCallableBuilder for the API method getSubscription. + * Returns the builder for the API method getSubscription. * * * @@ -254,7 +254,7 @@ public ApiCallableBuilder getSubscriptionM } /** - * Returns the PageStreamingApiCallableBuilder for the API method listSubscriptions. + * Returns the builder for the API method listSubscriptions. * * * @@ -266,7 +266,7 @@ public ApiCallableBuilder getSubscriptionM } /** - * Returns the ApiCallableBuilder for the API method deleteSubscription. + * Returns the builder for the API method deleteSubscription. * * * @@ -276,7 +276,7 @@ public ApiCallableBuilder deleteSubscriptionMe } /** - * Returns the ApiCallableBuilder for the API method modifyAckDeadline. + * Returns the builder for the API method modifyAckDeadline. * * * @@ -286,7 +286,7 @@ public ApiCallableBuilder modifyAckDeadlineMeth } /** - * Returns the ApiCallableBuilder for the API method acknowledge. + * Returns the builder for the API method acknowledge. * * * @@ -296,7 +296,7 @@ public ApiCallableBuilder acknowledgeMethod() { } /** - * Returns the ApiCallableBuilder for the API method pull. + * Returns the builder for the API method pull. * * * @@ -306,7 +306,7 @@ public ApiCallableBuilder pullMethod() { } /** - * Returns the ApiCallableBuilder for the API method modifyPushConfig. + * Returns the builder for the API method modifyPushConfig. * * * @@ -315,9 +315,11 @@ public ApiCallableBuilder modifyPushConfigMethod return methods.modifyPushConfigMethod; } - private static PageDescriptor + private static PageStreamingDescriptor< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> LIST_SUBSCRIPTIONS_PAGE_STR_DESC = - new PageDescriptor() { + new PageStreamingDescriptor< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription>() { @Override public Object emptyToken() { return ""; diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java index aaf292ff917d..a092c2fdd7ee 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java @@ -16,6 +16,7 @@ import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.RetryParams; +import com.google.api.gax.grpc.BundlingSettings; import com.google.gcloud.pubsub.testing.LocalPubsubHelper; import com.google.protobuf.ByteString; import com.google.pubsub.v1.PubsubMessage; @@ -30,6 +31,7 @@ import java.util.Collections; import java.util.List; +import org.joda.time.Duration; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -40,6 +42,7 @@ public class PublisherApiTest { private static LocalPubsubHelper pubsubHelper; private PublisherApi publisherApi; + private PublisherApi bundledPublisherApi; private SubscriberApi subscriberApi; @BeforeClass @@ -79,6 +82,18 @@ public void setUp() throws Exception { publisherSettings.provideChannelWith(channel); publisherApi = PublisherApi.create(publisherSettings); + BundlingSettings bundlingSettings = + BundlingSettings.newBuilder() + .setElementCountThreshold(10) + .setDelayThreshold(Duration.standardSeconds(30)) + .build(); + + PublisherSettings bundledPublisherSettings = PublisherSettings.create(); + bundledPublisherSettings.setRetryParamsOnAllMethods(retryParams); + bundledPublisherSettings.provideChannelWith(channel); + bundledPublisherSettings.publishMethod().setBundlingSettings(bundlingSettings); + bundledPublisherApi = PublisherApi.create(bundledPublisherSettings); + SubscriberSettings subscriberSettings = SubscriberSettings.create(); subscriberSettings.setRetryParamsOnAllMethods(retryParams); subscriberSettings.provideChannelWith(channel); @@ -93,6 +108,9 @@ public void tearDown() throws Exception { if (subscriberApi != null) { subscriberApi.close(); } + if (bundledPublisherApi != null) { + bundledPublisherApi.close(); + } pubsubHelper.reset(); } @@ -122,6 +140,26 @@ public void testPublish() throws Exception { "pubsub-message", response.getReceivedMessages(0).getMessage().getData().toStringUtf8()); } + @Test + public void testBundledPublish() throws Exception { + String topicName = PublisherApi.ResourceNames.formatTopicPath("my-project", "publish-topic"); + bundledPublisherApi.createTopic(topicName); + + String subscriberName = SubscriberApi.ResourceNames.formatSubscriptionPath("my-project", "my-subscribe"); + PushConfig config = PushConfig.getDefaultInstance(); + subscriberApi.createSubscription(subscriberName, topicName, config, 5); + + PubsubMessage msg = + PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("pubsub-message")).build(); + // This is a synchronous publish and should trigger the default blockingCallCountThreshold of 1 + bundledPublisherApi.publish(topicName, Collections.singletonList(msg)); + + PullResponse response = subscriberApi.pull(subscriberName, true, 100); + Assert.assertEquals(1, response.getReceivedMessagesCount()); + Assert.assertEquals( + "pubsub-message", response.getReceivedMessages(0).getMessage().getData().toStringUtf8()); + } + @Test public void testGetTopic() throws Exception { String topicName = PublisherApi.ResourceNames.formatTopicPath("my-project", "fun-topic"); From b47389583bf11a21220e58edc2ea59fc240b5ec5 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Tue, 22 Mar 2016 12:11:01 -0700 Subject: [PATCH 202/203] Regenerating (fixing style issues) --- .../gcloud/pubsub/spi/v1/PublisherApi.java | 48 +++++++++--------- .../pubsub/spi/v1/PublisherSettings.java | 9 ++-- .../gcloud/pubsub/spi/v1/SubscriberApi.java | 50 ++++++++++--------- .../pubsub/spi/v1/SubscriberSettings.java | 9 ++-- gcloud-java-pubsub/pom.xml | 2 +- .../gcloud/pubsub/spi/v1/PublisherApi.java | 48 +++++++++--------- .../pubsub/spi/v1/PublisherSettings.java | 9 ++-- .../gcloud/pubsub/spi/v1/SubscriberApi.java | 50 ++++++++++--------- .../pubsub/spi/v1/SubscriberSettings.java | 9 ++-- .../pubsub/spi/v1/PublisherApiTest.java | 6 ++- 10 files changed, 127 insertions(+), 113 deletions(-) diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java index 1930702f9e84..fa6da27a72bd 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java @@ -66,9 +66,25 @@ */ @javax.annotation.Generated("by GAPIC") public class PublisherApi implements AutoCloseable { + // ======== + // Members + // ======== + + private final ManagedChannel channel; + private final List closeables = new ArrayList<>(); + + private final ApiCallable createTopicCallable; + private final ApiCallable publishCallable; + private final ApiCallable getTopicCallable; + private final ApiCallable listTopicsCallable; + private final ApiCallable> listTopicsIterableCallable; + private final ApiCallable + listTopicSubscriptionsCallable; + private final ApiCallable> + listTopicSubscriptionsIterableCallable; + private final ApiCallable deleteTopicCallable; public static class ResourceNames { - private ResourceNames() {} // ======================= // ResourceNames Constants @@ -94,6 +110,8 @@ private ResourceNames() {} private static final PathTemplate TOPIC_PATH_TEMPLATE = PathTemplate.create("projects/{project}/topics/{topic}"); + private ResourceNames() {} + // ============================== // Resource Name Helper Functions // ============================== @@ -154,24 +172,6 @@ public static final String parseTopicFromTopicPath(String topicPath) { } } - // ======== - // Members - // ======== - - private final ManagedChannel channel; - private final List closeables = new ArrayList<>(); - - private final ApiCallable createTopicCallable; - private final ApiCallable publishCallable; - private final ApiCallable getTopicCallable; - private final ApiCallable listTopicsCallable; - private final ApiCallable> listTopicsIterableCallable; - private final ApiCallable - listTopicSubscriptionsCallable; - private final ApiCallable> - listTopicSubscriptionsIterableCallable; - private final ApiCallable deleteTopicCallable; - // =============== // Factory Methods // =============== @@ -187,8 +187,9 @@ public static PublisherApi create() throws IOException { } /** - * Constructs an instance of PublisherApi, using the given settings. The channels are created based - * on the settings passed in, or defaults for any settings that are not set. + * Constructs an instance of PublisherApi, using the given settings. + * The channels are created based on the settings passed in, or defaults for any + * settings that are not set. * * * @@ -198,8 +199,9 @@ public static PublisherApi create(PublisherSettings settings) throws IOException } /** - * Constructs an instance of PublisherApi, using the given settings. This is protected so that it - * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * Constructs an instance of PublisherApi, using the given settings. + * This is protected so that it easy to make a subclass, but otherwise, the static + * factory methods should be preferred. * * * diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java index 5f60fa374553..11566404546f 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java @@ -139,6 +139,8 @@ public class PublisherSettings extends ServiceApiSettings { RETRY_PARAM_DEFINITIONS = definitions.build(); } + private final MethodBuilders methods; + private static class MethodBuilders { private final ApiCallableBuilder createTopicMethod; private final BundlableApiCallableBuilder publishMethod; @@ -195,8 +197,6 @@ public MethodBuilders() { } } - private final MethodBuilders methods; - // =============== // Factory Methods // =============== @@ -219,8 +219,9 @@ public static PublisherSettings create() { } /** - * Constructs an instance of PublisherSettings with default settings. This is protected so that it - * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * Constructs an instance of PublisherSettings with default settings. This is protected + * so that it easy to make a subclass, but otherwise, the static factory methods should be + * preferred. * * * diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java index c794fddb1943..d53dca7f8885 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java @@ -65,9 +65,26 @@ */ @javax.annotation.Generated("by GAPIC") public class SubscriberApi implements AutoCloseable { + // ======== + // Members + // ======== + + private final ManagedChannel channel; + private final List closeables = new ArrayList<>(); + + private final ApiCallable createSubscriptionCallable; + private final ApiCallable getSubscriptionCallable; + private final ApiCallable + listSubscriptionsCallable; + private final ApiCallable> + listSubscriptionsIterableCallable; + private final ApiCallable deleteSubscriptionCallable; + private final ApiCallable modifyAckDeadlineCallable; + private final ApiCallable acknowledgeCallable; + private final ApiCallable pullCallable; + private final ApiCallable modifyPushConfigCallable; public static class ResourceNames { - private ResourceNames() {} // ======================= // ResourceNames Constants @@ -93,6 +110,8 @@ private ResourceNames() {} private static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = PathTemplate.create("projects/{project}/subscriptions/{subscription}"); + private ResourceNames() {} + // ============================== // Resource Name Helper Functions // ============================== @@ -154,25 +173,6 @@ public static final String parseSubscriptionFromSubscriptionPath(String subscrip } } - // ======== - // Members - // ======== - - private final ManagedChannel channel; - private final List closeables = new ArrayList<>(); - - private final ApiCallable createSubscriptionCallable; - private final ApiCallable getSubscriptionCallable; - private final ApiCallable - listSubscriptionsCallable; - private final ApiCallable> - listSubscriptionsIterableCallable; - private final ApiCallable deleteSubscriptionCallable; - private final ApiCallable modifyAckDeadlineCallable; - private final ApiCallable acknowledgeCallable; - private final ApiCallable pullCallable; - private final ApiCallable modifyPushConfigCallable; - // =============== // Factory Methods // =============== @@ -188,8 +188,9 @@ public static SubscriberApi create() throws IOException { } /** - * Constructs an instance of SubscriberApi, using the given settings. The channels are created based - * on the settings passed in, or defaults for any settings that are not set. + * Constructs an instance of SubscriberApi, using the given settings. + * The channels are created based on the settings passed in, or defaults for any + * settings that are not set. * * * @@ -199,8 +200,9 @@ public static SubscriberApi create(SubscriberSettings settings) throws IOExcepti } /** - * Constructs an instance of SubscriberApi, using the given settings. This is protected so that it - * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * Constructs an instance of SubscriberApi, using the given settings. + * This is protected so that it easy to make a subclass, but otherwise, the static + * factory methods should be preferred. * * * diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java index df9ea36e69b8..d9da44aa81f7 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java @@ -133,6 +133,8 @@ public class SubscriberSettings extends ServiceApiSettings { RETRY_PARAM_DEFINITIONS = definitions.build(); } + private final MethodBuilders methods; + private static class MethodBuilders { private final ApiCallableBuilder createSubscriptionMethod; private final ApiCallableBuilder getSubscriptionMethod; @@ -198,8 +200,6 @@ public MethodBuilders() { } } - private final MethodBuilders methods; - // =============== // Factory Methods // =============== @@ -222,8 +222,9 @@ public static SubscriberSettings create() { } /** - * Constructs an instance of SubscriberSettings with default settings. This is protected so that it - * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * Constructs an instance of SubscriberSettings with default settings. This is protected + * so that it easy to make a subclass, but otherwise, the static factory methods should be + * preferred. * * * diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index 987aa99667c9..2bd755f63a8c 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -19,7 +19,7 @@ com.google.api gax - 0.0.5-SNAPSHOT + 0.0.5 com.google.api.grpc diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java index 1930702f9e84..fa6da27a72bd 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java @@ -66,9 +66,25 @@ */ @javax.annotation.Generated("by GAPIC") public class PublisherApi implements AutoCloseable { + // ======== + // Members + // ======== + + private final ManagedChannel channel; + private final List closeables = new ArrayList<>(); + + private final ApiCallable createTopicCallable; + private final ApiCallable publishCallable; + private final ApiCallable getTopicCallable; + private final ApiCallable listTopicsCallable; + private final ApiCallable> listTopicsIterableCallable; + private final ApiCallable + listTopicSubscriptionsCallable; + private final ApiCallable> + listTopicSubscriptionsIterableCallable; + private final ApiCallable deleteTopicCallable; public static class ResourceNames { - private ResourceNames() {} // ======================= // ResourceNames Constants @@ -94,6 +110,8 @@ private ResourceNames() {} private static final PathTemplate TOPIC_PATH_TEMPLATE = PathTemplate.create("projects/{project}/topics/{topic}"); + private ResourceNames() {} + // ============================== // Resource Name Helper Functions // ============================== @@ -154,24 +172,6 @@ public static final String parseTopicFromTopicPath(String topicPath) { } } - // ======== - // Members - // ======== - - private final ManagedChannel channel; - private final List closeables = new ArrayList<>(); - - private final ApiCallable createTopicCallable; - private final ApiCallable publishCallable; - private final ApiCallable getTopicCallable; - private final ApiCallable listTopicsCallable; - private final ApiCallable> listTopicsIterableCallable; - private final ApiCallable - listTopicSubscriptionsCallable; - private final ApiCallable> - listTopicSubscriptionsIterableCallable; - private final ApiCallable deleteTopicCallable; - // =============== // Factory Methods // =============== @@ -187,8 +187,9 @@ public static PublisherApi create() throws IOException { } /** - * Constructs an instance of PublisherApi, using the given settings. The channels are created based - * on the settings passed in, or defaults for any settings that are not set. + * Constructs an instance of PublisherApi, using the given settings. + * The channels are created based on the settings passed in, or defaults for any + * settings that are not set. * * * @@ -198,8 +199,9 @@ public static PublisherApi create(PublisherSettings settings) throws IOException } /** - * Constructs an instance of PublisherApi, using the given settings. This is protected so that it - * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * Constructs an instance of PublisherApi, using the given settings. + * This is protected so that it easy to make a subclass, but otherwise, the static + * factory methods should be preferred. * * * diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java index 5f60fa374553..11566404546f 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java @@ -139,6 +139,8 @@ public class PublisherSettings extends ServiceApiSettings { RETRY_PARAM_DEFINITIONS = definitions.build(); } + private final MethodBuilders methods; + private static class MethodBuilders { private final ApiCallableBuilder createTopicMethod; private final BundlableApiCallableBuilder publishMethod; @@ -195,8 +197,6 @@ public MethodBuilders() { } } - private final MethodBuilders methods; - // =============== // Factory Methods // =============== @@ -219,8 +219,9 @@ public static PublisherSettings create() { } /** - * Constructs an instance of PublisherSettings with default settings. This is protected so that it - * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * Constructs an instance of PublisherSettings with default settings. This is protected + * so that it easy to make a subclass, but otherwise, the static factory methods should be + * preferred. * * * diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java index c794fddb1943..d53dca7f8885 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java @@ -65,9 +65,26 @@ */ @javax.annotation.Generated("by GAPIC") public class SubscriberApi implements AutoCloseable { + // ======== + // Members + // ======== + + private final ManagedChannel channel; + private final List closeables = new ArrayList<>(); + + private final ApiCallable createSubscriptionCallable; + private final ApiCallable getSubscriptionCallable; + private final ApiCallable + listSubscriptionsCallable; + private final ApiCallable> + listSubscriptionsIterableCallable; + private final ApiCallable deleteSubscriptionCallable; + private final ApiCallable modifyAckDeadlineCallable; + private final ApiCallable acknowledgeCallable; + private final ApiCallable pullCallable; + private final ApiCallable modifyPushConfigCallable; public static class ResourceNames { - private ResourceNames() {} // ======================= // ResourceNames Constants @@ -93,6 +110,8 @@ private ResourceNames() {} private static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE = PathTemplate.create("projects/{project}/subscriptions/{subscription}"); + private ResourceNames() {} + // ============================== // Resource Name Helper Functions // ============================== @@ -154,25 +173,6 @@ public static final String parseSubscriptionFromSubscriptionPath(String subscrip } } - // ======== - // Members - // ======== - - private final ManagedChannel channel; - private final List closeables = new ArrayList<>(); - - private final ApiCallable createSubscriptionCallable; - private final ApiCallable getSubscriptionCallable; - private final ApiCallable - listSubscriptionsCallable; - private final ApiCallable> - listSubscriptionsIterableCallable; - private final ApiCallable deleteSubscriptionCallable; - private final ApiCallable modifyAckDeadlineCallable; - private final ApiCallable acknowledgeCallable; - private final ApiCallable pullCallable; - private final ApiCallable modifyPushConfigCallable; - // =============== // Factory Methods // =============== @@ -188,8 +188,9 @@ public static SubscriberApi create() throws IOException { } /** - * Constructs an instance of SubscriberApi, using the given settings. The channels are created based - * on the settings passed in, or defaults for any settings that are not set. + * Constructs an instance of SubscriberApi, using the given settings. + * The channels are created based on the settings passed in, or defaults for any + * settings that are not set. * * * @@ -199,8 +200,9 @@ public static SubscriberApi create(SubscriberSettings settings) throws IOExcepti } /** - * Constructs an instance of SubscriberApi, using the given settings. This is protected so that it - * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * Constructs an instance of SubscriberApi, using the given settings. + * This is protected so that it easy to make a subclass, but otherwise, the static + * factory methods should be preferred. * * * diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java index df9ea36e69b8..d9da44aa81f7 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java @@ -133,6 +133,8 @@ public class SubscriberSettings extends ServiceApiSettings { RETRY_PARAM_DEFINITIONS = definitions.build(); } + private final MethodBuilders methods; + private static class MethodBuilders { private final ApiCallableBuilder createSubscriptionMethod; private final ApiCallableBuilder getSubscriptionMethod; @@ -198,8 +200,6 @@ public MethodBuilders() { } } - private final MethodBuilders methods; - // =============== // Factory Methods // =============== @@ -222,8 +222,9 @@ public static SubscriberSettings create() { } /** - * Constructs an instance of SubscriberSettings with default settings. This is protected so that it - * easy to make a subclass, but otherwise, the static factory methods should be preferred. + * Constructs an instance of SubscriberSettings with default settings. This is protected + * so that it easy to make a subclass, but otherwise, the static factory methods should be + * preferred. * * * diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java index a092c2fdd7ee..c25ca51ee713 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java @@ -126,7 +126,8 @@ public void testPublish() throws Exception { String topicName = PublisherApi.ResourceNames.formatTopicPath("my-project", "publish-topic"); publisherApi.createTopic(topicName); - String subscriberName = SubscriberApi.ResourceNames.formatSubscriptionPath("my-project", "my-subscribe"); + String subscriberName = + SubscriberApi.ResourceNames.formatSubscriptionPath("my-project", "my-subscribe"); PushConfig config = PushConfig.getDefaultInstance(); subscriberApi.createSubscription(subscriberName, topicName, config, 5); @@ -145,7 +146,8 @@ public void testBundledPublish() throws Exception { String topicName = PublisherApi.ResourceNames.formatTopicPath("my-project", "publish-topic"); bundledPublisherApi.createTopic(topicName); - String subscriberName = SubscriberApi.ResourceNames.formatSubscriptionPath("my-project", "my-subscribe"); + String subscriberName = + SubscriberApi.ResourceNames.formatSubscriptionPath("my-project", "my-subscribe"); PushConfig config = PushConfig.getDefaultInstance(); subscriberApi.createSubscription(subscriberName, topicName, config, 5); From 3a5bc2835144915c4b587a934acd9a40dc8fcffa Mon Sep 17 00:00:00 2001 From: Shin Fan Date: Mon, 28 Mar 2016 17:23:29 -0700 Subject: [PATCH 203/203] Update the pom version. --- gcloud-java-pubsub/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud-java-pubsub/pom.xml b/gcloud-java-pubsub/pom.xml index 2bd755f63a8c..2014b483b17e 100644 --- a/gcloud-java-pubsub/pom.xml +++ b/gcloud-java-pubsub/pom.xml @@ -10,7 +10,7 @@ com.google.gcloud gcloud-java-pom - 0.1.4-SNAPSHOT + 0.1.5 gcloud-java-pubsub